Avi Drissman | db497b3 | 2022-09-15 19:47:28 | [diff] [blame] | 1 | // Copyright 2020 The Chromium Authors |
K. Moon | ad77a18 | 2020-07-16 19:30:49 | [diff] [blame] | 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
| 5 | #ifndef PDF_PAINT_READY_RECT_H_ |
| 6 | #define PDF_PAINT_READY_RECT_H_ |
| 7 | |
K. Moon | 950a8527 | 2022-04-29 23:34:03 | [diff] [blame] | 8 | #include "third_party/skia/include/core/SkRefCnt.h" |
K. Moon | 30466c9 | 2020-07-21 21:46:03 | [diff] [blame] | 9 | #include "ui/gfx/geometry/rect.h" |
| 10 | |
K. Moon | 950a8527 | 2022-04-29 23:34:03 | [diff] [blame] | 11 | class SkImage; |
| 12 | |
K. Moon | ad77a18 | 2020-07-16 19:30:49 | [diff] [blame] | 13 | namespace chrome_pdf { |
| 14 | |
| 15 | // Stores information about a rectangle that has finished painting. The |
| 16 | // `PaintManager` will paint it only when everything else on the screen is also |
| 17 | // ready. |
K. Moon | 70565f6 | 2020-07-22 00:39:54 | [diff] [blame] | 18 | class PaintReadyRect { |
| 19 | public: |
Hui Yingst | ac4f9f9b | 2021-01-05 20:59:00 | [diff] [blame] | 20 | PaintReadyRect(const gfx::Rect& rect, |
K. Moon | 950a8527 | 2022-04-29 23:34:03 | [diff] [blame] | 21 | sk_sp<SkImage> image, |
K. Moon | 944dd5f | 2020-07-29 00:36:43 | [diff] [blame] | 22 | bool flush_now = false); |
| 23 | |
K. Moon | ad77a18 | 2020-07-16 19:30:49 | [diff] [blame] | 24 | PaintReadyRect(const PaintReadyRect& other); |
| 25 | PaintReadyRect& operator=(const PaintReadyRect& other); |
K. Moon | 70565f6 | 2020-07-22 00:39:54 | [diff] [blame] | 26 | ~PaintReadyRect(); |
K. Moon | ad77a18 | 2020-07-16 19:30:49 | [diff] [blame] | 27 | |
K. Moon | 70565f6 | 2020-07-22 00:39:54 | [diff] [blame] | 28 | const gfx::Rect& rect() const { return rect_; } |
| 29 | void set_rect(const gfx::Rect& rect) { rect_ = rect; } |
| 30 | |
K. Moon | 950a8527 | 2022-04-29 23:34:03 | [diff] [blame] | 31 | const SkImage& image() const { return *image_; } |
K. Moon | ad77a18 | 2020-07-16 19:30:49 | [diff] [blame] | 32 | |
| 33 | // Whether to flush to screen immediately; otherwise, when the rest of the |
| 34 | // plugin viewport is ready. |
K. Moon | 70565f6 | 2020-07-22 00:39:54 | [diff] [blame] | 35 | bool flush_now() const { return flush_now_; } |
| 36 | |
| 37 | private: |
| 38 | gfx::Rect rect_; |
K. Moon | 950a8527 | 2022-04-29 23:34:03 | [diff] [blame] | 39 | sk_sp<SkImage> image_; |
K. Moon | 70565f6 | 2020-07-22 00:39:54 | [diff] [blame] | 40 | bool flush_now_; |
K. Moon | ad77a18 | 2020-07-16 19:30:49 | [diff] [blame] | 41 | }; |
| 42 | |
| 43 | } // namespace chrome_pdf |
| 44 | |
| 45 | #endif // PDF_PAINT_READY_RECT_H_ |