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 #include "pdf/paint_manager.h" | 5 #include "pdf/paint_manager.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <algorithm> | 10 #include <algorithm> |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 25 | 25 |
| 26 PaintManager::PaintManager(pp::Instance* instance, | 26 PaintManager::PaintManager(pp::Instance* instance, |
| 27 Client* client, | 27 Client* client, |
| 28 bool is_always_opaque) | 28 bool is_always_opaque) |
| 29 : instance_(instance), | 29 : instance_(instance), |
| 30 client_(client), | 30 client_(client), |
| 31 is_always_opaque_(is_always_opaque), | 31 is_always_opaque_(is_always_opaque), |
| 32 callback_factory_(nullptr), | 32 callback_factory_(nullptr), |
| 33 manual_callback_pending_(false), | 33 manual_callback_pending_(false), |
| 34 flush_pending_(false), | 34 flush_pending_(false), |
| 35 flush_requested_(false), | |
| 35 has_pending_resize_(false), | 36 has_pending_resize_(false), |
| 36 graphics_need_to_be_bound_(false), | 37 graphics_need_to_be_bound_(false), |
| 37 pending_device_scale_(1.0), | 38 pending_device_scale_(1.0), |
| 38 device_scale_(1.0), | 39 device_scale_(1.0), |
| 39 in_paint_(false), | 40 in_paint_(false), |
| 40 first_paint_(true), | 41 first_paint_(true), |
| 41 view_size_changed_waiting_for_paint_(false) { | 42 view_size_changed_waiting_for_paint_(false) { |
| 42 // Set the callback object outside of the initializer list to avoid a | 43 // Set the callback object outside of the initializer list to avoid a |
| 43 // compiler warning about using "this" in an initializer list. | 44 // compiler warning about using "this" in an initializer list. |
| 44 callback_factory_.Initialize(this); | 45 callback_factory_.Initialize(this); |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 101 | 102 |
| 102 has_pending_resize_ = true; | 103 has_pending_resize_ = true; |
| 103 pending_size_ = new_size; | 104 pending_size_ = new_size; |
| 104 pending_device_scale_ = device_scale; | 105 pending_device_scale_ = device_scale; |
| 105 | 106 |
| 106 view_size_changed_waiting_for_paint_ = true; | 107 view_size_changed_waiting_for_paint_ = true; |
| 107 | 108 |
| 108 Invalidate(); | 109 Invalidate(); |
| 109 } | 110 } |
| 110 | 111 |
| 112 void PaintManager::SetTransform(float scale, | |
| 113 pp::Point origin, | |
| 114 pp::Point translate) { | |
| 115 if (!flush_pending_) { | |
| 116 graphics_.SetLayerTransform(scale, origin, translate); | |
| 117 flush_pending_ = true; | |
| 118 flush_requested_ = false; | |
| 119 graphics_.Flush( | |
|
Kevin McNee - google account
2016/10/24 15:57:55
Use the return value of Flush to determine how to
Kevin McNee - google account
2016/10/24 21:11:47
Done.
| |
| 120 callback_factory_.NewCallback(&PaintManager::OnFlushComplete)); | |
| 121 scale_ = 1.f; | |
| 122 origin_ = pp::Point(); | |
| 123 transform_ = pp::Point(); | |
|
Kevin McNee - google account
2016/10/24 15:57:55
Not used.
Kevin McNee - google account
2016/10/24 21:11:47
Done.
| |
| 124 } else { | |
| 125 flush_requested_ = true; | |
| 126 graphics_.SetLayerTransform(scale, origin, translate); | |
| 127 } | |
| 128 } | |
| 129 | |
| 130 void PaintManager::SetTransform(float scale) { | |
| 131 graphics_.SetLayerTransform(scale, pp::Point(), pp::Point()); | |
| 132 | |
| 133 EnsureCallbackPending(); | |
| 134 } | |
| 135 | |
| 111 void PaintManager::Invalidate() { | 136 void PaintManager::Invalidate() { |
| 112 if (graphics_.is_null() && !has_pending_resize_) | 137 if (graphics_.is_null() && !has_pending_resize_) |
| 113 return; | 138 return; |
| 114 | 139 |
| 115 EnsureCallbackPending(); | 140 EnsureCallbackPending(); |
| 116 aggregator_.InvalidateRect(pp::Rect(GetEffectiveSize())); | 141 aggregator_.InvalidateRect(pp::Rect(GetEffectiveSize())); |
| 117 } | 142 } |
| 118 | 143 |
| 119 void PaintManager::InvalidateRect(const pp::Rect& rect) { | 144 void PaintManager::InvalidateRect(const pp::Rect& rect) { |
| 120 DCHECK(!in_paint_); | 145 DCHECK(!in_paint_); |
| (...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 287 if (graphics_need_to_be_bound_) { | 312 if (graphics_need_to_be_bound_) { |
| 288 instance_->BindGraphics(graphics_); | 313 instance_->BindGraphics(graphics_); |
| 289 graphics_need_to_be_bound_ = false; | 314 graphics_need_to_be_bound_ = false; |
| 290 } | 315 } |
| 291 } | 316 } |
| 292 | 317 |
| 293 void PaintManager::OnFlushComplete(int32_t) { | 318 void PaintManager::OnFlushComplete(int32_t) { |
| 294 DCHECK(flush_pending_); | 319 DCHECK(flush_pending_); |
| 295 flush_pending_ = false; | 320 flush_pending_ = false; |
| 296 | 321 |
| 322 // If there was another flush request while flushing we flush again. | |
| 323 if (flush_requested_) { | |
| 324 flush_requested_ = false; | |
| 325 graphics_.Flush( | |
|
Kevin McNee - google account
2016/10/24 15:57:55
See above wrt calling Flush.
Kevin McNee - google account
2016/10/24 21:11:47
Done.
| |
| 326 callback_factory_.NewCallback(&PaintManager::OnFlushComplete)); | |
| 327 } | |
| 328 | |
| 297 // If more paints were enqueued while we were waiting for the flush to | 329 // If more paints were enqueued while we were waiting for the flush to |
| 298 // complete, execute them now. | 330 // complete, execute them now. |
| 299 if (aggregator_.HasPendingUpdate()) | 331 if (aggregator_.HasPendingUpdate()) |
| 300 DoPaint(); | 332 DoPaint(); |
| 301 } | 333 } |
| 302 | 334 |
| 303 void PaintManager::OnManualCallbackComplete(int32_t) { | 335 void PaintManager::OnManualCallbackComplete(int32_t) { |
| 304 DCHECK(manual_callback_pending_); | 336 DCHECK(manual_callback_pending_); |
| 305 manual_callback_pending_ = false; | 337 manual_callback_pending_ = false; |
| 306 | 338 |
| 307 // Just because we have a manual callback doesn't mean there are actually any | 339 // Just because we have a manual callback doesn't mean there are actually any |
| 308 // invalid regions. Even though we only schedule this callback when something | 340 // invalid regions. Even though we only schedule this callback when something |
| 309 // is pending, a Flush callback could have come in before this callback was | 341 // is pending, a Flush callback could have come in before this callback was |
| 310 // executed and that could have cleared the queue. | 342 // executed and that could have cleared the queue. |
| 311 if (aggregator_.HasPendingUpdate()) | 343 if (aggregator_.HasPendingUpdate()) |
| 312 DoPaint(); | 344 DoPaint(); |
| 313 } | 345 } |
| OLD | NEW |