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 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 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
139 // this will be a NOP. If the size has changed, a new device will be | 139 // this will be a NOP. If the size has changed, a new device will be |
140 // allocated to the given size and a paint to that device will be scheduled. | 140 // allocated to the given size and a paint to that device will be scheduled. |
141 // | 141 // |
142 // This is intended to be called from ViewChanged with the size of the | 142 // This is intended to be called from ViewChanged with the size of the |
143 // plugin. Since it tracks the old size and only allocates when the size | 143 // plugin. Since it tracks the old size and only allocates when the size |
144 // changes, you can always call this function without worrying about whether | 144 // changes, you can always call this function without worrying about whether |
145 // the size changed or ViewChanged is called for another reason (like the | 145 // the size changed or ViewChanged is called for another reason (like the |
146 // position changed). | 146 // position changed). |
147 void SetSize(const Size& new_size); | 147 void SetSize(const Size& new_size); |
148 | 148 |
149 // Provides access to the underlying device in case you need it. Note: if | 149 // Provides access to the underlying device in case you need it. If you have |
150 // you call Flush on this device the paint manager will get very confused, | 150 // done a SetSize, note that the graphics context won't be updated until |
151 // don't do this! | 151 // right before the next OnPaint call. |
| 152 // |
| 153 // Note: if you call Flush on this device the paint manager will get very |
| 154 // confused, don't do this! |
152 const Graphics2D& graphics() const { return graphics_; } | 155 const Graphics2D& graphics() const { return graphics_; } |
153 Graphics2D& graphics() { return graphics_; } | 156 Graphics2D& graphics() { return graphics_; } |
154 | 157 |
155 // Invalidate the entire plugin. | 158 // Invalidate the entire plugin. |
156 void Invalidate(); | 159 void Invalidate(); |
157 | 160 |
158 // Invalidate the given rect. | 161 // Invalidate the given rect. |
159 void InvalidateRect(const Rect& rect); | 162 void InvalidateRect(const Rect& rect); |
160 | 163 |
161 // The given rect should be scrolled by the given amounts. | 164 // The given rect should be scrolled by the given amounts. |
162 void ScrollRect(const Rect& clip_rect, const Point& amount); | 165 void ScrollRect(const Rect& clip_rect, const Point& amount); |
163 | 166 |
| 167 // Returns the size of the graphics context for the next paint operation. |
| 168 // This is the pending size if a resize is pending (the plugin has called |
| 169 // SetSize but we haven't actually painted it yet), or the current size of |
| 170 // no resize is pending. |
| 171 Size GetEffectiveSize() const; |
| 172 |
164 private: | 173 private: |
165 // Disallow copy and assign (these are unimplemented). | 174 // Disallow copy and assign (these are unimplemented). |
166 PaintManager(const PaintManager&); | 175 PaintManager(const PaintManager&); |
167 PaintManager& operator=(const PaintManager&); | 176 PaintManager& operator=(const PaintManager&); |
168 | 177 |
169 // Makes sure there is a callback that will trigger a paint at a later time. | 178 // Makes sure there is a callback that will trigger a paint at a later time. |
170 // This will be either a Flush callback telling us we're allowed to generate | 179 // This will be either a Flush callback telling us we're allowed to generate |
171 // more data, or, if there's no flush callback pending, a manual call back | 180 // more data, or, if there's no flush callback pending, a manual call back |
172 // to the message loop via ExecuteOnMainThread. | 181 // to the message loop via ExecuteOnMainThread. |
173 void EnsureCallbackPending(); | 182 void EnsureCallbackPending(); |
(...skipping 19 matching lines...) Expand all Loading... |
193 | 202 |
194 // This graphics device will be is_null() if no graphics has been manually | 203 // This graphics device will be is_null() if no graphics has been manually |
195 // set yet. | 204 // set yet. |
196 Graphics2D graphics_; | 205 Graphics2D graphics_; |
197 | 206 |
198 PaintAggregator aggregator_; | 207 PaintAggregator aggregator_; |
199 | 208 |
200 // See comment for EnsureCallbackPending for more on how these work. | 209 // See comment for EnsureCallbackPending for more on how these work. |
201 bool manual_callback_pending_; | 210 bool manual_callback_pending_; |
202 bool flush_pending_; | 211 bool flush_pending_; |
| 212 |
| 213 // When we get a resize, we don't bind right away (see SetSize). The |
| 214 // has_pending_resize_ tells us that we need to do a resize for the next |
| 215 // paint operation. When true, the new size is in pending_size_. |
| 216 bool has_pending_resize_; |
| 217 Size pending_size_; |
203 }; | 218 }; |
204 | 219 |
205 } // namespace pp | 220 } // namespace pp |
206 | 221 |
207 #endif // PPAPI_CPP_PAINT_MANAGER_H_ | 222 #endif // PPAPI_CPP_PAINT_MANAGER_H_ |
OLD | NEW |