| Index: cc/playback/display_item_list.cc
|
| diff --git a/cc/playback/display_item_list.cc b/cc/playback/display_item_list.cc
|
| index 3ad738ab7dbd0b554e659ac0ff21f2ed9583040a..f2d809b3f47c68c84f21cbaa18041fba5342d884 100644
|
| --- a/cc/playback/display_item_list.cc
|
| +++ b/cc/playback/display_item_list.cc
|
| @@ -22,6 +22,7 @@
|
| #include "cc/playback/largest_display_item.h"
|
| #include "cc/proto/display_item.pb.h"
|
| #include "cc/proto/gfx_conversions.h"
|
| +#include "cc/proto/picture_cache.h"
|
| #include "third_party/skia/include/core/SkCanvas.h"
|
| #include "third_party/skia/include/core/SkPictureRecorder.h"
|
| #include "third_party/skia/include/utils/SkPictureUtils.h"
|
| @@ -29,7 +30,7 @@
|
| #include "ui/gfx/skia_util.h"
|
|
|
| namespace cc {
|
| -class ImageSerializationProcessor;
|
| +class EnginePictureCache;
|
|
|
| namespace {
|
|
|
| @@ -46,6 +47,21 @@ bool DisplayItemsTracingEnabled() {
|
|
|
| const int kDefaultNumDisplayItemsToReserve = 100;
|
|
|
| +// SkPicture::uniqueID() starts at 1.
|
| +const uint32_t kInvalidEnginePictureID = 0;
|
| +
|
| +uint32_t GetUniqueSkPictureIDOrNothing(const proto::DisplayItem& item_proto) {
|
| + if (item_proto.type() == proto::DisplayItem::Type_Drawing) {
|
| + DCHECK(item_proto.has_drawing_item());
|
| + const proto::DrawingDisplayItem& details = item_proto.drawing_item();
|
| + DCHECK(details.has_id());
|
| + const proto::SkPictureID& sk_picture_id = details.id();
|
| + DCHECK(sk_picture_id.has_unique_id());
|
| + return sk_picture_id.unique_id();
|
| + }
|
| + return kInvalidEnginePictureID;
|
| +}
|
| +
|
| } // namespace
|
|
|
| scoped_refptr<DisplayItemList> DisplayItemList::Create(
|
| @@ -58,20 +74,25 @@ scoped_refptr<DisplayItemList> DisplayItemList::Create(
|
|
|
| scoped_refptr<DisplayItemList> DisplayItemList::CreateFromProto(
|
| const proto::DisplayItemList& proto,
|
| - ImageSerializationProcessor* image_serialization_processor) {
|
| + ClientPictureCache* client_picture_cache) {
|
| gfx::Rect layer_rect = ProtoToRect(proto.layer_rect());
|
| scoped_refptr<DisplayItemList> list =
|
| DisplayItemList::Create(ProtoToRect(proto.layer_rect()),
|
| DisplayItemListSettings(proto.settings()));
|
|
|
| + std::vector<uint32_t> engine_picture_ids;
|
| for (int i = 0; i < proto.items_size(); i++) {
|
| const proto::DisplayItem& item_proto = proto.items(i);
|
| DisplayItemProtoFactory::AllocateAndConstruct(
|
| - layer_rect, list.get(), item_proto, image_serialization_processor);
|
| + layer_rect, list.get(), item_proto, client_picture_cache);
|
| + engine_picture_ids.push_back(GetUniqueSkPictureIDOrNothing(item_proto));
|
| }
|
|
|
| list->Finalize();
|
|
|
| + // Now that the list has been constructed, ensure that the
|
| + // |engine_picture_ids_| map in order to the same DisplayItems.
|
| + list->engine_picture_ids_.swap(engine_picture_ids);
|
| return list;
|
| }
|
|
|
| @@ -100,9 +121,7 @@ DisplayItemList::DisplayItemList(gfx::Rect layer_rect,
|
| DisplayItemList::~DisplayItemList() {
|
| }
|
|
|
| -void DisplayItemList::ToProtobuf(
|
| - proto::DisplayItemList* proto,
|
| - ImageSerializationProcessor* image_serialization_processor) {
|
| +void DisplayItemList::ToProtobuf(proto::DisplayItemList* proto) {
|
| // The flattened SkPicture approach is going away, and the proto
|
| // doesn't currently support serializing that flattened picture.
|
| DCHECK(retain_individual_display_items_);
|
| @@ -112,7 +131,45 @@ void DisplayItemList::ToProtobuf(
|
|
|
| DCHECK_EQ(0, proto->items_size());
|
| for (const auto& item : items_)
|
| - item.ToProtobuf(proto->add_items(), image_serialization_processor);
|
| + item.ToProtobuf(proto->add_items());
|
| +}
|
| +
|
| +void DisplayItemList::MarkForRegistrationEngine(
|
| + EnginePictureCache* engine_picture_cache) {
|
| + DCHECK(!marked_);
|
| + marked_ = true;
|
| + for (const auto& item : items_)
|
| + item.MarkForRegistrationEngine(engine_picture_cache);
|
| +}
|
| +
|
| +void DisplayItemList::MarkForUnregistrationEngine(
|
| + EnginePictureCache* engine_picture_cache) {
|
| + DCHECK(marked_);
|
| + marked_ = false;
|
| + for (const auto& item : items_)
|
| + item.MarkForUnregistrationEngine(engine_picture_cache);
|
| +}
|
| +
|
| +void DisplayItemList::MarkForRegistrationClient(
|
| + ClientPictureCache* client_picture_cache) {
|
| + DCHECK(!marked_);
|
| + marked_ = true;
|
| + for (const uint32_t id : engine_picture_ids_) {
|
| + if (id == kInvalidEnginePictureID)
|
| + continue;
|
| + client_picture_cache->MarkPictureForRegistration(id);
|
| + }
|
| +}
|
| +
|
| +void DisplayItemList::MarkForUnregistrationClient(
|
| + ClientPictureCache* client_picture_cache) {
|
| + DCHECK(marked_);
|
| + marked_ = false;
|
| + for (const uint32_t id : engine_picture_ids_) {
|
| + if (id == kInvalidEnginePictureID)
|
| + continue;
|
| + client_picture_cache->MarkPictureForUnregistration(id);
|
| + }
|
| }
|
|
|
| void DisplayItemList::Raster(SkCanvas* canvas,
|
|
|