| 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/drawing_display_item.h" | 5 #include "cc/playback/drawing_display_item.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| 11 #include "base/strings/stringprintf.h" | 11 #include "base/strings/stringprintf.h" |
| 12 #include "base/trace_event/trace_event_argument.h" | 12 #include "base/trace_event/trace_event_argument.h" |
| 13 #include "base/values.h" | 13 #include "base/values.h" |
| 14 #include "cc/debug/picture_debug_util.h" | 14 #include "cc/debug/picture_debug_util.h" |
| 15 #include "cc/proto/display_item.pb.h" | 15 #include "cc/proto/display_item.pb.h" |
| 16 #include "cc/proto/image_serialization_processor.h" | 16 #include "cc/proto/image_serialization_processor.h" |
| 17 #include "third_party/skia/include/core/SkCanvas.h" | 17 #include "third_party/skia/include/core/SkCanvas.h" |
| 18 #include "third_party/skia/include/core/SkData.h" | 18 #include "third_party/skia/include/core/SkData.h" |
| 19 #include "third_party/skia/include/core/SkMatrix.h" | 19 #include "third_party/skia/include/core/SkMatrix.h" |
| 20 #include "third_party/skia/include/core/SkPicture.h" | 20 #include "third_party/skia/include/core/SkPicture.h" |
| 21 #include "third_party/skia/include/core/SkStream.h" | 21 #include "third_party/skia/include/core/SkStream.h" |
| 22 #include "third_party/skia/include/utils/SkPictureUtils.h" | 22 #include "third_party/skia/include/utils/SkPictureUtils.h" |
| 23 #include "ui/gfx/skia_util.h" | 23 #include "ui/gfx/skia_util.h" |
| 24 | 24 |
| 25 namespace cc { | 25 namespace cc { |
| 26 | 26 |
| 27 DrawingDisplayItem::DrawingDisplayItem() {} | 27 DrawingDisplayItem::DrawingDisplayItem() {} |
| 28 | 28 |
| 29 DrawingDisplayItem::DrawingDisplayItem(skia::RefPtr<const SkPicture> picture) { | 29 DrawingDisplayItem::DrawingDisplayItem(sk_sp<const SkPicture> picture) { |
| 30 SetNew(std::move(picture)); | 30 SetNew(std::move(picture)); |
| 31 } | 31 } |
| 32 | 32 |
| 33 DrawingDisplayItem::DrawingDisplayItem( | 33 DrawingDisplayItem::DrawingDisplayItem( |
| 34 const proto::DisplayItem& proto, | 34 const proto::DisplayItem& proto, |
| 35 ImageSerializationProcessor* image_serialization_processor) { | 35 ImageSerializationProcessor* image_serialization_processor) { |
| 36 DCHECK_EQ(proto::DisplayItem::Type_Drawing, proto.type()); | 36 DCHECK_EQ(proto::DisplayItem::Type_Drawing, proto.type()); |
| 37 | 37 |
| 38 skia::RefPtr<SkPicture> picture; | 38 sk_sp<SkPicture> picture; |
| 39 const proto::DrawingDisplayItem& details = proto.drawing_item(); | 39 const proto::DrawingDisplayItem& details = proto.drawing_item(); |
| 40 if (details.has_picture()) { | 40 if (details.has_picture()) { |
| 41 SkMemoryStream stream(details.picture().data(), details.picture().size()); | 41 SkMemoryStream stream(details.picture().data(), details.picture().size()); |
| 42 | 42 |
| 43 picture = skia::AdoptRef(SkPicture::CreateFromStream( | 43 picture = SkPicture::MakeFromStream( |
| 44 &stream, image_serialization_processor->GetPixelDeserializer())); | 44 &stream, image_serialization_processor->GetPixelDeserializer()); |
| 45 } | 45 } |
| 46 | 46 |
| 47 SetNew(std::move(picture)); | 47 SetNew(std::move(picture)); |
| 48 } | 48 } |
| 49 | 49 |
| 50 DrawingDisplayItem::DrawingDisplayItem(const DrawingDisplayItem& item) { | 50 DrawingDisplayItem::DrawingDisplayItem(const DrawingDisplayItem& item) { |
| 51 item.CloneTo(this); | 51 item.CloneTo(this); |
| 52 } | 52 } |
| 53 | 53 |
| 54 DrawingDisplayItem::~DrawingDisplayItem() { | 54 DrawingDisplayItem::~DrawingDisplayItem() { |
| 55 } | 55 } |
| 56 | 56 |
| 57 void DrawingDisplayItem::SetNew(skia::RefPtr<const SkPicture> picture) { | 57 void DrawingDisplayItem::SetNew(sk_sp<const SkPicture> picture) { |
| 58 picture_ = std::move(picture); | 58 picture_ = std::move(picture); |
| 59 } | 59 } |
| 60 | 60 |
| 61 void DrawingDisplayItem::ToProtobuf( | 61 void DrawingDisplayItem::ToProtobuf( |
| 62 proto::DisplayItem* proto, | 62 proto::DisplayItem* proto, |
| 63 ImageSerializationProcessor* image_serialization_processor) const { | 63 ImageSerializationProcessor* image_serialization_processor) const { |
| 64 proto->set_type(proto::DisplayItem::Type_Drawing); | 64 proto->set_type(proto::DisplayItem::Type_Drawing); |
| 65 | 65 |
| 66 proto::DrawingDisplayItem* details = proto->mutable_drawing_item(); | 66 proto::DrawingDisplayItem* details = proto->mutable_drawing_item(); |
| 67 | 67 |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 134 | 134 |
| 135 int DrawingDisplayItem::ApproximateOpCount() const { | 135 int DrawingDisplayItem::ApproximateOpCount() const { |
| 136 return picture_->approximateOpCount(); | 136 return picture_->approximateOpCount(); |
| 137 } | 137 } |
| 138 | 138 |
| 139 bool DrawingDisplayItem::IsSuitableForGpuRasterization() const { | 139 bool DrawingDisplayItem::IsSuitableForGpuRasterization() const { |
| 140 return picture_->suitableForGpuRasterization(NULL); | 140 return picture_->suitableForGpuRasterization(NULL); |
| 141 } | 141 } |
| 142 | 142 |
| 143 } // namespace cc | 143 } // namespace cc |
| OLD | NEW |