diff options
author | reveman@chromium.org <reveman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-11-29 08:00:33 +0000 |
---|---|---|
committer | reveman@chromium.org <reveman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-11-29 08:00:33 +0000 |
commit | 3b93eb0024027bf9cfb862a7ecdb84c9fecceac2 (patch) | |
tree | f90070f9998133f4907b38889bcf1f1a33c6d412 /cc/picture.cc | |
parent | 17324afbb74d72066687d967c69c7f9fdfd97928 (diff) | |
download | chromium_src-3b93eb0024027bf9cfb862a7ecdb84c9fecceac2.zip chromium_src-3b93eb0024027bf9cfb862a7ecdb84c9fecceac2.tar.gz chromium_src-3b93eb0024027bf9cfb862a7ecdb84c9fecceac2.tar.bz2 |
cc: Only record to a SkPicture once.
To safely use a SkPicture for playback on the impl thread
Picture::Record() can only be called once on the main thread.
BUG=skia:988
TEST=manual
Review URL: https://chromiumcodereview.appspot.com/11428065
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@170147 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'cc/picture.cc')
-rw-r--r-- | cc/picture.cc | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/cc/picture.cc b/cc/picture.cc index 4e1d470..4284c39 100644 --- a/cc/picture.cc +++ b/cc/picture.cc @@ -15,7 +15,7 @@ scoped_refptr<Picture> Picture::Create() { return make_scoped_refptr(new Picture()); } -Picture::Picture() : picture_(new SkPicture()) { +Picture::Picture() { } Picture::Picture(SkPicture* picture, gfx::Rect layer_rect, @@ -31,6 +31,7 @@ Picture::~Picture() { scoped_refptr<Picture> Picture::Clone() { // SkPicture is not thread-safe to rasterize with, so return a thread-safe // clone of it. + DCHECK(picture_.get()); SkPicture* clone = picture_->clone(); return make_scoped_refptr(new Picture(clone, layer_rect_, opaque_rect_)); } @@ -38,6 +39,11 @@ scoped_refptr<Picture> Picture::Clone() { void Picture::Record(ContentLayerClient* painter, gfx::Rect layer_rect, RenderingStats& stats) { TRACE_EVENT0("cc", "Picture::Record"); + + // Record() should only be called once. + DCHECK(!picture_.get()); + picture_.reset(new SkPicture); + SkCanvas* canvas = picture_->beginRecording( layer_rect.width(), layer_rect.height(), @@ -72,6 +78,7 @@ void Picture::Record(ContentLayerClient* painter, gfx::Rect layer_rect, void Picture::Raster(SkCanvas* canvas) { TRACE_EVENT0("cc", "Picture::Raster"); + DCHECK(picture_.get()); canvas->save(); canvas->translate(layer_rect_.x(), layer_rect_.y()); canvas->drawPicture(*picture_); |