| Index: cc/playback/drawing_display_item.cc
|
| diff --git a/cc/playback/drawing_display_item.cc b/cc/playback/drawing_display_item.cc
|
| index 05935778582c5d8d11b716610cac185db21816d5..f314608f74818dd4d2f3df7f484b9fe2b2b0d53f 100644
|
| --- a/cc/playback/drawing_display_item.cc
|
| +++ b/cc/playback/drawing_display_item.cc
|
| @@ -21,7 +21,29 @@
|
|
|
| namespace cc {
|
|
|
| -DrawingDisplayItem::DrawingDisplayItem() {
|
| +DrawingDisplayItem::DrawingDisplayItem() {}
|
| +
|
| +DrawingDisplayItem::DrawingDisplayItem(skia::RefPtr<SkPicture> picture) {
|
| + SetNew(std::move(picture));
|
| +}
|
| +
|
| +DrawingDisplayItem::DrawingDisplayItem(const proto::DisplayItem& proto) {
|
| + DCHECK_EQ(proto::DisplayItem::Type_Drawing, proto.type());
|
| +
|
| + skia::RefPtr<SkPicture> picture;
|
| + const proto::DrawingDisplayItem& details = proto.drawing_item();
|
| + if (details.has_picture()) {
|
| + SkMemoryStream stream(details.picture().data(), details.picture().size());
|
| +
|
| + // TODO(dtrainor, nyquist): Add an image decoder.
|
| + picture = skia::AdoptRef(SkPicture::CreateFromStream(&stream, nullptr));
|
| + }
|
| +
|
| + SetNew(std::move(picture));
|
| +}
|
| +
|
| +DrawingDisplayItem::DrawingDisplayItem(const DrawingDisplayItem& item) {
|
| + item.CloneTo(this);
|
| }
|
|
|
| DrawingDisplayItem::~DrawingDisplayItem() {
|
| @@ -29,9 +51,6 @@ DrawingDisplayItem::~DrawingDisplayItem() {
|
|
|
| void DrawingDisplayItem::SetNew(skia::RefPtr<SkPicture> picture) {
|
| picture_ = std::move(picture);
|
| - DisplayItem::SetNew(picture_->suitableForGpuRasterization(NULL),
|
| - picture_->approximateOpCount(),
|
| - SkPictureUtils::ApproximateBytesUsed(picture_.get()));
|
| }
|
|
|
| void DrawingDisplayItem::ToProtobuf(proto::DisplayItem* proto) const {
|
| @@ -53,21 +72,6 @@ void DrawingDisplayItem::ToProtobuf(proto::DisplayItem* proto) const {
|
| }
|
| }
|
|
|
| -void DrawingDisplayItem::FromProtobuf(const proto::DisplayItem& proto) {
|
| - DCHECK_EQ(proto::DisplayItem::Type_Drawing, proto.type());
|
| -
|
| - skia::RefPtr<SkPicture> picture;
|
| - const proto::DrawingDisplayItem& details = proto.drawing_item();
|
| - if (details.has_picture()) {
|
| - SkMemoryStream stream(details.picture().data(), details.picture().size());
|
| -
|
| - // TODO(dtrainor, nyquist): Add an image decoder.
|
| - picture = skia::AdoptRef(SkPicture::CreateFromStream(&stream, nullptr));
|
| - }
|
| -
|
| - SetNew(std::move(picture));
|
| -}
|
| -
|
| void DrawingDisplayItem::Raster(SkCanvas* canvas,
|
| const gfx::Rect& canvas_target_playback_rect,
|
| SkPicture::AbortCallback* callback) const {
|
| @@ -119,4 +123,16 @@ void DrawingDisplayItem::CloneTo(DrawingDisplayItem* item) const {
|
| item->SetNew(picture_);
|
| }
|
|
|
| +size_t DrawingDisplayItem::ExternalMemoryUsage() const {
|
| + return SkPictureUtils::ApproximateBytesUsed(picture_.get());
|
| +}
|
| +
|
| +int DrawingDisplayItem::ApproximateOpCount() const {
|
| + return picture_->approximateOpCount();
|
| +}
|
| +
|
| +bool DrawingDisplayItem::IsSuitableForGpuRasterization() const {
|
| + return picture_->suitableForGpuRasterization(NULL);
|
| +}
|
| +
|
| } // namespace cc
|
|
|