| Index: cc/playback/drawing_display_item.cc
|
| diff --git a/cc/playback/drawing_display_item.cc b/cc/playback/drawing_display_item.cc
|
| index 8bf18b3efdc1cff6264354fce62f565c30c88098..747aba090d09f1ea1af5a0b3283374e8b57ebd89 100644
|
| --- a/cc/playback/drawing_display_item.cc
|
| +++ b/cc/playback/drawing_display_item.cc
|
| @@ -15,6 +15,7 @@
|
| #include "cc/debug/picture_debug_util.h"
|
| #include "cc/proto/display_item.pb.h"
|
| #include "cc/proto/image_serialization_processor.h"
|
| +#include "cc/proto/picture_cache.h"
|
| #include "third_party/skia/include/core/SkCanvas.h"
|
| #include "third_party/skia/include/core/SkData.h"
|
| #include "third_party/skia/include/core/SkMatrix.h"
|
| @@ -33,17 +34,18 @@ DrawingDisplayItem::DrawingDisplayItem(sk_sp<const SkPicture> picture) {
|
|
|
| DrawingDisplayItem::DrawingDisplayItem(
|
| const proto::DisplayItem& proto,
|
| - ImageSerializationProcessor* image_serialization_processor) {
|
| + ClientPictureCache* client_picture_cache) {
|
| DCHECK_EQ(proto::DisplayItem::Type_Drawing, proto.type());
|
| + DCHECK(client_picture_cache);
|
|
|
| - sk_sp<SkPicture> picture;
|
| const proto::DrawingDisplayItem& details = proto.drawing_item();
|
| - if (details.has_picture()) {
|
| - SkMemoryStream stream(details.picture().data(), details.picture().size());
|
| + DCHECK(details.has_id());
|
| + const proto::SkPictureID& sk_picture_id = details.id();
|
| + DCHECK(sk_picture_id.has_unique_id());
|
|
|
| - picture = SkPicture::MakeFromStream(
|
| - &stream, image_serialization_processor->GetPixelDeserializer());
|
| - }
|
| + uint32_t unique_id = sk_picture_id.unique_id();
|
| + sk_sp<const SkPicture> picture = client_picture_cache->GetPicture(unique_id);
|
| + DCHECK(picture);
|
|
|
| SetNew(std::move(picture));
|
| }
|
| @@ -59,26 +61,27 @@ void DrawingDisplayItem::SetNew(sk_sp<const SkPicture> picture) {
|
| picture_ = std::move(picture);
|
| }
|
|
|
| -void DrawingDisplayItem::ToProtobuf(
|
| - proto::DisplayItem* proto,
|
| - ImageSerializationProcessor* image_serialization_processor) const {
|
| +void DrawingDisplayItem::ToProtobuf(proto::DisplayItem* proto) const {
|
| TRACE_EVENT0("cc.remote", "DrawingDisplayItem::ToProtobuf");
|
| proto->set_type(proto::DisplayItem::Type_Drawing);
|
|
|
| - proto::DrawingDisplayItem* details = proto->mutable_drawing_item();
|
| -
|
| - // Just use skia's serialize() method for now.
|
| - if (picture_) {
|
| - TRACE_EVENT0("cc.remote",
|
| - "DrawingDisplayItem::ToProtobuf SkPicture::Serialize");
|
| - SkDynamicMemoryWStream stream;
|
| - picture_->serialize(&stream,
|
| - image_serialization_processor->GetPixelSerializer());
|
| - if (stream.bytesWritten() > 0) {
|
| - SkAutoDataUnref data(stream.copyToData());
|
| - details->set_picture(data->data(), data->size());
|
| - }
|
| - }
|
| + if (!picture_)
|
| + return;
|
| +
|
| + proto->mutable_drawing_item()->mutable_id()->set_unique_id(
|
| + picture_->uniqueID());
|
| +}
|
| +
|
| +void DrawingDisplayItem::MarkForRegistrationEngine(
|
| + EnginePictureCache* engine_picture_cache) const {
|
| + if (picture_ && engine_picture_cache)
|
| + engine_picture_cache->MarkPictureForRegistration(picture_.get());
|
| +}
|
| +
|
| +void DrawingDisplayItem::MarkForUnregistrationEngine(
|
| + EnginePictureCache* engine_picture_cache) const {
|
| + if (picture_ && engine_picture_cache)
|
| + engine_picture_cache->MarkPictureForUnregistration(picture_.get());
|
| }
|
|
|
| void DrawingDisplayItem::Raster(SkCanvas* canvas,
|
|
|