| 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 | 20 |
| 21 #include "ui/gfx/skia_util.h" | 21 #include "ui/gfx/skia_util.h" |
| 22 | 22 |
| 23 namespace cc { | 23 namespace cc { |
| 24 | 24 |
| 25 CompositingDisplayItem::CompositingDisplayItem( | 25 CompositingDisplayItem::CompositingDisplayItem( |
| 26 uint8_t alpha, | 26 uint8_t alpha, |
| 27 SkBlendMode xfermode, | 27 SkBlendMode xfermode, |
| 28 SkRect* bounds, | 28 SkRect* bounds, |
| 29 sk_sp<SkColorFilter> cf, | 29 sk_sp<SkColorFilter> cf, |
| 30 bool lcd_text_requires_opaque_layer) { | 30 bool lcd_text_requires_opaque_layer) |
| 31 : DisplayItem(COMPOSITING) { |
| 31 SetNew(alpha, xfermode, bounds, std::move(cf), | 32 SetNew(alpha, xfermode, bounds, std::move(cf), |
| 32 lcd_text_requires_opaque_layer); | 33 lcd_text_requires_opaque_layer); |
| 33 } | 34 } |
| 34 | 35 |
| 35 CompositingDisplayItem::CompositingDisplayItem( | 36 CompositingDisplayItem::CompositingDisplayItem(const proto::DisplayItem& proto) |
| 36 const proto::DisplayItem& proto) { | 37 : DisplayItem(COMPOSITING) { |
| 37 DCHECK_EQ(proto::DisplayItem::Type_Compositing, proto.type()); | 38 DCHECK_EQ(proto::DisplayItem::Type_Compositing, proto.type()); |
| 38 | 39 |
| 39 const proto::CompositingDisplayItem& details = proto.compositing_item(); | 40 const proto::CompositingDisplayItem& details = proto.compositing_item(); |
| 40 uint8_t alpha = static_cast<uint8_t>(details.alpha()); | 41 uint8_t alpha = static_cast<uint8_t>(details.alpha()); |
| 41 SkBlendMode xfermode = SkXfermodeModeFromProto(details.mode()); | 42 SkBlendMode xfermode = SkXfermodeModeFromProto(details.mode()); |
| 42 std::unique_ptr<SkRect> bounds; | 43 std::unique_ptr<SkRect> bounds; |
| 43 if (details.has_bounds()) { | 44 if (details.has_bounds()) { |
| 44 bounds.reset( | 45 bounds.reset( |
| 45 new SkRect(gfx::RectFToSkRect(ProtoToRectF(details.bounds())))); | 46 new SkRect(gfx::RectFToSkRect(ProtoToRectF(details.bounds())))); |
| 46 } | 47 } |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 117 alpha_, static_cast<int>(xfermode_), visual_rect.ToString().c_str()); | 118 alpha_, static_cast<int>(xfermode_), visual_rect.ToString().c_str()); |
| 118 if (has_bounds_) { | 119 if (has_bounds_) { |
| 119 base::StringAppendF( | 120 base::StringAppendF( |
| 120 &info, ", bounds: [%f, %f, %f, %f]", static_cast<float>(bounds_.x()), | 121 &info, ", bounds: [%f, %f, %f, %f]", static_cast<float>(bounds_.x()), |
| 121 static_cast<float>(bounds_.y()), static_cast<float>(bounds_.width()), | 122 static_cast<float>(bounds_.y()), static_cast<float>(bounds_.width()), |
| 122 static_cast<float>(bounds_.height())); | 123 static_cast<float>(bounds_.height())); |
| 123 } | 124 } |
| 124 array->AppendString(info); | 125 array->AppendString(info); |
| 125 } | 126 } |
| 126 | 127 |
| 127 size_t CompositingDisplayItem::ExternalMemoryUsage() const { | 128 EndCompositingDisplayItem::EndCompositingDisplayItem() |
| 128 // TODO(pdr): Include color_filter's memory here. | 129 : DisplayItem(END_COMPOSITING) {} |
| 129 return 0; | |
| 130 } | |
| 131 | |
| 132 EndCompositingDisplayItem::EndCompositingDisplayItem() {} | |
| 133 | 130 |
| 134 EndCompositingDisplayItem::EndCompositingDisplayItem( | 131 EndCompositingDisplayItem::EndCompositingDisplayItem( |
| 135 const proto::DisplayItem& proto) { | 132 const proto::DisplayItem& proto) |
| 133 : DisplayItem(END_COMPOSITING) { |
| 136 DCHECK_EQ(proto::DisplayItem::Type_EndCompositing, proto.type()); | 134 DCHECK_EQ(proto::DisplayItem::Type_EndCompositing, proto.type()); |
| 137 } | 135 } |
| 138 | 136 |
| 139 EndCompositingDisplayItem::~EndCompositingDisplayItem() { | 137 EndCompositingDisplayItem::~EndCompositingDisplayItem() { |
| 140 } | 138 } |
| 141 | 139 |
| 142 void EndCompositingDisplayItem::ToProtobuf(proto::DisplayItem* proto) const { | 140 void EndCompositingDisplayItem::ToProtobuf(proto::DisplayItem* proto) const { |
| 143 proto->set_type(proto::DisplayItem::Type_EndCompositing); | 141 proto->set_type(proto::DisplayItem::Type_EndCompositing); |
| 144 } | 142 } |
| 145 | 143 |
| 146 void EndCompositingDisplayItem::Raster( | 144 void EndCompositingDisplayItem::Raster( |
| 147 SkCanvas* canvas, | 145 SkCanvas* canvas, |
| 148 SkPicture::AbortCallback* callback) const { | 146 SkPicture::AbortCallback* callback) const { |
| 149 canvas->restore(); | 147 canvas->restore(); |
| 150 } | 148 } |
| 151 | 149 |
| 152 void EndCompositingDisplayItem::AsValueInto( | 150 void EndCompositingDisplayItem::AsValueInto( |
| 153 const gfx::Rect& visual_rect, | 151 const gfx::Rect& visual_rect, |
| 154 base::trace_event::TracedValue* array) const { | 152 base::trace_event::TracedValue* array) const { |
| 155 array->AppendString( | 153 array->AppendString( |
| 156 base::StringPrintf("EndCompositingDisplayItem visualRect: [%s]", | 154 base::StringPrintf("EndCompositingDisplayItem visualRect: [%s]", |
| 157 visual_rect.ToString().c_str())); | 155 visual_rect.ToString().c_str())); |
| 158 } | 156 } |
| 159 | 157 |
| 160 size_t EndCompositingDisplayItem::ExternalMemoryUsage() const { | |
| 161 return 0; | |
| 162 } | |
| 163 | |
| 164 } // namespace cc | 158 } // namespace cc |
| OLD | NEW |