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