OLD | NEW |
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 Loading... |
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 int ClipPathDisplayItem::ApproximateOpCount() const { |
| 91 return 1; |
| 92 } |
| 93 |
| 94 EndClipPathDisplayItem::EndClipPathDisplayItem() {} |
| 95 |
| 96 EndClipPathDisplayItem::EndClipPathDisplayItem( |
| 97 const proto::DisplayItem& proto) { |
| 98 FromProtobuf(proto); |
85 } | 99 } |
86 | 100 |
87 EndClipPathDisplayItem::~EndClipPathDisplayItem() { | 101 EndClipPathDisplayItem::~EndClipPathDisplayItem() { |
88 } | 102 } |
89 | 103 |
90 void EndClipPathDisplayItem::ToProtobuf(proto::DisplayItem* proto) const { | 104 void EndClipPathDisplayItem::ToProtobuf(proto::DisplayItem* proto) const { |
91 proto->set_type(proto::DisplayItem::Type_EndClipPath); | 105 proto->set_type(proto::DisplayItem::Type_EndClipPath); |
92 } | 106 } |
93 | 107 |
94 void EndClipPathDisplayItem::FromProtobuf(const proto::DisplayItem& proto) { | 108 void EndClipPathDisplayItem::FromProtobuf(const proto::DisplayItem& proto) { |
95 DCHECK_EQ(proto::DisplayItem::Type_EndClipPath, proto.type()); | 109 DCHECK_EQ(proto::DisplayItem::Type_EndClipPath, proto.type()); |
96 } | 110 } |
97 | 111 |
98 void EndClipPathDisplayItem::Raster( | 112 void EndClipPathDisplayItem::Raster( |
99 SkCanvas* canvas, | 113 SkCanvas* canvas, |
100 const gfx::Rect& canvas_target_playback_rect, | 114 const gfx::Rect& canvas_target_playback_rect, |
101 SkPicture::AbortCallback* callback) const { | 115 SkPicture::AbortCallback* callback) const { |
102 canvas->restore(); | 116 canvas->restore(); |
103 } | 117 } |
104 | 118 |
105 void EndClipPathDisplayItem::AsValueInto( | 119 void EndClipPathDisplayItem::AsValueInto( |
106 const gfx::Rect& visual_rect, | 120 const gfx::Rect& visual_rect, |
107 base::trace_event::TracedValue* array) const { | 121 base::trace_event::TracedValue* array) const { |
108 array->AppendString( | 122 array->AppendString( |
109 base::StringPrintf("EndClipPathDisplayItem visualRect: [%s]", | 123 base::StringPrintf("EndClipPathDisplayItem visualRect: [%s]", |
110 visual_rect.ToString().c_str())); | 124 visual_rect.ToString().c_str())); |
111 } | 125 } |
112 | 126 |
| 127 size_t EndClipPathDisplayItem::ExternalMemoryUsage() const { |
| 128 return 0; |
| 129 } |
| 130 |
| 131 int EndClipPathDisplayItem::ApproximateOpCount() const { |
| 132 return 0; |
| 133 } |
| 134 |
113 } // namespace cc | 135 } // namespace cc |
OLD | NEW |