Index: cc/playback/clip_path_display_item.cc |
diff --git a/cc/playback/clip_path_display_item.cc b/cc/playback/clip_path_display_item.cc |
index 9ac5bdea80a6be6239267c57b9e27d127987927a..5494664521f70ef7760b020d433e29e70cdb7835 100644 |
--- a/cc/playback/clip_path_display_item.cc |
+++ b/cc/playback/clip_path_display_item.cc |
@@ -6,6 +6,8 @@ |
#include "base/strings/stringprintf.h" |
#include "base/trace_event/trace_event_argument.h" |
+#include "cc/proto/display_item.pb.h" |
+#include "cc/proto/skia_conversions.h" |
#include "third_party/skia/include/core/SkCanvas.h" |
namespace cc { |
@@ -29,6 +31,38 @@ void ClipPathDisplayItem::SetNew(const SkPath& clip_path, |
0 /* external_memory_usage */); |
} |
+void ClipPathDisplayItem::ToProtobuf(proto::DisplayItem* proto) { |
+ proto->set_type(proto::DisplayItem::Type_ClipPath); |
+ |
+ proto::ClipPathDisplayItem* details = proto->mutable_details_clip_path(); |
+ details->set_clip_op(SkRegionOpToProto(clip_op_)); |
+ details->set_antialias(antialias_); |
+ |
+ // Just use skia's serialization method for the SkPath for now. |
+ size_t path_size = clip_path_.writeToMemory(nullptr); |
+ if (path_size > 0) { |
+ scoped_ptr<char[]> buffer(new char[path_size]); |
+ clip_path_.writeToMemory(buffer.get()); |
+ details->set_clip_path(buffer.get(), path_size); |
vmpstr
2015/10/26 17:46:17
What's the parameter to set_clip_path? Is this a c
David Trainor- moved to gerrit
2015/10/26 20:42:56
I believe protobufs always copy the data passed in
|
+ } |
+} |
+ |
+void ClipPathDisplayItem::FromProtobuf(const proto::DisplayItem& proto) { |
+ DCHECK_EQ(proto::DisplayItem::Type_ClipPath, proto.type()); |
+ |
+ const proto::ClipPathDisplayItem& details = proto.details_clip_path(); |
+ SkRegion::Op clip_op = SkRegionOpFromProto(details.clip_op()); |
+ bool antialias = details.antialias(); |
+ |
+ SkPath clip_path; |
+ if (details.has_clip_path()) { |
+ clip_path.readFromMemory(details.clip_path().c_str(), |
vmpstr
2015/10/26 17:46:17
Does readFromMemory return some sort of a status c
David Trainor- moved to gerrit
2015/10/26 20:42:56
It returns the bytes read to build the SkPath. I
|
+ details.clip_path().size()); |
+ } |
+ |
+ SetNew(clip_path, clip_op, antialias); |
+} |
+ |
void ClipPathDisplayItem::Raster(SkCanvas* canvas, |
const gfx::Rect& canvas_target_playback_rect, |
SkPicture::AbortCallback* callback) const { |
@@ -55,6 +89,14 @@ EndClipPathDisplayItem::EndClipPathDisplayItem() { |
EndClipPathDisplayItem::~EndClipPathDisplayItem() { |
} |
+void EndClipPathDisplayItem::ToProtobuf(proto::DisplayItem* proto) { |
+ proto->set_type(proto::DisplayItem::Type_EndClipPath); |
+} |
+ |
+void EndClipPathDisplayItem::FromProtobuf(const proto::DisplayItem& proto) { |
+ DCHECK_EQ(proto::DisplayItem::Type_EndClipPath, proto.type()); |
+} |
+ |
void EndClipPathDisplayItem::Raster( |
SkCanvas* canvas, |
const gfx::Rect& canvas_target_playback_rect, |