[svg] Implement SourceAlpha input for filter effects

https://www.w3.org/TR/SVG11/filters.html#SourceAlpha

This is the last "trivial" filter input type.

Bug: skia:10841
Change-Id: I96a7c9ccd318dec3b2b3ddd656be714b6b8fc59e
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/356838
Reviewed-by: Florin Malita <fmalita@chromium.org>
Commit-Queue: Tyler Denniston <tdenniston@google.com>
This commit is contained in:
Tyler Denniston 2021-01-21 11:19:53 -05:00 committed by Skia Commit-Bot
parent cff854282d
commit 8a37fb2c60

View File

@ -6,6 +6,7 @@
*/
#include "include/core/SkColorFilter.h"
#include "include/effects/SkColorMatrix.h"
#include "include/effects/SkImageFilters.h"
#include "modules/svg/include/SkSVGFilterContext.h"
#include "modules/svg/include/SkSVGNode.h"
@ -54,6 +55,12 @@ std::tuple<sk_sp<SkImageFilter>, SkSVGColorspace> SkSVGFilterContext::getInput(
SkSVGColorspace inputCS = SkSVGColorspace::kSRGB;
sk_sp<SkImageFilter> result;
switch (inputType.type()) {
case SkSVGFeInputType::Type::kSourceAlpha: {
SkColorMatrix m;
m.setScale(0, 0, 0, 1.0f);
result = SkImageFilters::ColorFilter(SkColorFilters::Matrix(m), nullptr);
break;
}
case SkSVGFeInputType::Type::kSourceGraphic:
// Do nothing.
break;