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

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

Issue 2877483003: Implements core logic for Pixel Canvas (Closed)
Patch Set: Resolving comments Created 3 years, 5 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
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/paint_recorder.h" 8 #include "cc/paint/paint_recorder.h"
9 #include "third_party/skia/include/core/SkRefCnt.h" 9 #include "third_party/skia/include/core/SkRefCnt.h"
10 #include "ui/compositor/paint_cache.h" 10 #include "ui/compositor/paint_cache.h"
(...skipping 14 matching lines...) Expand all
25 : context_(context), 25 : context_(context),
26 record_canvas_(cache ? cache->ResetCache() : context_.list_->StartPaint(), 26 record_canvas_(cache ? cache->ResetCache() : context_.list_->StartPaint(),
27 gfx::RectToSkRect(gfx::Rect(recording_size))), 27 gfx::RectToSkRect(gfx::Rect(recording_size))),
28 canvas_(&record_canvas_, context.device_scale_factor_), 28 canvas_(&record_canvas_, context.device_scale_factor_),
29 cache_(cache), 29 cache_(cache),
30 recording_size_(recording_size) { 30 recording_size_(recording_size) {
31 #if DCHECK_IS_ON() 31 #if DCHECK_IS_ON()
32 DCHECK(!context.inside_paint_recorder_); 32 DCHECK(!context.inside_paint_recorder_);
33 context.inside_paint_recorder_ = true; 33 context.inside_paint_recorder_ = true;
34 #endif 34 #endif
35 if (context_.IsPixelCanvas()) {
36 canvas()->Save();
37 canvas()->Scale(context.paint_recording_scale_x_,
38 context.paint_recording_scale_y_);
39 }
35 } 40 }
36 41
37 PaintRecorder::PaintRecorder(const PaintContext& context, 42 PaintRecorder::PaintRecorder(const PaintContext& context,
38 const gfx::Size& recording_size) 43 const gfx::Size& recording_size)
39 : PaintRecorder(context, recording_size, nullptr) {} 44 : PaintRecorder(context,
45 gfx::ScaleToRoundedSize(recording_size,
46 context.paint_recording_scale_x_,
47 context.paint_recording_scale_y_),
48 nullptr) {}
40 49
41 PaintRecorder::~PaintRecorder() { 50 PaintRecorder::~PaintRecorder() {
42 #if DCHECK_IS_ON() 51 #if DCHECK_IS_ON()
43 context_.inside_paint_recorder_ = false; 52 context_.inside_paint_recorder_ = false;
44 #endif 53 #endif
54 if (context_.IsPixelCanvas())
55 canvas()->Restore();
45 // If using cache, append what we've saved there to the PaintContext. 56 // If using cache, append what we've saved there to the PaintContext.
46 // Otherwise, the content is already stored in the PaintContext, and we can 57 // Otherwise, the content is already stored in the PaintContext, and we can
47 // just close it. 58 // just close it.
48 if (cache_) { 59 if (cache_) {
49 cache_->FinalizeCache(); 60 cache_->FinalizeCache();
50 cache_->UseCache(context_, recording_size_); 61 cache_->UseCache(context_, recording_size_);
51 } else { 62 } else {
52 gfx::Rect bounds_in_layer = context_.ToLayerSpaceBounds(recording_size_); 63 gfx::Rect bounds_in_layer = context_.ToLayerSpaceBounds(recording_size_);
53 context_.list_->EndPaintOfUnpaired(bounds_in_layer); 64 context_.list_->EndPaintOfUnpaired(bounds_in_layer);
54 } 65 }
55 } 66 }
56 67
57 } // namespace ui 68 } // namespace ui
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698