OLD | NEW |
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 "base/strings/stringprintf.h" | 7 #include "base/strings/stringprintf.h" |
8 #include "base/trace_event/trace_event_argument.h" | 8 #include "base/trace_event/trace_event_argument.h" |
9 #include "cc/output/render_surface_filters.h" | 9 #include "cc/output/render_surface_filters.h" |
10 #include "cc/proto/display_item.pb.h" | 10 #include "cc/proto/display_item.pb.h" |
11 #include "cc/proto/gfx_conversions.h" | 11 #include "cc/proto/gfx_conversions.h" |
12 #include "skia/ext/refptr.h" | 12 #include "skia/ext/refptr.h" |
13 #include "third_party/skia/include/core/SkCanvas.h" | 13 #include "third_party/skia/include/core/SkCanvas.h" |
14 #include "third_party/skia/include/core/SkImageFilter.h" | 14 #include "third_party/skia/include/core/SkImageFilter.h" |
15 #include "third_party/skia/include/core/SkPaint.h" | 15 #include "third_party/skia/include/core/SkPaint.h" |
16 #include "third_party/skia/include/core/SkXfermode.h" | 16 #include "third_party/skia/include/core/SkXfermode.h" |
17 #include "ui/gfx/skia_util.h" | 17 #include "ui/gfx/skia_util.h" |
18 | 18 |
19 namespace cc { | 19 namespace cc { |
20 | 20 |
21 FilterDisplayItem::FilterDisplayItem() { | 21 FilterDisplayItem::FilterDisplayItem(const FilterOperations& filters, |
| 22 const gfx::RectF& bounds) { |
| 23 SetNew(filters, bounds); |
22 } | 24 } |
23 | 25 |
24 FilterDisplayItem::~FilterDisplayItem() { | 26 FilterDisplayItem::FilterDisplayItem(const proto::DisplayItem& proto) { |
| 27 FromProtobuf(proto); |
25 } | 28 } |
26 | 29 |
| 30 FilterDisplayItem::~FilterDisplayItem() {} |
| 31 |
27 void FilterDisplayItem::SetNew(const FilterOperations& filters, | 32 void FilterDisplayItem::SetNew(const FilterOperations& filters, |
28 const gfx::RectF& bounds) { | 33 const gfx::RectF& bounds) { |
29 filters_ = filters; | 34 filters_ = filters; |
30 bounds_ = bounds; | 35 bounds_ = bounds; |
31 | |
32 // FilterOperations doesn't expose its capacity, but size is probably good | |
33 // enough. | |
34 size_t external_memory_usage = filters_.size() * sizeof(filters_.at(0)); | |
35 DisplayItem::SetNew(true /* suitable_for_gpu_raster */, 1 /* op_count */, | |
36 external_memory_usage); | |
37 } | 36 } |
38 | 37 |
39 void FilterDisplayItem::ToProtobuf(proto::DisplayItem* proto) const { | 38 void FilterDisplayItem::ToProtobuf(proto::DisplayItem* proto) const { |
40 proto->set_type(proto::DisplayItem::Type_Filter); | 39 proto->set_type(proto::DisplayItem::Type_Filter); |
41 | 40 |
42 proto::FilterDisplayItem* details = proto->mutable_filter_item(); | 41 proto::FilterDisplayItem* details = proto->mutable_filter_item(); |
43 RectFToProto(bounds_, details->mutable_bounds()); | 42 RectFToProto(bounds_, details->mutable_bounds()); |
44 | 43 |
45 // TODO(dtrainor): Support serializing FilterOperations (crbug.com/541321). | 44 // TODO(dtrainor): Support serializing FilterOperations (crbug.com/541321). |
46 } | 45 } |
(...skipping 30 matching lines...) Expand all Loading... |
77 } | 76 } |
78 | 77 |
79 void FilterDisplayItem::AsValueInto( | 78 void FilterDisplayItem::AsValueInto( |
80 const gfx::Rect& visual_rect, | 79 const gfx::Rect& visual_rect, |
81 base::trace_event::TracedValue* array) const { | 80 base::trace_event::TracedValue* array) const { |
82 array->AppendString(base::StringPrintf( | 81 array->AppendString(base::StringPrintf( |
83 "FilterDisplayItem bounds: [%s] visualRect: [%s]", | 82 "FilterDisplayItem bounds: [%s] visualRect: [%s]", |
84 bounds_.ToString().c_str(), visual_rect.ToString().c_str())); | 83 bounds_.ToString().c_str(), visual_rect.ToString().c_str())); |
85 } | 84 } |
86 | 85 |
87 EndFilterDisplayItem::EndFilterDisplayItem() { | 86 size_t FilterDisplayItem::ExternalMemoryUsage() const { |
88 DisplayItem::SetNew(true /* suitable_for_gpu_raster */, 0 /* op_count */, | 87 // FilterOperations doesn't expose its capacity, but size is probably good |
89 0 /* external_memory_usage */); | 88 // enough. |
| 89 return filters_.size() * sizeof(filters_.at(0)); |
90 } | 90 } |
91 | 91 |
92 EndFilterDisplayItem::~EndFilterDisplayItem() { | 92 EndFilterDisplayItem::EndFilterDisplayItem() {} |
| 93 |
| 94 EndFilterDisplayItem::EndFilterDisplayItem(const proto::DisplayItem& proto) { |
| 95 FromProtobuf(proto); |
93 } | 96 } |
94 | 97 |
| 98 EndFilterDisplayItem::~EndFilterDisplayItem() {} |
| 99 |
95 void EndFilterDisplayItem::ToProtobuf(proto::DisplayItem* proto) const { | 100 void EndFilterDisplayItem::ToProtobuf(proto::DisplayItem* proto) const { |
96 proto->set_type(proto::DisplayItem::Type_EndFilter); | 101 proto->set_type(proto::DisplayItem::Type_EndFilter); |
97 } | 102 } |
98 | 103 |
99 void EndFilterDisplayItem::FromProtobuf(const proto::DisplayItem& proto) { | 104 void EndFilterDisplayItem::FromProtobuf(const proto::DisplayItem& proto) { |
100 DCHECK_EQ(proto::DisplayItem::Type_EndFilter, proto.type()); | 105 DCHECK_EQ(proto::DisplayItem::Type_EndFilter, proto.type()); |
101 } | 106 } |
102 | 107 |
103 void EndFilterDisplayItem::Raster(SkCanvas* canvas, | 108 void EndFilterDisplayItem::Raster(SkCanvas* canvas, |
104 const gfx::Rect& canvas_target_playback_rect, | 109 const gfx::Rect& canvas_target_playback_rect, |
105 SkPicture::AbortCallback* callback) const { | 110 SkPicture::AbortCallback* callback) const { |
106 canvas->restore(); | 111 canvas->restore(); |
107 canvas->restore(); | 112 canvas->restore(); |
108 } | 113 } |
109 | 114 |
110 void EndFilterDisplayItem::AsValueInto( | 115 void EndFilterDisplayItem::AsValueInto( |
111 const gfx::Rect& visual_rect, | 116 const gfx::Rect& visual_rect, |
112 base::trace_event::TracedValue* array) const { | 117 base::trace_event::TracedValue* array) const { |
113 array->AppendString( | 118 array->AppendString( |
114 base::StringPrintf("EndFilterDisplayItem visualRect: [%s]", | 119 base::StringPrintf("EndFilterDisplayItem visualRect: [%s]", |
115 visual_rect.ToString().c_str())); | 120 visual_rect.ToString().c_str())); |
116 } | 121 } |
117 | 122 |
| 123 size_t EndFilterDisplayItem::ExternalMemoryUsage() const { |
| 124 return 0; |
| 125 } |
| 126 |
118 } // namespace cc | 127 } // namespace cc |
OLD | NEW |