File: SkSVGFeComponentTransfer.h

package info (click to toggle)
wpewebkit 2.48.3-1
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 421,720 kB
  • sloc: cpp: 3,670,389; javascript: 194,411; ansic: 165,592; python: 46,476; asm: 19,276; ruby: 18,528; perl: 16,602; xml: 4,650; yacc: 2,360; java: 1,993; sh: 1,948; lex: 1,327; pascal: 366; makefile: 85
file content (82 lines) | stat: -rw-r--r-- 2,559 bytes parent folder | download | duplicates (14)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
/*
 * Copyright 2024 Google Inc.
 *
 * Use of this source code is governed by a BSD-style license that can be
 * found in the LICENSE file.
 */

#ifndef SkSVGFeComponentTransfer_DEFINED
#define SkSVGFeComponentTransfer_DEFINED

#include "include/core/SkRefCnt.h"
#include "include/private/base/SkAPI.h"
#include "modules/svg/include/SkSVGFe.h"
#include "modules/svg/include/SkSVGHiddenContainer.h"
#include "modules/svg/include/SkSVGNode.h"
#include "modules/svg/include/SkSVGTypes.h"

#include <cstdint>
#include <vector>

class SkImageFilter;
class SkSVGFilterContext;
class SkSVGRenderContext;

class SkSVGFeFunc final : public SkSVGHiddenContainer {
public:
    static sk_sp<SkSVGFeFunc> MakeFuncA() {
        return sk_sp<SkSVGFeFunc>(new SkSVGFeFunc(SkSVGTag::kFeFuncA));
    }

    static sk_sp<SkSVGFeFunc> MakeFuncR() {
        return sk_sp<SkSVGFeFunc>(new SkSVGFeFunc(SkSVGTag::kFeFuncR));
    }

    static sk_sp<SkSVGFeFunc> MakeFuncG() {
        return sk_sp<SkSVGFeFunc>(new SkSVGFeFunc(SkSVGTag::kFeFuncG));
    }

    static sk_sp<SkSVGFeFunc> MakeFuncB() {
        return sk_sp<SkSVGFeFunc>(new SkSVGFeFunc(SkSVGTag::kFeFuncB));
    }

    SVG_ATTR(Amplitude  , SkSVGNumberType,                          1)
    SVG_ATTR(Exponent   , SkSVGNumberType,                          1)
    SVG_ATTR(Intercept  , SkSVGNumberType,                          0)
    SVG_ATTR(Offset     , SkSVGNumberType,                          0)
    SVG_ATTR(Slope      , SkSVGNumberType,                          1)
    SVG_ATTR(TableValues, std::vector<SkSVGNumberType>,            {})
    SVG_ATTR(Type       , SkSVGFeFuncType, SkSVGFeFuncType::kIdentity)

    std::vector<uint8_t> getTable() const;

protected:
    bool parseAndSetAttribute(const char*, const char*) override;

private:
    SkSVGFeFunc(SkSVGTag tag) : INHERITED(tag) {}

    using INHERITED = SkSVGHiddenContainer;
};

class SK_API SkSVGFeComponentTransfer final : public SkSVGFe {
public:
    static constexpr SkSVGTag tag = SkSVGTag::kFeComponentTransfer;

    static sk_sp<SkSVGFeComponentTransfer> Make() {
        return sk_sp<SkSVGFeComponentTransfer>(new SkSVGFeComponentTransfer());
    }

protected:
    sk_sp<SkImageFilter> onMakeImageFilter(const SkSVGRenderContext&,
                                           const SkSVGFilterContext&) const override;

    std::vector<SkSVGFeInputType> getInputs() const override { return {this->getIn()}; }

private:
    SkSVGFeComponentTransfer() : INHERITED(tag) {}

    using INHERITED = SkSVGFe;
};

#endif //  SkSVGFeComponentTransfer_DEFINED