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

Side by Side 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 unified diff | 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 »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "cc/resources/display_item_list.h"
6
7 #include "base/debug/trace_event.h"
8 #include "base/debug/trace_event_argument.h"
9 #include "third_party/skia/include/core/SkCanvas.h"
10
11 namespace cc {
12
13 DisplayItemList::DisplayItemList()
14 : is_suitable_for_gpu_rasterization_(true), approximate_op_count_(0) {
15 }
16
17 scoped_refptr<DisplayItemList> DisplayItemList::Create() {
18 return make_scoped_refptr(new DisplayItemList());
19 }
20
21 DisplayItemList::~DisplayItemList() {
22 }
23
24 void DisplayItemList::Raster(SkCanvas* canvas,
25 SkDrawPictureCallback* callback,
26 float contents_scale) const {
27 canvas->save();
28 canvas->scale(contents_scale, contents_scale);
29 for (size_t i = 0; i < items_.size(); ++i) {
30 items_[i]->Raster(canvas, callback);
31 }
32 canvas->restore();
33 }
34
35 void DisplayItemList::AppendItem(scoped_ptr<DisplayItem> item) {
36 is_suitable_for_gpu_rasterization_ &= item->IsSuitableForGpuRasterization();
37 approximate_op_count_ += item->ApproximateOpCount();
38 items_.push_back(item.Pass());
39 }
40
41 bool DisplayItemList::IsSuitableForGpuRasterization() const {
42 // This is more permissive than Picture's implementation, since none of the
43 // items might individually trigger a veto even though they collectively have
44 // enough "bad" operations that a corresponding Picture would get vetoed.
45 return is_suitable_for_gpu_rasterization_;
46 }
47
48 int DisplayItemList::ApproximateOpCount() const {
49 return approximate_op_count_;
50 }
51
52 size_t DisplayItemList::PictureMemoryUsage() const {
53 size_t total_size = 0;
54
55 for (const auto& item : items_) {
56 total_size += item->PictureMemoryUsage();
57 }
58
59 return total_size;
60 }
61
62 scoped_refptr<base::debug::ConvertableToTraceFormat> DisplayItemList::AsValue()
63 const {
64 scoped_refptr<base::debug::TracedValue> state =
65 new base::debug::TracedValue();
66
67 // TODO(ajuma): Include the value of each item.
68 state->SetInteger("length", items_.size());
69 return state;
70 }
71
72 void DisplayItemList::EmitTraceSnapshot() const {
73 TRACE_EVENT_OBJECT_SNAPSHOT_WITH_ID(
74 TRACE_DISABLED_BY_DEFAULT("cc.debug") "," TRACE_DISABLED_BY_DEFAULT(
75 "devtools.timeline.picture"),
76 "cc::DisplayItemList", this, AsValue());
77 }
78
79 } // namespace cc
OLDNEW
« 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