Chromium Code Reviews| 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 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 139 // The given rect should be scrolled by the given amounts. | 139 // The given rect should be scrolled by the given amounts. |
| 140 void ScrollRect(const pp::Rect& clip_rect, const pp::Point& amount); | 140 void ScrollRect(const pp::Rect& clip_rect, const pp::Point& amount); |
| 141 | 141 |
| 142 // Returns the size of the graphics context for the next paint operation. | 142 // Returns the size of the graphics context for the next paint operation. |
| 143 // This is the pending size if a resize is pending (the plugin has called | 143 // This is the pending size if a resize is pending (the plugin has called |
| 144 // SetSize but we haven't actually painted it yet), or the current size of | 144 // SetSize but we haven't actually painted it yet), or the current size of |
| 145 // no resize is pending. | 145 // no resize is pending. |
| 146 pp::Size GetEffectiveSize() const; | 146 pp::Size GetEffectiveSize() const; |
| 147 float GetEffectiveDeviceScale() const; | 147 float GetEffectiveDeviceScale() const; |
| 148 | 148 |
| 149 // Set the transform for the graphics layer. | |
| 150 // If |schedule_flush| is true, it ensures a flush will be scheduled for | |
| 151 // this change. If |schedule_flush| is false, then the change will not take | |
| 152 // effect until another change causes a flush. | |
| 153 void SetTransform(float scale, | |
| 154 const pp::Point& origin, | |
| 155 const pp::Point& translate, | |
| 156 bool schedule_flush); | |
| 157 // Resets any transform for the graphics layer. | |
| 158 // This does not schedule a flush. | |
| 159 void ClearTransform(); | |
| 160 | |
| 149 private: | 161 private: |
| 150 // Disallow copy and assign (these are unimplemented). | 162 // Disallow copy and assign (these are unimplemented). |
| 151 PaintManager(const PaintManager&); | 163 PaintManager(const PaintManager&); |
| 152 PaintManager& operator=(const PaintManager&); | 164 PaintManager& operator=(const PaintManager&); |
| 153 | 165 |
| 154 // Makes sure there is a callback that will trigger a paint at a later time. | 166 // Makes sure there is a callback that will trigger a paint at a later time. |
| 155 // This will be either a Flush callback telling us we're allowed to generate | 167 // This will be either a Flush callback telling us we're allowed to generate |
| 156 // more data, or, if there's no flush callback pending, a manual call back | 168 // more data, or, if there's no flush callback pending, a manual call back |
| 157 // to the message loop via ExecuteOnMainThread. | 169 // to the message loop via ExecuteOnMainThread. |
| 158 void EnsureCallbackPending(); | 170 void EnsureCallbackPending(); |
| 159 | 171 |
| 160 // Does the client paint and executes a Flush if necessary. | 172 // Does the client paint and executes a Flush if necessary. |
| 161 void DoPaint(); | 173 void DoPaint(); |
| 162 | 174 |
| 175 // Executes a Flush. | |
| 176 void Flush(); | |
| 177 | |
| 163 // Callback for asynchronous completion of Flush. | 178 // Callback for asynchronous completion of Flush. |
| 164 void OnFlushComplete(int32_t); | 179 void OnFlushComplete(int32_t); |
| 165 | 180 |
| 166 // Callback for manual scheduling of paints when there is no flush callback | 181 // Callback for manual scheduling of paints when there is no flush callback |
| 167 // pending. | 182 // pending. |
| 168 void OnManualCallbackComplete(int32_t); | 183 void OnManualCallbackComplete(int32_t); |
| 169 | 184 |
| 170 pp::Instance* instance_; | 185 pp::Instance* instance_; |
| 171 | 186 |
| 172 // Non-owning pointer. See the constructor. | 187 // Non-owning pointer. See the constructor. |
| 173 Client* client_; | 188 Client* client_; |
| 174 | 189 |
| 175 bool is_always_opaque_; | 190 bool is_always_opaque_; |
| 176 | 191 |
| 177 pp::CompletionCallbackFactory<PaintManager> callback_factory_; | 192 pp::CompletionCallbackFactory<PaintManager> callback_factory_; |
| 178 | 193 |
| 179 // This graphics device will be is_null() if no graphics has been manually | 194 // This graphics device will be is_null() if no graphics has been manually |
| 180 // set yet. | 195 // set yet. |
| 181 pp::Graphics2D graphics_; | 196 pp::Graphics2D graphics_; |
| 182 | 197 |
| 183 PaintAggregator aggregator_; | 198 PaintAggregator aggregator_; |
| 184 | 199 |
| 185 // See comment for EnsureCallbackPending for more on how these work. | 200 // See comment for EnsureCallbackPending for more on how these work. |
| 186 bool manual_callback_pending_; | 201 bool manual_callback_pending_; |
| 187 bool flush_pending_; | 202 bool flush_pending_; |
|
Lei Zhang
2016/10/31 22:49:04
Are all four possible state combinations of |flush
Kevin McNee - google account
2016/11/07 23:08:27
Yes, all are valid:
When |flush_requested_| is fal
| |
| 203 bool flush_requested_; | |
| 188 | 204 |
| 189 // When we get a resize, we don't bind right away (see SetSize). The | 205 // When we get a resize, we don't bind right away (see SetSize). The |
| 190 // has_pending_resize_ tells us that we need to do a resize for the next | 206 // has_pending_resize_ tells us that we need to do a resize for the next |
| 191 // paint operation. When true, the new size is in pending_size_. | 207 // paint operation. When true, the new size is in pending_size_. |
| 192 bool has_pending_resize_; | 208 bool has_pending_resize_; |
| 193 bool graphics_need_to_be_bound_; | 209 bool graphics_need_to_be_bound_; |
| 194 pp::Size pending_size_; | 210 pp::Size pending_size_; |
| 195 pp::Size plugin_size_; | 211 pp::Size plugin_size_; |
| 196 float pending_device_scale_; | 212 float pending_device_scale_; |
| 197 float device_scale_; | 213 float device_scale_; |
| 198 | 214 |
| 199 // True iff we're in the middle of a paint. | 215 // True iff we're in the middle of a paint. |
| 200 bool in_paint_; | 216 bool in_paint_; |
| 201 | 217 |
| 202 // True if we haven't painted the plugin viewport yet. | 218 // True if we haven't painted the plugin viewport yet. |
| 203 bool first_paint_; | 219 bool first_paint_; |
| 204 | 220 |
| 205 // True when the view size just changed and we're waiting for a paint. | 221 // True when the view size just changed and we're waiting for a paint. |
| 206 bool view_size_changed_waiting_for_paint_; | 222 bool view_size_changed_waiting_for_paint_; |
| 207 }; | 223 }; |
| 208 | 224 |
| 209 #endif // PDF_PAINT_MANAGER_H_ | 225 #endif // PDF_PAINT_MANAGER_H_ |
| OLD | NEW |