Index: cc/playback/clip_display_item.cc |
diff --git a/cc/playback/clip_display_item.cc b/cc/playback/clip_display_item.cc |
index 5941502860bff21cff6723c64fbcc42c13e83574..ac2bc9392127558d64088bb5585afb6efed6d94b 100644 |
--- a/cc/playback/clip_display_item.cc |
+++ b/cc/playback/clip_display_item.cc |
@@ -6,8 +6,12 @@ |
#include <string> |
+#include "base/logging.h" |
#include "base/strings/stringprintf.h" |
#include "base/trace_event/trace_event_argument.h" |
+#include "cc/proto/display_item.pb.h" |
+#include "cc/proto/gfx_conversions.h" |
+#include "cc/proto/skia_conversions.h" |
#include "third_party/skia/include/core/SkCanvas.h" |
#include "ui/gfx/skia_util.h" |
@@ -31,6 +35,30 @@ void ClipDisplayItem::SetNew(gfx::Rect clip_rect, |
external_memory_usage); |
} |
+void ClipDisplayItem::ToProtobuf(proto::DisplayItem* proto) const { |
+ proto->set_type(proto::DisplayItem::Type_Clip); |
+ |
+ proto::ClipDisplayItem* details = proto->mutable_clip_item(); |
+ RectToProto(clip_rect_, details->mutable_clip_rect()); |
+ DCHECK_EQ(0, details->rounded_rects_size()); |
+ for (const auto& rrect : rounded_clip_rects_) { |
+ SkRRectToProto(rrect, details->add_rounded_rects()); |
+ } |
+} |
+ |
+void ClipDisplayItem::FromProtobuf(const proto::DisplayItem& proto) { |
+ DCHECK_EQ(proto::DisplayItem::Type_Clip, proto.type()); |
+ |
+ const proto::ClipDisplayItem& details = proto.clip_item(); |
+ gfx::Rect clip_rect = ProtoToRect(details.clip_rect()); |
+ std::vector<SkRRect> rounded_clip_rects; |
+ rounded_clip_rects.reserve(details.rounded_rects_size()); |
+ for (int i = 0; i < details.rounded_rects_size(); i++) { |
+ rounded_clip_rects.push_back(ProtoToSkRRect(details.rounded_rects(i))); |
+ } |
+ SetNew(clip_rect, rounded_clip_rects); |
+} |
+ |
void ClipDisplayItem::Raster(SkCanvas* canvas, |
const gfx::Rect& canvas_target_playback_rect, |
SkPicture::AbortCallback* callback) const { |
@@ -82,6 +110,14 @@ EndClipDisplayItem::EndClipDisplayItem() { |
EndClipDisplayItem::~EndClipDisplayItem() { |
} |
+void EndClipDisplayItem::ToProtobuf(proto::DisplayItem* proto) const { |
+ proto->set_type(proto::DisplayItem::Type_EndClip); |
+} |
+ |
+void EndClipDisplayItem::FromProtobuf(const proto::DisplayItem& proto) { |
+ DCHECK_EQ(proto::DisplayItem::Type_EndClip, proto.type()); |
+} |
+ |
void EndClipDisplayItem::Raster(SkCanvas* canvas, |
const gfx::Rect& canvas_target_playback_rect, |
SkPicture::AbortCallback* callback) const { |