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

Unified Diff: cc/resources/display_item_list.cc

Issue 1094553002: Revert "Speculative revert by sheriff" (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 8 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/display_item_list.h ('k') | cc/resources/display_item_list_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/resources/display_item_list.cc
diff --git a/cc/resources/display_item_list.cc b/cc/resources/display_item_list.cc
index b541c5f34d9a066bf4dfd7fdcbedeca6568850b6..0b2e12e06c1e394e6d934ad70705e5d9c9fcf152 100644
--- a/cc/resources/display_item_list.cc
+++ b/cc/resources/display_item_list.cc
@@ -20,12 +20,36 @@
namespace cc {
-DisplayItemList::DisplayItemList()
- : is_suitable_for_gpu_rasterization_(true), approximate_op_count_(0) {
+DisplayItemList::DisplayItemList(gfx::Rect layer_rect, bool use_cached_picture)
+ : recorder_(new SkPictureRecorder()),
+ use_cached_picture_(use_cached_picture),
+ retain_individual_display_items_(!use_cached_picture),
+ layer_rect_(layer_rect),
+ is_suitable_for_gpu_rasterization_(true),
+ approximate_op_count_(0) {
+ if (use_cached_picture_) {
+ SkRTreeFactory factory;
+ recorder_.reset(new SkPictureRecorder());
+ canvas_ = skia::SharePtr(recorder_->beginRecording(
+ layer_rect_.width(), layer_rect_.height(), &factory));
+ canvas_->translate(-layer_rect_.x(), -layer_rect_.y());
+ canvas_->clipRect(gfx::RectToSkRect(layer_rect_));
+
+ bool tracing_enabled;
+ TRACE_EVENT_CATEGORY_GROUP_ENABLED(
+ TRACE_DISABLED_BY_DEFAULT("cc.debug.picture") ","
+ TRACE_DISABLED_BY_DEFAULT("devtools.timeline.picture"),
+ &tracing_enabled);
+ if (tracing_enabled)
+ retain_individual_display_items_ = true;
+ }
}
-scoped_refptr<DisplayItemList> DisplayItemList::Create() {
- return make_scoped_refptr(new DisplayItemList());
+scoped_refptr<DisplayItemList> DisplayItemList::Create(
+ gfx::Rect layer_rect,
+ bool use_cached_picture) {
+ return make_scoped_refptr(
+ new DisplayItemList(layer_rect, use_cached_picture));
}
DisplayItemList::~DisplayItemList() {
@@ -34,7 +58,7 @@ DisplayItemList::~DisplayItemList() {
void DisplayItemList::Raster(SkCanvas* canvas,
SkDrawPictureCallback* callback,
float contents_scale) const {
- if (!picture_) {
+ if (!use_cached_picture_) {
canvas->save();
canvas->scale(contents_scale, contents_scale);
for (size_t i = 0; i < items_.size(); ++i) {
@@ -62,25 +86,25 @@ void DisplayItemList::Raster(SkCanvas* canvas,
}
void DisplayItemList::CreateAndCacheSkPicture() {
- // Convert to an SkPicture for faster rasterization. Code is identical to
- // that in Picture::Record.
- SkRTreeFactory factory;
- SkPictureRecorder recorder;
- skia::RefPtr<SkCanvas> canvas;
- canvas = skia::SharePtr(recorder.beginRecording(
- layer_rect_.width(), layer_rect_.height(), &factory));
- canvas->translate(-layer_rect_.x(), -layer_rect_.y());
- canvas->clipRect(gfx::RectToSkRect(layer_rect_));
- for (size_t i = 0; i < items_.size(); ++i)
- items_[i]->Raster(canvas.get(), NULL);
- picture_ = skia::AdoptRef(recorder.endRecordingAsPicture());
+ // Convert to an SkPicture for faster rasterization.
+ DCHECK(use_cached_picture_);
+ picture_ = skia::AdoptRef(recorder_->endRecordingAsPicture());
DCHECK(picture_);
+ recorder_.reset();
+ canvas_.clear();
}
void DisplayItemList::AppendItem(scoped_ptr<DisplayItem> item) {
is_suitable_for_gpu_rasterization_ &= item->IsSuitableForGpuRasterization();
approximate_op_count_ += item->ApproximateOpCount();
- items_.push_back(item.Pass());
+
+ if (use_cached_picture_) {
+ DCHECK(canvas_);
+ item->Raster(canvas_.get(), NULL);
+ }
+
+ if (retain_individual_display_items_)
+ items_.push_back(item.Pass());
}
bool DisplayItemList::IsSuitableForGpuRasterization() const {
@@ -126,8 +150,7 @@ DisplayItemList::AsValue() const {
recorder.beginRecording(layer_rect_.width(), layer_rect_.height());
canvas->translate(-layer_rect_.x(), -layer_rect_.y());
canvas->clipRect(gfx::RectToSkRect(layer_rect_));
- for (size_t i = 0; i < items_.size(); ++i)
- items_[i]->RasterForTracing(canvas);
+ Raster(canvas, NULL, 1.f);
skia::RefPtr<SkPicture> picture =
skia::AdoptRef(recorder.endRecordingAsPicture());
« no previous file with comments | « cc/resources/display_item_list.h ('k') | cc/resources/display_item_list_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698