Index: pdf/paint_manager.cc |
diff --git a/pdf/paint_manager.cc b/pdf/paint_manager.cc |
index 226994c3b054faa2e8b30af6768d844daa66f51e..7c738d124b0cb36c97a0f5b7f25c271bb1065217 100644 |
--- a/pdf/paint_manager.cc |
+++ b/pdf/paint_manager.cc |
@@ -23,6 +23,7 @@ PaintManager::PaintManager(pp::Instance* instance, |
callback_factory_(NULL), |
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), |
@@ -89,16 +90,38 @@ void PaintManager::SetSize(const pp::Size& new_size, float device_scale) { |
if (GetEffectiveSize() == new_size && |
GetEffectiveDeviceScale() == device_scale) |
return; |
- |
has_pending_resize_ = true; |
pending_size_ = new_size; |
pending_device_scale_ = device_scale; |
view_size_changed_waiting_for_paint_ = true; |
- |
Invalidate(); |
} |
+void PaintManager::SetTransform(float scale, |
+ pp::Point origin, |
+ pp::Point translate) { |
+ if (!flush_pending_) { |
+ graphics_.SetLayerTransform(scale, origin, translate); |
+ flush_pending_ = true; |
+ flush_requested_ = false; |
+ graphics_.Flush( |
+ callback_factory_.NewCallback(&PaintManager::OnFlushComplete)); |
+ scale_ = 1.f; |
+ origin_ = pp::Point(); |
+ transform_ = pp::Point(); |
+ } else { |
+ flush_requested_ = true; |
+ graphics_.SetLayerTransform(scale, origin, translate); |
+ } |
+} |
+ |
+void PaintManager::SetTransform(float scale) { |
+ graphics_.SetLayerTransform(scale, pp::Point(), pp::Point()); |
+ |
+ EnsureCallbackPending(); |
+} |
+ |
void PaintManager::Invalidate() { |
if (graphics_.is_null() && !has_pending_resize_) |
return; |
@@ -125,7 +148,6 @@ void PaintManager::InvalidateRect(const pp::Rect& rect) { |
void PaintManager::ScrollRect(const pp::Rect& clip_rect, |
const pp::Point& amount) { |
DCHECK(!in_paint_); |
- |
wjmaclean
2016/04/21 14:11:02
Undo white space changes.
alessandroa
2016/04/22 14:33:05
Done.
|
if (graphics_.is_null() && !has_pending_resize_) |
return; |
@@ -163,7 +185,6 @@ void PaintManager::EnsureCallbackPending() { |
void PaintManager::DoPaint() { |
in_paint_ = true; |
- |
wjmaclean
2016/04/21 14:11:02
Ditto.
alessandroa
2016/04/22 14:33:05
Done.
|
std::vector<ReadyRect> ready; |
std::vector<pp::Rect> pending; |
@@ -190,15 +211,16 @@ void PaintManager::DoPaint() { |
callback_factory_.CancelAll(); |
} |
- if (pending_device_scale_ != 1.0) |
+ if (pending_device_scale_ != device_scale_) |
bokan
2016/04/21 18:20:17
Is this related to the pinch zoom functionality or
alessandroa
2016/04/22 14:33:05
Reverted :)
|
graphics_.SetScale(1.0 / pending_device_scale_); |
+ |
wjmaclean
2016/04/21 14:11:02
Remove blank line.
alessandroa
2016/04/22 14:33:05
Done.
|
device_scale_ = pending_device_scale_; |
// This must be cleared before calling into the plugin since it may do |
// additional invalidation or sizing operations. |
has_pending_resize_ = false; |
pending_size_ = pp::Size(); |
- } |
+ } |
wjmaclean
2016/04/21 14:11:02
Undo this change ...
alessandroa
2016/04/22 14:33:05
Done.
|
PaintAggregator::PaintUpdate update = aggregator_.GetPendingUpdate(); |
client_->OnPaint(update.paint_rects, &ready, &pending); |
@@ -251,10 +273,8 @@ void PaintManager::DoPaint() { |
graphics_.PaintImageData( |
ready_rect.image_data, ready_rect.offset, ready_rect.rect); |
} |
- |
int32_t result = graphics_.Flush( |
callback_factory_.NewCallback(&PaintManager::OnFlushComplete)); |
- |
// If you trigger this assertion, then your plugin has called Flush() |
// manually. When using the PaintManager, you should not call Flush, it will |
// handle that for you because it needs to know when it can do the next paint |
@@ -284,7 +304,12 @@ void PaintManager::DoPaint() { |
void PaintManager::OnFlushComplete(int32_t) { |
DCHECK(flush_pending_); |
flush_pending_ = false; |
- |
+ // If there was another flush request while flushing we flush again. |
+ if (flush_requested_) { |
+ flush_requested_ = false; |
+ graphics_.Flush( |
+ callback_factory_.NewCallback(&PaintManager::OnFlushComplete)); |
+ } |
// If more paints were enqueued while we were waiting for the flush to |
// complete, execute them now. |
if (aggregator_.HasPendingUpdate()) |
@@ -294,7 +319,6 @@ void PaintManager::OnFlushComplete(int32_t) { |
void PaintManager::OnManualCallbackComplete(int32_t) { |
DCHECK(manual_callback_pending_); |
manual_callback_pending_ = false; |
- |
// Just because we have a manual callback doesn't mean there are actually any |
// invalid regions. Even though we only schedule this callback when something |
// is pending, a Flush callback could have come in before this callback was |