Index: cc/playback/clip_display_item.cc |
diff --git a/cc/playback/clip_display_item.cc b/cc/playback/clip_display_item.cc |
index e0901b88e07d5dbb3c8c000d131b97eabd6b5115..919bd4c5990bae2a4e4a4decf0b57965de07fa40 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) { |
+ proto->set_type(proto::DisplayItem::Type_Clip); |
+ |
+ proto::ClipDisplayItem* details = proto->mutable_details_clip(); |
+ RectToProto(clip_rect_, details->mutable_clip_rect()); |
+ details->clear_rounded_rects(); |
vmpstr
2015/10/26 17:46:17
dcheck that the size is 0 instead
David Trainor- moved to gerrit
2015/10/26 20:42:56
Done.
|
+ for (auto& rrect : rounded_clip_rects_) { |
vmpstr
2015/10/26 17:46:17
const auto&
David Trainor- moved to gerrit
2015/10/26 20:42:56
Done.
|
+ 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.details_clip(); |
+ 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 { |
@@ -87,6 +115,14 @@ EndClipDisplayItem::EndClipDisplayItem() { |
EndClipDisplayItem::~EndClipDisplayItem() { |
} |
+void EndClipDisplayItem::ToProtobuf(proto::DisplayItem* proto) { |
+ 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 { |