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

Unified Diff: ui/compositor/paint_recorder.cc

Issue 2877483003: Implements core logic for Pixel Canvas (Closed)
Patch Set: Sync with ToT Created 3 years, 4 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
« no previous file with comments | « ui/compositor/paint_recorder.h ('k') | ui/compositor/test/test_compositor_host_android.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/compositor/paint_recorder.cc
diff --git a/ui/compositor/paint_recorder.cc b/ui/compositor/paint_recorder.cc
index ddf9f1b76c9c4abe4fee81dc05775eac97802267..f85d3cbdc7685c815979a16faf6b302d2dd36fc2 100644
--- a/ui/compositor/paint_recorder.cc
+++ b/ui/compositor/paint_recorder.cc
@@ -21,6 +21,8 @@ namespace ui {
// to the |context|'s PaintOpBuffer.
PaintRecorder::PaintRecorder(const PaintContext& context,
const gfx::Size& recording_size,
+ float recording_scale_x,
+ float recording_scale_y,
PaintCache* cache)
: context_(context),
local_list_(cache ? base::MakeRefCounted<cc::DisplayItemList>(
@@ -38,19 +40,34 @@ PaintRecorder::PaintRecorder(const PaintContext& context,
}
#if DCHECK_IS_ON()
- DCHECK(!context.inside_paint_recorder_);
- context.inside_paint_recorder_ = true;
+ DCHECK(!context_.inside_paint_recorder_);
+ context_.inside_paint_recorder_ = true;
#endif
+ if (context_.is_pixel_canvas()) {
+ canvas()->Save();
+ canvas()->Scale(recording_scale_x, recording_scale_y);
+ }
}
+// TODO(malaykeshav): The scaling of recording size needs to be handled case
+// by case and the decision to perform the scale should be moved to the caller.
PaintRecorder::PaintRecorder(const PaintContext& context,
const gfx::Size& recording_size)
- : PaintRecorder(context, recording_size, nullptr) {}
+ : PaintRecorder(
+ context,
+ gfx::ScaleToRoundedSize(
+ recording_size,
+ context.is_pixel_canvas() ? context.device_scale_factor_ : 1.f),
+ context.device_scale_factor_,
+ context.device_scale_factor_,
+ nullptr) {}
PaintRecorder::~PaintRecorder() {
#if DCHECK_IS_ON()
context_.inside_paint_recorder_ = false;
#endif
+ if (context_.is_pixel_canvas())
+ canvas()->Restore();
// If using cache, append what we've saved there to the PaintContext.
// Otherwise, the content is already stored in the PaintContext, and we can
// just close it.
« no previous file with comments | « ui/compositor/paint_recorder.h ('k') | ui/compositor/test/test_compositor_host_android.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698