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

Unified Diff: pdf/paint_manager.cc

Issue 2400743002: Improved Pinch-Zoom for PDF. (Closed)
Patch Set: More code review changes. 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..2ffa5098bbdc01b03f90cda4d9289895fc08f174 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,30 @@ 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) {
+ if (graphics_.is_null())
+ return;
+
+ graphics_.SetLayerTransform(scale, origin, translate);
+
+ if (flush_pending_) {
Lei Zhang 2016/10/27 23:04:33 Given the differences in behavior, maybe this meth
Kevin McNee - google account 2016/10/28 19:19:38 I've made the behaviour w.r.t. flushing more expli
+ flush_requested_ = true;
+ return;
+ }
+ Flush();
+}
+
+void PaintManager::SetTransform(float scale) {
+ if (graphics_.is_null())
+ return;
+
+ graphics_.SetLayerTransform(scale, pp::Point(), pp::Point());
+
+ EnsureCallbackPending();
+}
+
void PaintManager::Invalidate() {
if (graphics_.is_null() && !has_pending_resize_)
return;
@@ -261,6 +286,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 +319,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 +329,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) {

Powered by Google App Engine
This is Rietveld 408576698