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

Side by Side Diff: cc/playback/transform_display_item.cc

Issue 1494223003: cc: Shrink size of display item (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Make SetNew private Created 5 years 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
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" 9 #include "cc/proto/display_item.pb.h"
10 #include "cc/proto/gfx_conversions.h" 10 #include "cc/proto/gfx_conversions.h"
11 #include "third_party/skia/include/core/SkCanvas.h" 11 #include "third_party/skia/include/core/SkCanvas.h"
12 12
13 namespace cc { 13 namespace cc {
14 14
15 TransformDisplayItem::TransformDisplayItem() 15 TransformDisplayItem::TransformDisplayItem(const gfx::Transform& transform)
16 : transform_(gfx::Transform::kSkipInitialization) { 16 : transform_(gfx::Transform::kSkipInitialization) {
17 SetNew(transform);
18 }
19
20 TransformDisplayItem::TransformDisplayItem(const proto::DisplayItem& proto) {
21 FromProtobuf(proto);
17 } 22 }
18 23
19 TransformDisplayItem::~TransformDisplayItem() { 24 TransformDisplayItem::~TransformDisplayItem() {
20 } 25 }
21 26
22 void TransformDisplayItem::SetNew(const gfx::Transform& transform) { 27 void TransformDisplayItem::SetNew(const gfx::Transform& transform) {
23 transform_ = transform; 28 transform_ = transform;
24
25 DisplayItem::SetNew(true /* suitable_for_gpu_raster */, 1 /* op_count */,
26 0 /* external_memory_usage */);
27 } 29 }
28 30
29 void TransformDisplayItem::ToProtobuf(proto::DisplayItem* proto) const { 31 void TransformDisplayItem::ToProtobuf(proto::DisplayItem* proto) const {
30 proto->set_type(proto::DisplayItem::Type_Transform); 32 proto->set_type(proto::DisplayItem::Type_Transform);
31 33
32 proto::TransformDisplayItem* details = proto->mutable_transform_item(); 34 proto::TransformDisplayItem* details = proto->mutable_transform_item();
33 TransformToProto(transform_, details->mutable_transform()); 35 TransformToProto(transform_, details->mutable_transform());
34 } 36 }
35 37
36 void TransformDisplayItem::FromProtobuf(const proto::DisplayItem& proto) { 38 void TransformDisplayItem::FromProtobuf(const proto::DisplayItem& proto) {
(...skipping 14 matching lines...) Expand all
51 } 53 }
52 54
53 void TransformDisplayItem::AsValueInto( 55 void TransformDisplayItem::AsValueInto(
54 const gfx::Rect& visual_rect, 56 const gfx::Rect& visual_rect,
55 base::trace_event::TracedValue* array) const { 57 base::trace_event::TracedValue* array) const {
56 array->AppendString(base::StringPrintf( 58 array->AppendString(base::StringPrintf(
57 "TransformDisplayItem transform: [%s] visualRect: [%s]", 59 "TransformDisplayItem transform: [%s] visualRect: [%s]",
58 transform_.ToString().c_str(), visual_rect.ToString().c_str())); 60 transform_.ToString().c_str(), visual_rect.ToString().c_str()));
59 } 61 }
60 62
61 EndTransformDisplayItem::EndTransformDisplayItem() { 63 size_t TransformDisplayItem::ExternalMemoryUsage() const {
62 DisplayItem::SetNew(true /* suitable_for_gpu_raster */, 0 /* op_count */, 64 return 0;
63 0 /* external_memory_usage */); 65 }
66
67 EndTransformDisplayItem::EndTransformDisplayItem() {}
68
69 EndTransformDisplayItem::EndTransformDisplayItem(
70 const proto::DisplayItem& proto) {
71 FromProtobuf(proto);
64 } 72 }
65 73
66 EndTransformDisplayItem::~EndTransformDisplayItem() { 74 EndTransformDisplayItem::~EndTransformDisplayItem() {
67 } 75 }
68 76
69 void EndTransformDisplayItem::ToProtobuf(proto::DisplayItem* proto) const { 77 void EndTransformDisplayItem::ToProtobuf(proto::DisplayItem* proto) const {
70 proto->set_type(proto::DisplayItem::Type_EndTransform); 78 proto->set_type(proto::DisplayItem::Type_EndTransform);
71 } 79 }
72 80
73 void EndTransformDisplayItem::FromProtobuf(const proto::DisplayItem& proto) { 81 void EndTransformDisplayItem::FromProtobuf(const proto::DisplayItem& proto) {
74 DCHECK_EQ(proto::DisplayItem::Type_EndTransform, proto.type()); 82 DCHECK_EQ(proto::DisplayItem::Type_EndTransform, proto.type());
75 } 83 }
76 84
77 void EndTransformDisplayItem::Raster( 85 void EndTransformDisplayItem::Raster(
78 SkCanvas* canvas, 86 SkCanvas* canvas,
79 const gfx::Rect& canvas_target_playback_rect, 87 const gfx::Rect& canvas_target_playback_rect,
80 SkPicture::AbortCallback* callback) const { 88 SkPicture::AbortCallback* callback) const {
81 canvas->restore(); 89 canvas->restore();
82 } 90 }
83 91
84 void EndTransformDisplayItem::AsValueInto( 92 void EndTransformDisplayItem::AsValueInto(
85 const gfx::Rect& visual_rect, 93 const gfx::Rect& visual_rect,
86 base::trace_event::TracedValue* array) const { 94 base::trace_event::TracedValue* array) const {
87 array->AppendString( 95 array->AppendString(
88 base::StringPrintf("EndTransformDisplayItem visualRect: [%s]", 96 base::StringPrintf("EndTransformDisplayItem visualRect: [%s]",
89 visual_rect.ToString().c_str())); 97 visual_rect.ToString().c_str()));
90 } 98 }
91 99
100 size_t EndTransformDisplayItem::ExternalMemoryUsage() const {
101 return 0;
102 }
103
92 } // namespace cc 104 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698