Remove SkImageFilter_Base::OutputProperties

This moves OutputProperties' fields into Context and decouples SkSpecialImage
makeSurface() functions from SkImageFilter_Base.

It adds a utility makeSurface() function to Context that calls the SkSpecialImage
functions. Currently that requires the source image to be provided to it.
In a later CL, Context will hold the source image and this makeSurface() function
will be even simpler to use.

This is split out from https://skia-review.googlesource.com/c/skia/+/232517

Bug: skia:9282
Change-Id: I3d742af323a1440e0dab54a576d45a4a44dc719b
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/234516
Commit-Queue: Michael Ludwig <michaelludwig@google.com>
Reviewed-by: Robert Phillips <robertphillips@google.com>
This commit is contained in:
Michael Ludwig 2019-08-14 14:35:15 -04:00 committed by Skia Commit-Bot
parent d566e2eab7
commit 03f9ca323a
30 changed files with 181 additions and 192 deletions

View File

@ -625,9 +625,8 @@ void SkBitmapDevice::drawSpecial(SkSpecialImage* src, int x, int y, const SkPain
SkMatrix::MakeTrans(SkIntToScalar(-x), SkIntToScalar(-y)), this->ctm());
const SkIRect clipBounds = fRCStack.rc().getBounds().makeOffset(-x, -y);
sk_sp<SkImageFilterCache> cache(this->getImageFilterCache());
SkImageFilter_Base::OutputProperties outputProperties(fBitmap.colorType(),
fBitmap.colorSpace());
SkImageFilter_Base::Context ctx(matrix, clipBounds, cache.get(), outputProperties);
SkImageFilter_Base::Context ctx(matrix, clipBounds, cache.get(), fBitmap.colorType(),
fBitmap.colorSpace());
filteredImage = as_IFB(filter)->filterImage(src, ctx, &offset);
if (!filteredImage) {

View File

@ -301,14 +301,12 @@ bool SkImageFilter_Base::applyCropRect(const Context& ctx, const SkIRect& srcBou
// Return a larger (newWidth x newHeight) copy of 'src' with black padding
// around it.
static sk_sp<SkSpecialImage> pad_image(SkSpecialImage* src,
const SkImageFilter_Base::OutputProperties& outProps,
static sk_sp<SkSpecialImage> pad_image(SkSpecialImage* src, const SkImageFilter_Base::Context& ctx,
int newWidth, int newHeight, int offX, int offY) {
// We would like to operate in the source's color space (so that we return an "identical"
// image, other than the padding. To achieve that, we'd create new output properties:
//
// SkImageFilter::OutputProperties outProps(src->getColorSpace());
//
// image, other than the padding. To achieve that, we'd create a new context using
// src->getColorSpace() to replace ctx.colorSpace().
// That fails in at least two ways. For formats that are texturable but not renderable (like
// F16 on some ES implementations), we can't create a surface to do the work. For sRGB, images
// may be tagged with an sRGB color space (which leads to an sRGB config in makeSurface). But
@ -320,7 +318,7 @@ static sk_sp<SkSpecialImage> pad_image(SkSpecialImage* src,
// switched to the destination space anyway. The one exception would be a filter that expected
// to consume unclamped F16 data, but the padded version of the image is pre-clamped to 8888.
// We can revisit this logic if that ever becomes an actual problem.
sk_sp<SkSpecialSurface> surf(src->makeSurface(outProps, SkISize::Make(newWidth, newHeight)));
sk_sp<SkSpecialSurface> surf(ctx.makeSurface(src, SkISize::Make(newWidth, newHeight)));
if (!surf) {
return nullptr;
}
@ -349,8 +347,7 @@ sk_sp<SkSpecialImage> SkImageFilter_Base::applyCropRectAndPad(const Context& ctx
if (srcBounds.contains(*bounds)) {
return sk_sp<SkSpecialImage>(SkRef(src));
} else {
sk_sp<SkSpecialImage> img(pad_image(src, ctx.outputProperties(),
bounds->width(), bounds->height(),
sk_sp<SkSpecialImage> img(pad_image(src, ctx, bounds->width(), bounds->height(),
Sk32_sat_sub(srcOffset->x(), bounds->x()),
Sk32_sat_sub(srcOffset->y(), bounds->y())));
*srcOffset = SkIPoint::Make(bounds->x(), bounds->y());
@ -403,28 +400,27 @@ SkImageFilter_Base::Context SkImageFilter_Base::mapContext(const Context& ctx) c
SkIRect clipBounds = this->onFilterNodeBounds(ctx.clipBounds(), ctx.ctm(),
MapDirection::kReverse_MapDirection,
&ctx.clipBounds());
return Context(ctx.ctm(), clipBounds, ctx.cache(), ctx.outputProperties());
return Context(ctx.ctm(), clipBounds, ctx.cache(), ctx.colorType(), ctx.colorSpace());
}
#if SK_SUPPORT_GPU
sk_sp<SkSpecialImage> SkImageFilter_Base::DrawWithFP(GrRecordingContext* context,
std::unique_ptr<GrFragmentProcessor> fp,
const SkIRect& bounds,
const OutputProperties& outputProperties,
SkColorType colorType,
const SkColorSpace* colorSpace,
GrProtected isProtected) {
GrPaint paint;
paint.addColorFragmentProcessor(std::move(fp));
paint.setPorterDuffXPFactory(SkBlendMode::kSrc);
sk_sp<SkColorSpace> colorSpace = sk_ref_sp(outputProperties.colorSpace());
GrColorType colorType = SkColorTypeToGrColorType(outputProperties.colorType());
sk_sp<GrRenderTargetContext> renderTargetContext(
context->priv().makeDeferredRenderTargetContext(
SkBackingFit::kApprox,
bounds.width(),
bounds.height(),
colorType,
std::move(colorSpace),
SkColorTypeToGrColorType(colorType),
sk_ref_sp(colorSpace),
1,
GrMipMapped::kNo,
kBottomLeft_GrSurfaceOrigin,
@ -449,21 +445,22 @@ sk_sp<SkSpecialImage> SkImageFilter_Base::DrawWithFP(GrRecordingContext* context
}
sk_sp<SkSpecialImage> SkImageFilter_Base::ImageToColorSpace(SkSpecialImage* src,
const OutputProperties& outProps) {
SkColorType colorType,
SkColorSpace* colorSpace) {
// There are several conditions that determine if we actually need to convert the source to the
// destination's color space. Rather than duplicate that logic here, just try to make an xform
// object. If that produces something, then both are tagged, and the source is in a different
// gamut than the dest. There is some overhead to making the xform, but those are cached, and
// if we get one back, that means we're about to use it during the conversion anyway.
auto colorSpaceXform = GrColorSpaceXform::Make(src->getColorSpace(), src->alphaType(),
outProps.colorSpace(), kPremul_SkAlphaType);
colorSpace, kPremul_SkAlphaType);
if (!colorSpaceXform) {
// No xform needed, just return the original image
return sk_ref_sp(src);
}
sk_sp<SkSpecialSurface> surf(src->makeSurface(outProps,
sk_sp<SkSpecialSurface> surf(src->makeSurface(colorType, colorSpace,
SkISize::Make(src->width(), src->height())));
if (!surf) {
return sk_ref_sp(src);

View File

@ -17,10 +17,11 @@
#include "include/gpu/GrTypes.h"
#endif
#include "src/core/SkSpecialImage.h"
#include "src/core/SkSpecialSurface.h"
class GrFragmentProcessor;
class GrRecordingContext;
class SkSpecialImage;
class SkSpecialSurface;
class SkImageFilterCache;
struct SkImageFilterCacheKey;
@ -28,55 +29,63 @@ struct SkImageFilterCacheKey;
// actual API surface that Skia will use to compute the filtered images.
class SkImageFilter_Base : public SkImageFilter {
public:
// Extra information about the output of a filter DAG. For now, this is just the color space
// (of the original requesting device). This is used when constructing intermediate rendering
// surfaces, so that we ensure we land in a surface that's similar/compatible to the final
// consumer of the DAG's output.
class OutputProperties {
public:
explicit OutputProperties(SkColorType colorType, SkColorSpace* colorSpace)
: fColorType(colorType), fColorSpace(colorSpace) {}
SkColorType colorType() const { return fColorType; }
SkColorSpace* colorSpace() const { return fColorSpace; }
private:
SkColorType fColorType;
// This will be a pointer to the device's color space, and our lifetime is bounded by
// the device, so we can store a bare pointer.
SkColorSpace* fColorSpace;
};
// The context contains all necessary information to describe how the image filter should be
// computed (i.e. the current layer matrix and clip), and the color information of the output of
// a filter DAG. For now, this is just the color space (of the original requesting device). This
// is used when constructing intermediate rendering surfaces, so that we ensure we land in a
// surface that's similar/compatible to the final consumer of the DAG's output.
class Context {
public:
// Creates a context with the given layer matrix and destination clip, reading from 'source'
// with an origin of (0,0).
Context(const SkMatrix& ctm, const SkIRect& clipBounds, SkImageFilterCache* cache,
const OutputProperties& outputProperties)
SkColorType colorType, SkColorSpace* colorSpace)
: fCTM(ctm)
, fClipBounds(clipBounds)
, fCache(cache)
, fOutputProperties(outputProperties)
{}
, fColorType(colorType)
, fColorSpace(colorSpace) {}
const SkMatrix& ctm() const { return fCTM; }
const SkIRect& clipBounds() const { return fClipBounds; }
SkImageFilterCache* cache() const { return fCache; }
const OutputProperties& outputProperties() const { return fOutputProperties; }
// The output device's color type, which can be used for intermediate images to be
// compatible with the eventual target of the filtered result.
SkColorType colorType() const { return fColorType; }
#if SK_SUPPORT_GPU
GrColorType grColorType() const { return SkColorTypeToGrColorType(fColorType); }
#endif
// The output device's color space, so intermediate images can match, and so filtering can
// be performed in the destination color space.
SkColorSpace* colorSpace() const { return fColorSpace; }
sk_sp<SkColorSpace> refColorSpace() const { return sk_ref_sp(fColorSpace); }
/**
* Since a context can be build directly, its constructor has no chance to
* "return null" if it's given invalid or unsupported inputs. Call this to
* know of the the context can be used.
* Since a context can be built directly, its constructor has no chance to "return null" if
* it's given invalid or unsupported inputs. Call this to know of the the context can be
* used.
*
* The SkImageFilterCache Key, for example, requires a finite ctm (no infinities
* or NaN), so that test is part of isValid.
* The SkImageFilterCache Key, for example, requires a finite ctm (no infinities or NaN),
* so that test is part of isValid.
*/
bool isValid() const { return fCTM.isFinite(); }
// Create a surface of the given size, that matches the context's color type and color space
// as closely as possible, and uses the same backend of the device that produced the source
// image.
sk_sp<SkSpecialSurface> makeSurface(const SkSpecialImage* source, const SkISize& size,
const SkSurfaceProps* props = nullptr) const {
return source->makeSurface(fColorType, fColorSpace, size, kPremul_SkAlphaType, props);
}
private:
SkMatrix fCTM;
SkIRect fClipBounds;
SkImageFilterCache* fCache;
OutputProperties fOutputProperties;
SkColorType fColorType;
// This pointer is owned by the device controlling the filter process, and our
// lifetime is bounded by the device, so it can be a bare pointer.
SkColorSpace* fColorSpace;
};
/**
@ -303,10 +312,10 @@ protected:
#if SK_SUPPORT_GPU
static sk_sp<SkSpecialImage> DrawWithFP(GrRecordingContext* context,
std::unique_ptr<GrFragmentProcessor>
fp,
std::unique_ptr<GrFragmentProcessor> fp,
const SkIRect& bounds,
const OutputProperties& outputProperties,
SkColorType colorType,
const SkColorSpace* colorSpace,
GrProtected isProtected = GrProtected::kNo);
/**
@ -314,7 +323,9 @@ protected:
* with the same gamut as the one from the OutputProperties. This allows filters that do many
* texture samples to guarantee that any color space conversion has happened before running.
*/
static sk_sp<SkSpecialImage> ImageToColorSpace(SkSpecialImage* src, const OutputProperties&);
static sk_sp<SkSpecialImage> ImageToColorSpace(SkSpecialImage* src,
SkColorType colorType,
SkColorSpace* colorSpace);
#endif
// If 'srcBounds' will sample outside the border of 'originalSrcBounds' (i.e., the sample

View File

@ -47,7 +47,7 @@ sk_sp<SkSpecialImage> SkLocalMatrixImageFilter::onFilterImage(SkSpecialImage* so
const Context& ctx,
SkIPoint* offset) const {
Context localCtx(SkMatrix::Concat(ctx.ctm(), fLocalM), ctx.clipBounds(), ctx.cache(),
ctx.outputProperties());
ctx.colorType(), ctx.colorSpace());
return this->filterInput(0, source, localCtx, offset);
}

View File

@ -70,7 +70,7 @@ sk_sp<SkSpecialImage> SkMatrixImageFilter::onFilterImage(SkSpecialImage* source,
SkIRect dstBounds;
dstRect.roundOut(&dstBounds);
sk_sp<SkSpecialSurface> surf(input->makeSurface(ctx.outputProperties(), dstBounds.size()));
sk_sp<SkSpecialSurface> surf(ctx.makeSurface(source, dstBounds.size()));
if (!surf) {
return nullptr;
}

View File

@ -58,7 +58,7 @@ public:
virtual sk_sp<SkSpecialImage> onMakeSubset(const SkIRect& subset) const = 0;
virtual sk_sp<SkSpecialSurface> onMakeSurface(
const SkImageFilter_Base::OutputProperties& outProps, const SkISize& size,
SkColorType colorType, const SkColorSpace* colorSpace, const SkISize& size,
SkAlphaType at, const SkSurfaceProps* = nullptr) const = 0;
// This subset (when not null) is relative to the backing store's coordinate frame, it has
@ -66,7 +66,7 @@ public:
virtual sk_sp<SkImage> onAsImage(const SkIRect* subset) const = 0;
virtual sk_sp<SkSurface> onMakeTightSurface(
const SkImageFilter_Base::OutputProperties& outProps,
SkColorType colorType, const SkColorSpace* colorSpace,
const SkISize& size, SkAlphaType at) const = 0;
private:
@ -159,15 +159,15 @@ sk_sp<GrTextureProxy> SkSpecialImage::asTextureProxyRef(GrRecordingContext* cont
#endif
sk_sp<SkSpecialSurface> SkSpecialImage::makeSurface(
const SkImageFilter_Base::OutputProperties& outProps, const SkISize& size,
SkColorType colorType, const SkColorSpace* colorSpace, const SkISize& size,
SkAlphaType at, const SkSurfaceProps* props) const {
return as_SIB(this)->onMakeSurface(outProps, size, at, props);
return as_SIB(this)->onMakeSurface(colorType, colorSpace, size, at, props);
}
sk_sp<SkSurface> SkSpecialImage::makeTightSurface(
const SkImageFilter_Base::OutputProperties& outProps, const SkISize& size,
SkColorType colorType, const SkColorSpace* colorSpace, const SkISize& size,
SkAlphaType at) const {
return as_SIB(this)->onMakeTightSurface(outProps, size, at);
return as_SIB(this)->onMakeTightSurface(colorType, colorSpace, size, at);
}
sk_sp<SkSpecialImage> SkSpecialImage::makeSubset(const SkIRect& subset) const {
@ -265,11 +265,11 @@ public:
}
#endif
sk_sp<SkSpecialSurface> onMakeSurface(const SkImageFilter_Base::OutputProperties& outProps,
sk_sp<SkSpecialSurface> onMakeSurface(SkColorType colorType, const SkColorSpace* colorSpace,
const SkISize& size, SkAlphaType at,
const SkSurfaceProps* props) const override {
SkColorSpace* colorSpace = outProps.colorSpace();
SkColorType colorType = kN32_SkColorType; // TODO: find ways to allow f16
// Ignore the requested color type, the raster backend currently only supports N32
colorType = kN32_SkColorType; // TODO: find ways to allow f16
SkImageInfo info = SkImageInfo::Make(size.width(), size.height(), colorType, at,
sk_ref_sp(colorSpace));
return SkSpecialSurface::MakeRaster(info, props);
@ -294,10 +294,10 @@ public:
return SkImage::MakeFromBitmap(fBitmap);
}
sk_sp<SkSurface> onMakeTightSurface(const SkImageFilter_Base::OutputProperties& outProps,
sk_sp<SkSurface> onMakeTightSurface(SkColorType colorType, const SkColorSpace* colorSpace,
const SkISize& size, SkAlphaType at) const override {
SkColorSpace* colorSpace = outProps.colorSpace();
SkColorType colorType = kN32_SkColorType; // TODO: find ways to allow f16
// Ignore the requested color type, the raster backend currently only supports N32
colorType = kN32_SkColorType; // TODO: find ways to allow f16
SkImageInfo info = SkImageInfo::Make(size.width(), size.height(), colorType, at,
sk_ref_sp(colorSpace));
return SkSurface::MakeRaster(info);
@ -455,16 +455,15 @@ public:
return fColorSpace.get();
}
sk_sp<SkSpecialSurface> onMakeSurface(const SkImageFilter_Base::OutputProperties& outProps,
const SkISize& size, SkAlphaType at,
sk_sp<SkSpecialSurface> onMakeSurface(SkColorType colorType, const SkColorSpace* colorSpace, const SkISize& size, SkAlphaType at,
const SkSurfaceProps* props) const override {
if (!fContext) {
return nullptr;
}
return SkSpecialSurface::MakeRenderTarget(fContext, size.width(), size.height(),
SkColorTypeToGrColorType(outProps.colorType()),
sk_ref_sp(outProps.colorSpace()), props);
SkColorTypeToGrColorType(colorType),
sk_ref_sp(colorSpace), props);
}
sk_sp<SkSpecialImage> onMakeSubset(const SkIRect& subset) const override {
@ -509,10 +508,12 @@ public:
return wrap_proxy_in_image(fContext, fTextureProxy, fAlphaType, fColorSpace);
}
sk_sp<SkSurface> onMakeTightSurface(const SkImageFilter_Base::OutputProperties& outProps,
sk_sp<SkSurface> onMakeTightSurface(SkColorType colorType, const SkColorSpace* colorSpace,
const SkISize& size, SkAlphaType at) const override {
SkColorSpace* colorSpace = outProps.colorSpace();
SkColorType colorType = colorSpace && colorSpace->gammaIsLinear()
// TODO (michaelludwig): Why does this ignore colorType but onMakeSurface doesn't ignore it?
// Once makeTightSurface() goes away, should this type overriding behavior be moved into
// onMakeSurface() or is this unnecessary?
colorType = colorSpace && colorSpace->gammaIsLinear()
? kRGBA_F16_SkColorType : kRGBA_8888_SkColorType;
SkImageInfo info = SkImageInfo::Make(size.width(), size.height(), colorType, at,
sk_ref_sp(colorSpace));

View File

@ -11,7 +11,6 @@
#include "include/core/SkImageInfo.h"
#include "include/core/SkRefCnt.h"
#include "include/core/SkSurfaceProps.h"
#include "src/core/SkImageFilter_Base.h"
#include "src/core/SkNextID.h"
class GrRecordingContext;
@ -91,7 +90,8 @@ public:
/**
* Create a new special surface with a backend that is compatible with this special image.
*/
sk_sp<SkSpecialSurface> makeSurface(const SkImageFilter_Base::OutputProperties& outProps,
sk_sp<SkSpecialSurface> makeSurface(SkColorType colorType,
const SkColorSpace* colorSpace,
const SkISize& size,
SkAlphaType at = kPremul_SkAlphaType,
const SkSurfaceProps* props = nullptr) const;
@ -99,8 +99,11 @@ public:
/**
* Create a new surface with a backend that is compatible with this special image.
* TODO: switch this to makeSurface once we resolved the naming issue
* TODO (michaelludwig) - This is only used by SkTileImageFilter, which appears should be
* updated to work correctly with subsets and then makeTightSurface() can go away entirely.
*/
sk_sp<SkSurface> makeTightSurface(const SkImageFilter_Base::OutputProperties& outProps,
sk_sp<SkSurface> makeTightSurface(SkColorType colorType,
const SkColorSpace* colorSpace,
const SkISize& size,
SkAlphaType at = kPremul_SkAlphaType) const;

View File

@ -170,12 +170,11 @@ sk_sp<SkSpecialImage> SkAlphaThresholdFilterImpl::onFilterImage(SkSpecialImage*
return nullptr;
}
const OutputProperties& outProps = ctx.outputProperties();
auto textureFP = GrSimpleTextureEffect::Make(std::move(inputProxy),
SkMatrix::MakeTrans(input->subset().x(),
input->subset().y()));
textureFP = GrColorSpaceXformEffect::Make(std::move(textureFP), input->getColorSpace(),
input->alphaType(), outProps.colorSpace());
input->alphaType(), ctx.colorSpace());
if (!textureFP) {
return nullptr;
}
@ -192,7 +191,7 @@ sk_sp<SkSpecialImage> SkAlphaThresholdFilterImpl::onFilterImage(SkSpecialImage*
std::move(thresholdFP) };
auto fp = GrFragmentProcessor::RunInSeries(fpSeries, 2);
return DrawWithFP(context, std::move(fp), bounds, outProps,
return DrawWithFP(context, std::move(fp), bounds, ctx.colorType(), ctx.colorSpace(),
isProtected ? GrProtected::kYes : GrProtected::kNo);
}
#endif

View File

@ -63,12 +63,12 @@ protected:
#if SK_SUPPORT_GPU
sk_sp<SkSpecialImage> filterImageGPU(SkSpecialImage* source,
const Context& ctx,
sk_sp<SkSpecialImage> background,
const SkIPoint& backgroundOffset,
sk_sp<SkSpecialImage> foreground,
const SkIPoint& foregroundOffset,
const SkIRect& bounds,
const OutputProperties& outputProperties) const;
const SkIRect& bounds) const;
#endif
void flatten(SkWriteBuffer& buffer) const override;
@ -240,12 +240,12 @@ sk_sp<SkSpecialImage> ArithmeticImageFilterImpl::onFilterImage(SkSpecialImage* s
#if SK_SUPPORT_GPU
if (source->isTextureBacked()) {
return this->filterImageGPU(source, background, backgroundOffset, foreground,
foregroundOffset, bounds, ctx.outputProperties());
return this->filterImageGPU(source, ctx, background, backgroundOffset, foreground,
foregroundOffset, bounds);
}
#endif
sk_sp<SkSpecialSurface> surf(source->makeSurface(ctx.outputProperties(), bounds.size()));
sk_sp<SkSpecialSurface> surf(ctx.makeSurface(source, bounds.size()));
if (!surf) {
return nullptr;
}
@ -326,12 +326,12 @@ SkIRect ArithmeticImageFilterImpl::onFilterBounds(const SkIRect& src,
sk_sp<SkSpecialImage> ArithmeticImageFilterImpl::filterImageGPU(
SkSpecialImage* source,
const Context& ctx,
sk_sp<SkSpecialImage> background,
const SkIPoint& backgroundOffset,
sk_sp<SkSpecialImage> foreground,
const SkIPoint& foregroundOffset,
const SkIRect& bounds,
const OutputProperties& outputProperties) const {
const SkIRect& bounds) const {
SkASSERT(source->isTextureBacked());
auto context = source->getContext();
@ -363,7 +363,7 @@ sk_sp<SkSpecialImage> ArithmeticImageFilterImpl::filterImageGPU(
GrTextureDomain::kDecal_Mode, GrSamplerState::Filter::kNearest);
bgFP = GrColorSpaceXformEffect::Make(std::move(bgFP), background->getColorSpace(),
background->alphaType(),
outputProperties.colorSpace());
ctx.colorSpace());
} else {
bgFP = GrConstColorProcessor::Make(SK_PMColor4fTRANSPARENT,
GrConstColorProcessor::InputMode::kIgnore);
@ -381,7 +381,7 @@ sk_sp<SkSpecialImage> ArithmeticImageFilterImpl::filterImageGPU(
foregroundFP = GrColorSpaceXformEffect::Make(std::move(foregroundFP),
foreground->getColorSpace(),
foreground->alphaType(),
outputProperties.colorSpace());
ctx.colorSpace());
paint.addColorFragmentProcessor(std::move(foregroundFP));
static int arithmeticIndex = GrSkSLFP::NewIndex();
@ -405,15 +405,13 @@ sk_sp<SkSpecialImage> ArithmeticImageFilterImpl::filterImageGPU(
paint.setPorterDuffXPFactory(SkBlendMode::kSrc);
GrColorType colorType = SkColorTypeToGrColorType(outputProperties.colorType());
sk_sp<GrRenderTargetContext> renderTargetContext(
context->priv().makeDeferredRenderTargetContext(
SkBackingFit::kApprox,
bounds.width(),
bounds.height(),
colorType,
sk_ref_sp(outputProperties.colorSpace()),
ctx.grColorType(),
ctx.refColorSpace(),
1,
GrMipMapped::kNo,
kBottomLeft_GrSurfaceOrigin,

View File

@ -54,9 +54,9 @@ private:
#if SK_SUPPORT_GPU
sk_sp<SkSpecialImage> gpuFilter(
SkSpecialImage *source, SkVector sigma, const sk_sp<SkSpecialImage> &input,
SkIRect inputBounds, SkIRect dstBounds, SkIPoint inputOffset,
const OutputProperties& outProps, SkIPoint* offset) const;
SkSpecialImage *source, const Context& ctx, SkVector sigma,
const sk_sp<SkSpecialImage> &input,
SkIRect inputBounds, SkIRect dstBounds, SkIPoint inputOffset, SkIPoint* offset) const;
#endif
SkSize fSigma;
@ -617,9 +617,9 @@ sk_sp<SkSpecialImage> SkBlurImageFilterImpl::onFilterImage(SkSpecialImage* sourc
if (source->isTextureBacked()) {
// Ensure the input is in the destination's gamut. This saves us from having to do the
// xform during the filter itself.
input = ImageToColorSpace(input.get(), ctx.outputProperties());
result = this->gpuFilter(source, sigma, input, inputBounds, dstBounds, inputOffset,
ctx.outputProperties(), &resultOffset);
input = ImageToColorSpace(input.get(), ctx.colorType(), ctx.colorSpace());
result = this->gpuFilter(source, ctx, sigma, input, inputBounds, dstBounds, inputOffset,
&resultOffset);
} else
#endif
{
@ -635,9 +635,9 @@ sk_sp<SkSpecialImage> SkBlurImageFilterImpl::onFilterImage(SkSpecialImage* sourc
#if SK_SUPPORT_GPU
sk_sp<SkSpecialImage> SkBlurImageFilterImpl::gpuFilter(
SkSpecialImage *source, SkVector sigma, const sk_sp<SkSpecialImage> &input,
SkIRect inputBounds, SkIRect dstBounds, SkIPoint inputOffset,
const OutputProperties& outProps, SkIPoint* offset) const
SkSpecialImage *source, const Context& ctx, SkVector sigma,
const sk_sp<SkSpecialImage> &input, SkIRect inputBounds, SkIRect dstBounds,
SkIPoint inputOffset, SkIPoint* offset) const
{
if (0 == sigma.x() && 0 == sigma.y()) {
offset->fX = inputBounds.x() + inputOffset.fX;
@ -652,11 +652,12 @@ sk_sp<SkSpecialImage> SkBlurImageFilterImpl::gpuFilter(
return nullptr;
}
// TODO (michaelludwig) - The color space choice is odd, should it just be ctx.refColorSpace()?
sk_sp<GrRenderTargetContext> renderTargetContext(SkGpuBlurUtils::GaussianBlur(
context,
std::move(inputTexture),
input->subset().topLeft(),
outProps.colorSpace() ? sk_ref_sp(input->getColorSpace()) : nullptr,
ctx.colorSpace() ? sk_ref_sp(input->getColorSpace()) : nullptr,
dstBounds,
inputBounds,
sigma.x(),

View File

@ -106,7 +106,7 @@ sk_sp<SkSpecialImage> SkColorFilterImageFilterImpl::onFilterImage(SkSpecialImage
return nullptr;
}
sk_sp<SkSpecialSurface> surf(source->makeSurface(ctx.outputProperties(), bounds.size()));
sk_sp<SkSpecialSurface> surf(ctx.makeSurface(source, bounds.size()));
if (!surf) {
return nullptr;
}

View File

@ -81,7 +81,8 @@ sk_sp<SkSpecialImage> SkComposeImageFilterImpl::onFilterImage(SkSpecialImage* so
SkIRect innerClipBounds;
innerClipBounds = this->getInput(0)->filterBounds(ctx.clipBounds(), ctx.ctm(),
kReverse_MapDirection, &ctx.clipBounds());
Context innerContext(ctx.ctm(), innerClipBounds, ctx.cache(), ctx.outputProperties());
Context innerContext(ctx.ctm(), innerClipBounds, ctx.cache(), ctx.colorType(),
ctx.colorSpace());
SkIPoint innerOffset = SkIPoint::Make(0, 0);
sk_sp<SkSpecialImage> inner(this->filterInput(1, source, innerContext, &innerOffset));
if (!inner) {
@ -92,7 +93,7 @@ sk_sp<SkSpecialImage> SkComposeImageFilterImpl::onFilterImage(SkSpecialImage* so
outerMatrix.postTranslate(SkIntToScalar(-innerOffset.x()), SkIntToScalar(-innerOffset.y()));
SkIRect clipBounds = ctx.clipBounds();
clipBounds.offset(-innerOffset.x(), -innerOffset.y());
Context outerContext(outerMatrix, clipBounds, ctx.cache(), ctx.outputProperties());
Context outerContext(outerMatrix, clipBounds, ctx.cache(), ctx.colorType(), ctx.colorSpace());
SkIPoint outerOffset = SkIPoint::Make(0, 0);
sk_sp<SkSpecialImage> outer(this->filterInput(0, inner.get(), outerContext, &outerOffset));

View File

@ -296,8 +296,7 @@ sk_sp<SkSpecialImage> SkDisplacementMapEffectImpl::onFilterImage(SkSpecialImage*
// With a more complex DAG attached to this input, it's not clear that working in ANY specific
// color space makes sense, so we ignore color spaces (and gamma) entirely. This may not be
// ideal, but it's at least consistent and predictable.
Context displContext(ctx.ctm(), ctx.clipBounds(), ctx.cache(),
OutputProperties(kN32_SkColorType, nullptr));
Context displContext(ctx.ctm(), ctx.clipBounds(), ctx.cache(), kN32_SkColorType, nullptr);
sk_sp<SkSpecialImage> displ(this->filterInput(0, source, displContext, &displOffset));
if (!displ) {
return nullptr;
@ -346,7 +345,6 @@ sk_sp<SkSpecialImage> SkDisplacementMapEffectImpl::onFilterImage(SkSpecialImage*
SkMatrix offsetMatrix = SkMatrix::MakeTrans(SkIntToScalar(colorOffset.fX - displOffset.fX),
SkIntToScalar(colorOffset.fY - displOffset.fY));
SkColorSpace* colorSpace = ctx.outputProperties().colorSpace();
std::unique_ptr<GrFragmentProcessor> fp =
GrDisplacementMapEffect::Make(fXChannelSelector,
@ -358,21 +356,20 @@ sk_sp<SkSpecialImage> SkDisplacementMapEffectImpl::onFilterImage(SkSpecialImage*
std::move(colorProxy),
color->subset());
fp = GrColorSpaceXformEffect::Make(std::move(fp), color->getColorSpace(),
color->alphaType(), colorSpace);
color->alphaType(), ctx.colorSpace());
GrPaint paint;
paint.addColorFragmentProcessor(std::move(fp));
paint.setPorterDuffXPFactory(SkBlendMode::kSrc);
SkMatrix matrix;
matrix.setTranslate(-SkIntToScalar(colorBounds.x()), -SkIntToScalar(colorBounds.y()));
GrColorType colorType = SkColorTypeToGrColorType(ctx.outputProperties().colorType());
sk_sp<GrRenderTargetContext> renderTargetContext(
context->priv().makeDeferredRenderTargetContext(SkBackingFit::kApprox,
bounds.width(),
bounds.height(),
colorType,
sk_ref_sp(colorSpace),
ctx.grColorType(),
ctx.refColorSpace(),
1,
GrMipMapped::kNo,
kBottomLeft_GrSurfaceOrigin,

View File

@ -115,7 +115,7 @@ sk_sp<SkSpecialImage> SkDropShadowImageFilterImpl::onFilterImage(SkSpecialImage*
return nullptr;
}
sk_sp<SkSpecialSurface> surf(source->makeSurface(ctx.outputProperties(), bounds.size()));
sk_sp<SkSpecialSurface> surf(ctx.makeSurface(source, bounds.size()));
if (!surf) {
return nullptr;
}

View File

@ -124,7 +124,7 @@ sk_sp<SkSpecialImage> SkImageSourceImpl::onFilterImage(SkSpecialImage* source, c
const SkIRect dstIRect = dstRect.roundOut();
sk_sp<SkSpecialSurface> surf(source->makeSurface(ctx.outputProperties(), dstIRect.size()));
sk_sp<SkSpecialSurface> surf(ctx.makeSurface(source, dstIRect.size()));
if (!surf) {
return nullptr;
}

View File

@ -422,10 +422,10 @@ protected:
#if SK_SUPPORT_GPU
sk_sp<SkSpecialImage> filterImageGPU(SkSpecialImage* source,
const Context& ctx,
SkSpecialImage* input,
const SkIRect& bounds,
const SkMatrix& matrix,
const OutputProperties& outputProperties) const;
const SkMatrix& matrix) const;
virtual std::unique_ptr<GrFragmentProcessor> makeFragmentProcessor(
sk_sp<GrTextureProxy>,
const SkMatrix&,
@ -471,10 +471,10 @@ void SkLightingImageFilterInternal::drawRect(GrRenderTargetContext* renderTarget
sk_sp<SkSpecialImage> SkLightingImageFilterInternal::filterImageGPU(
SkSpecialImage* source,
const Context& ctx,
SkSpecialImage* input,
const SkIRect& offsetBounds,
const SkMatrix& matrix,
const OutputProperties& outputProperties) const {
const SkMatrix& matrix) const {
SkASSERT(source->isTextureBacked());
auto context = source->getContext();
@ -482,15 +482,13 @@ sk_sp<SkSpecialImage> SkLightingImageFilterInternal::filterImageGPU(
sk_sp<GrTextureProxy> inputProxy(input->asTextureProxyRef(context));
SkASSERT(inputProxy);
GrColorType colorType = SkColorTypeToGrColorType(outputProperties.colorType());
sk_sp<GrRenderTargetContext> renderTargetContext(
context->priv().makeDeferredRenderTargetContext(
SkBackingFit::kApprox,
offsetBounds.width(),
offsetBounds.height(),
colorType,
sk_ref_sp(outputProperties.colorSpace()),
ctx.grColorType(),
ctx.refColorSpace(),
1,
GrMipMapped::kNo,
kBottomLeft_GrSurfaceOrigin,
@ -1271,7 +1269,7 @@ sk_sp<SkSpecialImage> SkDiffuseLightingImageFilter::onFilterImage(SkSpecialImage
SkMatrix matrix(ctx.ctm());
matrix.postTranslate(SkIntToScalar(-offset->fX), SkIntToScalar(-offset->fY));
return this->filterImageGPU(source, input.get(), bounds, matrix, ctx.outputProperties());
return this->filterImageGPU(source, ctx, input.get(), bounds, matrix);
}
#endif
@ -1406,7 +1404,7 @@ sk_sp<SkSpecialImage> SkSpecularLightingImageFilter::onFilterImage(SkSpecialImag
SkMatrix matrix(ctx.ctm());
matrix.postTranslate(SkIntToScalar(-offset->fX), SkIntToScalar(-offset->fY));
return this->filterImageGPU(source, input.get(), bounds, matrix, ctx.outputProperties());
return this->filterImageGPU(source, ctx, input.get(), bounds, matrix);
}
#endif

View File

@ -141,12 +141,12 @@ sk_sp<SkSpecialImage> SkMagnifierImageFilterImpl::onFilterImage(SkSpecialImage*
bounds.width() * invInset,
bounds.height() * invInset);
fp = GrColorSpaceXformEffect::Make(std::move(fp), input->getColorSpace(),
input->alphaType(), ctx.outputProperties().colorSpace());
input->alphaType(), ctx.colorSpace());
if (!fp) {
return nullptr;
}
return DrawWithFP(context, std::move(fp), bounds, ctx.outputProperties(),
return DrawWithFP(context, std::move(fp), bounds, ctx.colorType(), ctx.colorSpace(),
isProtected ? GrProtected::kYes : GrProtected::kNo);
}
#endif

View File

@ -442,7 +442,7 @@ sk_sp<SkSpecialImage> SkMatrixConvolutionImageFilterImpl::onFilterImage(SkSpecia
// called pad_image to account for our dilation of bounds, so the result will already be
// moved to the destination color space. If a filter DAG avoids that, then we use this
// fall-back, which saves us from having to do the xform during the filter itself.
input = ImageToColorSpace(input.get(), ctx.outputProperties());
input = ImageToColorSpace(input.get(), ctx.colorType(), ctx.colorSpace());
sk_sp<GrTextureProxy> inputProxy(input->asTextureProxyRef(context));
SkASSERT(inputProxy);
@ -469,7 +469,7 @@ sk_sp<SkSpecialImage> SkMatrixConvolutionImageFilterImpl::onFilterImage(SkSpecia
return nullptr;
}
return DrawWithFP(context, std::move(fp), dstBounds, ctx.outputProperties(),
return DrawWithFP(context, std::move(fp), dstBounds, ctx.colorType(), ctx.colorSpace(),
isProtected ? GrProtected::kYes : GrProtected::kNo);
}
#endif

View File

@ -100,7 +100,7 @@ sk_sp<SkSpecialImage> SkMergeImageFilterImpl::onFilterImage(
const int x0 = bounds.left();
const int y0 = bounds.top();
sk_sp<SkSpecialSurface> surf(source->makeSurface(ctx.outputProperties(), bounds.size()));
sk_sp<SkSpecialSurface> surf(ctx.makeSurface(source, bounds.size()));
if (!surf) {
return nullptr;
}

View File

@ -546,12 +546,11 @@ static void apply_morphology_pass(GrRenderTargetContext* renderTargetContext,
static sk_sp<SkSpecialImage> apply_morphology(
GrRecordingContext* context, SkSpecialImage* input, const SkIRect& rect,
MorphType morphType, SkISize radius,
const SkImageFilter_Base::OutputProperties& outputProperties) {
MorphType morphType, SkISize radius, const SkImageFilter_Base::Context& ctx) {
sk_sp<GrTextureProxy> srcTexture(input->asTextureProxyRef(context));
SkASSERT(srcTexture);
sk_sp<SkColorSpace> colorSpace = sk_ref_sp(outputProperties.colorSpace());
GrColorType colorType = SkColorTypeToGrColorType(outputProperties.colorType());
sk_sp<SkColorSpace> colorSpace = ctx.refColorSpace();
GrColorType colorType = ctx.grColorType();
// setup new clip
const GrFixedClip clip(SkIRect::MakeWH(srcTexture->width(), srcTexture->height()));
@ -777,11 +776,10 @@ sk_sp<SkSpecialImage> SkMorphologyImageFilterImpl::onFilterImage(SkSpecialImage*
// called pad_image to account for our dilation of bounds, so the result will already be
// moved to the destination color space. If a filter DAG avoids that, then we use this
// fall-back, which saves us from having to do the xform during the filter itself.
input = ImageToColorSpace(input.get(), ctx.outputProperties());
input = ImageToColorSpace(input.get(), ctx.colorType(), ctx.colorSpace());
sk_sp<SkSpecialImage> result(apply_morphology(context, input.get(), srcBounds, fType,
SkISize::Make(width, height),
ctx.outputProperties()));
SkISize::Make(width, height), ctx));
if (result) {
offset->fX = bounds.left();
offset->fY = bounds.top();

View File

@ -106,7 +106,7 @@ sk_sp<SkSpecialImage> SkOffsetImageFilterImpl::onFilterImage(SkSpecialImage* sou
return nullptr;
}
sk_sp<SkSpecialSurface> surf(source->makeSurface(ctx.outputProperties(), bounds.size()));
sk_sp<SkSpecialSurface> surf(ctx.makeSurface(source, bounds.size()));
if (!surf) {
return nullptr;
}

View File

@ -75,7 +75,7 @@ sk_sp<SkSpecialImage> SkPaintImageFilterImpl::onFilterImage(SkSpecialImage* sour
return nullptr;
}
sk_sp<SkSpecialSurface> surf(source->makeSurface(ctx.outputProperties(), bounds.size()));
sk_sp<SkSpecialSurface> surf(ctx.makeSurface(source, bounds.size()));
if (!surf) {
return nullptr;
}

View File

@ -127,8 +127,7 @@ sk_sp<SkSpecialImage> SkPictureImageFilterImpl::onFilterImage(SkSpecialImage* so
// Given the standard usage of the picture image filter (i.e., to render content at a fixed
// resolution that, most likely, differs from the screen's) disable LCD text.
SkSurfaceProps props(0, kUnknown_SkPixelGeometry);
sk_sp<SkSpecialSurface> surf(source->makeSurface(ctx.outputProperties(), bounds.size(),
kPremul_SkAlphaType, &props));
sk_sp<SkSpecialSurface> surf(ctx.makeSurface(source, bounds.size(), &props));
if (!surf) {
return nullptr;
}

View File

@ -131,7 +131,8 @@ sk_sp<SkSpecialImage> SkTileImageFilterImpl::onFilterImage(SkSpecialImage* sourc
if (inputBounds.contains(srcIRect)) {
subset = input->asImage(&srcIRect);
} else {
sk_sp<SkSurface> surf(input->makeTightSurface(ctx.outputProperties(), srcIRect.size()));
sk_sp<SkSurface> surf(input->makeTightSurface(ctx.colorType(), ctx.colorSpace(),
srcIRect.size()));
if (!surf) {
return nullptr;
}
@ -154,7 +155,7 @@ sk_sp<SkSpecialImage> SkTileImageFilterImpl::onFilterImage(SkSpecialImage* sourc
SkASSERT(subset->width() == srcIRect.width());
SkASSERT(subset->height() == srcIRect.height());
sk_sp<SkSpecialSurface> surf(source->makeSurface(ctx.outputProperties(), dstIRect.size()));
sk_sp<SkSpecialSurface> surf(ctx.makeSurface(source, dstIRect.size()));
if (!surf) {
return nullptr;
}

View File

@ -48,12 +48,12 @@ protected:
#if SK_SUPPORT_GPU
sk_sp<SkSpecialImage> filterImageGPU(SkSpecialImage* source,
const Context& ctx,
sk_sp<SkSpecialImage> background,
const SkIPoint& backgroundOffset,
sk_sp<SkSpecialImage> foreground,
const SkIPoint& foregroundOffset,
const SkIRect& bounds,
const OutputProperties& outputProperties) const;
const SkIRect& bounds) const;
#endif
void flatten(SkWriteBuffer&) const override;
@ -148,14 +148,12 @@ sk_sp<SkSpecialImage> SkXfermodeImageFilterImpl::onFilterImage(SkSpecialImage* s
#if SK_SUPPORT_GPU
if (source->isTextureBacked()) {
return this->filterImageGPU(source,
background, backgroundOffset,
foreground, foregroundOffset,
bounds, ctx.outputProperties());
return this->filterImageGPU(source, ctx, background, backgroundOffset,
foreground, foregroundOffset, bounds);
}
#endif
sk_sp<SkSpecialSurface> surf(source->makeSurface(ctx.outputProperties(), bounds.size()));
sk_sp<SkSpecialSurface> surf(ctx.makeSurface(source, bounds.size()));
if (!surf) {
return nullptr;
}
@ -244,12 +242,12 @@ void SkXfermodeImageFilterImpl::drawForeground(SkCanvas* canvas, SkSpecialImage*
sk_sp<SkSpecialImage> SkXfermodeImageFilterImpl::filterImageGPU(
SkSpecialImage* source,
const Context& ctx,
sk_sp<SkSpecialImage> background,
const SkIPoint& backgroundOffset,
sk_sp<SkSpecialImage> foreground,
const SkIPoint& foregroundOffset,
const SkIRect& bounds,
const OutputProperties& outputProperties) const {
const SkIRect& bounds) const {
SkASSERT(source->isTextureBacked());
auto context = source->getContext();
@ -278,7 +276,7 @@ sk_sp<SkSpecialImage> SkXfermodeImageFilterImpl::filterImageGPU(
GrTextureDomain::kDecal_Mode, GrSamplerState::Filter::kNearest);
bgFP = GrColorSpaceXformEffect::Make(std::move(bgFP), background->getColorSpace(),
background->alphaType(),
outputProperties.colorSpace());
ctx.colorSpace());
} else {
bgFP = GrConstColorProcessor::Make(SK_PMColor4fTRANSPARENT,
GrConstColorProcessor::InputMode::kIgnore);
@ -296,7 +294,7 @@ sk_sp<SkSpecialImage> SkXfermodeImageFilterImpl::filterImageGPU(
foregroundFP = GrColorSpaceXformEffect::Make(std::move(foregroundFP),
foreground->getColorSpace(),
foreground->alphaType(),
outputProperties.colorSpace());
ctx.colorSpace());
paint.addColorFragmentProcessor(std::move(foregroundFP));
std::unique_ptr<GrFragmentProcessor> xferFP = this->makeFGFrag(std::move(bgFP));
@ -311,12 +309,10 @@ sk_sp<SkSpecialImage> SkXfermodeImageFilterImpl::filterImageGPU(
paint.setPorterDuffXPFactory(SkBlendMode::kSrc);
GrColorType colorType = SkColorTypeToGrColorType(outputProperties.colorType());
sk_sp<GrRenderTargetContext> renderTargetContext(
context->priv().makeDeferredRenderTargetContext(
SkBackingFit::kApprox, bounds.width(), bounds.height(), colorType,
sk_ref_sp(outputProperties.colorSpace())));
SkBackingFit::kApprox, bounds.width(), bounds.height(), ctx.grColorType(),
ctx.refColorSpace()));
if (!renderTargetContext) {
return nullptr;
}

View File

@ -177,9 +177,8 @@ sk_sp<SkSpecialImage> SkGpuDevice::filterTexture(SkSpecialImage* srcImg,
if (colorType == kUnknown_SkColorType) {
colorType = kRGBA_8888_SkColorType;
}
SkImageFilter_Base::OutputProperties outputProperties(
colorType, fRenderTargetContext->colorSpaceInfo().colorSpace());
SkImageFilter_Base::Context ctx(matrix, clipBounds, cache.get(), outputProperties);
SkImageFilter_Base::Context ctx(matrix, clipBounds, cache.get(), colorType,
fRenderTargetContext->colorSpaceInfo().colorSpace());
return as_IFB(filter)->filterImage(srcImg, ctx, offset);
}

View File

@ -283,7 +283,6 @@ sk_sp<SkImage> SkImage::makeWithFilter(GrContext* grContext,
sk_sp<SkImageFilterCache> cache(
SkImageFilterCache::Create(SkImageFilterCache::kDefaultTransientSize));
SkImageFilter_Base::OutputProperties outputProperties(fInfo.colorType(), fInfo.colorSpace());
// The filters operate in the local space of the src image, where (0,0) corresponds to the
// subset's top left corner. But the clip bounds and any crop rects on the filters are in the
@ -291,7 +290,7 @@ sk_sp<SkImage> SkImage::makeWithFilter(GrContext* grContext,
// the clip bounds (since it is assumed to already be in image space).
SkImageFilter_Base::Context context(SkMatrix::MakeTrans(-subset.x(), -subset.y()),
clipBounds.makeOffset(-subset.x(), -subset.y()),
cache.get(), outputProperties);
cache.get(), fInfo.colorType(), fInfo.colorSpace());
sk_sp<SkSpecialImage> result = as_IFB(filter)->filterImage(srcSpecialImage.get(), context,
offset);

View File

@ -1729,9 +1729,8 @@ void SkPDFDevice::drawSpecial(SkSpecialImage* srcImg, int x, int y, const SkPain
sk_sp<SkImageFilterCache> cache(this->getImageFilterCache());
// TODO: Should PDF be operating in a specified color type/space? For now, run the filter
// in the same color space as the source (this is different from all other backends).
SkImageFilter_Base::OutputProperties outputProperties(
kN32_SkColorType, srcImg->getColorSpace());
SkImageFilter_Base::Context ctx(matrix, clipBounds, cache.get(), outputProperties);
SkImageFilter_Base::Context ctx(matrix, clipBounds, cache.get(), kN32_SkColorType,
srcImg->getColorSpace());
sk_sp<SkSpecialImage> resultImg(as_IFB(filter)->filterImage(srcImg, ctx, &offset));
if (resultImg) {

View File

@ -487,9 +487,8 @@ static void test_cropRects(skiatest::Reporter* reporter, GrContext* context) {
for (int i = 0; i < filters.count(); ++i) {
SkImageFilter* filter = filters.getFilter(i);
SkIPoint offset;
SkImageFilter_Base::OutputProperties noColorSpace(kN32_SkColorType, nullptr);
SkImageFilter_Base::Context ctx(SkMatrix::I(), SkIRect::MakeWH(100, 100), nullptr,
noColorSpace);
kN32_SkColorType, nullptr);
sk_sp<SkSpecialImage> resultImg(as_IFB(filter)->filterImage(srcImg.get(), ctx, &offset));
REPORTER_ASSERT(reporter, resultImg, filters.getName(i));
REPORTER_ASSERT(reporter, offset.fX == 20 && offset.fY == 30, filters.getName(i));
@ -510,8 +509,8 @@ static void test_negative_blur_sigma(skiatest::Reporter* reporter, GrContext* co
gradient));
SkIPoint offset;
SkImageFilter_Base::OutputProperties noColorSpace(kN32_SkColorType, nullptr);
SkImageFilter_Base::Context ctx(SkMatrix::I(), SkIRect::MakeWH(32, 32), nullptr, noColorSpace);
SkImageFilter_Base::Context ctx(SkMatrix::I(), SkIRect::MakeWH(32, 32), nullptr,
kN32_SkColorType, nullptr);
sk_sp<SkSpecialImage> positiveResult1(
as_IFB(positiveFilter)->filterImage(imgSrc.get(), ctx, &offset));
@ -524,7 +523,7 @@ static void test_negative_blur_sigma(skiatest::Reporter* reporter, GrContext* co
SkMatrix negativeScale;
negativeScale.setScale(-SK_Scalar1, SK_Scalar1);
SkImageFilter_Base::Context negativeCTX(negativeScale, SkIRect::MakeWH(32, 32), nullptr,
noColorSpace);
kN32_SkColorType, nullptr);
sk_sp<SkSpecialImage> negativeResult2(
as_IFB(positiveFilter)->filterImage(imgSrc.get(), negativeCTX, &offset));
@ -587,8 +586,8 @@ static void test_zero_blur_sigma(skiatest::Reporter* reporter, GrContext* contex
sk_sp<SkSpecialImage> image(surf->makeImageSnapshot());
SkIPoint offset;
SkImageFilter_Base::OutputProperties noColorSpace(kN32_SkColorType, nullptr);
SkImageFilter_Base::Context ctx(SkMatrix::I(), SkIRect::MakeWH(32, 32), nullptr, noColorSpace);
SkImageFilter_Base::Context ctx(SkMatrix::I(), SkIRect::MakeWH(32, 32), nullptr,
kN32_SkColorType, nullptr);
sk_sp<SkSpecialImage> result(as_IFB(filter)->filterImage(image.get(), ctx, &offset));
REPORTER_ASSERT(reporter, offset.fX == 5 && offset.fY == 0);
@ -624,9 +623,8 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(ImageFilterZeroBlurSigma_Gpu, reporter, ctxIn
static void test_fail_affects_transparent_black(skiatest::Reporter* reporter, GrContext* context) {
sk_sp<FailImageFilter> failFilter(new FailImageFilter());
sk_sp<SkSpecialImage> source(create_empty_special_image(context, 5));
SkImageFilter_Base::OutputProperties noColorSpace(kN32_SkColorType, nullptr);
SkImageFilter_Base::Context ctx(SkMatrix::I(), SkIRect::MakeXYWH(0, 0, 1, 1), nullptr,
noColorSpace);
kN32_SkColorType, nullptr);
sk_sp<SkColorFilter> green(SkColorFilters::Blend(SK_ColorGREEN, SkBlendMode::kSrc));
SkASSERT(green->affectsTransparentBlack());
sk_sp<SkImageFilter> greenFilter(SkImageFilters::ColorFilter(std::move(green),
@ -909,9 +907,8 @@ static void test_imagefilter_merge_result_size(skiatest::Reporter* reporter, GrC
sk_sp<SkSpecialImage> srcImg(create_empty_special_image(context, 1));
SkImageFilter_Base::OutputProperties noColorSpace(kN32_SkColorType, nullptr);
SkImageFilter_Base::Context ctx(SkMatrix::I(), SkIRect::MakeXYWH(0, 0, 100, 100), nullptr,
noColorSpace);
kN32_SkColorType, nullptr);
SkIPoint offset;
sk_sp<SkSpecialImage> resultImg(as_IFB(merge)->filterImage(srcImg.get(), ctx, &offset));
@ -1069,9 +1066,8 @@ static void test_big_kernel(skiatest::Reporter* reporter, GrContext* context) {
SkASSERT(srcImg);
SkIPoint offset;
SkImageFilter_Base::OutputProperties noColorSpace(kN32_SkColorType, nullptr);
SkImageFilter_Base::Context ctx(SkMatrix::I(), SkIRect::MakeWH(100, 100), nullptr,
noColorSpace);
kN32_SkColorType, nullptr);
sk_sp<SkSpecialImage> resultImg(as_IFB(filter)->filterImage(srcImg.get(), ctx, &offset));
REPORTER_ASSERT(reporter, resultImg);
REPORTER_ASSERT(reporter, SkToBool(context) == resultImg->isTextureBacked());
@ -1142,9 +1138,8 @@ static void test_clipped_picture_imagefilter(skiatest::Reporter* reporter, GrCon
sk_sp<SkImageFilter> imageFilter(SkImageFilters::Picture(picture));
SkIPoint offset;
SkImageFilter_Base::OutputProperties noColorSpace(kN32_SkColorType, nullptr);
SkImageFilter_Base::Context ctx(SkMatrix::I(), SkIRect::MakeXYWH(1, 1, 1, 1), nullptr,
noColorSpace);
kN32_SkColorType, nullptr);
sk_sp<SkSpecialImage> resultImage(as_IFB(imageFilter)->filterImage(srcImg.get(), ctx, &offset));
REPORTER_ASSERT(reporter, !resultImage);
@ -1369,9 +1364,8 @@ static void test_composed_imagefilter_offset(skiatest::Reporter* reporter, GrCon
sk_sp<SkImageFilter> composedFilter(SkImageFilters::Compose(std::move(blurFilter),
std::move(offsetFilter)));
SkIPoint offset;
SkImageFilter_Base::OutputProperties noColorSpace(kN32_SkColorType, nullptr);
SkImageFilter_Base::Context ctx(SkMatrix::I(), SkIRect::MakeWH(100, 100), nullptr,
noColorSpace);
kN32_SkColorType, nullptr);
sk_sp<SkSpecialImage> resultImg(
as_IFB(composedFilter)->filterImage(srcImg.get(), ctx, &offset));
@ -1406,9 +1400,8 @@ static void test_composed_imagefilter_bounds(skiatest::Reporter* reporter, GrCon
std::move(pictureFilter)));
sk_sp<SkSpecialImage> sourceImage(create_empty_special_image(context, 100));
SkImageFilter_Base::OutputProperties noColorSpace(kN32_SkColorType, nullptr);
SkImageFilter_Base::Context ctx(SkMatrix::I(), SkIRect::MakeWH(100, 100), nullptr,
noColorSpace);
kN32_SkColorType, nullptr);
SkIPoint offset;
sk_sp<SkSpecialImage> result(
as_IFB(composedFilter)->filterImage(sourceImage.get(), ctx, &offset));

View File

@ -81,8 +81,8 @@ static void test_image(const sk_sp<SkSpecialImage>& img, skiatest::Reporter* rep
//--------------
// Test that draw restricts itself to the subset
SkImageFilter_Base::OutputProperties outProps(kN32_SkColorType, img->getColorSpace());
sk_sp<SkSpecialSurface> surf(img->makeSurface(outProps, SkISize::Make(kFullSize, kFullSize),
sk_sp<SkSpecialSurface> surf(img->makeSurface(kN32_SkColorType, img->getColorSpace(),
SkISize::Make(kFullSize, kFullSize),
kPremul_SkAlphaType));
SkCanvas* canvas = surf->getCanvas();
@ -118,8 +118,8 @@ static void test_image(const sk_sp<SkSpecialImage>& img, skiatest::Reporter* rep
REPORTER_ASSERT(reporter, isGPUBacked != !!tightImg->peekPixels(&tmpPixmap));
}
{
SkImageFilter_Base::OutputProperties outProps(kN32_SkColorType, img->getColorSpace());
sk_sp<SkSurface> tightSurf(img->makeTightSurface(outProps, subset.size()));
sk_sp<SkSurface> tightSurf(img->makeTightSurface(kN32_SkColorType, img->getColorSpace(),
subset.size()));
REPORTER_ASSERT(reporter, tightSurf->width() == subset.width());
REPORTER_ASSERT(reporter, tightSurf->height() == subset.height());