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" | |
14 | 13 |
15 namespace cc { | 14 namespace cc { |
16 | 15 |
17 TransformDisplayItem::TransformDisplayItem(const gfx::Transform& transform) | 16 TransformDisplayItem::TransformDisplayItem(const gfx::Transform& transform) |
18 : DisplayItem(TRANSFORM), transform_(gfx::Transform::kSkipInitialization) { | 17 : DisplayItem(TRANSFORM), transform_(gfx::Transform::kSkipInitialization) { |
19 SetNew(transform); | 18 SetNew(transform); |
20 } | 19 } |
21 | 20 |
22 TransformDisplayItem::TransformDisplayItem(const proto::DisplayItem& proto) | 21 TransformDisplayItem::TransformDisplayItem(const proto::DisplayItem& proto) |
23 : DisplayItem(TRANSFORM) { | 22 : DisplayItem(TRANSFORM) { |
(...skipping 12 matching lines...) Expand all Loading... |
36 transform_ = transform; | 35 transform_ = transform; |
37 } | 36 } |
38 | 37 |
39 void TransformDisplayItem::ToProtobuf(proto::DisplayItem* proto) const { | 38 void TransformDisplayItem::ToProtobuf(proto::DisplayItem* proto) const { |
40 proto->set_type(proto::DisplayItem::Type_Transform); | 39 proto->set_type(proto::DisplayItem::Type_Transform); |
41 | 40 |
42 proto::TransformDisplayItem* details = proto->mutable_transform_item(); | 41 proto::TransformDisplayItem* details = proto->mutable_transform_item(); |
43 TransformToProto(transform_, details->mutable_transform()); | 42 TransformToProto(transform_, details->mutable_transform()); |
44 } | 43 } |
45 | 44 |
46 void TransformDisplayItem::Raster(SkCanvas* canvas, | 45 void TransformDisplayItem::Raster(PaintCanvas* canvas, |
47 SkPicture::AbortCallback* callback) const { | 46 PaintRecord::AbortCallback* callback) const { |
48 canvas->save(); | 47 canvas->save(); |
49 if (!transform_.IsIdentity()) | 48 if (!transform_.IsIdentity()) |
50 canvas->concat(transform_.matrix()); | 49 canvas->concat(transform_.matrix()); |
51 } | 50 } |
52 | 51 |
53 void TransformDisplayItem::AsValueInto( | 52 void TransformDisplayItem::AsValueInto( |
54 const gfx::Rect& visual_rect, | 53 const gfx::Rect& visual_rect, |
55 base::trace_event::TracedValue* array) const { | 54 base::trace_event::TracedValue* array) const { |
56 array->AppendString(base::StringPrintf( | 55 array->AppendString(base::StringPrintf( |
57 "TransformDisplayItem transform: [%s] visualRect: [%s]", | 56 "TransformDisplayItem transform: [%s] visualRect: [%s]", |
(...skipping 10 matching lines...) Expand all Loading... |
68 } | 67 } |
69 | 68 |
70 EndTransformDisplayItem::~EndTransformDisplayItem() { | 69 EndTransformDisplayItem::~EndTransformDisplayItem() { |
71 } | 70 } |
72 | 71 |
73 void EndTransformDisplayItem::ToProtobuf(proto::DisplayItem* proto) const { | 72 void EndTransformDisplayItem::ToProtobuf(proto::DisplayItem* proto) const { |
74 proto->set_type(proto::DisplayItem::Type_EndTransform); | 73 proto->set_type(proto::DisplayItem::Type_EndTransform); |
75 } | 74 } |
76 | 75 |
77 void EndTransformDisplayItem::Raster( | 76 void EndTransformDisplayItem::Raster( |
78 SkCanvas* canvas, | 77 PaintCanvas* canvas, |
79 SkPicture::AbortCallback* callback) const { | 78 PaintRecord::AbortCallback* callback) const { |
80 canvas->restore(); | 79 canvas->restore(); |
81 } | 80 } |
82 | 81 |
83 void EndTransformDisplayItem::AsValueInto( | 82 void EndTransformDisplayItem::AsValueInto( |
84 const gfx::Rect& visual_rect, | 83 const gfx::Rect& visual_rect, |
85 base::trace_event::TracedValue* array) const { | 84 base::trace_event::TracedValue* array) const { |
86 array->AppendString( | 85 array->AppendString( |
87 base::StringPrintf("EndTransformDisplayItem visualRect: [%s]", | 86 base::StringPrintf("EndTransformDisplayItem visualRect: [%s]", |
88 visual_rect.ToString().c_str())); | 87 visual_rect.ToString().c_str())); |
89 } | 88 } |
90 | 89 |
91 } // namespace cc | 90 } // namespace cc |
OLD | NEW |