Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
backdrop_filter_layer.cc
Go to the documentation of this file.
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
10 std::shared_ptr<const DlImageFilter> filter,
11 DlBlendMode blend_mode)
12 : filter_(std::move(filter)), blend_mode_(blend_mode) {}
13
14void BackdropFilterLayer::Diff(DiffContext* context, const Layer* old_layer) {
15 DiffContext::AutoSubtreeRestore subtree(context);
16 auto* prev = static_cast<const BackdropFilterLayer*>(old_layer);
17 if (!context->IsSubtreeDirty()) {
19 if (NotEquals(filter_, prev->filter_)) {
20 context->MarkSubtreeDirty(context->GetOldLayerPaintRegion(old_layer));
21 }
22 }
23
24 // Backdrop filter paints everywhere in cull rect
25 auto paint_bounds = context->GetCullRect();
27
28 if (filter_) {
30 auto filter_target_bounds = paint_bounds.roundOut();
31 SkIRect filter_input_bounds; // in screen coordinates
32 filter_->get_input_device_bounds(
33 filter_target_bounds, context->GetTransform3x3(), filter_input_bounds);
34 context->AddReadbackRegion(filter_target_bounds, filter_input_bounds);
35 }
36
37 DiffChildren(context, prev);
38
39 context->SetLayerPaintRegion(this, context->CurrentSubtreeRegion());
40}
41
55
57 FML_DCHECK(needs_painting(context));
58
59 auto mutator = context.state_stack.save();
60 mutator.applyBackdropFilter(paint_bounds(), filter_, blend_mode_);
61
62 PaintChildren(context);
63}
64
65} // namespace flutter
static float prev(float f)
void Preroll(PrerollContext *context) override
void Paint(PaintContext &context) const override
void Diff(DiffContext *context, const Layer *old_layer) override
BackdropFilterLayer(std::shared_ptr< const DlImageFilter > filter, DlBlendMode blend_mode)
void PrerollChildren(PrerollContext *context, SkRect *child_paint_bounds)
void PaintChildren(PaintContext &context) const override
virtual void DiffChildren(DiffContext *context, const ContainerLayer *old_layer)
const SkRect & child_paint_bounds() const
SkMatrix GetTransform3x3() const
void AddLayerBounds(const SkRect &rect)
void SetLayerPaintRegion(const Layer *layer, const PaintRegion &region)
void MarkSubtreeDirty(const PaintRegion &previous_paint_region=PaintRegion())
PaintRegion CurrentSubtreeRegion() const
PaintRegion GetOldLayerPaintRegion(const Layer *layer) const
SkRect MapRect(const SkRect &rect)
bool IsSubtreeDirty() const
void AddReadbackRegion(const SkIRect &paint_rect, const SkIRect &readback_rect)
SkRect GetCullRect() const
virtual void PushFilterToVisitedPlatformViews(const std::shared_ptr< const DlImageFilter > &filter, const SkRect &filter_rect)
void applyBackdropFilter(const SkRect &bounds, const std::shared_ptr< const DlImageFilter > &filter, DlBlendMode blend_mode)
static AutoPrerollSaveLayerState Create(PrerollContext *preroll_context, bool save_layer_is_active=true, bool layer_itself_performs_readback=false)
Definition layer.cc:40
const SkRect & paint_bounds() const
Definition layer.h:209
static constexpr int kSaveLayerRenderFlags
Definition layer.h:131
bool needs_painting(PaintContext &context) const
Definition layer.h:231
void set_paint_bounds(const SkRect &paint_bounds)
Definition layer.h:222
#define FML_DCHECK(condition)
Definition logging.h:103
bool NotEquals(const T *a, const T *b)
Definition ref_ptr.h:256
static constexpr SkRect MakeEmpty()
Definition SkRect.h:595
void roundOut(SkIRect *dst) const
Definition SkRect.h:1241
void join(const SkRect &r)
Definition SkRect.cpp:126
LayerStateStack & state_stack
Definition layer.h:100
LayerStateStack & state_stack
Definition layer.h:58
ExternalViewEmbedder * view_embedder
Definition layer.h:57