OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/compositing_display_item.h" | 5 #include "cc/playback/compositing_display_item.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include "base/strings/stringprintf.h" | 10 #include "base/strings/stringprintf.h" |
11 #include "base/trace_event/trace_event_argument.h" | 11 #include "base/trace_event/trace_event_argument.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 "cc/proto/skia_conversions.h" | 14 #include "cc/proto/skia_conversions.h" |
15 #include "third_party/skia/include/core/SkCanvas.h" | 15 #include "third_party/skia/include/core/SkCanvas.h" |
16 #include "third_party/skia/include/core/SkData.h" | 16 #include "third_party/skia/include/core/SkData.h" |
17 #include "third_party/skia/include/core/SkFlattenable.h" | 17 #include "third_party/skia/include/core/SkFlattenable.h" |
18 #include "third_party/skia/include/core/SkFlattenableSerialization.h" | 18 #include "third_party/skia/include/core/SkFlattenableSerialization.h" |
19 #include "third_party/skia/include/core/SkPaint.h" | 19 #include "third_party/skia/include/core/SkPaint.h" |
20 #include "third_party/skia/include/core/SkXfermode.h" | 20 #include "third_party/skia/include/core/SkXfermode.h" |
21 #include "ui/gfx/skia_util.h" | 21 #include "ui/gfx/skia_util.h" |
22 | 22 |
23 namespace cc { | 23 namespace cc { |
24 class ImageSerializationProcessor; | |
25 | 24 |
26 CompositingDisplayItem::CompositingDisplayItem( | 25 CompositingDisplayItem::CompositingDisplayItem( |
27 uint8_t alpha, | 26 uint8_t alpha, |
28 SkXfermode::Mode xfermode, | 27 SkXfermode::Mode xfermode, |
29 SkRect* bounds, | 28 SkRect* bounds, |
30 sk_sp<SkColorFilter> cf, | 29 sk_sp<SkColorFilter> cf, |
31 bool lcd_text_requires_opaque_layer) { | 30 bool lcd_text_requires_opaque_layer) { |
32 SetNew(alpha, xfermode, bounds, std::move(cf), | 31 SetNew(alpha, xfermode, bounds, std::move(cf), |
33 lcd_text_requires_opaque_layer); | 32 lcd_text_requires_opaque_layer); |
34 } | 33 } |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
71 bool lcd_text_requires_opaque_layer) { | 70 bool lcd_text_requires_opaque_layer) { |
72 alpha_ = alpha; | 71 alpha_ = alpha; |
73 xfermode_ = xfermode; | 72 xfermode_ = xfermode; |
74 has_bounds_ = !!bounds; | 73 has_bounds_ = !!bounds; |
75 if (bounds) | 74 if (bounds) |
76 bounds_ = SkRect(*bounds); | 75 bounds_ = SkRect(*bounds); |
77 color_filter_ = std::move(cf); | 76 color_filter_ = std::move(cf); |
78 lcd_text_requires_opaque_layer_ = lcd_text_requires_opaque_layer; | 77 lcd_text_requires_opaque_layer_ = lcd_text_requires_opaque_layer; |
79 } | 78 } |
80 | 79 |
81 void CompositingDisplayItem::ToProtobuf( | 80 void CompositingDisplayItem::ToProtobuf(proto::DisplayItem* proto) const { |
82 proto::DisplayItem* proto, | |
83 ImageSerializationProcessor* image_serialization_processor) const { | |
84 proto->set_type(proto::DisplayItem::Type_Compositing); | 81 proto->set_type(proto::DisplayItem::Type_Compositing); |
85 | 82 |
86 proto::CompositingDisplayItem* details = proto->mutable_compositing_item(); | 83 proto::CompositingDisplayItem* details = proto->mutable_compositing_item(); |
87 details->set_alpha(static_cast<uint32_t>(alpha_)); | 84 details->set_alpha(static_cast<uint32_t>(alpha_)); |
88 details->set_mode(SkXfermodeModeToProto(xfermode_)); | 85 details->set_mode(SkXfermodeModeToProto(xfermode_)); |
89 if (has_bounds_) | 86 if (has_bounds_) |
90 RectFToProto(gfx::SkRectToRectF(bounds_), details->mutable_bounds()); | 87 RectFToProto(gfx::SkRectToRectF(bounds_), details->mutable_bounds()); |
91 | 88 |
92 if (color_filter_) { | 89 if (color_filter_) { |
93 sk_sp<SkData> data(SkValidatingSerializeFlattenable(color_filter_.get())); | 90 sk_sp<SkData> data(SkValidatingSerializeFlattenable(color_filter_.get())); |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
136 EndCompositingDisplayItem::EndCompositingDisplayItem() {} | 133 EndCompositingDisplayItem::EndCompositingDisplayItem() {} |
137 | 134 |
138 EndCompositingDisplayItem::EndCompositingDisplayItem( | 135 EndCompositingDisplayItem::EndCompositingDisplayItem( |
139 const proto::DisplayItem& proto) { | 136 const proto::DisplayItem& proto) { |
140 DCHECK_EQ(proto::DisplayItem::Type_EndCompositing, proto.type()); | 137 DCHECK_EQ(proto::DisplayItem::Type_EndCompositing, proto.type()); |
141 } | 138 } |
142 | 139 |
143 EndCompositingDisplayItem::~EndCompositingDisplayItem() { | 140 EndCompositingDisplayItem::~EndCompositingDisplayItem() { |
144 } | 141 } |
145 | 142 |
146 void EndCompositingDisplayItem::ToProtobuf( | 143 void EndCompositingDisplayItem::ToProtobuf(proto::DisplayItem* proto) const { |
147 proto::DisplayItem* proto, | |
148 ImageSerializationProcessor* image_serialization_processor) const { | |
149 proto->set_type(proto::DisplayItem::Type_EndCompositing); | 144 proto->set_type(proto::DisplayItem::Type_EndCompositing); |
150 } | 145 } |
151 | 146 |
152 void EndCompositingDisplayItem::Raster( | 147 void EndCompositingDisplayItem::Raster( |
153 SkCanvas* canvas, | 148 SkCanvas* canvas, |
154 const gfx::Rect& canvas_target_playback_rect, | 149 const gfx::Rect& canvas_target_playback_rect, |
155 SkPicture::AbortCallback* callback) const { | 150 SkPicture::AbortCallback* callback) const { |
156 canvas->restore(); | 151 canvas->restore(); |
157 } | 152 } |
158 | 153 |
159 void EndCompositingDisplayItem::AsValueInto( | 154 void EndCompositingDisplayItem::AsValueInto( |
160 const gfx::Rect& visual_rect, | 155 const gfx::Rect& visual_rect, |
161 base::trace_event::TracedValue* array) const { | 156 base::trace_event::TracedValue* array) const { |
162 array->AppendString( | 157 array->AppendString( |
163 base::StringPrintf("EndCompositingDisplayItem visualRect: [%s]", | 158 base::StringPrintf("EndCompositingDisplayItem visualRect: [%s]", |
164 visual_rect.ToString().c_str())); | 159 visual_rect.ToString().c_str())); |
165 } | 160 } |
166 | 161 |
167 size_t EndCompositingDisplayItem::ExternalMemoryUsage() const { | 162 size_t EndCompositingDisplayItem::ExternalMemoryUsage() const { |
168 return 0; | 163 return 0; |
169 } | 164 } |
170 | 165 |
171 } // namespace cc | 166 } // namespace cc |
OLD | NEW |