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/compositing_display_item.h" | 5 #include "cc/paint/compositing_display_item.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include "base/strings/stringprintf.h" | 10 #include "base/strings/stringprintf.h" |
11 #include "base/trace_event/trace_event_argument.h" | 11 #include "base/trace_event/trace_event_argument.h" |
12 #include "third_party/skia/include/core/SkCanvas.h" | 12 #include "third_party/skia/include/core/SkCanvas.h" |
13 #include "third_party/skia/include/core/SkData.h" | 13 #include "third_party/skia/include/core/SkData.h" |
14 #include "third_party/skia/include/core/SkFlattenable.h" | 14 #include "third_party/skia/include/core/SkFlattenable.h" |
15 #include "third_party/skia/include/core/SkFlattenableSerialization.h" | 15 #include "third_party/skia/include/core/SkFlattenableSerialization.h" |
16 #include "third_party/skia/include/core/SkPaint.h" | 16 #include "third_party/skia/include/core/SkPaint.h" |
17 | 17 |
18 #include "ui/gfx/skia_util.h" | 18 #include "ui/gfx/skia_util.h" |
19 | 19 |
20 namespace cc { | 20 namespace cc { |
21 | 21 |
22 CompositingDisplayItem::CompositingDisplayItem( | 22 CompositingDisplayItem::CompositingDisplayItem( |
23 uint8_t alpha, | 23 uint8_t alpha, |
24 SkBlendMode xfermode, | 24 SkBlendMode xfermode, |
25 SkRect* bounds, | 25 SkRect* bounds, |
26 sk_sp<SkColorFilter> cf, | 26 sk_sp<SkColorFilter> cf, |
27 bool lcd_text_requires_opaque_layer) | 27 bool lcd_text_requires_opaque_layer) |
28 : DisplayItem(COMPOSITING) { | 28 : DisplayItem(COMPOSITING) { |
29 SetNew(alpha, xfermode, bounds, std::move(cf), | 29 SetNew(alpha, xfermode, bounds, std::move(cf), |
30 lcd_text_requires_opaque_layer); | 30 lcd_text_requires_opaque_layer); |
31 } | 31 } |
32 | 32 |
33 CompositingDisplayItem::~CompositingDisplayItem() { | 33 CompositingDisplayItem::~CompositingDisplayItem() {} |
34 } | |
35 | 34 |
36 void CompositingDisplayItem::SetNew(uint8_t alpha, | 35 void CompositingDisplayItem::SetNew(uint8_t alpha, |
37 SkBlendMode xfermode, | 36 SkBlendMode xfermode, |
38 SkRect* bounds, | 37 SkRect* bounds, |
39 sk_sp<SkColorFilter> cf, | 38 sk_sp<SkColorFilter> cf, |
40 bool lcd_text_requires_opaque_layer) { | 39 bool lcd_text_requires_opaque_layer) { |
41 alpha_ = alpha; | 40 alpha_ = alpha; |
42 xfermode_ = xfermode; | 41 xfermode_ = xfermode; |
43 has_bounds_ = !!bounds; | 42 has_bounds_ = !!bounds; |
44 if (bounds) | 43 if (bounds) |
45 bounds_ = SkRect(*bounds); | 44 bounds_ = SkRect(*bounds); |
46 color_filter_ = std::move(cf); | 45 color_filter_ = std::move(cf); |
47 lcd_text_requires_opaque_layer_ = lcd_text_requires_opaque_layer; | 46 lcd_text_requires_opaque_layer_ = lcd_text_requires_opaque_layer; |
48 } | 47 } |
49 | 48 |
50 void CompositingDisplayItem::Raster( | 49 void CompositingDisplayItem::Raster(SkCanvas* canvas, |
51 SkCanvas* canvas, | 50 SkPicture::AbortCallback* callback) const { |
52 SkPicture::AbortCallback* callback) const { | |
53 SkPaint paint; | 51 SkPaint paint; |
54 paint.setBlendMode(xfermode_); | 52 paint.setBlendMode(xfermode_); |
55 paint.setAlpha(alpha_); | 53 paint.setAlpha(alpha_); |
56 paint.setColorFilter(color_filter_); | 54 paint.setColorFilter(color_filter_); |
57 const SkRect* bounds = has_bounds_ ? &bounds_ : nullptr; | 55 const SkRect* bounds = has_bounds_ ? &bounds_ : nullptr; |
58 if (lcd_text_requires_opaque_layer_) | 56 if (lcd_text_requires_opaque_layer_) |
59 canvas->saveLayer(bounds, &paint); | 57 canvas->saveLayer(bounds, &paint); |
60 else | 58 else |
61 canvas->saveLayerPreserveLCDTextRequests(bounds, &paint); | 59 canvas->saveLayerPreserveLCDTextRequests(bounds, &paint); |
62 } | 60 } |
63 | 61 |
64 EndCompositingDisplayItem::EndCompositingDisplayItem() | 62 EndCompositingDisplayItem::EndCompositingDisplayItem() |
65 : DisplayItem(END_COMPOSITING) {} | 63 : DisplayItem(END_COMPOSITING) {} |
66 | 64 |
67 EndCompositingDisplayItem::~EndCompositingDisplayItem() { | 65 EndCompositingDisplayItem::~EndCompositingDisplayItem() {} |
68 } | |
69 | 66 |
70 void EndCompositingDisplayItem::Raster( | 67 void EndCompositingDisplayItem::Raster( |
71 SkCanvas* canvas, | 68 SkCanvas* canvas, |
72 SkPicture::AbortCallback* callback) const { | 69 SkPicture::AbortCallback* callback) const { |
73 canvas->restore(); | 70 canvas->restore(); |
74 } | 71 } |
75 | 72 |
76 } // namespace cc | 73 } // namespace cc |
OLD | NEW |