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

Side by Side Diff: ui/compositor/paint_recorder.cc

Issue 2849953004: SV Test
Patch Set: Created 3 years, 7 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 unified diff | Download patch
« no previous file with comments | « ui/compositor/paint_recorder.h ('k') | ui/gfx/canvas.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ui/compositor/paint_recorder.h" 5 #include "ui/compositor/paint_recorder.h"
6 6
7 #include "cc/paint/display_item_list.h" 7 #include "cc/paint/display_item_list.h"
8 #include "cc/paint/drawing_display_item.h" 8 #include "cc/paint/drawing_display_item.h"
9 #include "cc/paint/paint_recorder.h" 9 #include "cc/paint/paint_recorder.h"
10 #include "third_party/skia/include/core/SkRefCnt.h" 10 #include "third_party/skia/include/core/SkRefCnt.h"
11 #include "ui/compositor/paint_cache.h" 11 #include "ui/compositor/paint_cache.h"
12 #include "ui/compositor/paint_context.h" 12 #include "ui/compositor/paint_context.h"
13 #include "ui/gfx/skia_util.h" 13 #include "ui/gfx/skia_util.h"
14 14
15 namespace ui { 15 namespace ui {
16 namespace {
17 /*
18 gfx::Size ScaleIfNeeded(const gfx::Size& size,
19 const PaintContext& context,
20 bool is_already_scaled) {
21 if (is_already_scaled)
22 return size;
23 return gfx::ScaleToCeiledSize(size, context.device_scale_factor(),
24 context.device_scale_factor());
25 }
26 */
27 }
16 28
17 // This class records a reference to the context, the canvas returned 29 // This class records a reference to the context, the canvas returned
18 // by its recorder_, and the cache. Thus all 3 of these must remain 30 // by its recorder_, and the cache. Thus all 3 of these must remain
19 // valid for the lifetime of this object. 31 // valid for the lifetime of this object.
20 PaintRecorder::PaintRecorder(const PaintContext& context, 32 PaintRecorder::PaintRecorder(const PaintContext& context,
21 const gfx::Size& recording_size, 33 const gfx::Size& recording_size,
22 PaintCache* cache) 34 PaintCache* cache,
35 bool is_scaled)
23 : context_(context), 36 : context_(context),
24 canvas_(context.recorder_->beginRecording( 37 canvas_(
25 gfx::RectToSkRect(gfx::Rect(recording_size))), 38 context.recorder_->beginRecording(gfx::RectToSkRect(
26 context.device_scale_factor_), 39 gfx::Rect(context.pixel_size()))),
40 context.device_scale_factor()),
27 cache_(cache), 41 cache_(cache),
28 bounds_in_layer_(context.ToLayerSpaceBounds(recording_size)) { 42 bounds_in_layer_(context.ToLayerSpaceBounds(
43 context.pixel_size())) {
29 #if DCHECK_IS_ON() 44 #if DCHECK_IS_ON()
30 DCHECK(!context.inside_paint_recorder_); 45 DCHECK(!context.inside_paint_recorder_);
31 context.inside_paint_recorder_ = true; 46 context.inside_paint_recorder_ = true;
32 #endif 47 #endif
48 if (is_scaled) {
49 if (context.pixel_size() != recording_size) {
50 LOG(ERROR) << "Pixel size mismatch in paint recorder:" << context.pixel_si ze().ToString() << " vs " << recording_size.ToString();
51 }
52 } else {
53 if (context.size() != recording_size) {
54 LOG(ERROR) << "size mismatch in paint recorder:" << context.size().ToStrin g() << " vs " << recording_size.ToString();
55 }
56 }
57 gfx::Vector2dF scale = context.CanvasScale();
58 canvas()->Scale(scale.x(), scale.y());
33 } 59 }
34 60
35 PaintRecorder::PaintRecorder(const PaintContext& context, 61 PaintRecorder::PaintRecorder(const PaintContext& context,
36 const gfx::Size& recording_size) 62 const gfx::Size& recording_size)
37 : PaintRecorder(context, recording_size, nullptr) { 63 : PaintRecorder(context, recording_size, nullptr, false) {
38 } 64 }
39 65
40 PaintRecorder::~PaintRecorder() { 66 PaintRecorder::~PaintRecorder() {
41 #if DCHECK_IS_ON() 67 #if DCHECK_IS_ON()
42 context_.inside_paint_recorder_ = false; 68 context_.inside_paint_recorder_ = false;
43 #endif 69 #endif
44 const auto& item = 70 const auto& item =
45 context_.list_->CreateAndAppendDrawingItem<cc::DrawingDisplayItem>( 71 context_.list_->CreateAndAppendDrawingItem<cc::DrawingDisplayItem>(
46 bounds_in_layer_, context_.recorder_->finishRecordingAsPicture()); 72 bounds_in_layer_, context_.recorder_->finishRecordingAsPicture());
47 if (cache_) 73 if (cache_)
48 cache_->SetCache(item); 74 cache_->SetCache(item);
49 } 75 }
50 76
51 } // namespace ui 77 } // namespace ui
OLDNEW
« 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