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

Unified Diff: ui/compositor/paint_recorder.cc

Issue 2849953004: SV Test
Patch Set: Created 3 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
« no previous file with comments | « ui/compositor/paint_recorder.h ('k') | ui/gfx/canvas.h » ('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 f93d700b37e487a8f3491f3dcd570e3c09b97648..30270cd744da82f6380417632fa235f797bc18fb 100644
--- a/ui/compositor/paint_recorder.cc
+++ b/ui/compositor/paint_recorder.cc
@@ -13,28 +13,54 @@
#include "ui/gfx/skia_util.h"
namespace ui {
+namespace {
+/*
+gfx::Size ScaleIfNeeded(const gfx::Size& size,
+ const PaintContext& context,
+ bool is_already_scaled) {
+ if (is_already_scaled)
+ return size;
+ return gfx::ScaleToCeiledSize(size, context.device_scale_factor(),
+ context.device_scale_factor());
+}
+*/
+}
// This class records a reference to the context, the canvas returned
// by its recorder_, and the cache. Thus all 3 of these must remain
// valid for the lifetime of this object.
PaintRecorder::PaintRecorder(const PaintContext& context,
const gfx::Size& recording_size,
- PaintCache* cache)
+ PaintCache* cache,
+ bool is_scaled)
: context_(context),
- canvas_(context.recorder_->beginRecording(
- gfx::RectToSkRect(gfx::Rect(recording_size))),
- context.device_scale_factor_),
+ canvas_(
+ context.recorder_->beginRecording(gfx::RectToSkRect(
+ gfx::Rect(context.pixel_size()))),
+ context.device_scale_factor()),
cache_(cache),
- bounds_in_layer_(context.ToLayerSpaceBounds(recording_size)) {
+ bounds_in_layer_(context.ToLayerSpaceBounds(
+ context.pixel_size())) {
#if DCHECK_IS_ON()
DCHECK(!context.inside_paint_recorder_);
context.inside_paint_recorder_ = true;
#endif
+ if (is_scaled) {
+ if (context.pixel_size() != recording_size) {
+ LOG(ERROR) << "Pixel size mismatch in paint recorder:" << context.pixel_size().ToString() << " vs " << recording_size.ToString();
+ }
+ } else {
+ if (context.size() != recording_size) {
+ LOG(ERROR) << "size mismatch in paint recorder:" << context.size().ToString() << " vs " << recording_size.ToString();
+ }
+ }
+ gfx::Vector2dF scale = context.CanvasScale();
+ canvas()->Scale(scale.x(), scale.y());
}
PaintRecorder::PaintRecorder(const PaintContext& context,
const gfx::Size& recording_size)
- : PaintRecorder(context, recording_size, nullptr) {
+ : PaintRecorder(context, recording_size, nullptr, false) {
}
PaintRecorder::~PaintRecorder() {
« no previous file with comments | « ui/compositor/paint_recorder.h ('k') | ui/gfx/canvas.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698