OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/float_clip_display_item.h" | 5 #include "cc/playback/float_clip_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 #include "ui/gfx/skia_util.h" | 10 #include "ui/gfx/skia_util.h" |
11 | 11 |
12 namespace cc { | 12 namespace cc { |
13 | 13 |
14 FloatClipDisplayItem::FloatClipDisplayItem() { | 14 FloatClipDisplayItem::FloatClipDisplayItem() { |
15 } | 15 } |
16 | 16 |
17 FloatClipDisplayItem::~FloatClipDisplayItem() { | 17 FloatClipDisplayItem::~FloatClipDisplayItem() { |
18 } | 18 } |
19 | 19 |
20 void FloatClipDisplayItem::SetNew(const gfx::RectF& clip_rect) { | 20 void FloatClipDisplayItem::SetNew(const gfx::RectF& clip_rect) { |
21 clip_rect_ = clip_rect; | 21 clip_rect_ = clip_rect; |
22 | 22 |
23 size_t memory_usage = sizeof(gfx::RectF); | |
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 FloatClipDisplayItem::Raster(SkCanvas* canvas, | 27 void FloatClipDisplayItem::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 canvas->clipRect(gfx::RectFToSkRect(clip_rect_)); | 31 canvas->clipRect(gfx::RectFToSkRect(clip_rect_)); |
33 } | 32 } |
34 | 33 |
35 void FloatClipDisplayItem::AsValueInto( | 34 void FloatClipDisplayItem::AsValueInto( |
36 base::trace_event::TracedValue* array) const { | 35 base::trace_event::TracedValue* array) const { |
37 array->AppendString(base::StringPrintf("FloatClipDisplayItem rect: [%s]", | 36 array->AppendString(base::StringPrintf("FloatClipDisplayItem rect: [%s]", |
38 clip_rect_.ToString().c_str())); | 37 clip_rect_.ToString().c_str())); |
39 } | 38 } |
40 | 39 |
41 EndFloatClipDisplayItem::EndFloatClipDisplayItem() { | 40 EndFloatClipDisplayItem::EndFloatClipDisplayItem() { |
42 DisplayItem::SetNew(true /* suitable_for_gpu_raster */, 0 /* op_count */, | 41 DisplayItem::SetNew(true /* suitable_for_gpu_raster */, 0 /* op_count */, |
43 0 /* memory_usage */); | 42 0 /* external_memory_usage */); |
44 } | 43 } |
45 | 44 |
46 EndFloatClipDisplayItem::~EndFloatClipDisplayItem() { | 45 EndFloatClipDisplayItem::~EndFloatClipDisplayItem() { |
47 } | 46 } |
48 | 47 |
49 void EndFloatClipDisplayItem::Raster( | 48 void EndFloatClipDisplayItem::Raster( |
50 SkCanvas* canvas, | 49 SkCanvas* canvas, |
51 const gfx::Rect& canvas_target_playback_rect, | 50 const gfx::Rect& canvas_target_playback_rect, |
52 SkPicture::AbortCallback* callback) const { | 51 SkPicture::AbortCallback* callback) const { |
53 canvas->restore(); | 52 canvas->restore(); |
54 } | 53 } |
55 | 54 |
56 void EndFloatClipDisplayItem::AsValueInto( | 55 void EndFloatClipDisplayItem::AsValueInto( |
57 base::trace_event::TracedValue* array) const { | 56 base::trace_event::TracedValue* array) const { |
58 array->AppendString("EndFloatClipDisplayItem"); | 57 array->AppendString("EndFloatClipDisplayItem"); |
59 } | 58 } |
60 | 59 |
61 } // namespace cc | 60 } // namespace cc |
OLD | NEW |