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 SkPicture::AbortCallback* callback) const { | 58 SkPicture::AbortCallback* callback) const { |
(...skipping 27 matching lines...) Expand all Loading... |
89 } | 86 } |
90 | 87 |
91 EndFilterDisplayItem::EndFilterDisplayItem() {} | 88 EndFilterDisplayItem::EndFilterDisplayItem() {} |
92 | 89 |
93 EndFilterDisplayItem::EndFilterDisplayItem(const proto::DisplayItem& proto) { | 90 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( | 96 void EndFilterDisplayItem::ToProtobuf(proto::DisplayItem* proto) const { |
100 proto::DisplayItem* proto, | |
101 ImageSerializationProcessor* image_serialization_processor) const { | |
102 proto->set_type(proto::DisplayItem::Type_EndFilter); | 97 proto->set_type(proto::DisplayItem::Type_EndFilter); |
103 } | 98 } |
104 | 99 |
105 void EndFilterDisplayItem::Raster(SkCanvas* canvas, | 100 void EndFilterDisplayItem::Raster(SkCanvas* canvas, |
106 SkPicture::AbortCallback* callback) const { | 101 SkPicture::AbortCallback* callback) const { |
107 canvas->restore(); | 102 canvas->restore(); |
108 canvas->restore(); | 103 canvas->restore(); |
109 } | 104 } |
110 | 105 |
111 void EndFilterDisplayItem::AsValueInto( | 106 void EndFilterDisplayItem::AsValueInto( |
112 const gfx::Rect& visual_rect, | 107 const gfx::Rect& visual_rect, |
113 base::trace_event::TracedValue* array) const { | 108 base::trace_event::TracedValue* array) const { |
114 array->AppendString( | 109 array->AppendString( |
115 base::StringPrintf("EndFilterDisplayItem visualRect: [%s]", | 110 base::StringPrintf("EndFilterDisplayItem visualRect: [%s]", |
116 visual_rect.ToString().c_str())); | 111 visual_rect.ToString().c_str())); |
117 } | 112 } |
118 | 113 |
119 size_t EndFilterDisplayItem::ExternalMemoryUsage() const { | 114 size_t EndFilterDisplayItem::ExternalMemoryUsage() const { |
120 return 0; | 115 return 0; |
121 } | 116 } |
122 | 117 |
123 } // namespace cc | 118 } // namespace cc |
OLD | NEW |