1 | // Copyright 2013 The Flutter 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 "flutter/flow/layers/color_filter_layer.h" |
6 | |
7 | namespace flutter { |
8 | |
9 | ColorFilterLayer::ColorFilterLayer(sk_sp<SkColorFilter> filter) |
10 | : filter_(std::move(filter)) {} |
11 | |
12 | void ColorFilterLayer::Preroll(PrerollContext* context, |
13 | const SkMatrix& matrix) { |
14 | Layer::AutoPrerollSaveLayerState save = |
15 | Layer::AutoPrerollSaveLayerState::Create(context); |
16 | ContainerLayer::Preroll(context, matrix); |
17 | } |
18 | |
19 | void ColorFilterLayer::Paint(PaintContext& context) const { |
20 | TRACE_EVENT0("flutter", "ColorFilterLayer::Paint"); |
21 | FML_DCHECK(needs_painting()); |
22 | |
23 | SkPaint paint; |
24 | paint.setColorFilter(filter_); |
25 | |
26 | Layer::AutoSaveLayer save = |
27 | Layer::AutoSaveLayer::Create(context, paint_bounds(), &paint); |
28 | PaintChildren(context); |
29 | } |
30 | |
31 | } // namespace flutter |
32 |