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

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

Issue 1494223003: cc: Shrink size of display item (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: danakj review Created 5 years 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
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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/clip_path_display_item.h" 5 #include "cc/playback/clip_path_display_item.h"
6 6
7 #include "base/strings/stringprintf.h" 7 #include "base/strings/stringprintf.h"
8 #include "base/trace_event/trace_event_argument.h" 8 #include "base/trace_event/trace_event_argument.h"
9 #include "cc/proto/display_item.pb.h" 9 #include "cc/proto/display_item.pb.h"
10 #include "cc/proto/skia_conversions.h" 10 #include "cc/proto/skia_conversions.h"
11 #include "third_party/skia/include/core/SkCanvas.h" 11 #include "third_party/skia/include/core/SkCanvas.h"
12 12
13 namespace cc { 13 namespace cc {
14 14
15 ClipPathDisplayItem::ClipPathDisplayItem() { 15 ClipPathDisplayItem::ClipPathDisplayItem(const SkPath& clip_path,
16 SkRegion::Op clip_op,
17 bool antialias) {
18 SetNew(clip_path, clip_op, antialias);
19 }
20
21 ClipPathDisplayItem::ClipPathDisplayItem(const proto::DisplayItem& proto) {
22 FromProtobuf(proto);
16 } 23 }
17 24
18 ClipPathDisplayItem::~ClipPathDisplayItem() { 25 ClipPathDisplayItem::~ClipPathDisplayItem() {
19 } 26 }
20 27
21 void ClipPathDisplayItem::SetNew(const SkPath& clip_path, 28 void ClipPathDisplayItem::SetNew(const SkPath& clip_path,
22 SkRegion::Op clip_op, 29 SkRegion::Op clip_op,
23 bool antialias) { 30 bool antialias) {
24 clip_path_ = clip_path; 31 clip_path_ = clip_path;
25 clip_op_ = clip_op; 32 clip_op_ = clip_op;
26 antialias_ = antialias; 33 antialias_ = antialias;
27
28 // The size of SkPath's external storage is not currently accounted for (and
29 // may well be shared anyway).
30 DisplayItem::SetNew(true /* suitable_for_gpu_raster */, 1 /* op_count */,
31 0 /* external_memory_usage */);
32 } 34 }
33 35
34 void ClipPathDisplayItem::ToProtobuf(proto::DisplayItem* proto) const { 36 void ClipPathDisplayItem::ToProtobuf(proto::DisplayItem* proto) const {
35 proto->set_type(proto::DisplayItem::Type_ClipPath); 37 proto->set_type(proto::DisplayItem::Type_ClipPath);
36 38
37 proto::ClipPathDisplayItem* details = proto->mutable_clip_path_item(); 39 proto::ClipPathDisplayItem* details = proto->mutable_clip_path_item();
38 details->set_clip_op(SkRegionOpToProto(clip_op_)); 40 details->set_clip_op(SkRegionOpToProto(clip_op_));
39 details->set_antialias(antialias_); 41 details->set_antialias(antialias_);
40 42
41 // Just use skia's serialization method for the SkPath for now. 43 // Just use skia's serialization method for the SkPath for now.
(...skipping 30 matching lines...) Expand all
72 } 74 }
73 75
74 void ClipPathDisplayItem::AsValueInto( 76 void ClipPathDisplayItem::AsValueInto(
75 const gfx::Rect& visual_rect, 77 const gfx::Rect& visual_rect,
76 base::trace_event::TracedValue* array) const { 78 base::trace_event::TracedValue* array) const {
77 array->AppendString(base::StringPrintf( 79 array->AppendString(base::StringPrintf(
78 "ClipPathDisplayItem length: %d visualRect: [%s]", 80 "ClipPathDisplayItem length: %d visualRect: [%s]",
79 clip_path_.countPoints(), visual_rect.ToString().c_str())); 81 clip_path_.countPoints(), visual_rect.ToString().c_str()));
80 } 82 }
81 83
82 EndClipPathDisplayItem::EndClipPathDisplayItem() { 84 size_t ClipPathDisplayItem::ExternalMemoryUsage() const {
83 DisplayItem::SetNew(true /* suitable_for_gpu_raster */, 0 /* op_count */, 85 // The size of SkPath's external storage is not currently accounted for (and
84 0 /* external_memory_usage */); 86 // may well be shared anyway).
87 return 0;
88 }
89
90 EndClipPathDisplayItem::EndClipPathDisplayItem() {}
91
92 EndClipPathDisplayItem::EndClipPathDisplayItem(
93 const proto::DisplayItem& proto) {
94 FromProtobuf(proto);
85 } 95 }
86 96
87 EndClipPathDisplayItem::~EndClipPathDisplayItem() { 97 EndClipPathDisplayItem::~EndClipPathDisplayItem() {
88 } 98 }
89 99
90 void EndClipPathDisplayItem::ToProtobuf(proto::DisplayItem* proto) const { 100 void EndClipPathDisplayItem::ToProtobuf(proto::DisplayItem* proto) const {
91 proto->set_type(proto::DisplayItem::Type_EndClipPath); 101 proto->set_type(proto::DisplayItem::Type_EndClipPath);
92 } 102 }
93 103
94 void EndClipPathDisplayItem::FromProtobuf(const proto::DisplayItem& proto) { 104 void EndClipPathDisplayItem::FromProtobuf(const proto::DisplayItem& proto) {
95 DCHECK_EQ(proto::DisplayItem::Type_EndClipPath, proto.type()); 105 DCHECK_EQ(proto::DisplayItem::Type_EndClipPath, proto.type());
96 } 106 }
97 107
98 void EndClipPathDisplayItem::Raster( 108 void EndClipPathDisplayItem::Raster(
99 SkCanvas* canvas, 109 SkCanvas* canvas,
100 const gfx::Rect& canvas_target_playback_rect, 110 const gfx::Rect& canvas_target_playback_rect,
101 SkPicture::AbortCallback* callback) const { 111 SkPicture::AbortCallback* callback) const {
102 canvas->restore(); 112 canvas->restore();
103 } 113 }
104 114
105 void EndClipPathDisplayItem::AsValueInto( 115 void EndClipPathDisplayItem::AsValueInto(
106 const gfx::Rect& visual_rect, 116 const gfx::Rect& visual_rect,
107 base::trace_event::TracedValue* array) const { 117 base::trace_event::TracedValue* array) const {
108 array->AppendString( 118 array->AppendString(
109 base::StringPrintf("EndClipPathDisplayItem visualRect: [%s]", 119 base::StringPrintf("EndClipPathDisplayItem visualRect: [%s]",
110 visual_rect.ToString().c_str())); 120 visual_rect.ToString().c_str()));
111 } 121 }
112 122
123 size_t EndClipPathDisplayItem::ExternalMemoryUsage() const {
124 return 0;
125 }
126
113 } // namespace cc 127 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698