Chromium Code Reviews| 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..6b208b438f6fe98e6a7e8f5fbb5e1c49fdca02a6 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()); |
| + DCHECK_EQ(0, details->rounded_rects_size()); |
|
David Trainor- moved to gerrit
2015/10/14 23:09:28
TODO: details->clear_rounded_rects()?
David Trainor- moved to gerrit
2015/10/20 20:26:49
Done.
|
| + for (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.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 { |