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/resources/compositing_display_item.h" | 5 #include "cc/resources/compositing_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 "third_party/skia/include/core/SkPaint.h" | 10 #include "third_party/skia/include/core/SkPaint.h" |
11 #include "third_party/skia/include/core/SkXfermode.h" | 11 #include "third_party/skia/include/core/SkXfermode.h" |
12 #include "ui/gfx/skia_util.h" | 12 #include "ui/gfx/skia_util.h" |
13 | 13 |
14 namespace cc { | 14 namespace cc { |
15 | 15 |
16 CompositingDisplayItem::CompositingDisplayItem(uint8_t alpha, | 16 CompositingDisplayItem::CompositingDisplayItem() { |
17 SkXfermode::Mode xfermode, | |
18 SkRect* bounds, | |
19 skia::RefPtr<SkColorFilter> cf) | |
20 : alpha_(alpha), | |
21 xfermode_(xfermode), | |
22 has_bounds_(!!bounds), | |
23 color_filter_(cf) { | |
24 if (bounds) | |
25 bounds_ = SkRect(*bounds); | |
26 } | 17 } |
27 | 18 |
28 CompositingDisplayItem::~CompositingDisplayItem() { | 19 CompositingDisplayItem::~CompositingDisplayItem() { |
29 } | 20 } |
30 | 21 |
| 22 void CompositingDisplayItem::SetNew(uint8_t alpha, |
| 23 SkXfermode::Mode xfermode, |
| 24 SkRect* bounds, |
| 25 skia::RefPtr<SkColorFilter> cf) { |
| 26 alpha_ = alpha; |
| 27 xfermode_ = xfermode; |
| 28 has_bounds_ = !!bounds; |
| 29 if (bounds) |
| 30 bounds_ = SkRect(*bounds); |
| 31 color_filter_ = cf; |
| 32 } |
| 33 |
31 void CompositingDisplayItem::Raster(SkCanvas* canvas, | 34 void CompositingDisplayItem::Raster(SkCanvas* canvas, |
32 SkDrawPictureCallback* callback) const { | 35 SkDrawPictureCallback* callback) const { |
33 SkPaint paint; | 36 SkPaint paint; |
34 paint.setXfermodeMode(xfermode_); | 37 paint.setXfermodeMode(xfermode_); |
35 paint.setAlpha(alpha_); | 38 paint.setAlpha(alpha_); |
36 paint.setColorFilter(color_filter_.get()); | 39 paint.setColorFilter(color_filter_.get()); |
37 canvas->saveLayer(has_bounds_ ? &bounds_ : nullptr, &paint); | 40 canvas->saveLayer(has_bounds_ ? &bounds_ : nullptr, &paint); |
38 } | 41 } |
39 | 42 |
40 bool CompositingDisplayItem::IsSuitableForGpuRasterization() const { | 43 bool CompositingDisplayItem::IsSuitableForGpuRasterization() const { |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
84 size_t EndCompositingDisplayItem::PictureMemoryUsage() const { | 87 size_t EndCompositingDisplayItem::PictureMemoryUsage() const { |
85 return 0; | 88 return 0; |
86 } | 89 } |
87 | 90 |
88 void EndCompositingDisplayItem::AsValueInto( | 91 void EndCompositingDisplayItem::AsValueInto( |
89 base::trace_event::TracedValue* array) const { | 92 base::trace_event::TracedValue* array) const { |
90 array->AppendString("EndCompositingDisplayItem"); | 93 array->AppendString("EndCompositingDisplayItem"); |
91 } | 94 } |
92 | 95 |
93 } // namespace cc | 96 } // namespace cc |
OLD | NEW |