Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(137)

Unified Diff: pdf/paint_manager.cc

Issue 1901903002: Improved Pinch-Zoom for PDF (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@pepper_add_set_layer_transform
Patch Set: Added LICENSE file Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: pdf/paint_manager.cc
diff --git a/pdf/paint_manager.cc b/pdf/paint_manager.cc
index 226994c3b054faa2e8b30af6768d844daa66f51e..01256e2f9e98cc18da693152857be6d952f6cded 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;
@@ -251,10 +274,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 +305,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 +320,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

Powered by Google App Engine
This is Rietveld 408576698