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 const gfx::Rect& canvas_target_playback_rect, | 46 const gfx::Rect& canvas_target_playback_rect, |
50 SkPicture::AbortCallback* callback) const { | 47 SkPicture::AbortCallback* callback) const { |
51 canvas->save(); | 48 canvas->save(); |
(...skipping 16 matching lines...) Expand all Loading... |
68 EndTransformDisplayItem::EndTransformDisplayItem() {} | 65 EndTransformDisplayItem::EndTransformDisplayItem() {} |
69 | 66 |
70 EndTransformDisplayItem::EndTransformDisplayItem( | 67 EndTransformDisplayItem::EndTransformDisplayItem( |
71 const proto::DisplayItem& proto) { | 68 const proto::DisplayItem& proto) { |
72 DCHECK_EQ(proto::DisplayItem::Type_EndTransform, proto.type()); | 69 DCHECK_EQ(proto::DisplayItem::Type_EndTransform, proto.type()); |
73 } | 70 } |
74 | 71 |
75 EndTransformDisplayItem::~EndTransformDisplayItem() { | 72 EndTransformDisplayItem::~EndTransformDisplayItem() { |
76 } | 73 } |
77 | 74 |
78 void EndTransformDisplayItem::ToProtobuf( | 75 void EndTransformDisplayItem::ToProtobuf(proto::DisplayItem* proto) const { |
79 proto::DisplayItem* proto, | |
80 ImageSerializationProcessor* image_serialization_processor) const { | |
81 proto->set_type(proto::DisplayItem::Type_EndTransform); | 76 proto->set_type(proto::DisplayItem::Type_EndTransform); |
82 } | 77 } |
83 | 78 |
84 void EndTransformDisplayItem::Raster( | 79 void EndTransformDisplayItem::Raster( |
85 SkCanvas* canvas, | 80 SkCanvas* canvas, |
86 const gfx::Rect& canvas_target_playback_rect, | 81 const gfx::Rect& canvas_target_playback_rect, |
87 SkPicture::AbortCallback* callback) const { | 82 SkPicture::AbortCallback* callback) const { |
88 canvas->restore(); | 83 canvas->restore(); |
89 } | 84 } |
90 | 85 |
91 void EndTransformDisplayItem::AsValueInto( | 86 void EndTransformDisplayItem::AsValueInto( |
92 const gfx::Rect& visual_rect, | 87 const gfx::Rect& visual_rect, |
93 base::trace_event::TracedValue* array) const { | 88 base::trace_event::TracedValue* array) const { |
94 array->AppendString( | 89 array->AppendString( |
95 base::StringPrintf("EndTransformDisplayItem visualRect: [%s]", | 90 base::StringPrintf("EndTransformDisplayItem visualRect: [%s]", |
96 visual_rect.ToString().c_str())); | 91 visual_rect.ToString().c_str())); |
97 } | 92 } |
98 | 93 |
99 size_t EndTransformDisplayItem::ExternalMemoryUsage() const { | 94 size_t EndTransformDisplayItem::ExternalMemoryUsage() const { |
100 return 0; | 95 return 0; |
101 } | 96 } |
102 | 97 |
103 } // namespace cc | 98 } // namespace cc |
OLD | NEW |