OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 PPAPI_CPP_PAINT_MANAGER_H_ | 5 #ifndef PPAPI_CPP_PAINT_MANAGER_H_ |
6 #define PPAPI_CPP_PAINT_MANAGER_H_ | 6 #define PPAPI_CPP_PAINT_MANAGER_H_ |
7 | 7 |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "ppapi/cpp/completion_callback.h" | 10 #include "ppapi/cpp/completion_callback.h" |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
83 /// automatically if you return true from this function since the | 83 /// automatically if you return true from this function since the |
84 /// <code>PaintManager</code> needs to handle the callback. | 84 /// <code>PaintManager</code> needs to handle the callback. |
85 /// | 85 /// |
86 /// It is legal for you to cause invalidates inside of Paint which will | 86 /// It is legal for you to cause invalidates inside of Paint which will |
87 /// then get executed as soon as the Flush for this update has completed. | 87 /// then get executed as soon as the Flush for this update has completed. |
88 /// However, this is not very nice to the host system since it will spin the | 88 /// However, this is not very nice to the host system since it will spin the |
89 /// CPU, possibly updating much faster than necessary. It is best to have a | 89 /// CPU, possibly updating much faster than necessary. It is best to have a |
90 /// 1/60 second timer to do an invalidate instead. This will limit your | 90 /// 1/60 second timer to do an invalidate instead. This will limit your |
91 /// animation to the slower of 60Hz or "however fast Flush can complete." | 91 /// animation to the slower of 60Hz or "however fast Flush can complete." |
92 /// | 92 /// |
93 /// @param graphics A <code>Graphics2D</code> to be painted. | 93 /// @param[in] graphics A <code>Graphics2D</code> to be painted. |
94 /// @param paint_rects A list of rects to paint. | 94 /// @param[in] paint_rects A list of rects to paint. |
95 /// @param paint_bounds A union of the rects to paint. | 95 /// @param[in] paint_bounds A union of the rects to paint. |
| 96 /// |
| 97 /// @return true if successful, otherwise false. |
96 virtual bool OnPaint(Graphics2D& graphics, | 98 virtual bool OnPaint(Graphics2D& graphics, |
97 const std::vector<Rect>& paint_rects, | 99 const std::vector<Rect>& paint_rects, |
98 const Rect& paint_bounds) = 0; | 100 const Rect& paint_bounds) = 0; |
99 | 101 |
100 protected: | 102 protected: |
101 // You shouldn't be doing deleting through this interface. | 103 // You shouldn't be doing deleting through this interface. |
102 virtual ~Client() {} | 104 virtual ~Client() {} |
103 }; | 105 }; |
104 | 106 |
105 /// Default constructor for creating an is_null() <code>PaintManager</code> | 107 /// Default constructor for creating an is_null() <code>PaintManager</code> |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
148 /// paint manager). | 150 /// paint manager). |
149 /// @param client A non-owning pointer and must remain valid (normally the | 151 /// @param client A non-owning pointer and must remain valid (normally the |
150 /// object implementing the Client interface will own the paint manager). | 152 /// object implementing the Client interface will own the paint manager). |
151 /// @param is_always_opaque A flag passed to the device contexts that this | 153 /// @param is_always_opaque A flag passed to the device contexts that this |
152 /// class creates. Set this to true if your instance always draws an opaque | 154 /// class creates. Set this to true if your instance always draws an opaque |
153 /// image to the device. This is used as a hint to the browser that it does | 155 /// image to the device. This is used as a hint to the browser that it does |
154 /// not need to do alpha blending, which speeds up painting. If you generate | 156 /// not need to do alpha blending, which speeds up painting. If you generate |
155 /// non-opqaue pixels or aren't sure, set this to false for more general | 157 /// non-opqaue pixels or aren't sure, set this to false for more general |
156 /// blending. | 158 /// blending. |
157 /// | 159 /// |
158 /// If you set is_always_opaque, your alpha channel should always be set to | 160 /// If you set <code>is_always_opaque</code>, your alpha channel should |
159 /// 0xFF or there may be painting artifacts. Being opaque will allow the | 161 /// always be set to <code>0xFF</code> or there may be painting artifacts. |
160 /// browser to do a memcpy rather than a blend to paint the plugin, and this | 162 /// Being opaque will allow the browser to do a memcpy rather than a blend |
161 /// means your alpha values will get set on the page backing store. If these | 163 /// to paint the plugin, and this means your alpha values will get set on the |
162 /// values are incorrect, it could mess up future blending. If you aren't | 164 /// page backing store. If these values are incorrect, it could mess up |
163 /// sure, it is always correct to specify that it it not opaque. | 165 /// future blending. If you aren't sure, it is always correct to specify that |
| 166 /// it it not opaque. |
164 void Initialize(Instance* instance, Client* client, bool is_always_opaque); | 167 void Initialize(Instance* instance, Client* client, bool is_always_opaque); |
165 | 168 |
166 /// Setter function setting the max ratio of paint rect area to scroll rect | 169 /// Setter function setting the max ratio of paint rect area to scroll rect |
167 /// area that we will tolerate before downgrading the scroll into a repaint. | 170 /// area that we will tolerate before downgrading the scroll into a repaint. |
168 /// | 171 /// |
169 /// If the combined area of paint rects contained within the scroll | 172 /// If the combined area of paint rects contained within the scroll |
170 /// rect grows too large, then we might as well just treat | 173 /// rect grows too large, then we might as well just treat |
171 /// the scroll rect as a paint rect. | 174 /// the scroll rect as a paint rect. |
172 /// | 175 /// |
173 /// @param[in] area The max ratio of paint rect area to scroll rect area that | 176 /// @param[in] area The max ratio of paint rect area to scroll rect area that |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
216 /// | 219 /// |
217 /// <strong>Note:</strong> If you call Flush on this device the paint manager | 220 /// <strong>Note:</strong> If you call Flush on this device the paint manager |
218 /// will get very confused, don't do this! | 221 /// will get very confused, don't do this! |
219 Graphics2D& graphics() { return graphics_; } | 222 Graphics2D& graphics() { return graphics_; } |
220 | 223 |
221 /// Invalidate() invalidate the entire instance. | 224 /// Invalidate() invalidate the entire instance. |
222 void Invalidate(); | 225 void Invalidate(); |
223 | 226 |
224 /// InvalidateRect() Invalidate the provided rect. | 227 /// InvalidateRect() Invalidate the provided rect. |
225 /// | 228 /// |
226 /// @param rect The <code>Rect</code> to be invalidated. | 229 /// @param[in] rect The <code>Rect</code> to be invalidated. |
227 void InvalidateRect(const Rect& rect); | 230 void InvalidateRect(const Rect& rect); |
228 | 231 |
229 /// ScrollRect() scrolls the provided <code>clip_rect</code> by the | 232 /// ScrollRect() scrolls the provided <code>clip_rect</code> by the |
230 /// <code>amount</code> argument. | 233 /// <code>amount</code> argument. |
231 /// | 234 /// |
232 /// @param clip_rect The clip rectangle to scroll. | 235 /// @param clip_rect The clip rectangle to scroll. |
233 /// @param amount The amount to scroll <code>clip_rect</code>. | 236 /// @param amount The amount to scroll <code>clip_rect</code>. |
234 void ScrollRect(const Rect& clip_rect, const Point& amount); | 237 void ScrollRect(const Rect& clip_rect, const Point& amount); |
235 | 238 |
236 /// GetEffectiveSize() returns the size of the graphics context for the | 239 /// GetEffectiveSize() returns the size of the graphics context for the |
237 /// next paint operation. This is the pending size if a resize is pending | 240 /// next paint operation. This is the pending size if a resize is pending |
238 /// (the instance has called SetSize() but we haven't actually painted it | 241 /// (the instance has called SetSize() but we haven't actually painted it |
239 /// yet), or the current size of no resize is pending. | 242 /// yet), or the current size of no resize is pending. |
240 /// | 243 /// |
241 /// @return The effetive size. | 244 /// @return The effective size. |
242 Size GetEffectiveSize() const; | 245 Size GetEffectiveSize() const; |
243 | 246 |
244 private: | 247 private: |
245 // Disallow copy and assign (these are unimplemented). | 248 // Disallow copy and assign (these are unimplemented). |
246 PaintManager(const PaintManager&); | 249 PaintManager(const PaintManager&); |
247 PaintManager& operator=(const PaintManager&); | 250 PaintManager& operator=(const PaintManager&); |
248 | 251 |
249 // Makes sure there is a callback that will trigger a paint at a later time. | 252 // Makes sure there is a callback that will trigger a paint at a later time. |
250 // This will be either a Flush callback telling us we're allowed to generate | 253 // This will be either a Flush callback telling us we're allowed to generate |
251 // more data, or, if there's no flush callback pending, a manual call back | 254 // more data, or, if there's no flush callback pending, a manual call back |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
284 // When we get a resize, we don't bind right away (see SetSize). The | 287 // When we get a resize, we don't bind right away (see SetSize). The |
285 // has_pending_resize_ tells us that we need to do a resize for the next | 288 // has_pending_resize_ tells us that we need to do a resize for the next |
286 // paint operation. When true, the new size is in pending_size_. | 289 // paint operation. When true, the new size is in pending_size_. |
287 bool has_pending_resize_; | 290 bool has_pending_resize_; |
288 Size pending_size_; | 291 Size pending_size_; |
289 }; | 292 }; |
290 | 293 |
291 } // namespace pp | 294 } // namespace pp |
292 | 295 |
293 #endif // PPAPI_CPP_PAINT_MANAGER_H_ | 296 #endif // PPAPI_CPP_PAINT_MANAGER_H_ |
OLD | NEW |