| 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 | 16 |
| 17 TransformDisplayItem::TransformDisplayItem(const gfx::Transform& transform) | 17 TransformDisplayItem::TransformDisplayItem(const gfx::Transform& transform) |
| 18 : transform_(gfx::Transform::kSkipInitialization) { | 18 : DisplayItem(TRANSFORM), transform_(gfx::Transform::kSkipInitialization) { |
| 19 SetNew(transform); | 19 SetNew(transform); |
| 20 } | 20 } |
| 21 | 21 |
| 22 TransformDisplayItem::TransformDisplayItem(const proto::DisplayItem& proto) { | 22 TransformDisplayItem::TransformDisplayItem(const proto::DisplayItem& proto) |
| 23 : DisplayItem(TRANSFORM) { |
| 23 DCHECK_EQ(proto::DisplayItem::Type_Transform, proto.type()); | 24 DCHECK_EQ(proto::DisplayItem::Type_Transform, proto.type()); |
| 24 | 25 |
| 25 const proto::TransformDisplayItem& details = proto.transform_item(); | 26 const proto::TransformDisplayItem& details = proto.transform_item(); |
| 26 gfx::Transform transform = ProtoToTransform(details.transform()); | 27 gfx::Transform transform = ProtoToTransform(details.transform()); |
| 27 | 28 |
| 28 SetNew(transform); | 29 SetNew(transform); |
| 29 } | 30 } |
| 30 | 31 |
| 31 TransformDisplayItem::~TransformDisplayItem() { | 32 TransformDisplayItem::~TransformDisplayItem() { |
| 32 } | 33 } |
| (...skipping 17 matching lines...) Expand all Loading... |
| 50 } | 51 } |
| 51 | 52 |
| 52 void TransformDisplayItem::AsValueInto( | 53 void TransformDisplayItem::AsValueInto( |
| 53 const gfx::Rect& visual_rect, | 54 const gfx::Rect& visual_rect, |
| 54 base::trace_event::TracedValue* array) const { | 55 base::trace_event::TracedValue* array) const { |
| 55 array->AppendString(base::StringPrintf( | 56 array->AppendString(base::StringPrintf( |
| 56 "TransformDisplayItem transform: [%s] visualRect: [%s]", | 57 "TransformDisplayItem transform: [%s] visualRect: [%s]", |
| 57 transform_.ToString().c_str(), visual_rect.ToString().c_str())); | 58 transform_.ToString().c_str(), visual_rect.ToString().c_str())); |
| 58 } | 59 } |
| 59 | 60 |
| 60 size_t TransformDisplayItem::ExternalMemoryUsage() const { | 61 EndTransformDisplayItem::EndTransformDisplayItem() |
| 61 return 0; | 62 : DisplayItem(END_TRANSFORM) {} |
| 62 } | |
| 63 | |
| 64 EndTransformDisplayItem::EndTransformDisplayItem() {} | |
| 65 | 63 |
| 66 EndTransformDisplayItem::EndTransformDisplayItem( | 64 EndTransformDisplayItem::EndTransformDisplayItem( |
| 67 const proto::DisplayItem& proto) { | 65 const proto::DisplayItem& proto) |
| 66 : DisplayItem(END_TRANSFORM) { |
| 68 DCHECK_EQ(proto::DisplayItem::Type_EndTransform, proto.type()); | 67 DCHECK_EQ(proto::DisplayItem::Type_EndTransform, proto.type()); |
| 69 } | 68 } |
| 70 | 69 |
| 71 EndTransformDisplayItem::~EndTransformDisplayItem() { | 70 EndTransformDisplayItem::~EndTransformDisplayItem() { |
| 72 } | 71 } |
| 73 | 72 |
| 74 void EndTransformDisplayItem::ToProtobuf(proto::DisplayItem* proto) const { | 73 void EndTransformDisplayItem::ToProtobuf(proto::DisplayItem* proto) const { |
| 75 proto->set_type(proto::DisplayItem::Type_EndTransform); | 74 proto->set_type(proto::DisplayItem::Type_EndTransform); |
| 76 } | 75 } |
| 77 | 76 |
| 78 void EndTransformDisplayItem::Raster( | 77 void EndTransformDisplayItem::Raster( |
| 79 SkCanvas* canvas, | 78 SkCanvas* canvas, |
| 80 SkPicture::AbortCallback* callback) const { | 79 SkPicture::AbortCallback* callback) const { |
| 81 canvas->restore(); | 80 canvas->restore(); |
| 82 } | 81 } |
| 83 | 82 |
| 84 void EndTransformDisplayItem::AsValueInto( | 83 void EndTransformDisplayItem::AsValueInto( |
| 85 const gfx::Rect& visual_rect, | 84 const gfx::Rect& visual_rect, |
| 86 base::trace_event::TracedValue* array) const { | 85 base::trace_event::TracedValue* array) const { |
| 87 array->AppendString( | 86 array->AppendString( |
| 88 base::StringPrintf("EndTransformDisplayItem visualRect: [%s]", | 87 base::StringPrintf("EndTransformDisplayItem visualRect: [%s]", |
| 89 visual_rect.ToString().c_str())); | 88 visual_rect.ToString().c_str())); |
| 90 } | 89 } |
| 91 | 90 |
| 92 size_t EndTransformDisplayItem::ExternalMemoryUsage() const { | |
| 93 return 0; | |
| 94 } | |
| 95 | |
| 96 } // namespace cc | 91 } // namespace cc |
| OLD | NEW |