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

Unified Diff: pdf/paint_manager.cc

Issue 2400743002: Improved Pinch-Zoom for PDF. (Closed)
Patch Set: Created 4 years, 2 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 7811f07d5f6ca36662be9c1089cef10c8a11be26..8efa5586534f2d8ab941443cccbf4c0d026d882d 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),
@@ -98,16 +99,38 @@ void PaintManager::SetSize(const pp::Size& new_size, float device_scale) {
if (GetEffectiveSize() == new_size &&
GetEffectiveDeviceScale() == device_scale)
return;
-
has_pending_resize_ = true;
Kevin McNee - google account 2016/10/06 21:53:18 Unnecessary whitespace change.
Kevin McNee - google account 2016/10/13 18:19:24 Done.
pending_size_ = new_size;
pending_device_scale_ = device_scale;
view_size_changed_waiting_for_paint_ = true;
-
Invalidate();
Kevin McNee - google account 2016/10/06 21:53:18 Unnecessary whitespace change.
Kevin McNee - google account 2016/10/13 18:19:24 Done.
}
+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;
@@ -260,10 +283,8 @@ void PaintManager::DoPaint() {
graphics_.PaintImageData(
ready_rect.image_data, ready_rect.offset, ready_rect.rect);
}
Kevin McNee - google account 2016/10/06 21:53:18 Unnecessary whitespace change.
Kevin McNee - google account 2016/10/13 18:19:24 Done.
-
int32_t result = graphics_.Flush(
callback_factory_.NewCallback(&PaintManager::OnFlushComplete));
Kevin McNee - google account 2016/10/06 21:53:18 Unnecessary whitespace change.
Kevin McNee - google account 2016/10/13 18:19:24 Done.
-
// 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
@@ -293,7 +314,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())
@@ -303,7 +329,6 @@ void PaintManager::OnFlushComplete(int32_t) {
void PaintManager::OnManualCallbackComplete(int32_t) {
DCHECK(manual_callback_pending_);
manual_callback_pending_ = false;
Kevin McNee - google account 2016/10/06 21:53:18 Unnecessary whitespace change.
Kevin McNee - google account 2016/10/13 18:19:24 Done.
-
// 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