Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3555)

Unified Diff: cc/playback/clip_display_item.cc

Issue 1407793002: Add protobuf serialization to DisplayItemList (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@blimp_display2
Patch Set: Comments are hard Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « cc/playback/clip_display_item.h ('k') | cc/playback/clip_path_display_item.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 {
« no previous file with comments | « cc/playback/clip_display_item.h ('k') | cc/playback/clip_path_display_item.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698