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

Side by Side Diff: cc/playback/float_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, 1 month 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 unified diff | Download patch
« no previous file with comments | « cc/playback/float_clip_display_item.h ('k') | cc/playback/transform_display_item.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "cc/playback/float_clip_display_item.h" 5 #include "cc/playback/float_clip_display_item.h"
6 6
7 #include "base/strings/stringprintf.h" 7 #include "base/strings/stringprintf.h"
8 #include "base/trace_event/trace_event_argument.h" 8 #include "base/trace_event/trace_event_argument.h"
9 #include "cc/proto/display_item.pb.h"
10 #include "cc/proto/gfx_conversions.h"
9 #include "third_party/skia/include/core/SkCanvas.h" 11 #include "third_party/skia/include/core/SkCanvas.h"
10 #include "ui/gfx/skia_util.h" 12 #include "ui/gfx/skia_util.h"
11 13
12 namespace cc { 14 namespace cc {
13 15
14 FloatClipDisplayItem::FloatClipDisplayItem() { 16 FloatClipDisplayItem::FloatClipDisplayItem() {
15 } 17 }
16 18
17 FloatClipDisplayItem::~FloatClipDisplayItem() { 19 FloatClipDisplayItem::~FloatClipDisplayItem() {
18 } 20 }
19 21
20 void FloatClipDisplayItem::SetNew(const gfx::RectF& clip_rect) { 22 void FloatClipDisplayItem::SetNew(const gfx::RectF& clip_rect) {
21 clip_rect_ = clip_rect; 23 clip_rect_ = clip_rect;
22 24
23 DisplayItem::SetNew(true /* suitable_for_gpu_raster */, 1 /* op_count */, 25 DisplayItem::SetNew(true /* suitable_for_gpu_raster */, 1 /* op_count */,
24 0 /* external_memory_usage */); 26 0 /* external_memory_usage */);
25 } 27 }
26 28
29 void FloatClipDisplayItem::ToProtobuf(proto::DisplayItem* proto) const {
30 proto->set_type(proto::DisplayItem::Type_FloatClip);
31
32 proto::FloatClipDisplayItem* details = proto->mutable_float_clip_item();
33 RectFToProto(clip_rect_, details->mutable_clip_rect());
34 }
35
36 void FloatClipDisplayItem::FromProtobuf(const proto::DisplayItem& proto) {
37 DCHECK_EQ(proto::DisplayItem::Type_FloatClip, proto.type());
38
39 const proto::FloatClipDisplayItem& details = proto.float_clip_item();
40 gfx::RectF clip_rect = ProtoToRectF(details.clip_rect());
41
42 SetNew(clip_rect);
43 }
44
27 void FloatClipDisplayItem::Raster(SkCanvas* canvas, 45 void FloatClipDisplayItem::Raster(SkCanvas* canvas,
28 const gfx::Rect& canvas_target_playback_rect, 46 const gfx::Rect& canvas_target_playback_rect,
29 SkPicture::AbortCallback* callback) const { 47 SkPicture::AbortCallback* callback) const {
30 canvas->save(); 48 canvas->save();
31 canvas->clipRect(gfx::RectFToSkRect(clip_rect_)); 49 canvas->clipRect(gfx::RectFToSkRect(clip_rect_));
32 } 50 }
33 51
34 void FloatClipDisplayItem::AsValueInto( 52 void FloatClipDisplayItem::AsValueInto(
35 base::trace_event::TracedValue* array) const { 53 base::trace_event::TracedValue* array) const {
36 array->AppendString(base::StringPrintf("FloatClipDisplayItem rect: [%s]", 54 array->AppendString(base::StringPrintf("FloatClipDisplayItem rect: [%s]",
37 clip_rect_.ToString().c_str())); 55 clip_rect_.ToString().c_str()));
38 } 56 }
39 57
40 EndFloatClipDisplayItem::EndFloatClipDisplayItem() { 58 EndFloatClipDisplayItem::EndFloatClipDisplayItem() {
41 DisplayItem::SetNew(true /* suitable_for_gpu_raster */, 0 /* op_count */, 59 DisplayItem::SetNew(true /* suitable_for_gpu_raster */, 0 /* op_count */,
42 0 /* external_memory_usage */); 60 0 /* external_memory_usage */);
43 } 61 }
44 62
45 EndFloatClipDisplayItem::~EndFloatClipDisplayItem() { 63 EndFloatClipDisplayItem::~EndFloatClipDisplayItem() {
46 } 64 }
47 65
66 void EndFloatClipDisplayItem::ToProtobuf(proto::DisplayItem* proto) const {
67 proto->set_type(proto::DisplayItem::Type_EndFloatClip);
68 }
69
70 void EndFloatClipDisplayItem::FromProtobuf(const proto::DisplayItem& proto) {
71 DCHECK_EQ(proto::DisplayItem::Type_EndFloatClip, proto.type());
72 }
73
48 void EndFloatClipDisplayItem::Raster( 74 void EndFloatClipDisplayItem::Raster(
49 SkCanvas* canvas, 75 SkCanvas* canvas,
50 const gfx::Rect& canvas_target_playback_rect, 76 const gfx::Rect& canvas_target_playback_rect,
51 SkPicture::AbortCallback* callback) const { 77 SkPicture::AbortCallback* callback) const {
52 canvas->restore(); 78 canvas->restore();
53 } 79 }
54 80
55 void EndFloatClipDisplayItem::AsValueInto( 81 void EndFloatClipDisplayItem::AsValueInto(
56 base::trace_event::TracedValue* array) const { 82 base::trace_event::TracedValue* array) const {
57 array->AppendString("EndFloatClipDisplayItem"); 83 array->AppendString("EndFloatClipDisplayItem");
58 } 84 }
59 85
60 } // namespace cc 86 } // namespace cc
OLDNEW
« no previous file with comments | « cc/playback/float_clip_display_item.h ('k') | cc/playback/transform_display_item.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698