Index: pdf/paint_manager.cc |
diff --git a/pdf/paint_manager.cc b/pdf/paint_manager.cc |
index 7811f07d5f6ca36662be9c1089cef10c8a11be26..ea9cc7814679f0c077ce1e0861a83fab2d4fef93 100644 |
--- a/pdf/paint_manager.cc |
+++ b/pdf/paint_manager.cc |
@@ -32,6 +32,7 @@ PaintManager::PaintManager(pp::Instance* instance, |
callback_factory_(nullptr), |
manual_callback_pending_(false), |
flush_pending_(false), |
+ flush_requested_(false), |
has_pending_resize_(false), |
graphics_need_to_be_bound_(false), |
pending_device_scale_(1.0), |
@@ -108,6 +109,29 @@ void PaintManager::SetSize(const pp::Size& new_size, float device_scale) { |
Invalidate(); |
} |
+void PaintManager::SetTransform(float scale, |
+ const pp::Point& origin, |
+ const pp::Point& translate, |
+ bool schedule_flush) { |
+ if (graphics_.is_null()) |
+ return; |
+ |
+ graphics_.SetLayerTransform(scale, origin, translate); |
+ |
+ if (!schedule_flush) |
+ return; |
+ |
+ if (flush_pending_) { |
+ flush_requested_ = true; |
+ return; |
+ } |
+ Flush(); |
+} |
+ |
+void PaintManager::ClearTransform() { |
+ SetTransform(1.f, pp::Point(), pp::Point(), false); |
+} |
+ |
void PaintManager::Invalidate() { |
if (graphics_.is_null() && !has_pending_resize_) |
return; |
@@ -261,6 +285,20 @@ void PaintManager::DoPaint() { |
ready_rect.image_data, ready_rect.offset, ready_rect.rect); |
} |
+ Flush(); |
+ |
+ in_paint_ = false; |
+ first_paint_ = false; |
+ |
+ if (graphics_need_to_be_bound_) { |
+ instance_->BindGraphics(graphics_); |
+ graphics_need_to_be_bound_ = false; |
+ } |
+} |
+ |
+void PaintManager::Flush() { |
+ flush_requested_ = false; |
+ |
int32_t result = graphics_.Flush( |
callback_factory_.NewCallback(&PaintManager::OnFlushComplete)); |
@@ -280,14 +318,6 @@ void PaintManager::DoPaint() { |
} else { |
DCHECK(result == PP_OK); // Catch all other errors in debug mode. |
} |
- |
- in_paint_ = false; |
- first_paint_ = false; |
- |
- if (graphics_need_to_be_bound_) { |
- instance_->BindGraphics(graphics_); |
- graphics_need_to_be_bound_ = false; |
- } |
} |
void PaintManager::OnFlushComplete(int32_t) { |
@@ -298,6 +328,11 @@ void PaintManager::OnFlushComplete(int32_t) { |
// complete, execute them now. |
if (aggregator_.HasPendingUpdate()) |
DoPaint(); |
+ |
+ // If there was another flush request while flushing we flush again. |
+ if (flush_requested_) { |
+ Flush(); |
+ } |
} |
void PaintManager::OnManualCallbackComplete(int32_t) { |