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

Unified Diff: cc/resources/display_item_list.cc

Issue 761903003: Update from https://crrev.com/306655 (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 6 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 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
new file mode 100644
index 0000000000000000000000000000000000000000..2ead28d07344d1ee9efb4748d7ad0b46d2acf67d
--- /dev/null
+++ b/cc/resources/display_item_list.cc
@@ -0,0 +1,79 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "cc/resources/display_item_list.h"
+
+#include "base/debug/trace_event.h"
+#include "base/debug/trace_event_argument.h"
+#include "third_party/skia/include/core/SkCanvas.h"
+
+namespace cc {
+
+DisplayItemList::DisplayItemList()
+ : is_suitable_for_gpu_rasterization_(true), approximate_op_count_(0) {
+}
+
+scoped_refptr<DisplayItemList> DisplayItemList::Create() {
+ return make_scoped_refptr(new DisplayItemList());
+}
+
+DisplayItemList::~DisplayItemList() {
+}
+
+void DisplayItemList::Raster(SkCanvas* canvas,
+ SkDrawPictureCallback* callback,
+ float contents_scale) const {
+ canvas->save();
+ canvas->scale(contents_scale, contents_scale);
+ for (size_t i = 0; i < items_.size(); ++i) {
+ items_[i]->Raster(canvas, callback);
+ }
+ canvas->restore();
+}
+
+void DisplayItemList::AppendItem(scoped_ptr<DisplayItem> item) {
+ is_suitable_for_gpu_rasterization_ &= item->IsSuitableForGpuRasterization();
+ approximate_op_count_ += item->ApproximateOpCount();
+ items_.push_back(item.Pass());
+}
+
+bool DisplayItemList::IsSuitableForGpuRasterization() const {
+ // This is more permissive than Picture's implementation, since none of the
+ // items might individually trigger a veto even though they collectively have
+ // enough "bad" operations that a corresponding Picture would get vetoed.
+ return is_suitable_for_gpu_rasterization_;
+}
+
+int DisplayItemList::ApproximateOpCount() const {
+ return approximate_op_count_;
+}
+
+size_t DisplayItemList::PictureMemoryUsage() const {
+ size_t total_size = 0;
+
+ for (const auto& item : items_) {
+ total_size += item->PictureMemoryUsage();
+ }
+
+ return total_size;
+}
+
+scoped_refptr<base::debug::ConvertableToTraceFormat> DisplayItemList::AsValue()
+ const {
+ scoped_refptr<base::debug::TracedValue> state =
+ new base::debug::TracedValue();
+
+ // TODO(ajuma): Include the value of each item.
+ state->SetInteger("length", items_.size());
+ return state;
+}
+
+void DisplayItemList::EmitTraceSnapshot() const {
+ TRACE_EVENT_OBJECT_SNAPSHOT_WITH_ID(
+ TRACE_DISABLED_BY_DEFAULT("cc.debug") "," TRACE_DISABLED_BY_DEFAULT(
+ "devtools.timeline.picture"),
+ "cc::DisplayItemList", this, AsValue());
+}
+
+} // namespace cc
« 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