| 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 "cc/paint/paint_flags.h" |
| 12 #include "cc/proto/display_item.pb.h" | 13 #include "cc/proto/display_item.pb.h" |
| 13 #include "cc/proto/gfx_conversions.h" | 14 #include "cc/proto/gfx_conversions.h" |
| 14 #include "cc/proto/skia_conversions.h" | 15 #include "cc/proto/skia_conversions.h" |
| 15 #include "third_party/skia/include/core/SkCanvas.h" | |
| 16 #include "third_party/skia/include/core/SkData.h" | 16 #include "third_party/skia/include/core/SkData.h" |
| 17 #include "third_party/skia/include/core/SkFlattenable.h" | 17 #include "third_party/skia/include/core/SkFlattenable.h" |
| 18 #include "third_party/skia/include/core/SkFlattenableSerialization.h" | 18 #include "third_party/skia/include/core/SkFlattenableSerialization.h" |
| 19 #include "third_party/skia/include/core/SkPaint.h" | |
| 20 | 19 |
| 21 #include "ui/gfx/skia_util.h" | 20 #include "ui/gfx/skia_util.h" |
| 22 | 21 |
| 23 namespace cc { | 22 namespace cc { |
| 24 | 23 |
| 25 CompositingDisplayItem::CompositingDisplayItem( | 24 CompositingDisplayItem::CompositingDisplayItem( |
| 26 uint8_t alpha, | 25 uint8_t alpha, |
| 27 SkBlendMode xfermode, | 26 SkBlendMode xfermode, |
| 28 SkRect* bounds, | 27 SkRect* bounds, |
| 29 sk_sp<SkColorFilter> cf, | 28 sk_sp<SkColorFilter> cf, |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 90 if (color_filter_) { | 89 if (color_filter_) { |
| 91 sk_sp<SkData> data(SkValidatingSerializeFlattenable(color_filter_.get())); | 90 sk_sp<SkData> data(SkValidatingSerializeFlattenable(color_filter_.get())); |
| 92 if (data->size() > 0) | 91 if (data->size() > 0) |
| 93 details->set_color_filter(data->data(), data->size()); | 92 details->set_color_filter(data->data(), data->size()); |
| 94 } | 93 } |
| 95 | 94 |
| 96 details->set_lcd_text_requires_opaque_layer(lcd_text_requires_opaque_layer_); | 95 details->set_lcd_text_requires_opaque_layer(lcd_text_requires_opaque_layer_); |
| 97 } | 96 } |
| 98 | 97 |
| 99 void CompositingDisplayItem::Raster( | 98 void CompositingDisplayItem::Raster( |
| 100 SkCanvas* canvas, | 99 PaintCanvas* canvas, |
| 101 SkPicture::AbortCallback* callback) const { | 100 PaintRecord::AbortCallback* callback) const { |
| 102 SkPaint paint; | 101 PaintFlags paint; |
| 103 paint.setBlendMode(xfermode_); | 102 paint.setBlendMode(xfermode_); |
| 104 paint.setAlpha(alpha_); | 103 paint.setAlpha(alpha_); |
| 105 paint.setColorFilter(color_filter_); | 104 paint.setColorFilter(color_filter_); |
| 106 const SkRect* bounds = has_bounds_ ? &bounds_ : nullptr; | 105 const SkRect* bounds = has_bounds_ ? &bounds_ : nullptr; |
| 107 if (lcd_text_requires_opaque_layer_) | 106 if (lcd_text_requires_opaque_layer_) |
| 108 canvas->saveLayer(bounds, &paint); | 107 canvas->saveLayer(bounds, &paint); |
| 109 else | 108 else |
| 110 canvas->saveLayerPreserveLCDTextRequests(bounds, &paint); | 109 canvas->saveLayerPreserveLCDTextRequests(bounds, &paint); |
| 111 } | 110 } |
| 112 | 111 |
| (...skipping 22 matching lines...) Expand all Loading... |
| 135 } | 134 } |
| 136 | 135 |
| 137 EndCompositingDisplayItem::~EndCompositingDisplayItem() { | 136 EndCompositingDisplayItem::~EndCompositingDisplayItem() { |
| 138 } | 137 } |
| 139 | 138 |
| 140 void EndCompositingDisplayItem::ToProtobuf(proto::DisplayItem* proto) const { | 139 void EndCompositingDisplayItem::ToProtobuf(proto::DisplayItem* proto) const { |
| 141 proto->set_type(proto::DisplayItem::Type_EndCompositing); | 140 proto->set_type(proto::DisplayItem::Type_EndCompositing); |
| 142 } | 141 } |
| 143 | 142 |
| 144 void EndCompositingDisplayItem::Raster( | 143 void EndCompositingDisplayItem::Raster( |
| 145 SkCanvas* canvas, | 144 PaintCanvas* canvas, |
| 146 SkPicture::AbortCallback* callback) const { | 145 PaintRecord::AbortCallback* callback) const { |
| 147 canvas->restore(); | 146 canvas->restore(); |
| 148 } | 147 } |
| 149 | 148 |
| 150 void EndCompositingDisplayItem::AsValueInto( | 149 void EndCompositingDisplayItem::AsValueInto( |
| 151 const gfx::Rect& visual_rect, | 150 const gfx::Rect& visual_rect, |
| 152 base::trace_event::TracedValue* array) const { | 151 base::trace_event::TracedValue* array) const { |
| 153 array->AppendString( | 152 array->AppendString( |
| 154 base::StringPrintf("EndCompositingDisplayItem visualRect: [%s]", | 153 base::StringPrintf("EndCompositingDisplayItem visualRect: [%s]", |
| 155 visual_rect.ToString().c_str())); | 154 visual_rect.ToString().c_str())); |
| 156 } | 155 } |
| 157 | 156 |
| 158 } // namespace cc | 157 } // namespace cc |
| OLD | NEW |