Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
SkLocalMatrixImageFilter.h
Go to the documentation of this file.
1/*
2 * Copyright 2015 The Android Open Source Project
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7
8#ifndef SkLocalMatrixImageFilter_DEFINED
9#define SkLocalMatrixImageFilter_DEFINED
10
13#include "include/core/SkRect.h"
17
18#include <optional>
19
20class SkImageFilter;
21class SkReadBuffer;
22class SkWriteBuffer;
23
24/**
25 * Wraps another imagefilter + matrix, such that using this filter will give the same result
26 * as using the wrapped filter with the matrix applied to its context.
27 */
29public:
30 static sk_sp<SkImageFilter> Make(const SkMatrix& localMatrix, sk_sp<SkImageFilter> input);
31
32 SkRect computeFastBounds(const SkRect&) const override;
33
34protected:
35 void flatten(SkWriteBuffer&) const override;
36
37private:
39
40 SkLocalMatrixImageFilter(const SkMatrix& localMatrix,
41 const SkMatrix& invLocalMatrix,
42 sk_sp<SkImageFilter> const* input)
43 : SkImageFilter_Base(input, 1)
44 , fLocalMatrix{localMatrix}
45 , fInvLocalMatrix{invLocalMatrix} {}
46
47 MatrixCapability onGetCTMCapability() const override { return MatrixCapability::kComplex; }
48
49 skif::FilterResult onFilterImage(const skif::Context& ctx) const override;
50
52 const skif::Mapping&,
53 const skif::LayerSpace<SkIRect>& desiredOutput,
54 std::optional<skif::LayerSpace<SkIRect>> contentBounds) const override;
55
56 std::optional<skif::LayerSpace<SkIRect>> onGetOutputLayerBounds(
57 const skif::Mapping&,
58 std::optional<skif::LayerSpace<SkIRect>> contentBounds) const override;
59
60 skif::Mapping localMapping(const skif::Mapping&) const;
61
62 // NOTE: This is not a ParameterSpace<SkMatrix> like that of SkMatrixTransformImageFilter.
63 // It's a bit pedantic, but does impact the math. A parameter-space transform has to be modified
64 // to represent a layer-space transform: (L*P*L^-1); while this local matrix changes L directly
65 // to L*P for its child filter.
66 SkMatrix fLocalMatrix;
67 SkMatrix fInvLocalMatrix;
68};
69
70#endif
#define SK_FLATTENABLE_HOOKS(type)
friend class SkImageFilter_Base
skif::LayerSpace< SkIRect > onGetInputLayerBounds(const skif::Mapping &, const skif::LayerSpace< SkIRect > &desiredOutput, std::optional< skif::LayerSpace< SkIRect > > contentBounds) const override
MatrixCapability onGetCTMCapability() const override
std::optional< skif::LayerSpace< SkIRect > > onGetOutputLayerBounds(const skif::Mapping &, std::optional< skif::LayerSpace< SkIRect > > contentBounds) const override
skif::FilterResult onFilterImage(const skif::Context &ctx) const override
void flatten(SkWriteBuffer &) const override
static sk_sp< SkImageFilter > Make(const SkMatrix &localMatrix, sk_sp< SkImageFilter > input)
SkRect computeFastBounds(const SkRect &) const override