• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright 2024 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 SkSVGFeComponentTransfer_DEFINED
9 #define SkSVGFeComponentTransfer_DEFINED
10 
11 #include "modules/svg/include/SkSVGFe.h"
12 #include "modules/svg/include/SkSVGHiddenContainer.h"
13 #include "modules/svg/include/SkSVGNode.h"
14 #include "modules/svg/include/SkSVGTypes.h"
15 
16 #include <cstdint>
17 
18 class SkSVGFeFunc final : public SkSVGHiddenContainer {
19 public:
MakeFuncA()20     static sk_sp<SkSVGFeFunc> MakeFuncA() {
21         return sk_sp<SkSVGFeFunc>(new SkSVGFeFunc(SkSVGTag::kFeFuncA));
22     }
23 
MakeFuncR()24     static sk_sp<SkSVGFeFunc> MakeFuncR() {
25         return sk_sp<SkSVGFeFunc>(new SkSVGFeFunc(SkSVGTag::kFeFuncR));
26     }
27 
MakeFuncG()28     static sk_sp<SkSVGFeFunc> MakeFuncG() {
29         return sk_sp<SkSVGFeFunc>(new SkSVGFeFunc(SkSVGTag::kFeFuncG));
30     }
31 
MakeFuncB()32     static sk_sp<SkSVGFeFunc> MakeFuncB() {
33         return sk_sp<SkSVGFeFunc>(new SkSVGFeFunc(SkSVGTag::kFeFuncB));
34     }
35 
36     SVG_ATTR(Amplitude  , SkSVGNumberType,                          1)
37     SVG_ATTR(Exponent   , SkSVGNumberType,                          1)
38     SVG_ATTR(Intercept  , SkSVGNumberType,                          0)
39     SVG_ATTR(Offset     , SkSVGNumberType,                          0)
40     SVG_ATTR(Slope      , SkSVGNumberType,                          1)
41     SVG_ATTR(TableValues, std::vector<SkSVGNumberType>,            {})
42     SVG_ATTR(Type       , SkSVGFeFuncType, SkSVGFeFuncType::kIdentity)
43 
44     std::vector<uint8_t> getTable() const;
45 
46 protected:
47     bool parseAndSetAttribute(const char*, const char*) override;
48 
49 private:
SkSVGFeFunc(SkSVGTag tag)50     SkSVGFeFunc(SkSVGTag tag) : INHERITED(tag) {}
51 
52     using INHERITED = SkSVGHiddenContainer;
53 };
54 
55 class SK_API SkSVGFeComponentTransfer final : public SkSVGFe {
56 public:
57     static constexpr SkSVGTag tag = SkSVGTag::kFeComponentTransfer;
58 
Make()59     static sk_sp<SkSVGFeComponentTransfer> Make() {
60         return sk_sp<SkSVGFeComponentTransfer>(new SkSVGFeComponentTransfer());
61     }
62 
63 protected:
64     sk_sp<SkImageFilter> onMakeImageFilter(const SkSVGRenderContext&,
65                                            const SkSVGFilterContext&) const override;
66 
getInputs()67     std::vector<SkSVGFeInputType> getInputs() const override { return {this->getIn()}; }
68 
69 private:
SkSVGFeComponentTransfer()70     SkSVGFeComponentTransfer() : INHERITED(tag) {}
71 
72     using INHERITED = SkSVGFe;
73 };
74 
75 #endif //  SkSVGFeComponentTransfer_DEFINED
76