| 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.h" | 12 #include "base/trace_event/trace_event.h" |
| 13 #include "base/trace_event/trace_event_argument.h" | 13 #include "base/trace_event/trace_event_argument.h" |
| 14 #include "base/values.h" | 14 #include "base/values.h" |
| 15 #include "cc/blimp/client_picture_cache.h" | 15 #include "cc/blimp/client_picture_cache.h" |
| 16 #include "cc/blimp/image_serialization_processor.h" | 16 #include "cc/blimp/image_serialization_processor.h" |
| 17 #include "cc/debug/picture_debug_util.h" | 17 #include "cc/debug/picture_debug_util.h" |
| 18 #include "cc/proto/display_item.pb.h" | 18 #include "cc/proto/display_item.pb.h" |
| 19 #include "third_party/skia/include/core/SkCanvas.h" | 19 #include "third_party/skia/include/core/SkCanvas.h" |
| 20 #include "third_party/skia/include/core/SkData.h" | 20 #include "third_party/skia/include/core/SkData.h" |
| 21 #include "third_party/skia/include/core/SkMatrix.h" | 21 #include "third_party/skia/include/core/SkMatrix.h" |
| 22 #include "third_party/skia/include/core/SkPicture.h" | 22 #include "third_party/skia/include/core/SkPicture.h" |
| 23 #include "third_party/skia/include/core/SkStream.h" | 23 #include "third_party/skia/include/core/SkStream.h" |
| 24 #include "third_party/skia/include/utils/SkPictureUtils.h" | 24 #include "third_party/skia/include/utils/SkPictureUtils.h" |
| 25 #include "ui/gfx/skia_util.h" | 25 #include "ui/gfx/skia_util.h" |
| 26 | 26 |
| 27 namespace cc { | 27 namespace cc { |
| 28 | 28 |
| 29 DrawingDisplayItem::DrawingDisplayItem() {} | 29 DrawingDisplayItem::DrawingDisplayItem() : DisplayItem(DRAWING) {} |
| 30 | 30 |
| 31 DrawingDisplayItem::DrawingDisplayItem(sk_sp<const SkPicture> picture) { | 31 DrawingDisplayItem::DrawingDisplayItem(sk_sp<const SkPicture> picture) |
| 32 : DisplayItem(DRAWING) { |
| 32 SetNew(std::move(picture)); | 33 SetNew(std::move(picture)); |
| 33 } | 34 } |
| 34 | 35 |
| 35 DrawingDisplayItem::DrawingDisplayItem( | 36 DrawingDisplayItem::DrawingDisplayItem( |
| 36 const proto::DisplayItem& proto, | 37 const proto::DisplayItem& proto, |
| 37 ClientPictureCache* client_picture_cache, | 38 ClientPictureCache* client_picture_cache, |
| 38 std::vector<uint32_t>* used_engine_picture_ids) { | 39 std::vector<uint32_t>* used_engine_picture_ids) |
| 40 : DisplayItem(DRAWING) { |
| 39 DCHECK_EQ(proto::DisplayItem::Type_Drawing, proto.type()); | 41 DCHECK_EQ(proto::DisplayItem::Type_Drawing, proto.type()); |
| 40 DCHECK(client_picture_cache); | 42 DCHECK(client_picture_cache); |
| 41 | 43 |
| 42 const proto::DrawingDisplayItem& details = proto.drawing_item(); | 44 const proto::DrawingDisplayItem& details = proto.drawing_item(); |
| 43 DCHECK(details.has_id()); | 45 DCHECK(details.has_id()); |
| 44 const proto::SkPictureID& sk_picture_id = details.id(); | 46 const proto::SkPictureID& sk_picture_id = details.id(); |
| 45 DCHECK(sk_picture_id.has_unique_id()); | 47 DCHECK(sk_picture_id.has_unique_id()); |
| 46 | 48 |
| 47 uint32_t unique_id = sk_picture_id.unique_id(); | 49 uint32_t unique_id = sk_picture_id.unique_id(); |
| 48 sk_sp<const SkPicture> picture = client_picture_cache->GetPicture(unique_id); | 50 sk_sp<const SkPicture> picture = client_picture_cache->GetPicture(unique_id); |
| 49 DCHECK(picture); | 51 DCHECK(picture); |
| 50 | 52 |
| 51 used_engine_picture_ids->push_back(unique_id); | 53 used_engine_picture_ids->push_back(unique_id); |
| 52 SetNew(std::move(picture)); | 54 SetNew(std::move(picture)); |
| 53 } | 55 } |
| 54 | 56 |
| 55 DrawingDisplayItem::DrawingDisplayItem(const DrawingDisplayItem& item) { | 57 DrawingDisplayItem::DrawingDisplayItem(const DrawingDisplayItem& item) |
| 58 : DisplayItem(DRAWING) { |
| 56 item.CloneTo(this); | 59 item.CloneTo(this); |
| 57 } | 60 } |
| 58 | 61 |
| 59 DrawingDisplayItem::~DrawingDisplayItem() { | 62 DrawingDisplayItem::~DrawingDisplayItem() { |
| 60 } | 63 } |
| 61 | 64 |
| 62 void DrawingDisplayItem::SetNew(sk_sp<const SkPicture> picture) { | 65 void DrawingDisplayItem::SetNew(sk_sp<const SkPicture> picture) { |
| 63 picture_ = std::move(picture); | 66 picture_ = std::move(picture); |
| 64 } | 67 } |
| 65 | 68 |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 125 size_t DrawingDisplayItem::ExternalMemoryUsage() const { | 128 size_t DrawingDisplayItem::ExternalMemoryUsage() const { |
| 126 return SkPictureUtils::ApproximateBytesUsed(picture_.get()); | 129 return SkPictureUtils::ApproximateBytesUsed(picture_.get()); |
| 127 } | 130 } |
| 128 | 131 |
| 129 DISABLE_CFI_PERF | 132 DISABLE_CFI_PERF |
| 130 int DrawingDisplayItem::ApproximateOpCount() const { | 133 int DrawingDisplayItem::ApproximateOpCount() const { |
| 131 return picture_->approximateOpCount(); | 134 return picture_->approximateOpCount(); |
| 132 } | 135 } |
| 133 | 136 |
| 134 } // namespace cc | 137 } // namespace cc |
| OLD | NEW |