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

Side by Side Diff: cc/playback/filter_display_item.cc

Issue 2561523002: cc: Devirtualize DisplayItem::ExternalMemoryUsage(). (Closed)
Patch Set: externalmem: . Created 4 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/playback/filter_display_item.h ('k') | cc/playback/float_clip_display_item.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "cc/playback/filter_display_item.h" 5 #include "cc/playback/filter_display_item.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include "base/strings/stringprintf.h" 9 #include "base/strings/stringprintf.h"
10 #include "base/trace_event/trace_event_argument.h" 10 #include "base/trace_event/trace_event_argument.h"
11 #include "cc/output/render_surface_filters.h" 11 #include "cc/output/render_surface_filters.h"
12 #include "cc/proto/display_item.pb.h" 12 #include "cc/proto/display_item.pb.h"
13 #include "cc/proto/gfx_conversions.h" 13 #include "cc/proto/gfx_conversions.h"
14 #include "third_party/skia/include/core/SkCanvas.h" 14 #include "third_party/skia/include/core/SkCanvas.h"
15 #include "third_party/skia/include/core/SkImageFilter.h" 15 #include "third_party/skia/include/core/SkImageFilter.h"
16 #include "third_party/skia/include/core/SkPaint.h" 16 #include "third_party/skia/include/core/SkPaint.h"
17 #include "third_party/skia/include/core/SkRefCnt.h" 17 #include "third_party/skia/include/core/SkRefCnt.h"
18 #include "ui/gfx/skia_util.h" 18 #include "ui/gfx/skia_util.h"
19 19
20 namespace cc { 20 namespace cc {
21 21
22 FilterDisplayItem::FilterDisplayItem(const FilterOperations& filters, 22 FilterDisplayItem::FilterDisplayItem(const FilterOperations& filters,
23 const gfx::RectF& bounds, 23 const gfx::RectF& bounds,
24 const gfx::PointF& origin) { 24 const gfx::PointF& origin)
25 : DisplayItem(FILTER) {
25 SetNew(filters, bounds, origin); 26 SetNew(filters, bounds, origin);
26 } 27 }
27 28
28 FilterDisplayItem::FilterDisplayItem(const proto::DisplayItem& proto) { 29 FilterDisplayItem::FilterDisplayItem(const proto::DisplayItem& proto)
30 : DisplayItem(FILTER) {
29 DCHECK_EQ(proto::DisplayItem::Type_Filter, proto.type()); 31 DCHECK_EQ(proto::DisplayItem::Type_Filter, proto.type());
30 32
31 const proto::FilterDisplayItem& details = proto.filter_item(); 33 const proto::FilterDisplayItem& details = proto.filter_item();
32 gfx::RectF bounds = ProtoToRectF(details.bounds()); 34 gfx::RectF bounds = ProtoToRectF(details.bounds());
33 35
34 // TODO(dtrainor): Support deserializing FilterOperations (crbug.com/541321). 36 // TODO(dtrainor): Support deserializing FilterOperations (crbug.com/541321).
35 FilterOperations filters; 37 FilterOperations filters;
36 gfx::PointF origin(.0f, .0f); // TODO(senorblanco): Support origin. 38 gfx::PointF origin(.0f, .0f); // TODO(senorblanco): Support origin.
37 SetNew(filters, bounds, origin); 39 SetNew(filters, bounds, origin);
38 } 40 }
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
75 } 77 }
76 78
77 void FilterDisplayItem::AsValueInto( 79 void FilterDisplayItem::AsValueInto(
78 const gfx::Rect& visual_rect, 80 const gfx::Rect& visual_rect,
79 base::trace_event::TracedValue* array) const { 81 base::trace_event::TracedValue* array) const {
80 array->AppendString(base::StringPrintf( 82 array->AppendString(base::StringPrintf(
81 "FilterDisplayItem bounds: [%s] visualRect: [%s]", 83 "FilterDisplayItem bounds: [%s] visualRect: [%s]",
82 bounds_.ToString().c_str(), visual_rect.ToString().c_str())); 84 bounds_.ToString().c_str(), visual_rect.ToString().c_str()));
83 } 85 }
84 86
85 size_t FilterDisplayItem::ExternalMemoryUsage() const { 87 EndFilterDisplayItem::EndFilterDisplayItem() : DisplayItem(END_FILTER) {}
86 // FilterOperations doesn't expose its capacity, but size is probably good
87 // enough.
88 return filters_.size() * sizeof(filters_.at(0));
89 }
90 88
91 EndFilterDisplayItem::EndFilterDisplayItem() {} 89 EndFilterDisplayItem::EndFilterDisplayItem(const proto::DisplayItem& proto)
92 90 : DisplayItem(END_FILTER) {
93 EndFilterDisplayItem::EndFilterDisplayItem(const proto::DisplayItem& proto) {
94 DCHECK_EQ(proto::DisplayItem::Type_EndFilter, proto.type()); 91 DCHECK_EQ(proto::DisplayItem::Type_EndFilter, proto.type());
95 } 92 }
96 93
97 EndFilterDisplayItem::~EndFilterDisplayItem() {} 94 EndFilterDisplayItem::~EndFilterDisplayItem() {}
98 95
99 void EndFilterDisplayItem::ToProtobuf(proto::DisplayItem* proto) const { 96 void EndFilterDisplayItem::ToProtobuf(proto::DisplayItem* proto) const {
100 proto->set_type(proto::DisplayItem::Type_EndFilter); 97 proto->set_type(proto::DisplayItem::Type_EndFilter);
101 } 98 }
102 99
103 void EndFilterDisplayItem::Raster(SkCanvas* canvas, 100 void EndFilterDisplayItem::Raster(SkCanvas* canvas,
104 SkPicture::AbortCallback* callback) const { 101 SkPicture::AbortCallback* callback) const {
105 canvas->restore(); 102 canvas->restore();
106 canvas->restore(); 103 canvas->restore();
107 } 104 }
108 105
109 void EndFilterDisplayItem::AsValueInto( 106 void EndFilterDisplayItem::AsValueInto(
110 const gfx::Rect& visual_rect, 107 const gfx::Rect& visual_rect,
111 base::trace_event::TracedValue* array) const { 108 base::trace_event::TracedValue* array) const {
112 array->AppendString( 109 array->AppendString(
113 base::StringPrintf("EndFilterDisplayItem visualRect: [%s]", 110 base::StringPrintf("EndFilterDisplayItem visualRect: [%s]",
114 visual_rect.ToString().c_str())); 111 visual_rect.ToString().c_str()));
115 } 112 }
116 113
117 size_t EndFilterDisplayItem::ExternalMemoryUsage() const {
118 return 0;
119 }
120
121 } // namespace cc 114 } // namespace cc
OLDNEW
« no previous file with comments | « cc/playback/filter_display_item.h ('k') | cc/playback/float_clip_display_item.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698