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

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

Issue 2476113002: Change call-sites now that SkCanvas is not ref-counted (Closed)
Patch Set: address comments from #6 Created 4 years, 1 month 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/playback/display_item_list.h" 7 #include "cc/playback/display_item_list.h"
8 #include "cc/playback/drawing_display_item.h" 8 #include "cc/playback/drawing_display_item.h"
9 #include "third_party/skia/include/core/SkPictureRecorder.h" 9 #include "third_party/skia/include/core/SkPictureRecorder.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 16
17 PaintRecorder::PaintRecorder(const PaintContext& context, 17 PaintRecorder::PaintRecorder(const PaintContext& context,
18 const gfx::Size& recording_size, 18 const gfx::Size& recording_size,
19 PaintCache* cache) 19 PaintCache* cache)
20 : context_(context), 20 : context_(context),
21 // The SkCanvas reference returned by beginRecording is shared with 21 // The SkCanvas pointer returned by beginRecording is owned by the
22 // the recorder_ so no need to store a RefPtr to it on this class, we just 22 // recorder_
danakj 2016/11/14 20:59:56 fix wrapping please
reed1 2016/11/14 21:28:51 Done.
23 // store the gfx::Canvas. 23 // so no need to store a RefPtr to it on this class, we just store the
danakj 2016/11/14 20:59:56 Hm this is still referring to RefPtr. How about s
reed1 2016/11/14 21:28:51 New comment uploaded, that also references cache,
24 canvas_(sk_ref_sp(context.recorder_->beginRecording( 24 // gfx::Canvas.
25 gfx::RectToSkRect(gfx::Rect(recording_size)))), 25 // The caller must ensure that the PaintContext's recorder_ outlives this
26 // object.
27 canvas_(context.recorder_->beginRecording(
28 gfx::RectToSkRect(gfx::Rect(recording_size))),
26 context.device_scale_factor_), 29 context.device_scale_factor_),
27 cache_(cache), 30 cache_(cache),
28 bounds_in_layer_(context.ToLayerSpaceBounds(recording_size)) { 31 bounds_in_layer_(context.ToLayerSpaceBounds(recording_size)) {
29 #if DCHECK_IS_ON() 32 #if DCHECK_IS_ON()
30 DCHECK(!context.inside_paint_recorder_); 33 DCHECK(!context.inside_paint_recorder_);
31 context.inside_paint_recorder_ = true; 34 context.inside_paint_recorder_ = true;
32 #endif 35 #endif
33 } 36 }
34 37
35 PaintRecorder::PaintRecorder(const PaintContext& context, 38 PaintRecorder::PaintRecorder(const PaintContext& context,
36 const gfx::Size& recording_size) 39 const gfx::Size& recording_size)
37 : PaintRecorder(context, recording_size, nullptr) { 40 : PaintRecorder(context, recording_size, nullptr) {
38 } 41 }
39 42
40 PaintRecorder::~PaintRecorder() { 43 PaintRecorder::~PaintRecorder() {
41 #if DCHECK_IS_ON() 44 #if DCHECK_IS_ON()
42 context_.inside_paint_recorder_ = false; 45 context_.inside_paint_recorder_ = false;
43 #endif 46 #endif
44 const auto& item = 47 const auto& item =
45 context_.list_->CreateAndAppendDrawingItem<cc::DrawingDisplayItem>( 48 context_.list_->CreateAndAppendDrawingItem<cc::DrawingDisplayItem>(
46 bounds_in_layer_, context_.recorder_->finishRecordingAsPicture()); 49 bounds_in_layer_, context_.recorder_->finishRecordingAsPicture());
47 if (cache_) 50 if (cache_)
48 cache_->SetCache(item); 51 cache_->SetCache(item);
49 } 52 }
50 53
51 } // namespace ui 54 } // namespace ui
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/platform/graphics/GraphicsContext.cpp ('k') | ui/gfx/blit_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698