Skia
2D Graphics Library
SkSVGFilterContext.h
Go to the documentation of this file.
1 /*
2  * Copyright 2020 Google Inc.
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 SkSVGFilterContext_DEFINED
9 #define SkSVGFilterContext_DEFINED
10 
11 #include "include/core/SkRect.h"
12 #include "include/core/SkRefCnt.h"
13 #include "include/core/SkString.h"
15 #include "src/core/SkTHash.h"
16 
17 class SkImageFilter;
18 class SkSVGFeInputType;
19 class SkSVGRenderContext;
20 
22 public:
25  : fFilterEffectsRegion(filterEffectsRegion)
26  , fPrimitiveUnits(primitiveUnits)
27  , fPreviousResult({nullptr, filterEffectsRegion, SkSVGColorspace::kSRGB}) {}
28 
29  const SkRect& filterEffectsRegion() const { return fFilterEffectsRegion; }
30 
32 
33  const SkSVGObjectBoundingBoxUnits& primitiveUnits() const { return fPrimitiveUnits; }
34 
36 
38 
40 
42  const SkSVGFeInputType&) const;
43 
45 
47 
48 private:
49  struct Result {
50  sk_sp<SkImageFilter> fImageFilter;
51  SkRect fFilterSubregion;
52  SkSVGColorspace fColorspace;
53  };
54 
55  const Result* findResultById(const SkSVGStringType&) const;
56 
57  std::tuple<sk_sp<SkImageFilter>, SkSVGColorspace> getInput(const SkSVGRenderContext&,
58  const SkSVGFeInputType&) const;
59 
60  SkRect fFilterEffectsRegion;
61 
62  SkSVGObjectBoundingBoxUnits fPrimitiveUnits;
63 
64  skia_private::THashMap<SkSVGStringType, Result> fResults;
65 
66  Result fPreviousResult;
67 };
68 
69 #endif // SkSVGFilterContext_DEFINED
SkSVGColorspace
Definition: SkSVGTypes.h:719
Base class for image filters.
Definition: SkImageFilter.h:35
Definition: SkSVGTypes.h:635
Definition: SkSVGFilterContext.h:21
SkSVGColorspace resolveInputColorspace(const SkSVGRenderContext &, const SkSVGFeInputType &) const
const SkRect & filterPrimitiveSubregion(const SkSVGFeInputType &) const
sk_sp< SkImageFilter > resolveInput(const SkSVGRenderContext &, const SkSVGFeInputType &) const
void registerResult(const SkSVGStringType &, const sk_sp< SkImageFilter > &, const SkRect &, SkSVGColorspace)
SkSVGFilterContext(const SkRect &filterEffectsRegion, const SkSVGObjectBoundingBoxUnits &primitiveUnits)
Definition: SkSVGFilterContext.h:23
const SkSVGObjectBoundingBoxUnits & primitiveUnits() const
Definition: SkSVGFilterContext.h:33
const SkRect & filterEffectsRegion() const
Definition: SkSVGFilterContext.h:29
void setPreviousResult(const sk_sp< SkImageFilter > &, const SkRect &, SkSVGColorspace)
bool previousResultIsSourceGraphic() const
sk_sp< SkImageFilter > resolveInput(const SkSVGRenderContext &, const SkSVGFeInputType &, SkSVGColorspace) const
Definition: SkSVGTypes.h:454
Definition: SkSVGRenderContext.h:61
Light weight class for managing strings.
Definition: SkString.h:118
SkRect holds four float coordinates describing the upper and lower bounds of a rectangle.
Definition: SkRect.h:582