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

Side by Side Diff: cc/playback/transform_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/transform_display_item.h ('k') | cc/proto/BUILD.gn » ('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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/transform_display_item.h" 5 #include "cc/playback/transform_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 12
11 namespace cc { 13 namespace cc {
12 14
13 TransformDisplayItem::TransformDisplayItem() 15 TransformDisplayItem::TransformDisplayItem()
14 : transform_(gfx::Transform::kSkipInitialization) { 16 : transform_(gfx::Transform::kSkipInitialization) {
15 } 17 }
16 18
17 TransformDisplayItem::~TransformDisplayItem() { 19 TransformDisplayItem::~TransformDisplayItem() {
18 } 20 }
19 21
20 void TransformDisplayItem::SetNew(const gfx::Transform& transform) { 22 void TransformDisplayItem::SetNew(const gfx::Transform& transform) {
21 transform_ = transform; 23 transform_ = transform;
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 TransformDisplayItem::ToProtobuf(proto::DisplayItem* proto) const {
30 proto->set_type(proto::DisplayItem::Type_Transform);
31
32 proto::TransformDisplayItem* details = proto->mutable_transform_item();
33 TransformToProto(transform_, details->mutable_transform());
34 }
35
36 void TransformDisplayItem::FromProtobuf(const proto::DisplayItem& proto) {
37 DCHECK_EQ(proto::DisplayItem::Type_Transform, proto.type());
38
39 const proto::TransformDisplayItem& details = proto.transform_item();
40 gfx::Transform transform = ProtoToTransform(details.transform());
41
42 SetNew(transform);
43 }
44
27 void TransformDisplayItem::Raster(SkCanvas* canvas, 45 void TransformDisplayItem::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 if (!transform_.IsIdentity()) 49 if (!transform_.IsIdentity())
32 canvas->concat(transform_.matrix()); 50 canvas->concat(transform_.matrix());
33 } 51 }
34 52
35 void TransformDisplayItem::AsValueInto( 53 void TransformDisplayItem::AsValueInto(
36 base::trace_event::TracedValue* array) const { 54 base::trace_event::TracedValue* array) const {
37 array->AppendString(base::StringPrintf("TransformDisplayItem transform: [%s]", 55 array->AppendString(base::StringPrintf("TransformDisplayItem transform: [%s]",
38 transform_.ToString().c_str())); 56 transform_.ToString().c_str()));
39 } 57 }
40 58
41 EndTransformDisplayItem::EndTransformDisplayItem() { 59 EndTransformDisplayItem::EndTransformDisplayItem() {
42 DisplayItem::SetNew(true /* suitable_for_gpu_raster */, 0 /* op_count */, 60 DisplayItem::SetNew(true /* suitable_for_gpu_raster */, 0 /* op_count */,
43 0 /* external_memory_usage */); 61 0 /* external_memory_usage */);
44 } 62 }
45 63
46 EndTransformDisplayItem::~EndTransformDisplayItem() { 64 EndTransformDisplayItem::~EndTransformDisplayItem() {
47 } 65 }
48 66
67 void EndTransformDisplayItem::ToProtobuf(proto::DisplayItem* proto) const {
68 proto->set_type(proto::DisplayItem::Type_EndTransform);
69 }
70
71 void EndTransformDisplayItem::FromProtobuf(const proto::DisplayItem& proto) {
72 DCHECK_EQ(proto::DisplayItem::Type_EndTransform, proto.type());
73 }
74
49 void EndTransformDisplayItem::Raster( 75 void EndTransformDisplayItem::Raster(
50 SkCanvas* canvas, 76 SkCanvas* canvas,
51 const gfx::Rect& canvas_target_playback_rect, 77 const gfx::Rect& canvas_target_playback_rect,
52 SkPicture::AbortCallback* callback) const { 78 SkPicture::AbortCallback* callback) const {
53 canvas->restore(); 79 canvas->restore();
54 } 80 }
55 81
56 void EndTransformDisplayItem::AsValueInto( 82 void EndTransformDisplayItem::AsValueInto(
57 base::trace_event::TracedValue* array) const { 83 base::trace_event::TracedValue* array) const {
58 array->AppendString("EndTransformDisplayItem"); 84 array->AppendString("EndTransformDisplayItem");
59 } 85 }
60 86
61 } // namespace cc 87 } // namespace cc
OLDNEW
« no previous file with comments | « cc/playback/transform_display_item.h ('k') | cc/proto/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698