paint_ready_rect.h 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. // Copyright 2020 The Chromium Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style license that can be
  3. // found in the LICENSE file.
  4. #ifndef PDF_PAINT_READY_RECT_H_
  5. #define PDF_PAINT_READY_RECT_H_
  6. #include "third_party/skia/include/core/SkRefCnt.h"
  7. #include "ui/gfx/geometry/rect.h"
  8. class SkImage;
  9. namespace chrome_pdf {
  10. // Stores information about a rectangle that has finished painting. The
  11. // `PaintManager` will paint it only when everything else on the screen is also
  12. // ready.
  13. class PaintReadyRect {
  14. public:
  15. PaintReadyRect(const gfx::Rect& rect,
  16. sk_sp<SkImage> image,
  17. bool flush_now = false);
  18. PaintReadyRect(const PaintReadyRect& other);
  19. PaintReadyRect& operator=(const PaintReadyRect& other);
  20. ~PaintReadyRect();
  21. const gfx::Rect& rect() const { return rect_; }
  22. void set_rect(const gfx::Rect& rect) { rect_ = rect; }
  23. const SkImage& image() const { return *image_; }
  24. // Whether to flush to screen immediately; otherwise, when the rest of the
  25. // plugin viewport is ready.
  26. bool flush_now() const { return flush_now_; }
  27. private:
  28. gfx::Rect rect_;
  29. sk_sp<SkImage> image_;
  30. bool flush_now_;
  31. };
  32. } // namespace chrome_pdf
  33. #endif // PDF_PAINT_READY_RECT_H_