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

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

Issue 1521373005: Revert of cc: Shrink size of display item (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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
« no previous file with comments | « cc/playback/transform_display_item.h ('k') | cc/test/fake_content_layer_client.cc » ('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" 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(const gfx::Transform& transform) 15 TransformDisplayItem::TransformDisplayItem()
16 : transform_(gfx::Transform::kSkipInitialization) { 16 : transform_(gfx::Transform::kSkipInitialization) {
17 SetNew(transform);
18 }
19
20 TransformDisplayItem::TransformDisplayItem(const proto::DisplayItem& proto) {
21 DCHECK_EQ(proto::DisplayItem::Type_Transform, proto.type());
22
23 const proto::TransformDisplayItem& details = proto.transform_item();
24 gfx::Transform transform = ProtoToTransform(details.transform());
25
26 SetNew(transform);
27 } 17 }
28 18
29 TransformDisplayItem::~TransformDisplayItem() { 19 TransformDisplayItem::~TransformDisplayItem() {
30 } 20 }
31 21
32 void TransformDisplayItem::SetNew(const gfx::Transform& transform) { 22 void TransformDisplayItem::SetNew(const gfx::Transform& transform) {
33 transform_ = transform; 23 transform_ = transform;
24
25 DisplayItem::SetNew(true /* suitable_for_gpu_raster */, 1 /* op_count */,
26 0 /* external_memory_usage */);
34 } 27 }
35 28
36 void TransformDisplayItem::ToProtobuf(proto::DisplayItem* proto) const { 29 void TransformDisplayItem::ToProtobuf(proto::DisplayItem* proto) const {
37 proto->set_type(proto::DisplayItem::Type_Transform); 30 proto->set_type(proto::DisplayItem::Type_Transform);
38 31
39 proto::TransformDisplayItem* details = proto->mutable_transform_item(); 32 proto::TransformDisplayItem* details = proto->mutable_transform_item();
40 TransformToProto(transform_, details->mutable_transform()); 33 TransformToProto(transform_, details->mutable_transform());
41 } 34 }
42 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
43 void TransformDisplayItem::Raster(SkCanvas* canvas, 45 void TransformDisplayItem::Raster(SkCanvas* canvas,
44 const gfx::Rect& canvas_target_playback_rect, 46 const gfx::Rect& canvas_target_playback_rect,
45 SkPicture::AbortCallback* callback) const { 47 SkPicture::AbortCallback* callback) const {
46 canvas->save(); 48 canvas->save();
47 if (!transform_.IsIdentity()) 49 if (!transform_.IsIdentity())
48 canvas->concat(transform_.matrix()); 50 canvas->concat(transform_.matrix());
49 } 51 }
50 52
51 void TransformDisplayItem::AsValueInto( 53 void TransformDisplayItem::AsValueInto(
52 const gfx::Rect& visual_rect, 54 const gfx::Rect& visual_rect,
53 base::trace_event::TracedValue* array) const { 55 base::trace_event::TracedValue* array) const {
54 array->AppendString(base::StringPrintf( 56 array->AppendString(base::StringPrintf(
55 "TransformDisplayItem transform: [%s] visualRect: [%s]", 57 "TransformDisplayItem transform: [%s] visualRect: [%s]",
56 transform_.ToString().c_str(), visual_rect.ToString().c_str())); 58 transform_.ToString().c_str(), visual_rect.ToString().c_str()));
57 } 59 }
58 60
59 size_t TransformDisplayItem::ExternalMemoryUsage() const { 61 EndTransformDisplayItem::EndTransformDisplayItem() {
60 return 0; 62 DisplayItem::SetNew(true /* suitable_for_gpu_raster */, 0 /* op_count */,
61 } 63 0 /* external_memory_usage */);
62
63 EndTransformDisplayItem::EndTransformDisplayItem() {}
64
65 EndTransformDisplayItem::EndTransformDisplayItem(
66 const proto::DisplayItem& proto) {
67 DCHECK_EQ(proto::DisplayItem::Type_EndTransform, proto.type());
68 } 64 }
69 65
70 EndTransformDisplayItem::~EndTransformDisplayItem() { 66 EndTransformDisplayItem::~EndTransformDisplayItem() {
71 } 67 }
72 68
73 void EndTransformDisplayItem::ToProtobuf(proto::DisplayItem* proto) const { 69 void EndTransformDisplayItem::ToProtobuf(proto::DisplayItem* proto) const {
74 proto->set_type(proto::DisplayItem::Type_EndTransform); 70 proto->set_type(proto::DisplayItem::Type_EndTransform);
75 } 71 }
76 72
73 void EndTransformDisplayItem::FromProtobuf(const proto::DisplayItem& proto) {
74 DCHECK_EQ(proto::DisplayItem::Type_EndTransform, proto.type());
75 }
76
77 void EndTransformDisplayItem::Raster( 77 void EndTransformDisplayItem::Raster(
78 SkCanvas* canvas, 78 SkCanvas* canvas,
79 const gfx::Rect& canvas_target_playback_rect, 79 const gfx::Rect& canvas_target_playback_rect,
80 SkPicture::AbortCallback* callback) const { 80 SkPicture::AbortCallback* callback) const {
81 canvas->restore(); 81 canvas->restore();
82 } 82 }
83 83
84 void EndTransformDisplayItem::AsValueInto( 84 void EndTransformDisplayItem::AsValueInto(
85 const gfx::Rect& visual_rect, 85 const gfx::Rect& visual_rect,
86 base::trace_event::TracedValue* array) const { 86 base::trace_event::TracedValue* array) const {
87 array->AppendString( 87 array->AppendString(
88 base::StringPrintf("EndTransformDisplayItem visualRect: [%s]", 88 base::StringPrintf("EndTransformDisplayItem visualRect: [%s]",
89 visual_rect.ToString().c_str())); 89 visual_rect.ToString().c_str()));
90 } 90 }
91 91
92 size_t EndTransformDisplayItem::ExternalMemoryUsage() const {
93 return 0;
94 }
95
96 } // namespace cc 92 } // namespace cc
OLDNEW
« no previous file with comments | « cc/playback/transform_display_item.h ('k') | cc/test/fake_content_layer_client.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698