Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(69)

Side by Side Diff: cc/playback/drawing_display_item.cc

Issue 1564233005: Make cc::DrawingDisplayItem hold a const SkPicture. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « cc/playback/drawing_display_item.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "third_party/skia/include/core/SkCanvas.h" 16 #include "third_party/skia/include/core/SkCanvas.h"
17 #include "third_party/skia/include/core/SkData.h" 17 #include "third_party/skia/include/core/SkData.h"
18 #include "third_party/skia/include/core/SkMatrix.h" 18 #include "third_party/skia/include/core/SkMatrix.h"
19 #include "third_party/skia/include/core/SkPicture.h" 19 #include "third_party/skia/include/core/SkPicture.h"
20 #include "third_party/skia/include/core/SkStream.h" 20 #include "third_party/skia/include/core/SkStream.h"
21 #include "third_party/skia/include/utils/SkPictureUtils.h" 21 #include "third_party/skia/include/utils/SkPictureUtils.h"
22 #include "ui/gfx/skia_util.h" 22 #include "ui/gfx/skia_util.h"
23 23
24 namespace cc { 24 namespace cc {
25 25
26 DrawingDisplayItem::DrawingDisplayItem() {} 26 DrawingDisplayItem::DrawingDisplayItem() {}
27 27
28 DrawingDisplayItem::DrawingDisplayItem(skia::RefPtr<SkPicture> picture) { 28 DrawingDisplayItem::DrawingDisplayItem(skia::RefPtr<const SkPicture> picture) {
29 SetNew(std::move(picture)); 29 SetNew(std::move(picture));
30 } 30 }
31 31
32 DrawingDisplayItem::DrawingDisplayItem(const proto::DisplayItem& proto) { 32 DrawingDisplayItem::DrawingDisplayItem(const proto::DisplayItem& proto) {
33 DCHECK_EQ(proto::DisplayItem::Type_Drawing, proto.type()); 33 DCHECK_EQ(proto::DisplayItem::Type_Drawing, proto.type());
34 34
35 skia::RefPtr<SkPicture> picture; 35 skia::RefPtr<SkPicture> picture;
36 const proto::DrawingDisplayItem& details = proto.drawing_item(); 36 const proto::DrawingDisplayItem& details = proto.drawing_item();
37 if (details.has_picture()) { 37 if (details.has_picture()) {
38 SkMemoryStream stream(details.picture().data(), details.picture().size()); 38 SkMemoryStream stream(details.picture().data(), details.picture().size());
39 39
40 // TODO(dtrainor, nyquist): Add an image decoder. 40 // TODO(dtrainor, nyquist): Add an image decoder.
41 picture = skia::AdoptRef(SkPicture::CreateFromStream(&stream, nullptr)); 41 picture = skia::AdoptRef(SkPicture::CreateFromStream(&stream, nullptr));
42 } 42 }
43 43
44 SetNew(std::move(picture)); 44 SetNew(std::move(picture));
45 } 45 }
46 46
47 DrawingDisplayItem::DrawingDisplayItem(const DrawingDisplayItem& item) { 47 DrawingDisplayItem::DrawingDisplayItem(const DrawingDisplayItem& item) {
48 item.CloneTo(this); 48 item.CloneTo(this);
49 } 49 }
50 50
51 DrawingDisplayItem::~DrawingDisplayItem() { 51 DrawingDisplayItem::~DrawingDisplayItem() {
52 } 52 }
53 53
54 void DrawingDisplayItem::SetNew(skia::RefPtr<SkPicture> picture) { 54 void DrawingDisplayItem::SetNew(skia::RefPtr<const SkPicture> picture) {
55 picture_ = std::move(picture); 55 picture_ = std::move(picture);
56 } 56 }
57 57
58 void DrawingDisplayItem::ToProtobuf(proto::DisplayItem* proto) const { 58 void DrawingDisplayItem::ToProtobuf(proto::DisplayItem* proto) const {
59 proto->set_type(proto::DisplayItem::Type_Drawing); 59 proto->set_type(proto::DisplayItem::Type_Drawing);
60 60
61 proto::DrawingDisplayItem* details = proto->mutable_drawing_item(); 61 proto::DrawingDisplayItem* details = proto->mutable_drawing_item();
62 62
63 // Just use skia's serialize() method for now. 63 // Just use skia's serialize() method for now.
64 if (picture_) { 64 if (picture_) {
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
131 131
132 int DrawingDisplayItem::ApproximateOpCount() const { 132 int DrawingDisplayItem::ApproximateOpCount() const {
133 return picture_->approximateOpCount(); 133 return picture_->approximateOpCount();
134 } 134 }
135 135
136 bool DrawingDisplayItem::IsSuitableForGpuRasterization() const { 136 bool DrawingDisplayItem::IsSuitableForGpuRasterization() const {
137 return picture_->suitableForGpuRasterization(NULL); 137 return picture_->suitableForGpuRasterization(NULL);
138 } 138 }
139 139
140 } // namespace cc 140 } // namespace cc
OLDNEW
« no previous file with comments | « cc/playback/drawing_display_item.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698