| 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 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 135 EndCompositingDisplayItem::EndCompositingDisplayItem() {} | 132 EndCompositingDisplayItem::EndCompositingDisplayItem() {} |
| 136 | 133 |
| 137 EndCompositingDisplayItem::EndCompositingDisplayItem( | 134 EndCompositingDisplayItem::EndCompositingDisplayItem( |
| 138 const proto::DisplayItem& proto) { | 135 const proto::DisplayItem& proto) { |
| 139 DCHECK_EQ(proto::DisplayItem::Type_EndCompositing, proto.type()); | 136 DCHECK_EQ(proto::DisplayItem::Type_EndCompositing, proto.type()); |
| 140 } | 137 } |
| 141 | 138 |
| 142 EndCompositingDisplayItem::~EndCompositingDisplayItem() { | 139 EndCompositingDisplayItem::~EndCompositingDisplayItem() { |
| 143 } | 140 } |
| 144 | 141 |
| 145 void EndCompositingDisplayItem::ToProtobuf( | 142 void EndCompositingDisplayItem::ToProtobuf(proto::DisplayItem* proto) const { |
| 146 proto::DisplayItem* proto, | |
| 147 ImageSerializationProcessor* image_serialization_processor) const { | |
| 148 proto->set_type(proto::DisplayItem::Type_EndCompositing); | 143 proto->set_type(proto::DisplayItem::Type_EndCompositing); |
| 149 } | 144 } |
| 150 | 145 |
| 151 void EndCompositingDisplayItem::Raster( | 146 void EndCompositingDisplayItem::Raster( |
| 152 SkCanvas* canvas, | 147 SkCanvas* canvas, |
| 153 SkPicture::AbortCallback* callback) const { | 148 SkPicture::AbortCallback* callback) const { |
| 154 canvas->restore(); | 149 canvas->restore(); |
| 155 } | 150 } |
| 156 | 151 |
| 157 void EndCompositingDisplayItem::AsValueInto( | 152 void EndCompositingDisplayItem::AsValueInto( |
| 158 const gfx::Rect& visual_rect, | 153 const gfx::Rect& visual_rect, |
| 159 base::trace_event::TracedValue* array) const { | 154 base::trace_event::TracedValue* array) const { |
| 160 array->AppendString( | 155 array->AppendString( |
| 161 base::StringPrintf("EndCompositingDisplayItem visualRect: [%s]", | 156 base::StringPrintf("EndCompositingDisplayItem visualRect: [%s]", |
| 162 visual_rect.ToString().c_str())); | 157 visual_rect.ToString().c_str())); |
| 163 } | 158 } |
| 164 | 159 |
| 165 size_t EndCompositingDisplayItem::ExternalMemoryUsage() const { | 160 size_t EndCompositingDisplayItem::ExternalMemoryUsage() const { |
| 166 return 0; | 161 return 0; |
| 167 } | 162 } |
| 168 | 163 |
| 169 } // namespace cc | 164 } // namespace cc |
| OLD | NEW |