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