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