1cb93a386Sopenharmony_ci/* 2cb93a386Sopenharmony_ci * Copyright 2020 Google Inc. 3cb93a386Sopenharmony_ci * 4cb93a386Sopenharmony_ci * Use of this source code is governed by a BSD-style license that can be 5cb93a386Sopenharmony_ci * found in the LICENSE file. 6cb93a386Sopenharmony_ci */ 7cb93a386Sopenharmony_ci 8cb93a386Sopenharmony_ci#include "include/effects/SkImageFilters.h" 9cb93a386Sopenharmony_ci#include "modules/svg/include/SkSVGAttributeParser.h" 10cb93a386Sopenharmony_ci#include "modules/svg/include/SkSVGFeOffset.h" 11cb93a386Sopenharmony_ci#include "modules/svg/include/SkSVGFilterContext.h" 12cb93a386Sopenharmony_ci#include "modules/svg/include/SkSVGRenderContext.h" 13cb93a386Sopenharmony_ci#include "modules/svg/include/SkSVGValue.h" 14cb93a386Sopenharmony_ci 15cb93a386Sopenharmony_cibool SkSVGFeOffset::parseAndSetAttribute(const char* name, const char* value) { 16cb93a386Sopenharmony_ci return INHERITED::parseAndSetAttribute(name, value) || 17cb93a386Sopenharmony_ci this->setDx(SkSVGAttributeParser::parse<SkSVGNumberType>("dx", name, value)) || 18cb93a386Sopenharmony_ci this->setDy(SkSVGAttributeParser::parse<SkSVGNumberType>("dy", name, value)); 19cb93a386Sopenharmony_ci} 20cb93a386Sopenharmony_ci 21cb93a386Sopenharmony_cisk_sp<SkImageFilter> SkSVGFeOffset::onMakeImageFilter(const SkSVGRenderContext& ctx, 22cb93a386Sopenharmony_ci const SkSVGFilterContext& fctx) const { 23cb93a386Sopenharmony_ci const auto d = SkV2{this->getDx(), this->getDy()} 24cb93a386Sopenharmony_ci * ctx.transformForCurrentOBB(fctx.primitiveUnits()).scale; 25cb93a386Sopenharmony_ci 26cb93a386Sopenharmony_ci sk_sp<SkImageFilter> in = 27cb93a386Sopenharmony_ci fctx.resolveInput(ctx, this->getIn(), this->resolveColorspace(ctx, fctx)); 28cb93a386Sopenharmony_ci return SkImageFilters::Offset(d.x, d.y, std::move(in), this->resolveFilterSubregion(ctx, fctx)); 29cb93a386Sopenharmony_ci} 30