OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef PDF_PAINT_MANAGER_H_ | 5 #ifndef PDF_PAINT_MANAGER_H_ |
6 #define PDF_PAINT_MANAGER_H_ | 6 #define PDF_PAINT_MANAGER_H_ |
7 | 7 |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <vector> | 10 #include <vector> |
(...skipping 15 matching lines...) Expand all Loading... |
26 // supports having higher-priority rects flushing right away, i.e. the | 26 // supports having higher-priority rects flushing right away, i.e. the |
27 // scrollbars. | 27 // scrollbars. |
28 // | 28 // |
29 // The client's OnPaint | 29 // The client's OnPaint |
30 class PaintManager { | 30 class PaintManager { |
31 public: | 31 public: |
32 // Like PaintAggregator's version, but allows the plugin to tell us whether | 32 // Like PaintAggregator's version, but allows the plugin to tell us whether |
33 // it should be flushed to the screen immediately or when the rest of the | 33 // it should be flushed to the screen immediately or when the rest of the |
34 // plugin viewport is ready. | 34 // plugin viewport is ready. |
35 struct ReadyRect { | 35 struct ReadyRect { |
36 pp::Point offset; | 36 ReadyRect(); |
37 pp::Rect rect; | 37 ReadyRect(const pp::Rect& r, const pp::ImageData& i, bool f); |
38 pp::ImageData image_data; | 38 ReadyRect(const ReadyRect& that); |
39 bool flush_now; | |
40 | |
41 ReadyRect(const pp::Rect& r, const pp::ImageData& i, bool f) | |
42 : rect(r), image_data(i), flush_now(f) {} | |
43 | 39 |
44 operator PaintAggregator::ReadyRect() const { | 40 operator PaintAggregator::ReadyRect() const { |
45 PaintAggregator::ReadyRect rv; | 41 PaintAggregator::ReadyRect rv; |
46 rv.offset = offset; | 42 rv.offset = offset; |
47 rv.rect = rect; | 43 rv.rect = rect; |
48 rv.image_data = image_data; | 44 rv.image_data = image_data; |
49 return rv; | 45 return rv; |
50 } | 46 } |
| 47 |
| 48 pp::Point offset; |
| 49 pp::Rect rect; |
| 50 pp::ImageData image_data; |
| 51 bool flush_now; |
51 }; | 52 }; |
52 class Client { | 53 class Client { |
53 public: | 54 public: |
54 // Paints the given invalid area of the plugin to the given graphics | 55 // Paints the given invalid area of the plugin to the given graphics |
55 // device. Returns true if anything was painted. | 56 // device. Returns true if anything was painted. |
56 // | 57 // |
57 // You are given the list of rects to paint in |paint_rects|. You can | 58 // You are given the list of rects to paint in |paint_rects|. You can |
58 // combine painting into less rectangles if it's more efficient. When a | 59 // combine painting into less rectangles if it's more efficient. When a |
59 // rect is painted, information about that paint should be inserted into | 60 // rect is painted, information about that paint should be inserted into |
60 // |ready|. Otherwise if a paint needs more work, add the rect to | 61 // |ready|. Otherwise if a paint needs more work, add the rect to |
61 // |pending|. If |pending| is not empty, your OnPaint function will get | 62 // |pending|. If |pending| is not empty, your OnPaint function will get |
62 // called again. Once OnPaint is called and it returns no pending rects, | 63 // called again. Once OnPaint is called and it returns no pending rects, |
63 // all the previously ready rects will be flushed on screen. The exception | 64 // all the previously ready rects will be flushed on screen. The exception |
64 // is for ready rects that have |flush_now| set to true. These will be | 65 // is for ready rects that have |flush_now| set to true. These will be |
65 // flushed right away. | 66 // flushed right away. |
66 // | 67 // |
67 // Do not call Flush() on the graphics device, this will be done | 68 // Do not call Flush() on the graphics device, this will be done |
68 // automatically if you return true from this function since the | 69 // automatically if you return true from this function since the |
69 // PaintManager needs to handle the callback. | 70 // PaintManager needs to handle the callback. |
70 // | 71 // |
71 // Calling Invalidate/Scroll is not allowed while inside an OnPaint | 72 // Calling Invalidate/Scroll is not allowed while inside an OnPaint |
72 virtual void OnPaint(const std::vector<pp::Rect>& paint_rects, | 73 virtual void OnPaint(const std::vector<pp::Rect>& paint_rects, |
73 std::vector<ReadyRect>* ready, | 74 std::vector<ReadyRect>* ready, |
74 std::vector<pp::Rect>* pending) = 0; | 75 std::vector<pp::Rect>* pending) = 0; |
| 76 |
75 protected: | 77 protected: |
76 // You shouldn't be doing deleting through this interface. | 78 // You shouldn't be doing deleting through this interface. |
77 virtual ~Client() {} | 79 virtual ~Client() {} |
78 }; | 80 }; |
79 | 81 |
80 // The instance is the plugin instance using this paint manager to do its | 82 // The instance is the plugin instance using this paint manager to do its |
81 // painting. Painting will automatically go to this instance and you don't | 83 // painting. Painting will automatically go to this instance and you don't |
82 // have to manually bind any device context (this is all handled by the | 84 // have to manually bind any device context (this is all handled by the |
83 // paint manager). | 85 // paint manager). |
84 // | 86 // |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
198 bool in_paint_; | 200 bool in_paint_; |
199 | 201 |
200 // True if we haven't painted the plugin viewport yet. | 202 // True if we haven't painted the plugin viewport yet. |
201 bool first_paint_; | 203 bool first_paint_; |
202 | 204 |
203 // True when the view size just changed and we're waiting for a paint. | 205 // True when the view size just changed and we're waiting for a paint. |
204 bool view_size_changed_waiting_for_paint_; | 206 bool view_size_changed_waiting_for_paint_; |
205 }; | 207 }; |
206 | 208 |
207 #endif // PDF_PAINT_MANAGER_H_ | 209 #endif // PDF_PAINT_MANAGER_H_ |
OLD | NEW |