| OLD | NEW |
| (Empty) |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "cc/playback/compositing_display_item.h" | |
| 6 | |
| 7 #include <stddef.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 | |
| 20 namespace cc { | |
| 21 | |
| 22 CompositingDisplayItem::CompositingDisplayItem( | |
| 23 uint8_t alpha, | |
| 24 SkBlendMode xfermode, | |
| 25 SkRect* bounds, | |
| 26 sk_sp<SkColorFilter> cf, | |
| 27 bool lcd_text_requires_opaque_layer) | |
| 28 : DisplayItem(COMPOSITING) { | |
| 29 SetNew(alpha, xfermode, bounds, std::move(cf), | |
| 30 lcd_text_requires_opaque_layer); | |
| 31 } | |
| 32 | |
| 33 CompositingDisplayItem::~CompositingDisplayItem() { | |
| 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 | |
| 64 EndCompositingDisplayItem::EndCompositingDisplayItem() | |
| 65 : DisplayItem(END_COMPOSITING) {} | |
| 66 | |
| 67 EndCompositingDisplayItem::~EndCompositingDisplayItem() { | |
| 68 } | |
| 69 | |
| 70 void EndCompositingDisplayItem::Raster( | |
| 71 SkCanvas* canvas, | |
| 72 SkPicture::AbortCallback* callback) const { | |
| 73 canvas->restore(); | |
| 74 } | |
| 75 | |
| 76 } // namespace cc | |
| OLD | NEW |