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/backdrop_filter_layer.h"
6
7namespace flutter {
8
9BackdropFilterLayer::BackdropFilterLayer(sk_sp<SkImageFilter> filter)
10 : filter_(std::move(filter)) {}
11
12void BackdropFilterLayer::Preroll(PrerollContext* context,
13 const SkMatrix& matrix) {
14 Layer::AutoPrerollSaveLayerState save =
15 Layer::AutoPrerollSaveLayerState::Create(context, true, bool(filter_));
16 ContainerLayer::Preroll(context, matrix);
17}
18
19void BackdropFilterLayer::Paint(PaintContext& context) const {
20 TRACE_EVENT0("flutter", "BackdropFilterLayer::Paint");
21 FML_DCHECK(needs_painting());
22
23 Layer::AutoSaveLayer save = Layer::AutoSaveLayer::Create(
24 context,
25 SkCanvas::SaveLayerRec{&paint_bounds(), nullptr, filter_.get(), 0});
26 PaintChildren(context);
27}
28
29} // namespace flutter
30