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/filter_display_item.h" | 5 #include "cc/playback/filter_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 "cc/output/render_surface_filters.h" | 9 #include "cc/output/render_surface_filters.h" |
10 #include "skia/ext/refptr.h" | 10 #include "skia/ext/refptr.h" |
11 #include "third_party/skia/include/core/SkCanvas.h" | 11 #include "third_party/skia/include/core/SkCanvas.h" |
12 #include "third_party/skia/include/core/SkImageFilter.h" | 12 #include "third_party/skia/include/core/SkImageFilter.h" |
13 #include "third_party/skia/include/core/SkPaint.h" | 13 #include "third_party/skia/include/core/SkPaint.h" |
14 #include "third_party/skia/include/core/SkXfermode.h" | 14 #include "third_party/skia/include/core/SkXfermode.h" |
15 #include "ui/gfx/skia_util.h" | 15 #include "ui/gfx/skia_util.h" |
16 | 16 |
17 namespace cc { | 17 namespace cc { |
18 | 18 |
19 FilterDisplayItem::FilterDisplayItem() { | 19 FilterDisplayItem::FilterDisplayItem() { |
20 } | 20 } |
21 | 21 |
22 FilterDisplayItem::~FilterDisplayItem() { | 22 FilterDisplayItem::~FilterDisplayItem() { |
23 } | 23 } |
24 | 24 |
25 void FilterDisplayItem::SetNew(const FilterOperations& filters, | 25 void FilterDisplayItem::SetNew(const FilterOperations& filters, |
26 const gfx::RectF& bounds) { | 26 const gfx::RectF& bounds) { |
27 filters_ = filters; | 27 filters_ = filters; |
28 bounds_ = bounds; | 28 bounds_ = bounds; |
29 | 29 |
30 size_t memory_usage = | 30 // FilterOperations doesn't expose its capacity, but size is probably good |
31 sizeof(skia::RefPtr<SkImageFilter>) + sizeof(gfx::RectF); | 31 // enough. |
| 32 size_t external_memory_usage = filters_.size() * sizeof(filters_.at(0)); |
32 DisplayItem::SetNew(true /* suitable_for_gpu_raster */, 1 /* op_count */, | 33 DisplayItem::SetNew(true /* suitable_for_gpu_raster */, 1 /* op_count */, |
33 memory_usage); | 34 external_memory_usage); |
34 } | 35 } |
35 | 36 |
36 void FilterDisplayItem::Raster(SkCanvas* canvas, | 37 void FilterDisplayItem::Raster(SkCanvas* canvas, |
37 const gfx::Rect& canvas_target_playback_rect, | 38 const gfx::Rect& canvas_target_playback_rect, |
38 SkPicture::AbortCallback* callback) const { | 39 SkPicture::AbortCallback* callback) const { |
39 canvas->save(); | 40 canvas->save(); |
40 canvas->translate(bounds_.x(), bounds_.y()); | 41 canvas->translate(bounds_.x(), bounds_.y()); |
41 | 42 |
42 skia::RefPtr<SkImageFilter> image_filter = | 43 skia::RefPtr<SkImageFilter> image_filter = |
43 RenderSurfaceFilters::BuildImageFilter( | 44 RenderSurfaceFilters::BuildImageFilter( |
(...skipping 11 matching lines...) Expand all Loading... |
55 } | 56 } |
56 | 57 |
57 void FilterDisplayItem::AsValueInto( | 58 void FilterDisplayItem::AsValueInto( |
58 base::trace_event::TracedValue* array) const { | 59 base::trace_event::TracedValue* array) const { |
59 array->AppendString(base::StringPrintf("FilterDisplayItem bounds: [%s]", | 60 array->AppendString(base::StringPrintf("FilterDisplayItem bounds: [%s]", |
60 bounds_.ToString().c_str())); | 61 bounds_.ToString().c_str())); |
61 } | 62 } |
62 | 63 |
63 EndFilterDisplayItem::EndFilterDisplayItem() { | 64 EndFilterDisplayItem::EndFilterDisplayItem() { |
64 DisplayItem::SetNew(true /* suitable_for_gpu_raster */, 0 /* op_count */, | 65 DisplayItem::SetNew(true /* suitable_for_gpu_raster */, 0 /* op_count */, |
65 0 /* memory_usage */); | 66 0 /* external_memory_usage */); |
66 } | 67 } |
67 | 68 |
68 EndFilterDisplayItem::~EndFilterDisplayItem() { | 69 EndFilterDisplayItem::~EndFilterDisplayItem() { |
69 } | 70 } |
70 | 71 |
71 void EndFilterDisplayItem::Raster(SkCanvas* canvas, | 72 void EndFilterDisplayItem::Raster(SkCanvas* canvas, |
72 const gfx::Rect& canvas_target_playback_rect, | 73 const gfx::Rect& canvas_target_playback_rect, |
73 SkPicture::AbortCallback* callback) const { | 74 SkPicture::AbortCallback* callback) const { |
74 canvas->restore(); | 75 canvas->restore(); |
75 canvas->restore(); | 76 canvas->restore(); |
76 } | 77 } |
77 | 78 |
78 void EndFilterDisplayItem::AsValueInto( | 79 void EndFilterDisplayItem::AsValueInto( |
79 base::trace_event::TracedValue* array) const { | 80 base::trace_event::TracedValue* array) const { |
80 array->AppendString("EndFilterDisplayItem"); | 81 array->AppendString("EndFilterDisplayItem"); |
81 } | 82 } |
82 | 83 |
83 } // namespace cc | 84 } // namespace cc |
OLD | NEW |