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

Unified Diff: cc/resources/picture.cc

Issue 160023002: cc: Only make num_threads - 1 SkPicture clones. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: sw renderer too Created 6 years, 10 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « cc/resources/picture.h ('k') | cc/resources/pixel_buffer_raster_worker_pool.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/resources/picture.cc
diff --git a/cc/resources/picture.cc b/cc/resources/picture.cc
index 2034ecb9bea064da73f3d494a2884d8a6447a9ce..02d7650e00fcf41897f5f1ee33137b70296869e3 100644
--- a/cc/resources/picture.cc
+++ b/cc/resources/picture.cc
@@ -92,11 +92,7 @@ scoped_refptr<Picture> Picture::Create(
picture->Record(client, tile_grid_info);
if (gather_pixel_refs)
picture->GatherPixelRefs(tile_grid_info);
- if (num_raster_threads > 0)
- picture->CloneForDrawing(num_raster_threads);
-
- // This picture may be rasterized on a different thread.
- picture->raster_thread_checker_.DetachFromThread();
+ picture->CloneForDrawing(num_raster_threads);
return picture;
}
@@ -192,12 +188,11 @@ Picture::~Picture() {
TRACE_DISABLED_BY_DEFAULT("cc.debug"), "cc::Picture", this);
}
-scoped_refptr<Picture> Picture::GetCloneForDrawingOnThread(
- unsigned thread_index) const {
+Picture* Picture::GetCloneForDrawingOnThread(unsigned thread_index) {
// SkPicture is not thread-safe to rasterize with, this returns a clone
// to rasterize with on a specific thread.
- CHECK_GT(clones_.size(), thread_index);
- return clones_[thread_index];
+ CHECK_GE(clones_.size(), thread_index);
+ return thread_index == clones_.size() ? this : clones_[thread_index].get();
}
void Picture::CloneForDrawing(int num_threads) {
@@ -206,19 +201,24 @@ void Picture::CloneForDrawing(int num_threads) {
DCHECK(picture_);
DCHECK(clones_.empty());
- scoped_ptr<SkPicture[]> clones(new SkPicture[num_threads]);
- picture_->clone(&clones[0], num_threads);
+ // We can re-use this picture for one raster worker thread.
+ raster_thread_checker_.DetachFromThread();
+
+ if (num_threads > 1) {
+ scoped_ptr<SkPicture[]> clones(new SkPicture[num_threads - 1]);
+ picture_->clone(&clones[0], num_threads - 1);
- for (int i = 0; i < num_threads; i++) {
- scoped_refptr<Picture> clone = make_scoped_refptr(
- new Picture(skia::AdoptRef(new SkPicture(clones[i])),
- layer_rect_,
- opaque_rect_,
- pixel_refs_));
- clones_.push_back(clone);
+ for (int i = 0; i < num_threads - 1; i++) {
+ scoped_refptr<Picture> clone = make_scoped_refptr(
+ new Picture(skia::AdoptRef(new SkPicture(clones[i])),
+ layer_rect_,
+ opaque_rect_,
+ pixel_refs_));
+ clones_.push_back(clone);
- clone->EmitTraceSnapshotAlias(this);
- clone->raster_thread_checker_.DetachFromThread();
+ clone->EmitTraceSnapshotAlias(this);
+ clone->raster_thread_checker_.DetachFromThread();
+ }
}
}
« no previous file with comments | « cc/resources/picture.h ('k') | cc/resources/pixel_buffer_raster_worker_pool.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698