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

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

Issue 2877483003: Implements core logic for Pixel Canvas (Closed)
Patch Set: Updated GetContextScaleType() from public to protected Created 3 years, 6 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.effective_scale_factor_x(),
38 context.effective_scale_factor_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 context.ScaleToCorneredPixelSize(recording_size),
46 nullptr) {}
40 47
41 PaintRecorder::~PaintRecorder() { 48 PaintRecorder::~PaintRecorder() {
42 #if DCHECK_IS_ON() 49 #if DCHECK_IS_ON()
43 context_.inside_paint_recorder_ = false; 50 context_.inside_paint_recorder_ = false;
44 #endif 51 #endif
52 if (context_.IsPixelCanvas())
53 canvas()->Restore();
45 // If using cache, append what we've saved there to the PaintContext. 54 // 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 55 // Otherwise, the content is already stored in the PaintContext, and we can
47 // just close it. 56 // just close it.
48 if (cache_) { 57 if (cache_) {
49 cache_->FinalizeCache(); 58 cache_->FinalizeCache();
50 cache_->UseCache(context_, recording_size_); 59 cache_->UseCache(context_, recording_size_);
51 } else { 60 } else {
52 gfx::Rect bounds_in_layer = context_.ToLayerSpaceBounds(recording_size_); 61 gfx::Rect bounds_in_layer = context_.ToLayerSpaceBounds(recording_size_);
53 context_.list_->EndPaintOfUnpaired(bounds_in_layer); 62 context_.list_->EndPaintOfUnpaired(bounds_in_layer);
54 } 63 }
55 } 64 }
56 65
57 } // namespace ui 66 } // namespace ui
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698