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 "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 "third_party/skia/include/core/SkCanvas.h" | 9 #include "third_party/skia/include/core/SkCanvas.h" |
10 | 10 |
11 namespace cc { | 11 namespace cc { |
12 | 12 |
13 TransformDisplayItem::TransformDisplayItem() | 13 TransformDisplayItem::TransformDisplayItem() |
14 : transform_(gfx::Transform::kSkipInitialization) { | 14 : transform_(gfx::Transform::kSkipInitialization) { |
15 } | 15 } |
16 | 16 |
17 TransformDisplayItem::~TransformDisplayItem() { | 17 TransformDisplayItem::~TransformDisplayItem() { |
18 } | 18 } |
19 | 19 |
20 void TransformDisplayItem::SetNew(const gfx::Transform& transform) { | 20 void TransformDisplayItem::SetNew(const gfx::Transform& transform) { |
21 transform_ = transform; | 21 transform_ = transform; |
22 | 22 |
23 size_t memory_usage = sizeof(gfx::Transform); | |
24 DisplayItem::SetNew(true /* suitable_for_gpu_raster */, 1 /* op_count */, | 23 DisplayItem::SetNew(true /* suitable_for_gpu_raster */, 1 /* op_count */, |
25 memory_usage); | 24 0 /* external_memory_usage */); |
26 } | 25 } |
27 | 26 |
28 void TransformDisplayItem::Raster(SkCanvas* canvas, | 27 void TransformDisplayItem::Raster(SkCanvas* canvas, |
29 const gfx::Rect& canvas_target_playback_rect, | 28 const gfx::Rect& canvas_target_playback_rect, |
30 SkPicture::AbortCallback* callback) const { | 29 SkPicture::AbortCallback* callback) const { |
31 canvas->save(); | 30 canvas->save(); |
32 if (!transform_.IsIdentity()) | 31 if (!transform_.IsIdentity()) |
33 canvas->concat(transform_.matrix()); | 32 canvas->concat(transform_.matrix()); |
34 } | 33 } |
35 | 34 |
36 void TransformDisplayItem::AsValueInto( | 35 void TransformDisplayItem::AsValueInto( |
37 base::trace_event::TracedValue* array) const { | 36 base::trace_event::TracedValue* array) const { |
38 array->AppendString(base::StringPrintf("TransformDisplayItem transform: [%s]", | 37 array->AppendString(base::StringPrintf("TransformDisplayItem transform: [%s]", |
39 transform_.ToString().c_str())); | 38 transform_.ToString().c_str())); |
40 } | 39 } |
41 | 40 |
42 EndTransformDisplayItem::EndTransformDisplayItem() { | 41 EndTransformDisplayItem::EndTransformDisplayItem() { |
43 DisplayItem::SetNew(true /* suitable_for_gpu_raster */, 0 /* op_count */, | 42 DisplayItem::SetNew(true /* suitable_for_gpu_raster */, 0 /* op_count */, |
44 0 /* memory_usage */); | 43 0 /* external_memory_usage */); |
45 } | 44 } |
46 | 45 |
47 EndTransformDisplayItem::~EndTransformDisplayItem() { | 46 EndTransformDisplayItem::~EndTransformDisplayItem() { |
48 } | 47 } |
49 | 48 |
50 void EndTransformDisplayItem::Raster( | 49 void EndTransformDisplayItem::Raster( |
51 SkCanvas* canvas, | 50 SkCanvas* canvas, |
52 const gfx::Rect& canvas_target_playback_rect, | 51 const gfx::Rect& canvas_target_playback_rect, |
53 SkPicture::AbortCallback* callback) const { | 52 SkPicture::AbortCallback* callback) const { |
54 canvas->restore(); | 53 canvas->restore(); |
55 } | 54 } |
56 | 55 |
57 void EndTransformDisplayItem::AsValueInto( | 56 void EndTransformDisplayItem::AsValueInto( |
58 base::trace_event::TracedValue* array) const { | 57 base::trace_event::TracedValue* array) const { |
59 array->AppendString("EndTransformDisplayItem"); | 58 array->AppendString("EndTransformDisplayItem"); |
60 } | 59 } |
61 | 60 |
62 } // namespace cc | 61 } // namespace cc |
OLD | NEW |