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 <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 "third_party/skia/include/core/SkXfermode.h" | 18 #include "third_party/skia/include/core/SkXfermode.h" |
19 #include "ui/gfx/skia_util.h" | 19 #include "ui/gfx/skia_util.h" |
20 | 20 |
21 namespace cc { | 21 namespace cc { |
22 class ImageSerializationProcessor; | |
23 | 22 |
24 FilterDisplayItem::FilterDisplayItem(const FilterOperations& filters, | 23 FilterDisplayItem::FilterDisplayItem(const FilterOperations& filters, |
25 const gfx::RectF& bounds) { | 24 const gfx::RectF& bounds) { |
26 SetNew(filters, bounds); | 25 SetNew(filters, bounds); |
27 } | 26 } |
28 | 27 |
29 FilterDisplayItem::FilterDisplayItem(const proto::DisplayItem& proto) { | 28 FilterDisplayItem::FilterDisplayItem(const proto::DisplayItem& proto) { |
30 DCHECK_EQ(proto::DisplayItem::Type_Filter, proto.type()); | 29 DCHECK_EQ(proto::DisplayItem::Type_Filter, proto.type()); |
31 | 30 |
32 const proto::FilterDisplayItem& details = proto.filter_item(); | 31 const proto::FilterDisplayItem& details = proto.filter_item(); |
33 gfx::RectF bounds = ProtoToRectF(details.bounds()); | 32 gfx::RectF bounds = ProtoToRectF(details.bounds()); |
34 | 33 |
35 // TODO(dtrainor): Support deserializing FilterOperations (crbug.com/541321). | 34 // TODO(dtrainor): Support deserializing FilterOperations (crbug.com/541321). |
36 FilterOperations filters; | 35 FilterOperations filters; |
37 | 36 |
38 SetNew(filters, bounds); | 37 SetNew(filters, bounds); |
39 } | 38 } |
40 | 39 |
41 FilterDisplayItem::~FilterDisplayItem() {} | 40 FilterDisplayItem::~FilterDisplayItem() {} |
42 | 41 |
43 void FilterDisplayItem::SetNew(const FilterOperations& filters, | 42 void FilterDisplayItem::SetNew(const FilterOperations& filters, |
44 const gfx::RectF& bounds) { | 43 const gfx::RectF& bounds) { |
45 filters_ = filters; | 44 filters_ = filters; |
46 bounds_ = bounds; | 45 bounds_ = bounds; |
47 } | 46 } |
48 | 47 |
49 void FilterDisplayItem::ToProtobuf( | 48 void FilterDisplayItem::ToProtobuf(proto::DisplayItem* proto) const { |
50 proto::DisplayItem* proto, | |
51 ImageSerializationProcessor* image_serialization_processor) const { | |
52 proto->set_type(proto::DisplayItem::Type_Filter); | 49 proto->set_type(proto::DisplayItem::Type_Filter); |
53 | 50 |
54 proto::FilterDisplayItem* details = proto->mutable_filter_item(); | 51 proto::FilterDisplayItem* details = proto->mutable_filter_item(); |
55 RectFToProto(bounds_, details->mutable_bounds()); | 52 RectFToProto(bounds_, details->mutable_bounds()); |
56 | 53 |
57 // TODO(dtrainor): Support serializing FilterOperations (crbug.com/541321). | 54 // TODO(dtrainor): Support serializing FilterOperations (crbug.com/541321). |
58 } | 55 } |
59 | 56 |
60 void FilterDisplayItem::Raster(SkCanvas* canvas, | 57 void FilterDisplayItem::Raster(SkCanvas* canvas, |
61 const gfx::Rect& canvas_target_playback_rect, | 58 const gfx::Rect& canvas_target_playback_rect, |
(...skipping 28 matching lines...) Expand all Loading... |
90 } | 87 } |
91 | 88 |
92 EndFilterDisplayItem::EndFilterDisplayItem() {} | 89 EndFilterDisplayItem::EndFilterDisplayItem() {} |
93 | 90 |
94 EndFilterDisplayItem::EndFilterDisplayItem(const proto::DisplayItem& proto) { | 91 EndFilterDisplayItem::EndFilterDisplayItem(const proto::DisplayItem& proto) { |
95 DCHECK_EQ(proto::DisplayItem::Type_EndFilter, proto.type()); | 92 DCHECK_EQ(proto::DisplayItem::Type_EndFilter, proto.type()); |
96 } | 93 } |
97 | 94 |
98 EndFilterDisplayItem::~EndFilterDisplayItem() {} | 95 EndFilterDisplayItem::~EndFilterDisplayItem() {} |
99 | 96 |
100 void EndFilterDisplayItem::ToProtobuf( | 97 void EndFilterDisplayItem::ToProtobuf(proto::DisplayItem* proto) const { |
101 proto::DisplayItem* proto, | |
102 ImageSerializationProcessor* image_serialization_processor) const { | |
103 proto->set_type(proto::DisplayItem::Type_EndFilter); | 98 proto->set_type(proto::DisplayItem::Type_EndFilter); |
104 } | 99 } |
105 | 100 |
106 void EndFilterDisplayItem::Raster(SkCanvas* canvas, | 101 void EndFilterDisplayItem::Raster(SkCanvas* canvas, |
107 const gfx::Rect& canvas_target_playback_rect, | 102 const gfx::Rect& canvas_target_playback_rect, |
108 SkPicture::AbortCallback* callback) const { | 103 SkPicture::AbortCallback* callback) const { |
109 canvas->restore(); | 104 canvas->restore(); |
110 canvas->restore(); | 105 canvas->restore(); |
111 } | 106 } |
112 | 107 |
113 void EndFilterDisplayItem::AsValueInto( | 108 void EndFilterDisplayItem::AsValueInto( |
114 const gfx::Rect& visual_rect, | 109 const gfx::Rect& visual_rect, |
115 base::trace_event::TracedValue* array) const { | 110 base::trace_event::TracedValue* array) const { |
116 array->AppendString( | 111 array->AppendString( |
117 base::StringPrintf("EndFilterDisplayItem visualRect: [%s]", | 112 base::StringPrintf("EndFilterDisplayItem visualRect: [%s]", |
118 visual_rect.ToString().c_str())); | 113 visual_rect.ToString().c_str())); |
119 } | 114 } |
120 | 115 |
121 size_t EndFilterDisplayItem::ExternalMemoryUsage() const { | 116 size_t EndFilterDisplayItem::ExternalMemoryUsage() const { |
122 return 0; | 117 return 0; |
123 } | 118 } |
124 | 119 |
125 } // namespace cc | 120 } // namespace cc |
OLD | NEW |