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

Unified Diff: pdf/paint_manager.cc

Issue 2400743002: Improved Pinch-Zoom for PDF. (Closed)
Patch Set: 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..b612dac120d14c93a1acfa0c6a1b1b1e01fdc797 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,23 @@ void PaintManager::SetSize(const pp::Size& new_size, float device_scale) {
Invalidate();
}
+void PaintManager::SetTransform(float scale,
+ pp::Point origin,
+ pp::Point translate) {
+ graphics_.SetLayerTransform(scale, origin, translate);
Lei Zhang 2016/10/27 16:56:36 A few methods check for the following. Should this
Kevin McNee - google account 2016/10/27 21:40:30 Yeah, checking graphics_.is_null() is a good idea,
+ if (!flush_pending_) {
Lei Zhang 2016/10/27 16:56:36 Does this read better? if (flush_pending_) { fl
Kevin McNee - google account 2016/10/27 21:40:30 Done.
+ Flush();
+ } else {
+ flush_requested_ = true;
+ }
+}
+
+void PaintManager::SetTransform(float scale) {
+ graphics_.SetLayerTransform(scale, pp::Point(), pp::Point());
+
+ EnsureCallbackPending();
+}
+
void PaintManager::Invalidate() {
if (graphics_.is_null() && !has_pending_resize_)
return;
@@ -261,6 +279,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 +312,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 +322,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