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

Unified Diff: cc/playback/clip_path_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_path_display_item.h ('k') | cc/playback/compositing_display_item.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 f7fd60626e5447738841624b8aa9a2c77a6a780b..3b4662107055df1b01080736d6d001962ad42928 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,39 @@ void ClipPathDisplayItem::SetNew(const SkPath& clip_path,
0 /* external_memory_usage */);
}
+void ClipPathDisplayItem::ToProtobuf(proto::DisplayItem* proto) const {
+ proto->set_type(proto::DisplayItem::Type_ClipPath);
+
+ proto::ClipPathDisplayItem* details = proto->mutable_clip_path_item();
+ 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(std::string(buffer.get(), path_size));
+ }
+}
+
+void ClipPathDisplayItem::FromProtobuf(const proto::DisplayItem& proto) {
+ DCHECK_EQ(proto::DisplayItem::Type_ClipPath, proto.type());
+
+ const proto::ClipPathDisplayItem& details = proto.clip_path_item();
+ SkRegion::Op clip_op = SkRegionOpFromProto(details.clip_op());
+ bool antialias = details.antialias();
+
+ SkPath clip_path;
+ if (details.has_clip_path()) {
+ size_t bytes_read = clip_path.readFromMemory(details.clip_path().c_str(),
+ details.clip_path().size());
+ DCHECK_EQ(details.clip_path().size(), bytes_read);
+ }
+
+ SetNew(clip_path, clip_op, antialias);
+}
+
void ClipPathDisplayItem::Raster(SkCanvas* canvas,
const gfx::Rect& canvas_target_playback_rect,
SkPicture::AbortCallback* callback) const {
@@ -50,6 +85,14 @@ EndClipPathDisplayItem::EndClipPathDisplayItem() {
EndClipPathDisplayItem::~EndClipPathDisplayItem() {
}
+void EndClipPathDisplayItem::ToProtobuf(proto::DisplayItem* proto) const {
+ 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,
« no previous file with comments | « cc/playback/clip_path_display_item.h ('k') | cc/playback/compositing_display_item.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698