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 <stddef.h> | 7 #include <stddef.h> |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include "base/strings/stringprintf.h" | 10 #include "base/strings/stringprintf.h" |
11 #include "base/trace_event/trace_event_argument.h" | 11 #include "base/trace_event/trace_event_argument.h" |
12 #include "cc/proto/display_item.pb.h" | 12 #include "cc/proto/display_item.pb.h" |
13 #include "cc/proto/skia_conversions.h" | 13 #include "cc/proto/skia_conversions.h" |
14 #include "third_party/skia/include/core/SkCanvas.h" | 14 #include "third_party/skia/include/core/SkCanvas.h" |
15 | 15 |
16 namespace cc { | 16 namespace cc { |
17 class ImageSerializationProcessor; | |
18 | 17 |
19 ClipPathDisplayItem::ClipPathDisplayItem(const SkPath& clip_path, | 18 ClipPathDisplayItem::ClipPathDisplayItem(const SkPath& clip_path, |
20 SkRegion::Op clip_op, | 19 SkRegion::Op clip_op, |
21 bool antialias) { | 20 bool antialias) { |
22 SetNew(clip_path, clip_op, antialias); | 21 SetNew(clip_path, clip_op, antialias); |
23 } | 22 } |
24 | 23 |
25 ClipPathDisplayItem::ClipPathDisplayItem(const proto::DisplayItem& proto) { | 24 ClipPathDisplayItem::ClipPathDisplayItem(const proto::DisplayItem& proto) { |
26 DCHECK_EQ(proto::DisplayItem::Type_ClipPath, proto.type()); | 25 DCHECK_EQ(proto::DisplayItem::Type_ClipPath, proto.type()); |
27 | 26 |
(...skipping 15 matching lines...) Expand all Loading... |
43 } | 42 } |
44 | 43 |
45 void ClipPathDisplayItem::SetNew(const SkPath& clip_path, | 44 void ClipPathDisplayItem::SetNew(const SkPath& clip_path, |
46 SkRegion::Op clip_op, | 45 SkRegion::Op clip_op, |
47 bool antialias) { | 46 bool antialias) { |
48 clip_path_ = clip_path; | 47 clip_path_ = clip_path; |
49 clip_op_ = clip_op; | 48 clip_op_ = clip_op; |
50 antialias_ = antialias; | 49 antialias_ = antialias; |
51 } | 50 } |
52 | 51 |
53 void ClipPathDisplayItem::ToProtobuf( | 52 void ClipPathDisplayItem::ToProtobuf(proto::DisplayItem* proto) const { |
54 proto::DisplayItem* proto, | |
55 ImageSerializationProcessor* image_serialization_processor) const { | |
56 proto->set_type(proto::DisplayItem::Type_ClipPath); | 53 proto->set_type(proto::DisplayItem::Type_ClipPath); |
57 | 54 |
58 proto::ClipPathDisplayItem* details = proto->mutable_clip_path_item(); | 55 proto::ClipPathDisplayItem* details = proto->mutable_clip_path_item(); |
59 details->set_clip_op(SkRegionOpToProto(clip_op_)); | 56 details->set_clip_op(SkRegionOpToProto(clip_op_)); |
60 details->set_antialias(antialias_); | 57 details->set_antialias(antialias_); |
61 | 58 |
62 // Just use skia's serialization method for the SkPath for now. | 59 // Just use skia's serialization method for the SkPath for now. |
63 size_t path_size = clip_path_.writeToMemory(nullptr); | 60 size_t path_size = clip_path_.writeToMemory(nullptr); |
64 if (path_size > 0) { | 61 if (path_size > 0) { |
65 std::unique_ptr<uint8_t[]> buffer(new uint8_t[path_size]); | 62 std::unique_ptr<uint8_t[]> buffer(new uint8_t[path_size]); |
(...skipping 25 matching lines...) Expand all Loading... |
91 EndClipPathDisplayItem::EndClipPathDisplayItem() {} | 88 EndClipPathDisplayItem::EndClipPathDisplayItem() {} |
92 | 89 |
93 EndClipPathDisplayItem::EndClipPathDisplayItem( | 90 EndClipPathDisplayItem::EndClipPathDisplayItem( |
94 const proto::DisplayItem& proto) { | 91 const proto::DisplayItem& proto) { |
95 DCHECK_EQ(proto::DisplayItem::Type_EndClipPath, proto.type()); | 92 DCHECK_EQ(proto::DisplayItem::Type_EndClipPath, proto.type()); |
96 } | 93 } |
97 | 94 |
98 EndClipPathDisplayItem::~EndClipPathDisplayItem() { | 95 EndClipPathDisplayItem::~EndClipPathDisplayItem() { |
99 } | 96 } |
100 | 97 |
101 void EndClipPathDisplayItem::ToProtobuf( | 98 void EndClipPathDisplayItem::ToProtobuf(proto::DisplayItem* proto) const { |
102 proto::DisplayItem* proto, | |
103 ImageSerializationProcessor* image_serialization_processor) const { | |
104 proto->set_type(proto::DisplayItem::Type_EndClipPath); | 99 proto->set_type(proto::DisplayItem::Type_EndClipPath); |
105 } | 100 } |
106 | 101 |
107 void EndClipPathDisplayItem::Raster( | 102 void EndClipPathDisplayItem::Raster( |
108 SkCanvas* canvas, | 103 SkCanvas* canvas, |
109 SkPicture::AbortCallback* callback) const { | 104 SkPicture::AbortCallback* callback) const { |
110 canvas->restore(); | 105 canvas->restore(); |
111 } | 106 } |
112 | 107 |
113 void EndClipPathDisplayItem::AsValueInto( | 108 void EndClipPathDisplayItem::AsValueInto( |
114 const gfx::Rect& visual_rect, | 109 const gfx::Rect& visual_rect, |
115 base::trace_event::TracedValue* array) const { | 110 base::trace_event::TracedValue* array) const { |
116 array->AppendString( | 111 array->AppendString( |
117 base::StringPrintf("EndClipPathDisplayItem visualRect: [%s]", | 112 base::StringPrintf("EndClipPathDisplayItem visualRect: [%s]", |
118 visual_rect.ToString().c_str())); | 113 visual_rect.ToString().c_str())); |
119 } | 114 } |
120 | 115 |
121 size_t EndClipPathDisplayItem::ExternalMemoryUsage() const { | 116 size_t EndClipPathDisplayItem::ExternalMemoryUsage() const { |
122 return 0; | 117 return 0; |
123 } | 118 } |
124 | 119 |
125 } // namespace cc | 120 } // namespace cc |
OLD | NEW |