Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
third_party
skia
modules
svg
src
SkSVGFeImage.cpp
Go to the documentation of this file.
1
/*
2
* Copyright 2021 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
#include "
include/core/SkSamplingOptions.h
"
9
#include "
include/effects/SkImageFilters.h
"
10
#include "
modules/svg/include/SkSVGFeImage.h
"
11
#include "
modules/svg/include/SkSVGFilterContext.h
"
12
#include "
modules/svg/include/SkSVGImage.h
"
13
#include "
modules/svg/include/SkSVGRenderContext.h
"
14
#include "
modules/svg/include/SkSVGValue.h
"
15
16
bool
SkSVGFeImage::parseAndSetAttribute
(
const
char
* n,
const
char
* v) {
17
return
INHERITED::parseAndSetAttribute
(n, v) ||
18
this->setHref(SkSVGAttributeParser::parse<SkSVGIRI>(
"xlink:href"
, n, v)) ||
19
this->setPreserveAspectRatio(SkSVGAttributeParser::parse<SkSVGPreserveAspectRatio>(
20
"preserveAspectRatio"
, n, v));
21
}
22
23
sk_sp<SkImageFilter>
SkSVGFeImage::onMakeImageFilter
(
const
SkSVGRenderContext
& ctx,
24
const
SkSVGFilterContext
& fctx)
const
{
25
// Load image and map viewbox (image bounds) to viewport (filter effects subregion).
26
const
SkRect
viewport = this->
resolveFilterSubregion
(ctx, fctx);
27
const
auto
imgInfo =
28
SkSVGImage::LoadImage
(ctx.
resourceProvider
(), fHref, viewport, fPreserveAspectRatio);
29
if
(!imgInfo.fImage) {
30
return
nullptr
;
31
}
32
33
// Create the image filter mapped according to aspect ratio
34
const
SkRect
srcRect =
SkRect::Make
(imgInfo.fImage->bounds());
35
const
SkRect
& dstRect = imgInfo.fDst;
36
// TODO: image-rendering property
37
auto
imgfilt =
SkImageFilters::Image
(imgInfo.fImage, srcRect, dstRect,
38
SkSamplingOptions
(
SkFilterMode::kLinear
,
39
SkMipmapMode::kNearest
));
40
41
// Aspect ratio mapping may end up drawing content outside of the filter effects region,
42
// so perform an explicit crop.
43
return
SkImageFilters::Merge
(&imgfilt, 1, fctx.
filterEffectsRegion
());
44
}
SkImageFilters.h
SkSVGFeImage.h
SkSVGFilterContext.h
SkSVGImage.h
SkSVGRenderContext.h
SkSVGValue.h
SkSamplingOptions.h
SkFilterMode::kLinear
@ kLinear
SkMipmapMode::kNearest
@ kNearest
SkImageFilters::Merge
static sk_sp< SkImageFilter > Merge(sk_sp< SkImageFilter > *const filters, int count, const CropRect &cropRect={})
Definition
SkMergeImageFilter.cpp:55
SkImageFilters::Image
static sk_sp< SkImageFilter > Image(sk_sp< SkImage > image, const SkRect &srcRect, const SkRect &dstRect, const SkSamplingOptions &sampling)
Definition
SkImageImageFilter.cpp:77
SkSVGFeImage::parseAndSetAttribute
bool parseAndSetAttribute(const char *, const char *) override
Definition
SkSVGFeImage.cpp:16
SkSVGFeImage::onMakeImageFilter
sk_sp< SkImageFilter > onMakeImageFilter(const SkSVGRenderContext &, const SkSVGFilterContext &) const override
Definition
SkSVGFeImage.cpp:23
SkSVGFe::resolveFilterSubregion
SkRect resolveFilterSubregion(const SkSVGRenderContext &, const SkSVGFilterContext &) const
Definition
SkSVGFe.cpp:54
SkSVGFe::parseAndSetAttribute
bool parseAndSetAttribute(const char *, const char *) override
Definition
SkSVGFe.cpp:93
SkSVGFilterContext
Definition
SkSVGFilterContext.h:21
SkSVGFilterContext::filterEffectsRegion
const SkRect & filterEffectsRegion() const
Definition
SkSVGFilterContext.h:29
SkSVGImage::LoadImage
static ImageInfo LoadImage(const sk_sp< skresources::ResourceProvider > &, const SkSVGIRI &, const SkRect &, SkSVGPreserveAspectRatio)
Definition
SkSVGImage.cpp:57
SkSVGRenderContext
Definition
SkSVGRenderContext.h:63
SkSVGRenderContext::resourceProvider
const sk_sp< skresources::ResourceProvider > & resourceProvider() const
Definition
SkSVGRenderContext.h:142
sk_sp
Definition
SkRefCnt.h:220
SkRect
Definition
extension.cpp:13
SkRect::Make
static SkRect Make(const SkISize &size)
Definition
SkRect.h:669
SkSamplingOptions
Definition
SkSamplingOptions.h:58
Generated on Fri Apr 26 2024 06:16:27 for Flutter Engine by
1.9.8