62a683e476
- Add primitiveUnits attribute to SkSVGFilter class - Add optional x, y, width, height attributes to filter effect base class (SkSVGFe) - Add function to return list of inputs for all filter effects - Add function to compute filter primitive subregion and use it in all filter effect classes. Currently the "primitive subregion" just returns the entire filter effect region, so there should be no diffs on gold with this change. Bug: skia:10841 Change-Id: I1de283bebe302c0710d6b09d62a2472787820a49 Reviewed-on: https://skia-review.googlesource.com/c/skia/+/343107 Reviewed-by: Florin Malita <fmalita@chromium.org> Commit-Queue: Tyler Denniston <tdenniston@google.com>
53 lines
1.7 KiB
C++
53 lines
1.7 KiB
C++
/*
|
|
* Copyright 2020 Google Inc.
|
|
*
|
|
* Use of this source code is governed by a BSD-style license that can be
|
|
* found in the LICENSE file.
|
|
*/
|
|
|
|
#ifndef SkSVGFe_DEFINED
|
|
#define SkSVGFe_DEFINED
|
|
|
|
#include <vector>
|
|
|
|
#include "modules/svg/include/SkSVGHiddenContainer.h"
|
|
|
|
class SkImageFilter;
|
|
class SkSVGFilterContext;
|
|
|
|
class SkSVGFe : public SkSVGHiddenContainer {
|
|
public:
|
|
static bool IsFilterEffect(const sk_sp<SkSVGNode>& node) {
|
|
return node->tag() == SkSVGTag::kFeTurbulence || node->tag() == SkSVGTag::kFeColorMatrix ||
|
|
node->tag() == SkSVGTag::kFeComposite || node->tag() == SkSVGTag::kFeFlood;
|
|
}
|
|
|
|
sk_sp<SkImageFilter> makeImageFilter(const SkSVGRenderContext& ctx,
|
|
const SkSVGFilterContext& fctx) const;
|
|
|
|
// https://www.w3.org/TR/SVG11/filters.html#FilterPrimitiveSubRegion
|
|
SkRect resolveFilterSubregion(const SkSVGRenderContext&, const SkSVGFilterContext&) const;
|
|
|
|
SVG_ATTR(In, SkSVGFeInputType, SkSVGFeInputType(SkSVGFeInputType::Type::kSourceGraphic))
|
|
SVG_ATTR(Result, SkSVGStringType, SkSVGStringType())
|
|
SVG_OPTIONAL_ATTR(X, SkSVGLength)
|
|
SVG_OPTIONAL_ATTR(Y, SkSVGLength)
|
|
SVG_OPTIONAL_ATTR(Width, SkSVGLength)
|
|
SVG_OPTIONAL_ATTR(Height, SkSVGLength)
|
|
|
|
protected:
|
|
explicit SkSVGFe(SkSVGTag t) : INHERITED(t) {}
|
|
|
|
virtual sk_sp<SkImageFilter> onMakeImageFilter(const SkSVGRenderContext&,
|
|
const SkSVGFilterContext&) const = 0;
|
|
|
|
virtual std::vector<SkSVGFeInputType> getInputs() const = 0;
|
|
|
|
bool parseAndSetAttribute(const char*, const char*) override;
|
|
|
|
private:
|
|
using INHERITED = SkSVGHiddenContainer;
|
|
};
|
|
|
|
#endif // SkSVGFe_DEFINED
|