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

Side by Side Diff: cc/picture.cc

Issue 11412255: cc: Use skia::RefPtr in place of raw pointers and SkAutoTUnref. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: ref() Created 8 years 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 | Annotate | Revision Log
« no previous file with comments | « cc/picture.h ('k') | cc/render_pass.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 2012 The Chromium Authors. All rights reserved. 1 // Copyright 2012 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 "base/debug/trace_event.h" 5 #include "base/debug/trace_event.h"
6 #include "cc/content_layer_client.h" 6 #include "cc/content_layer_client.h"
7 #include "cc/picture.h" 7 #include "cc/picture.h"
8 #include "cc/rendering_stats.h" 8 #include "cc/rendering_stats.h"
9 #include "third_party/skia/include/core/SkCanvas.h" 9 #include "third_party/skia/include/core/SkCanvas.h"
10 #include "ui/gfx/rect_conversions.h" 10 #include "ui/gfx/rect_conversions.h"
11 11
12 namespace cc { 12 namespace cc {
13 13
14 scoped_refptr<Picture> Picture::Create() { 14 scoped_refptr<Picture> Picture::Create() {
15 return make_scoped_refptr(new Picture()); 15 return make_scoped_refptr(new Picture());
16 } 16 }
17 17
18 Picture::Picture() { 18 Picture::Picture() {
19 } 19 }
20 20
21 Picture::Picture(SkPicture* picture, gfx::Rect layer_rect, 21 Picture::Picture(const skia::RefPtr<SkPicture>& picture,
22 gfx::Rect layer_rect,
22 gfx::Rect opaque_rect) : 23 gfx::Rect opaque_rect) :
23 layer_rect_(layer_rect), 24 layer_rect_(layer_rect),
24 opaque_rect_(opaque_rect), 25 opaque_rect_(opaque_rect),
25 picture_(picture) { 26 picture_(picture) {
26 } 27 }
27 28
28 Picture::~Picture() { 29 Picture::~Picture() {
29 } 30 }
30 31
31 scoped_refptr<Picture> Picture::Clone() { 32 scoped_refptr<Picture> Picture::Clone() {
32 // SkPicture is not thread-safe to rasterize with, so return a thread-safe 33 // SkPicture is not thread-safe to rasterize with, so return a thread-safe
33 // clone of it. 34 // clone of it.
34 DCHECK(picture_.get()); 35 DCHECK(picture_);
35 SkPicture* clone = picture_->clone(); 36 skia::RefPtr<SkPicture> clone = skia::AdoptRef(picture_->clone());
36 return make_scoped_refptr(new Picture(clone, layer_rect_, opaque_rect_)); 37 return make_scoped_refptr(new Picture(clone, layer_rect_, opaque_rect_));
37 } 38 }
38 39
39 void Picture::Record(ContentLayerClient* painter, gfx::Rect layer_rect, 40 void Picture::Record(ContentLayerClient* painter, gfx::Rect layer_rect,
40 RenderingStats& stats) { 41 RenderingStats& stats) {
41 TRACE_EVENT0("cc", "Picture::Record"); 42 TRACE_EVENT0("cc", "Picture::Record");
42 43
43 // Record() should only be called once. 44 // Record() should only be called once.
44 DCHECK(!picture_.get()); 45 DCHECK(!picture_);
45 picture_.reset(new SkPicture); 46 picture_ = skia::AdoptRef(new SkPicture);
46 47
47 SkCanvas* canvas = picture_->beginRecording( 48 SkCanvas* canvas = picture_->beginRecording(
48 layer_rect.width(), 49 layer_rect.width(),
49 layer_rect.height(), 50 layer_rect.height(),
50 SkPicture::kOptimizeForClippedPlayback_RecordingFlag); 51 SkPicture::kOptimizeForClippedPlayback_RecordingFlag);
51 52
52 canvas->save(); 53 canvas->save();
53 canvas->translate(SkFloatToScalar(-layer_rect.x()), 54 canvas->translate(SkFloatToScalar(-layer_rect.x()),
54 SkFloatToScalar(-layer_rect.y())); 55 SkFloatToScalar(-layer_rect.y()));
55 56
(...skipping 17 matching lines...) Expand all
73 74
74 canvas->restore(); 75 canvas->restore();
75 picture_->endRecording(); 76 picture_->endRecording();
76 77
77 opaque_rect_ = gfx::ToEnclosedRect(opaque_layer_rect); 78 opaque_rect_ = gfx::ToEnclosedRect(opaque_layer_rect);
78 layer_rect_ = layer_rect; 79 layer_rect_ = layer_rect;
79 } 80 }
80 81
81 void Picture::Raster(SkCanvas* canvas) { 82 void Picture::Raster(SkCanvas* canvas) {
82 TRACE_EVENT0("cc", "Picture::Raster"); 83 TRACE_EVENT0("cc", "Picture::Raster");
83 DCHECK(picture_.get()); 84 DCHECK(picture_);
84 canvas->save(); 85 canvas->save();
85 canvas->translate(layer_rect_.x(), layer_rect_.y()); 86 canvas->translate(layer_rect_.x(), layer_rect_.y());
86 canvas->drawPicture(*picture_); 87 canvas->drawPicture(*picture_);
87 canvas->restore(); 88 canvas->restore();
88 } 89 }
89 90
90 } // namespace cc 91 } // namespace cc
OLDNEW
« no previous file with comments | « cc/picture.h ('k') | cc/render_pass.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698