| 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 <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 "cc/paint/paint_flags.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" | |
| 17 | 16 |
| 18 #include "ui/gfx/skia_util.h" | 17 #include "ui/gfx/skia_util.h" |
| 19 | 18 |
| 20 namespace cc { | 19 namespace cc { |
| 21 | 20 |
| 22 CompositingDisplayItem::CompositingDisplayItem( | 21 CompositingDisplayItem::CompositingDisplayItem( |
| 23 uint8_t alpha, | 22 uint8_t alpha, |
| 24 SkBlendMode xfermode, | 23 SkBlendMode xfermode, |
| 25 SkRect* bounds, | 24 SkRect* bounds, |
| 26 sk_sp<SkColorFilter> cf, | 25 sk_sp<SkColorFilter> cf, |
| (...skipping 14 matching lines...) Expand all Loading... |
| 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( |
| 51 SkCanvas* canvas, | 50 PaintCanvas* canvas, |
| 52 SkPicture::AbortCallback* callback) const { | 51 PaintRecord::AbortCallback* callback) const { |
| 53 SkPaint paint; | 52 PaintFlags paint; |
| 54 paint.setBlendMode(xfermode_); | 53 paint.setBlendMode(xfermode_); |
| 55 paint.setAlpha(alpha_); | 54 paint.setAlpha(alpha_); |
| 56 paint.setColorFilter(color_filter_); | 55 paint.setColorFilter(color_filter_); |
| 57 const SkRect* bounds = has_bounds_ ? &bounds_ : nullptr; | 56 const SkRect* bounds = has_bounds_ ? &bounds_ : nullptr; |
| 58 if (lcd_text_requires_opaque_layer_) | 57 if (lcd_text_requires_opaque_layer_) |
| 59 canvas->saveLayer(bounds, &paint); | 58 canvas->saveLayer(bounds, &paint); |
| 60 else | 59 else |
| 61 canvas->saveLayerPreserveLCDTextRequests(bounds, &paint); | 60 canvas->saveLayerPreserveLCDTextRequests(bounds, &paint); |
| 62 } | 61 } |
| 63 | 62 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 76 array->AppendString(info); | 75 array->AppendString(info); |
| 77 } | 76 } |
| 78 | 77 |
| 79 EndCompositingDisplayItem::EndCompositingDisplayItem() | 78 EndCompositingDisplayItem::EndCompositingDisplayItem() |
| 80 : DisplayItem(END_COMPOSITING) {} | 79 : DisplayItem(END_COMPOSITING) {} |
| 81 | 80 |
| 82 EndCompositingDisplayItem::~EndCompositingDisplayItem() { | 81 EndCompositingDisplayItem::~EndCompositingDisplayItem() { |
| 83 } | 82 } |
| 84 | 83 |
| 85 void EndCompositingDisplayItem::Raster( | 84 void EndCompositingDisplayItem::Raster( |
| 86 SkCanvas* canvas, | 85 PaintCanvas* canvas, |
| 87 SkPicture::AbortCallback* callback) const { | 86 PaintRecord::AbortCallback* callback) const { |
| 88 canvas->restore(); | 87 canvas->restore(); |
| 89 } | 88 } |
| 90 | 89 |
| 91 void EndCompositingDisplayItem::AsValueInto( | 90 void EndCompositingDisplayItem::AsValueInto( |
| 92 const gfx::Rect& visual_rect, | 91 const gfx::Rect& visual_rect, |
| 93 base::trace_event::TracedValue* array) const { | 92 base::trace_event::TracedValue* array) const { |
| 94 array->AppendString( | 93 array->AppendString( |
| 95 base::StringPrintf("EndCompositingDisplayItem visualRect: [%s]", | 94 base::StringPrintf("EndCompositingDisplayItem visualRect: [%s]", |
| 96 visual_rect.ToString().c_str())); | 95 visual_rect.ToString().c_str())); |
| 97 } | 96 } |
| 98 | 97 |
| 99 } // namespace cc | 98 } // namespace cc |
| OLD | NEW |