OLD | NEW |
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 <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include "base/strings/stringprintf.h" | 9 #include "base/strings/stringprintf.h" |
10 #include "base/trace_event/trace_event_argument.h" | 10 #include "base/trace_event/trace_event_argument.h" |
11 #include "cc/proto/display_item.pb.h" | 11 #include "cc/proto/display_item.pb.h" |
12 #include "cc/proto/gfx_conversions.h" | 12 #include "cc/proto/gfx_conversions.h" |
13 #include "third_party/skia/include/core/SkCanvas.h" | 13 #include "third_party/skia/include/core/SkCanvas.h" |
14 | 14 |
15 namespace cc { | 15 namespace cc { |
16 class ImageSerializationProcessor; | |
17 | 16 |
18 TransformDisplayItem::TransformDisplayItem(const gfx::Transform& transform) | 17 TransformDisplayItem::TransformDisplayItem(const gfx::Transform& transform) |
19 : transform_(gfx::Transform::kSkipInitialization) { | 18 : transform_(gfx::Transform::kSkipInitialization) { |
20 SetNew(transform); | 19 SetNew(transform); |
21 } | 20 } |
22 | 21 |
23 TransformDisplayItem::TransformDisplayItem(const proto::DisplayItem& proto) { | 22 TransformDisplayItem::TransformDisplayItem(const proto::DisplayItem& proto) { |
24 DCHECK_EQ(proto::DisplayItem::Type_Transform, proto.type()); | 23 DCHECK_EQ(proto::DisplayItem::Type_Transform, proto.type()); |
25 | 24 |
26 const proto::TransformDisplayItem& details = proto.transform_item(); | 25 const proto::TransformDisplayItem& details = proto.transform_item(); |
27 gfx::Transform transform = ProtoToTransform(details.transform()); | 26 gfx::Transform transform = ProtoToTransform(details.transform()); |
28 | 27 |
29 SetNew(transform); | 28 SetNew(transform); |
30 } | 29 } |
31 | 30 |
32 TransformDisplayItem::~TransformDisplayItem() { | 31 TransformDisplayItem::~TransformDisplayItem() { |
33 } | 32 } |
34 | 33 |
35 void TransformDisplayItem::SetNew(const gfx::Transform& transform) { | 34 void TransformDisplayItem::SetNew(const gfx::Transform& transform) { |
36 transform_ = transform; | 35 transform_ = transform; |
37 } | 36 } |
38 | 37 |
39 void TransformDisplayItem::ToProtobuf( | 38 void TransformDisplayItem::ToProtobuf(proto::DisplayItem* proto) const { |
40 proto::DisplayItem* proto, | |
41 ImageSerializationProcessor* image_serialization_processor) const { | |
42 proto->set_type(proto::DisplayItem::Type_Transform); | 39 proto->set_type(proto::DisplayItem::Type_Transform); |
43 | 40 |
44 proto::TransformDisplayItem* details = proto->mutable_transform_item(); | 41 proto::TransformDisplayItem* details = proto->mutable_transform_item(); |
45 TransformToProto(transform_, details->mutable_transform()); | 42 TransformToProto(transform_, details->mutable_transform()); |
46 } | 43 } |
47 | 44 |
48 void TransformDisplayItem::Raster(SkCanvas* canvas, | 45 void TransformDisplayItem::Raster(SkCanvas* canvas, |
49 SkPicture::AbortCallback* callback) const { | 46 SkPicture::AbortCallback* callback) const { |
50 canvas->save(); | 47 canvas->save(); |
51 if (!transform_.IsIdentity()) | 48 if (!transform_.IsIdentity()) |
(...skipping 15 matching lines...) Expand all Loading... |
67 EndTransformDisplayItem::EndTransformDisplayItem() {} | 64 EndTransformDisplayItem::EndTransformDisplayItem() {} |
68 | 65 |
69 EndTransformDisplayItem::EndTransformDisplayItem( | 66 EndTransformDisplayItem::EndTransformDisplayItem( |
70 const proto::DisplayItem& proto) { | 67 const proto::DisplayItem& proto) { |
71 DCHECK_EQ(proto::DisplayItem::Type_EndTransform, proto.type()); | 68 DCHECK_EQ(proto::DisplayItem::Type_EndTransform, proto.type()); |
72 } | 69 } |
73 | 70 |
74 EndTransformDisplayItem::~EndTransformDisplayItem() { | 71 EndTransformDisplayItem::~EndTransformDisplayItem() { |
75 } | 72 } |
76 | 73 |
77 void EndTransformDisplayItem::ToProtobuf( | 74 void EndTransformDisplayItem::ToProtobuf(proto::DisplayItem* proto) const { |
78 proto::DisplayItem* proto, | |
79 ImageSerializationProcessor* image_serialization_processor) const { | |
80 proto->set_type(proto::DisplayItem::Type_EndTransform); | 75 proto->set_type(proto::DisplayItem::Type_EndTransform); |
81 } | 76 } |
82 | 77 |
83 void EndTransformDisplayItem::Raster( | 78 void EndTransformDisplayItem::Raster( |
84 SkCanvas* canvas, | 79 SkCanvas* canvas, |
85 SkPicture::AbortCallback* callback) const { | 80 SkPicture::AbortCallback* callback) const { |
86 canvas->restore(); | 81 canvas->restore(); |
87 } | 82 } |
88 | 83 |
89 void EndTransformDisplayItem::AsValueInto( | 84 void EndTransformDisplayItem::AsValueInto( |
90 const gfx::Rect& visual_rect, | 85 const gfx::Rect& visual_rect, |
91 base::trace_event::TracedValue* array) const { | 86 base::trace_event::TracedValue* array) const { |
92 array->AppendString( | 87 array->AppendString( |
93 base::StringPrintf("EndTransformDisplayItem visualRect: [%s]", | 88 base::StringPrintf("EndTransformDisplayItem visualRect: [%s]", |
94 visual_rect.ToString().c_str())); | 89 visual_rect.ToString().c_str())); |
95 } | 90 } |
96 | 91 |
97 size_t EndTransformDisplayItem::ExternalMemoryUsage() const { | 92 size_t EndTransformDisplayItem::ExternalMemoryUsage() const { |
98 return 0; | 93 return 0; |
99 } | 94 } |
100 | 95 |
101 } // namespace cc | 96 } // namespace cc |
OLD | NEW |