Remove color space xform from GrTextureDomain & GrSimpleTextureEffect

Bug: skia:
Change-Id: I31435d334da28cce9bbc654c4b98746b03078897
Reviewed-on: https://skia-review.googlesource.com/61460
Reviewed-by: Brian Salomon <bsalomon@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
This commit is contained in:
Brian Osman 2017-10-18 13:15:13 -04:00 committed by Skia Commit-Bot
parent 8fed655df8
commit 2240be96d9
30 changed files with 75 additions and 157 deletions

View File

@ -117,7 +117,7 @@ DEF_SIMPLE_GM_BG(texdata, canvas, 2 * S, 2 * S, SK_ColorBLACK) {
} else {
vm.reset();
}
paint.addColorTextureProcessor(tContext->asTextureProxyRef(), nullptr, vm);
paint.addColorTextureProcessor(tContext->asTextureProxyRef(), vm);
renderTargetContext->drawRect(clip, GrPaint::Clone(paint), GrAA::kNo, vm,
SkRect::MakeWH(2 * S, 2 * S));

View File

@ -123,7 +123,7 @@ protected:
GrPaint grPaint;
grPaint.setXPFactory(GrPorterDuffXPFactory::Get(SkBlendMode::kSrc));
auto fp = GrTextureDomainEffect::Make(
proxy, nullptr, textureMatrices[tm],
proxy, textureMatrices[tm],
GrTextureDomain::MakeTexelDomainForMode(texelDomains[d], mode), mode,
GrSamplerState::Filter::kNearest);

View File

@ -55,7 +55,6 @@ bool SkColorSpaceXformImageGenerator::onGetPixels(const SkImageInfo& info, void*
#if SK_SUPPORT_GPU
#include "GrClip.h"
#include "GrColorSpaceXform.h"
#include "GrContext.h"
#include "GrPaint.h"
#include "GrRenderTargetContext.h"
@ -95,8 +94,7 @@ sk_sp<GrTextureProxy> SkColorSpaceXformImageGenerator::onGenerateTexture(
GrPaint paint;
paint.setPorterDuffXPFactory(SkBlendMode::kSrc);
paint.addColorTextureProcessor(std::move(proxy), nullptr,
SkMatrix::MakeTrans(origin.fX, origin.fY));
paint.addColorTextureProcessor(std::move(proxy), SkMatrix::MakeTrans(origin.fX, origin.fY));
paint.addColorFragmentProcessor(std::move(xform));
const SkRect rect = SkRect::MakeWH(info.width(), info.height());

View File

@ -280,7 +280,6 @@ sk_sp<GrRenderTargetContext> GaussianBlur(GrContext* context,
domain.inset((i < scaleFactorX) ? SK_ScalarHalf : 0.0f,
(i < scaleFactorY) ? SK_ScalarHalf : 0.0f);
auto fp = GrTextureDomainEffect::Make(std::move(srcProxy),
nullptr,
SkMatrix::I(),
domain,
modeForScaling,
@ -289,7 +288,7 @@ sk_sp<GrRenderTargetContext> GaussianBlur(GrContext* context,
srcRect.offset(-srcOffset);
srcOffset.set(0, 0);
} else {
paint.addColorTextureProcessor(std::move(srcProxy), nullptr, SkMatrix::I(),
paint.addColorTextureProcessor(std::move(srcProxy), SkMatrix::I(),
GrSamplerState::ClampBilerp());
}
paint.setPorterDuffXPFactory(SkBlendMode::kSrc);
@ -400,7 +399,6 @@ sk_sp<GrRenderTargetContext> GaussianBlur(GrContext* context,
if (GrTextureDomain::kIgnore_Mode != mode) {
SkRect domain = SkRect::Make(localSrcBounds);
auto fp = GrTextureDomainEffect::Make(std::move(srcProxy),
nullptr,
SkMatrix::I(),
domain,
modeForScaling,
@ -408,7 +406,7 @@ sk_sp<GrRenderTargetContext> GaussianBlur(GrContext* context,
paint.addColorFragmentProcessor(std::move(fp));
} else {
// FIXME: this should be mitchell, not bilinear.
paint.addColorTextureProcessor(std::move(srcProxy), nullptr, SkMatrix::I(),
paint.addColorTextureProcessor(std::move(srcProxy), SkMatrix::I(),
GrSamplerState::ClampBilerp());
}
paint.setPorterDuffXPFactory(SkBlendMode::kSrc);

View File

@ -306,7 +306,7 @@ sk_sp<SkSpecialImage> ArithmeticImageFilterImpl::filterImageGPU(
SkMatrix backgroundMatrix = SkMatrix::MakeTrans(-SkIntToScalar(backgroundOffset.fX),
-SkIntToScalar(backgroundOffset.fY));
bgFP = GrTextureDomainEffect::Make(
std::move(backgroundProxy), nullptr, backgroundMatrix,
std::move(backgroundProxy), backgroundMatrix,
GrTextureDomain::MakeTexelDomain(background->subset()),
GrTextureDomain::kDecal_Mode, GrSamplerState::Filter::kNearest);
bgFP = GrColorSpaceXformEffect::Make(std::move(bgFP), background->getColorSpace(),
@ -320,7 +320,7 @@ sk_sp<SkSpecialImage> ArithmeticImageFilterImpl::filterImageGPU(
SkMatrix foregroundMatrix = SkMatrix::MakeTrans(-SkIntToScalar(foregroundOffset.fX),
-SkIntToScalar(foregroundOffset.fY));
auto foregroundFP = GrTextureDomainEffect::Make(
std::move(foregroundProxy), nullptr, foregroundMatrix,
std::move(foregroundProxy), foregroundMatrix,
GrTextureDomain::MakeTexelDomain(foreground->subset()),
GrTextureDomain::kDecal_Mode, GrSamplerState::Filter::kNearest);
foregroundFP = GrColorSpaceXformEffect::Make(std::move(foregroundFP),

View File

@ -1269,7 +1269,7 @@ sk_sp<GrTextureProxy> SkBlurMaskFilterImpl::filterMaskGPU(GrContext* context,
GrPaint paint;
// Blend pathTexture over blurTexture.
paint.addCoverageFragmentProcessor(GrSimpleTextureEffect::Make(std::move(srcProxy),
nullptr, SkMatrix::I()));
SkMatrix::I()));
if (kInner_SkBlurStyle == fBlurStyle) {
// inner: dst = dst * src
paint.setCoverageSetOpXPFactory(SkRegion::kIntersect_Op);

View File

@ -16,6 +16,7 @@
#include "SkColorData.h"
#if SK_SUPPORT_GPU
#include "GrClip.h"
#include "GrColorSpaceXform.h"
#include "GrContext.h"
#include "GrCoordTransform.h"
#include "GrRenderTargetContext.h"

View File

@ -294,7 +294,7 @@ sk_sp<SkSpecialImage> SkXfermodeImageFilter_Base::filterImageGPU(
if (backgroundProxy) {
SkMatrix bgMatrix = SkMatrix::MakeTrans(-SkIntToScalar(backgroundOffset.fX),
-SkIntToScalar(backgroundOffset.fY));
bgFP = GrTextureDomainEffect::Make(std::move(backgroundProxy), nullptr, bgMatrix,
bgFP = GrTextureDomainEffect::Make(std::move(backgroundProxy), bgMatrix,
GrTextureDomain::MakeTexelDomain(background->subset()),
GrTextureDomain::kDecal_Mode,
GrSamplerState::Filter::kNearest);
@ -309,7 +309,7 @@ sk_sp<SkSpecialImage> SkXfermodeImageFilter_Base::filterImageGPU(
SkMatrix fgMatrix = SkMatrix::MakeTrans(-SkIntToScalar(foregroundOffset.fX),
-SkIntToScalar(foregroundOffset.fY));
auto foregroundFP = GrTextureDomainEffect::Make(
std::move(foregroundProxy), nullptr, fgMatrix,
std::move(foregroundProxy), fgMatrix,
GrTextureDomain::MakeTexelDomain(foreground->subset()),
GrTextureDomain::kDecal_Mode, GrSamplerState::Filter::kNearest);
foregroundFP = GrColorSpaceXformEffect::Make(std::move(foregroundFP),

View File

@ -42,8 +42,7 @@ static bool draw_mask(GrRenderTargetContext* renderTargetContext,
SkMatrix matrix = SkMatrix::MakeTrans(-SkIntToScalar(maskRect.fLeft),
-SkIntToScalar(maskRect.fTop));
matrix.preConcat(viewMatrix);
paint.addCoverageFragmentProcessor(GrSimpleTextureEffect::Make(std::move(mask),
nullptr, matrix));
paint.addCoverageFragmentProcessor(GrSimpleTextureEffect::Make(std::move(mask), matrix));
renderTargetContext->fillRectWithLocalMatrix(clip, std::move(paint), GrAA::kNo, SkMatrix::I(),
SkRect::Make(maskRect), inverse);

View File

@ -491,7 +491,7 @@ bool GrContextPriv::writeSurfacePixels(GrSurfaceContext* dst,
}
if (tempProxy) {
auto fp = GrSimpleTextureEffect::Make(tempProxy, nullptr, SkMatrix::I());
auto fp = GrSimpleTextureEffect::Make(tempProxy, SkMatrix::I());
if (premulOnGpu) {
fp = fContext->createUPMToPMEffect(std::move(fp), useConfigConversionEffect);
}
@ -623,7 +623,7 @@ bool GrContextPriv::readSurfacePixels(GrSurfaceContext* src,
if (tempRTC) {
SkMatrix textureMatrix = SkMatrix::MakeTrans(SkIntToScalar(left), SkIntToScalar(top));
sk_sp<GrTextureProxy> proxy = src->asTextureProxyRef();
auto fp = GrSimpleTextureEffect::Make(std::move(proxy), nullptr, textureMatrix);
auto fp = GrSimpleTextureEffect::Make(std::move(proxy), textureMatrix);
if (unpremulOnGpu) {
fp = fContext->createPMToUPMEffect(std::move(fp), useConfigConversionEffect);
// We no longer need to do this on CPU after the read back.

View File

@ -37,34 +37,26 @@ void GrPaint::setCoverageSetOpXPFactory(SkRegion::Op regionOp, bool invertCovera
this->setXPFactory(GrCoverageSetOpXPFactory::Get(regionOp, invertCoverage));
}
void GrPaint::addColorTextureProcessor(sk_sp<GrTextureProxy> proxy,
sk_sp<GrColorSpaceXform> colorSpaceXform,
const SkMatrix& matrix) {
this->addColorFragmentProcessor(GrSimpleTextureEffect::Make(std::move(proxy),
std::move(colorSpaceXform),
matrix));
void GrPaint::addColorTextureProcessor(sk_sp<GrTextureProxy> proxy, const SkMatrix& matrix) {
this->addColorFragmentProcessor(GrSimpleTextureEffect::Make(std::move(proxy), matrix));
}
void GrPaint::addColorTextureProcessor(sk_sp<GrTextureProxy> proxy,
sk_sp<GrColorSpaceXform> colorSpaceXform,
const SkMatrix& matrix,
void GrPaint::addColorTextureProcessor(sk_sp<GrTextureProxy> proxy, const SkMatrix& matrix,
const GrSamplerState& samplerState) {
this->addColorFragmentProcessor(GrSimpleTextureEffect::Make(std::move(proxy),
std::move(colorSpaceXform),
matrix, samplerState));
this->addColorFragmentProcessor(GrSimpleTextureEffect::Make(std::move(proxy), matrix,
samplerState));
}
void GrPaint::addCoverageTextureProcessor(sk_sp<GrTextureProxy> proxy,
const SkMatrix& matrix) {
this->addCoverageFragmentProcessor(GrSimpleTextureEffect::Make(std::move(proxy),
nullptr, matrix));
this->addCoverageFragmentProcessor(GrSimpleTextureEffect::Make(std::move(proxy), matrix));
}
void GrPaint::addCoverageTextureProcessor(sk_sp<GrTextureProxy> proxy,
const SkMatrix& matrix,
const GrSamplerState& params) {
this->addCoverageFragmentProcessor(GrSimpleTextureEffect::Make(std::move(proxy),
nullptr, matrix, params));
this->addCoverageFragmentProcessor(GrSimpleTextureEffect::Make(std::move(proxy), matrix,
params));
}
bool GrPaint::isConstantBlendedColor(GrColor* constantColor) const {

View File

@ -17,7 +17,6 @@
#include "SkRegion.h"
#include "SkTLazy.h"
class GrColorSpaceXform;
class GrTextureProxy;
class GrXPFactory;
@ -110,10 +109,8 @@ public:
* Helpers for adding color or coverage effects that sample a texture. The matrix is applied
* to the src space position to compute texture coordinates.
*/
void addColorTextureProcessor(sk_sp<GrTextureProxy>,
sk_sp<GrColorSpaceXform>, const SkMatrix&);
void addColorTextureProcessor(sk_sp<GrTextureProxy>, sk_sp<GrColorSpaceXform>, const SkMatrix&,
const GrSamplerState&);
void addColorTextureProcessor(sk_sp<GrTextureProxy>, const SkMatrix&);
void addColorTextureProcessor(sk_sp<GrTextureProxy>, const SkMatrix&, const GrSamplerState&);
void addCoverageTextureProcessor(sk_sp<GrTextureProxy>, const SkMatrix&);
void addCoverageTextureProcessor(sk_sp<GrTextureProxy>, const SkMatrix&, const GrSamplerState&);

View File

@ -22,6 +22,7 @@
class GrBackendSemaphore;
class GrCCPRAtlas;
class GrClip;
class GrColorSpaceXform;
class GrCoverageCountingPathRenderer;
class GrDrawingManager;
class GrDrawOp;

View File

@ -157,7 +157,7 @@ void GrSoftwarePathRenderer::DrawToTargetWithShapeMask(
SkIntToScalar(-textureOriginInDeviceSpace.fY));
maskMatrix.preConcat(viewMatrix);
paint.addCoverageFragmentProcessor(GrSimpleTextureEffect::Make(
std::move(proxy), nullptr, maskMatrix, GrSamplerState::Filter::kNearest));
std::move(proxy), maskMatrix, GrSamplerState::Filter::kNearest));
DrawNonAARect(renderTargetContext, std::move(paint), userStencilSettings, clip, SkMatrix::I(),
dstRect, invert);
}

View File

@ -59,11 +59,11 @@ sk_sp<GrTextureProxy> GrTextureProducer::CopyOnGpu(GrContext* context,
// better!
SkASSERT(copyParams.fFilter != GrSamplerState::Filter::kMipMap);
paint.addColorFragmentProcessor(
GrTextureDomainEffect::Make(std::move(inputProxy), nullptr, SkMatrix::I(),
domain, GrTextureDomain::kClamp_Mode, copyParams.fFilter));
GrTextureDomainEffect::Make(std::move(inputProxy), SkMatrix::I(), domain,
GrTextureDomain::kClamp_Mode, copyParams.fFilter));
} else {
GrSamplerState samplerState(GrSamplerState::WrapMode::kClamp, copyParams.fFilter);
paint.addColorTextureProcessor(std::move(inputProxy), nullptr, SkMatrix::I(), samplerState);
paint.addColorTextureProcessor(std::move(inputProxy), SkMatrix::I(), samplerState);
}
paint.setPorterDuffXPFactory(SkBlendMode::kSrc);
@ -228,13 +228,12 @@ std::unique_ptr<GrFragmentProcessor> GrTextureProducer::CreateFragmentProcessorF
SkASSERT(kTightCopy_DomainMode != domainMode);
if (filterOrNullForBicubic) {
if (kDomain_DomainMode == domainMode) {
return GrTextureDomainEffect::Make(std::move(proxy), nullptr, textureMatrix, domain,
return GrTextureDomainEffect::Make(std::move(proxy), textureMatrix, domain,
GrTextureDomain::kClamp_Mode,
*filterOrNullForBicubic);
} else {
GrSamplerState samplerState(GrSamplerState::WrapMode::kClamp, *filterOrNullForBicubic);
return GrSimpleTextureEffect::Make(std::move(proxy), nullptr, textureMatrix,
samplerState);
return GrSimpleTextureEffect::Make(std::move(proxy), textureMatrix, samplerState);
}
} else {
if (kDomain_DomainMode == domainMode) {

View File

@ -1006,7 +1006,7 @@ void SkGpuDevice::drawBitmapTile(const SkBitmap& bitmap,
if (bicubic) {
fp = GrBicubicEffect::Make(std::move(proxy), texMatrix, domain);
} else {
fp = GrTextureDomainEffect::Make(std::move(proxy), nullptr, texMatrix, domain,
fp = GrTextureDomainEffect::Make(std::move(proxy), texMatrix, domain,
GrTextureDomain::kClamp_Mode, samplerState.filter());
}
} else if (bicubic) {
@ -1014,7 +1014,7 @@ void SkGpuDevice::drawBitmapTile(const SkBitmap& bitmap,
GrSamplerState::WrapMode wrapMode[2] = {samplerState.wrapModeX(), samplerState.wrapModeY()};
fp = GrBicubicEffect::Make(std::move(proxy), texMatrix, wrapMode);
} else {
fp = GrSimpleTextureEffect::Make(std::move(proxy), nullptr, texMatrix, samplerState);
fp = GrSimpleTextureEffect::Make(std::move(proxy), texMatrix, samplerState);
}
fp = GrColorSpaceXformEffect::Make(std::move(fp), bitmap.colorSpace(),
@ -1082,7 +1082,7 @@ void SkGpuDevice::drawSpecial(SkSpecialImage* special1, int left, int top, const
SkPaint tmpUnfiltered(paint);
tmpUnfiltered.setImageFilter(nullptr);
auto fp = GrSimpleTextureEffect::Make(std::move(proxy), nullptr, SkMatrix::I());
auto fp = GrSimpleTextureEffect::Make(std::move(proxy), SkMatrix::I());
fp = GrColorSpaceXformEffect::Make(std::move(fp), result->getColorSpace(),
fRenderTargetContext->getColorSpace());
if (GrPixelConfigIsAlphaOnly(config)) {

View File

@ -73,7 +73,7 @@
std::unique_ptr<GrFragmentProcessor> upmToPM(
new GrConfigConversionEffect(kToPremul_PMConversion));
paint1.addColorTextureProcessor(dataProxy, nullptr, SkMatrix::I());
paint1.addColorTextureProcessor(dataProxy, SkMatrix::I());
paint1.addColorFragmentProcessor(pmToUPM->clone());
paint1.setPorterDuffXPFactory(SkBlendMode::kSrc);
@ -83,16 +83,14 @@
return false;
}
paint2.addColorTextureProcessor(readRTC->asTextureProxyRef(), nullptr,
SkMatrix::I());
paint2.addColorTextureProcessor(readRTC->asTextureProxyRef(), SkMatrix::I());
paint2.addColorFragmentProcessor(std::move(upmToPM));
paint2.setPorterDuffXPFactory(SkBlendMode::kSrc);
tempRTC->fillRectToRect(GrNoClip(), std::move(paint2), GrAA::kNo, SkMatrix::I(), kRect,
kRect);
paint3.addColorTextureProcessor(tempRTC->asTextureProxyRef(), nullptr,
SkMatrix::I());
paint3.addColorTextureProcessor(tempRTC->asTextureProxyRef(), SkMatrix::I());
paint3.addColorFragmentProcessor(std::move(pmToUPM));
paint3.setPorterDuffXPFactory(SkBlendMode::kSrc);

View File

@ -84,7 +84,7 @@ public:
std::unique_ptr<GrFragmentProcessor> upmToPM(
new GrConfigConversionEffect(kToPremul_PMConversion));
paint1.addColorTextureProcessor(dataProxy, nullptr, SkMatrix::I());
paint1.addColorTextureProcessor(dataProxy, SkMatrix::I());
paint1.addColorFragmentProcessor(pmToUPM->clone());
paint1.setPorterDuffXPFactory(SkBlendMode::kSrc);
@ -94,14 +94,14 @@ public:
return false;
}
paint2.addColorTextureProcessor(readRTC->asTextureProxyRef(), nullptr, SkMatrix::I());
paint2.addColorTextureProcessor(readRTC->asTextureProxyRef(), SkMatrix::I());
paint2.addColorFragmentProcessor(std::move(upmToPM));
paint2.setPorterDuffXPFactory(SkBlendMode::kSrc);
tempRTC->fillRectToRect(GrNoClip(), std::move(paint2), GrAA::kNo, SkMatrix::I(), kRect,
kRect);
paint3.addColorTextureProcessor(tempRTC->asTextureProxyRef(), nullptr, SkMatrix::I());
paint3.addColorTextureProcessor(tempRTC->asTextureProxyRef(), SkMatrix::I());
paint3.addColorFragmentProcessor(std::move(pmToUPM));
paint3.setPorterDuffXPFactory(SkBlendMode::kSrc);

View File

@ -23,60 +23,37 @@ public:
GrGLSLFPFragmentBuilder* fragBuilder = args.fFragBuilder;
const GrSimpleTextureEffect& _outer = args.fFp.cast<GrSimpleTextureEffect>();
(void)_outer;
auto colorXform = _outer.colorXform();
(void)colorXform;
auto matrix = _outer.matrix();
(void)matrix;
fColorSpaceHelper.emitCode(args.fUniformHandler, _outer.colorXform().get());
SkString sk_TransformedCoords2D_0 = fragBuilder->ensureCoords2D(args.fTransformedCoords[0]);
fragBuilder->codeAppendf(
"half4 _tmpVar1;%s = %s * %stexture(%s, %s).%s%s;\n", args.fOutputColor,
"%s = %s * texture(%s, %s).%s;\n", args.fOutputColor,
args.fInputColor ? args.fInputColor : "half4(1)",
fColorSpaceHelper.isValid() ? "(_tmpVar1 = " : "",
fragBuilder->getProgramBuilder()->samplerVariable(args.fTexSamplers[0]).c_str(),
sk_TransformedCoords2D_0.c_str(),
fragBuilder->getProgramBuilder()->samplerSwizzle(args.fTexSamplers[0]).c_str(),
fColorSpaceHelper.isValid()
? SkStringPrintf(", half4(clamp((%s * half4(_tmpVar1.rgb, 1.0)).rgb, 0.0, "
"_tmpVar1.a), _tmpVar1.a))",
args.fUniformHandler->getUniformCStr(
fColorSpaceHelper.gamutXformUniform()))
.c_str()
: "");
fragBuilder->getProgramBuilder()->samplerSwizzle(args.fTexSamplers[0]).c_str());
}
private:
void onSetData(const GrGLSLProgramDataManager& pdman,
const GrFragmentProcessor& _proc) override {
const GrSimpleTextureEffect& _outer = _proc.cast<GrSimpleTextureEffect>();
{
if (fColorSpaceHelper.isValid()) {
fColorSpaceHelper.setData(pdman, _outer.colorXform().get());
}
}
}
const GrFragmentProcessor& _proc) override {}
UniformHandle fImageVar;
GrGLSLColorSpaceXformHelper fColorSpaceHelper;
};
GrGLSLFragmentProcessor* GrSimpleTextureEffect::onCreateGLSLInstance() const {
return new GrGLSLSimpleTextureEffect();
}
void GrSimpleTextureEffect::onGetGLSLProcessorKey(const GrShaderCaps& caps,
GrProcessorKeyBuilder* b) const {
b->add32(GrColorSpaceXform::XformKey(fColorXform.get()));
}
GrProcessorKeyBuilder* b) const {}
bool GrSimpleTextureEffect::onIsEqual(const GrFragmentProcessor& other) const {
const GrSimpleTextureEffect& that = other.cast<GrSimpleTextureEffect>();
(void)that;
if (fImage != that.fImage) return false;
if (fColorXform != that.fColorXform) return false;
if (fMatrix != that.fMatrix) return false;
return true;
}
GrSimpleTextureEffect::GrSimpleTextureEffect(const GrSimpleTextureEffect& src)
: INHERITED(kGrSimpleTextureEffect_ClassID, src.optimizationFlags())
, fImage(src.fImage)
, fColorXform(src.fColorXform)
, fMatrix(src.fMatrix)
, fImageCoordTransform(src.fImageCoordTransform) {
this->addTextureSampler(&fImage);
@ -98,9 +75,7 @@ std::unique_ptr<GrFragmentProcessor> GrSimpleTextureEffect::TestCreate(
: GrSamplerState::Filter::kNearest);
const SkMatrix& matrix = GrTest::TestMatrix(testData->fRandom);
sk_sp<GrColorSpaceXform> colorSpaceXform = GrTest::TestColorXform(testData->fRandom);
return GrSimpleTextureEffect::Make(testData->textureProxy(texIdx), std::move(colorSpaceXform),
matrix);
return GrSimpleTextureEffect::Make(testData->textureProxy(texIdx), matrix);
}
#endif
#endif

View File

@ -6,7 +6,6 @@
*/
in uniform sampler2D image;
in uniform colorSpaceXform colorXform;
in half4x4 matrix;
@constructorParams {
@ -23,29 +22,26 @@ in half4x4 matrix;
@make {
static std::unique_ptr<GrFragmentProcessor> Make(sk_sp<GrTextureProxy> proxy,
sk_sp<GrColorSpaceXform> colorSpaceXform,
const SkMatrix& matrix) {
return std::unique_ptr<GrFragmentProcessor>(
new GrSimpleTextureEffect(std::move(proxy), std::move(colorSpaceXform), matrix,
new GrSimpleTextureEffect(std::move(proxy), matrix,
GrSamplerState(GrSamplerState::WrapMode::kClamp, GrSamplerState::Filter::kNearest)));
}
/* clamp mode */
static std::unique_ptr<GrFragmentProcessor> Make(sk_sp<GrTextureProxy> proxy,
sk_sp<GrColorSpaceXform> colorSpaceXform,
const SkMatrix& matrix,
GrSamplerState::Filter filter) {
return std::unique_ptr<GrFragmentProcessor>(
new GrSimpleTextureEffect(std::move(proxy), std::move(colorSpaceXform), matrix,
new GrSimpleTextureEffect(std::move(proxy), matrix,
GrSamplerState(GrSamplerState::WrapMode::kClamp, filter)));
}
static std::unique_ptr<GrFragmentProcessor> Make(sk_sp<GrTextureProxy> proxy,
sk_sp<GrColorSpaceXform> colorSpaceXform,
const SkMatrix& matrix,
const GrSamplerState& p) {
return std::unique_ptr<GrFragmentProcessor>(
new GrSimpleTextureEffect(std::move(proxy), std::move(colorSpaceXform), matrix, p));
new GrSimpleTextureEffect(std::move(proxy), matrix, p));
}
}
@ -56,7 +52,7 @@ in half4x4 matrix;
}
void main() {
sk_OutColor = sk_InColor * texture(image, sk_TransformedCoords2D[0], colorXform);
sk_OutColor = sk_InColor * texture(image, sk_TransformedCoords2D[0]);
}
@test(testData) {
@ -69,7 +65,5 @@ void main() {
: GrSamplerState::Filter::kNearest);
const SkMatrix& matrix = GrTest::TestMatrix(testData->fRandom);
sk_sp<GrColorSpaceXform> colorSpaceXform = GrTest::TestColorXform(testData->fRandom);
return GrSimpleTextureEffect::Make(testData->textureProxy(texIdx), std::move(colorSpaceXform),
matrix);
return GrSimpleTextureEffect::Make(testData->textureProxy(texIdx), matrix);
}

View File

@ -17,52 +17,44 @@
#include "GrColorSpaceXform.h"
class GrSimpleTextureEffect : public GrFragmentProcessor {
public:
sk_sp<GrColorSpaceXform> colorXform() const { return fColorXform; }
SkMatrix44 matrix() const { return fMatrix; }
static std::unique_ptr<GrFragmentProcessor> Make(sk_sp<GrTextureProxy> proxy,
sk_sp<GrColorSpaceXform>
colorSpaceXform,
const SkMatrix& matrix) {
return std::unique_ptr<GrFragmentProcessor>(
new GrSimpleTextureEffect(std::move(proxy), std::move(colorSpaceXform), matrix,
new GrSimpleTextureEffect(std::move(proxy), matrix,
GrSamplerState(GrSamplerState::WrapMode::kClamp,
GrSamplerState::Filter::kNearest)));
}
/* clamp mode */
static std::unique_ptr<GrFragmentProcessor> Make(sk_sp<GrTextureProxy> proxy,
sk_sp<GrColorSpaceXform>
colorSpaceXform,
const SkMatrix& matrix,
GrSamplerState::Filter filter) {
return std::unique_ptr<GrFragmentProcessor>(new GrSimpleTextureEffect(
std::move(proxy), std::move(colorSpaceXform), matrix,
std::move(proxy), matrix,
GrSamplerState(GrSamplerState::WrapMode::kClamp, filter)));
}
static std::unique_ptr<GrFragmentProcessor> Make(sk_sp<GrTextureProxy> proxy,
sk_sp<GrColorSpaceXform>
colorSpaceXform,
const SkMatrix& matrix,
const GrSamplerState& p) {
return std::unique_ptr<GrFragmentProcessor>(
new GrSimpleTextureEffect(std::move(proxy), std::move(colorSpaceXform), matrix, p));
new GrSimpleTextureEffect(std::move(proxy), matrix, p));
}
GrSimpleTextureEffect(const GrSimpleTextureEffect& src);
std::unique_ptr<GrFragmentProcessor> clone() const override;
const char* name() const override { return "SimpleTextureEffect"; }
private:
GrSimpleTextureEffect(sk_sp<GrTextureProxy> image, sk_sp<GrColorSpaceXform> colorXform,
SkMatrix44 matrix, GrSamplerState samplerParams)
GrSimpleTextureEffect(sk_sp<GrTextureProxy> image, SkMatrix44 matrix,
GrSamplerState samplerParams)
: INHERITED(kGrSimpleTextureEffect_ClassID,
(OptimizationFlags)kCompatibleWithCoverageAsAlpha_OptimizationFlag |
(GrPixelConfigIsOpaque(image->config())
? kPreservesOpaqueInput_OptimizationFlag
: kNone_OptimizationFlags))
, fImage(std::move(image), samplerParams)
, fColorXform(colorXform)
, fMatrix(matrix)
, fImageCoordTransform(matrix, fImage.proxy()) {
this->addTextureSampler(&fImage);
@ -73,7 +65,6 @@ private:
bool onIsEqual(const GrFragmentProcessor&) const override;
GR_DECLARE_FRAGMENT_PROCESSOR_TEST
TextureSampler fImage;
sk_sp<GrColorSpaceXform> fColorXform;
SkMatrix44 fMatrix;
GrCoordTransform fImageCoordTransform;
typedef GrFragmentProcessor INHERITED;

View File

@ -13,7 +13,6 @@
#include "GrSurfaceProxyPriv.h"
#include "GrTexture.h"
#include "SkFloatingPoint.h"
#include "glsl/GrGLSLColorSpaceXformHelper.h"
#include "glsl/GrGLSLFragmentProcessor.h"
#include "glsl/GrGLSLFragmentShaderBuilder.h"
#include "glsl/GrGLSLProgramDataManager.h"
@ -67,8 +66,7 @@ void GrTextureDomain::GLDomain::sampleTexture(GrGLSLShaderBuilder* builder,
const char* outColor,
const SkString& inCoords,
GrGLSLFragmentProcessor::SamplerHandle sampler,
const char* inModulateColor,
GrGLSLColorSpaceXformHelper* colorXformHelper) {
const char* inModulateColor) {
SkASSERT((Mode)-1 == fMode || textureDomain.mode() == fMode);
SkDEBUGCODE(fMode = textureDomain.mode();)
@ -87,7 +85,7 @@ void GrTextureDomain::GLDomain::sampleTexture(GrGLSLShaderBuilder* builder,
case kIgnore_Mode: {
builder->codeAppendf("%s = ", outColor);
builder->appendTextureLookupAndModulate(inModulateColor, sampler, inCoords.c_str(),
kFloat2_GrSLType, colorXformHelper);
kFloat2_GrSLType);
builder->codeAppend(";");
break;
}
@ -98,7 +96,7 @@ void GrTextureDomain::GLDomain::sampleTexture(GrGLSLShaderBuilder* builder,
builder->codeAppendf("%s = ", outColor);
builder->appendTextureLookupAndModulate(inModulateColor, sampler, clampedCoords.c_str(),
kFloat2_GrSLType, colorXformHelper);
kFloat2_GrSLType);
builder->codeAppend(";");
break;
}
@ -117,7 +115,7 @@ void GrTextureDomain::GLDomain::sampleTexture(GrGLSLShaderBuilder* builder,
builder->codeAppend("half4 outside = half4(0.0, 0.0, 0.0, 0.0);");
builder->codeAppend("half4 inside = ");
builder->appendTextureLookupAndModulate(inModulateColor, sampler, inCoords.c_str(),
kFloat2_GrSLType, colorXformHelper);
kFloat2_GrSLType);
builder->codeAppend(";");
builder->codeAppendf("float x = (%s).x;", inCoords.c_str());
@ -138,7 +136,7 @@ void GrTextureDomain::GLDomain::sampleTexture(GrGLSLShaderBuilder* builder,
builder->codeAppendf("%s = any(outside) ? half4(0.0, 0.0, 0.0, 0.0) : ",
outColor);
builder->appendTextureLookupAndModulate(inModulateColor, sampler, inCoords.c_str(),
kFloat2_GrSLType, colorXformHelper);
kFloat2_GrSLType);
builder->codeAppend(";");
}
break;
@ -151,7 +149,7 @@ void GrTextureDomain::GLDomain::sampleTexture(GrGLSLShaderBuilder* builder,
builder->codeAppendf("%s = ", outColor);
builder->appendTextureLookupAndModulate(inModulateColor, sampler, clampedCoords.c_str(),
kFloat2_GrSLType, colorXformHelper);
kFloat2_GrSLType);
builder->codeAppend(";");
break;
}
@ -207,23 +205,20 @@ inline GrFragmentProcessor::OptimizationFlags GrTextureDomainEffect::OptFlags(
std::unique_ptr<GrFragmentProcessor> GrTextureDomainEffect::Make(
sk_sp<GrTextureProxy> proxy,
sk_sp<GrColorSpaceXform> colorSpaceXform,
const SkMatrix& matrix,
const SkRect& domain,
GrTextureDomain::Mode mode,
GrSamplerState::Filter filterMode) {
if (GrTextureDomain::kIgnore_Mode == mode ||
(GrTextureDomain::kClamp_Mode == mode && can_ignore_rect(proxy.get(), domain))) {
return GrSimpleTextureEffect::Make(std::move(proxy),
std::move(colorSpaceXform), matrix, filterMode);
return GrSimpleTextureEffect::Make(std::move(proxy), matrix, filterMode);
} else {
return std::unique_ptr<GrFragmentProcessor>(new GrTextureDomainEffect(
std::move(proxy), std::move(colorSpaceXform), matrix, domain, mode, filterMode));
std::move(proxy), matrix, domain, mode, filterMode));
}
}
GrTextureDomainEffect::GrTextureDomainEffect(sk_sp<GrTextureProxy> proxy,
sk_sp<GrColorSpaceXform> colorSpaceXform,
const SkMatrix& matrix,
const SkRect& domain,
GrTextureDomain::Mode mode,
@ -231,8 +226,7 @@ GrTextureDomainEffect::GrTextureDomainEffect(sk_sp<GrTextureProxy> proxy,
: INHERITED(kGrTextureDomainEffect_ClassID, OptFlags(proxy->config(), mode))
, fCoordTransform(matrix, proxy.get())
, fTextureDomain(proxy.get(), domain, mode)
, fTextureSampler(std::move(proxy), filterMode)
, fColorSpaceXform(std::move(colorSpaceXform)) {
, fTextureSampler(std::move(proxy), filterMode) {
SkASSERT(mode != GrTextureDomain::kRepeat_Mode ||
filterMode == GrSamplerState::Filter::kNearest);
this->addCoordTransform(&fCoordTransform);
@ -243,8 +237,7 @@ GrTextureDomainEffect::GrTextureDomainEffect(const GrTextureDomainEffect& that)
: INHERITED(kGrTextureDomainEffect_ClassID, that.optimizationFlags())
, fCoordTransform(that.fCoordTransform)
, fTextureDomain(that.fTextureDomain)
, fTextureSampler(that.fTextureSampler)
, fColorSpaceXform(that.fColorSpaceXform) {
, fTextureSampler(that.fTextureSampler) {
this->addCoordTransform(&fCoordTransform);
this->addTextureSampler(&fTextureSampler);
}
@ -252,7 +245,6 @@ GrTextureDomainEffect::GrTextureDomainEffect(const GrTextureDomainEffect& that)
void GrTextureDomainEffect::onGetGLSLProcessorKey(const GrShaderCaps& caps,
GrProcessorKeyBuilder* b) const {
b->add32(GrTextureDomain::GLDomain::DomainKey(fTextureDomain));
b->add32(GrColorSpaceXform::XformKey(this->colorSpaceXform()));
}
GrGLSLFragmentProcessor* GrTextureDomainEffect::onCreateGLSLInstance() const {
@ -265,7 +257,6 @@ GrGLSLFragmentProcessor* GrTextureDomainEffect::onCreateGLSLInstance() const {
GrGLSLFPFragmentBuilder* fragBuilder = args.fFragBuilder;
SkString coords2D = fragBuilder->ensureCoords2D(args.fTransformedCoords[0]);
fColorSpaceHelper.emitCode(args.fUniformHandler, tde.colorSpaceXform());
fGLDomain.sampleTexture(fragBuilder,
args.fUniformHandler,
args.fShaderCaps,
@ -273,8 +264,7 @@ GrGLSLFragmentProcessor* GrTextureDomainEffect::onCreateGLSLInstance() const {
args.fOutputColor,
coords2D,
args.fTexSamplers[0],
args.fInputColor,
&fColorSpaceHelper);
args.fInputColor);
}
protected:
@ -285,14 +275,10 @@ GrGLSLFragmentProcessor* GrTextureDomainEffect::onCreateGLSLInstance() const {
GrSurfaceProxy* proxy = tde.textureSampler(0).proxy();
fGLDomain.setData(pdman, domain, proxy);
if (SkToBool(tde.colorSpaceXform())) {
fColorSpaceHelper.setData(pdman, tde.colorSpaceXform());
}
}
private:
GrTextureDomain::GLDomain fGLDomain;
GrGLSLColorSpaceXformHelper fColorSpaceHelper;
};
return new GLSLProcessor;
@ -321,10 +307,8 @@ std::unique_ptr<GrFragmentProcessor> GrTextureDomainEffect::TestCreate(GrProcess
(GrTextureDomain::Mode) d->fRandom->nextULessThan(GrTextureDomain::kModeCount);
const SkMatrix& matrix = GrTest::TestMatrix(d->fRandom);
bool bilerp = mode != GrTextureDomain::kRepeat_Mode ? d->fRandom->nextBool() : false;
sk_sp<GrColorSpaceXform> colorSpaceXform = GrTest::TestColorXform(d->fRandom);
return GrTextureDomainEffect::Make(
std::move(proxy),
std::move(colorSpaceXform),
matrix,
domain,
mode,

View File

@ -10,12 +10,10 @@
#include "GrCoordTransform.h"
#include "GrFragmentProcessor.h"
#include "GrColorSpaceXform.h"
#include "glsl/GrGLSLFragmentProcessor.h"
#include "glsl/GrGLSLProgramDataManager.h"
class GrGLProgramBuilder;
class GrGLSLColorSpaceXformHelper;
class GrGLSLShaderBuilder;
class GrInvariantOutput;
class GrGLSLUniformHandler;
@ -111,8 +109,7 @@ public:
const char* outColor,
const SkString& inCoords,
GrGLSLFragmentProcessor::SamplerHandle sampler,
const char* inModulateColor = nullptr,
GrGLSLColorSpaceXformHelper* colorXformHelper = nullptr);
const char* inModulateColor = nullptr);
/**
* Call this from GrGLSLFragmentProcessor::setData() to upload uniforms necessary for the
@ -154,7 +151,6 @@ protected:
class GrTextureDomainEffect : public GrFragmentProcessor {
public:
static std::unique_ptr<GrFragmentProcessor> Make(sk_sp<GrTextureProxy>,
sk_sp<GrColorSpaceXform>,
const SkMatrix&,
const SkRect& domain,
GrTextureDomain::Mode,
@ -179,10 +175,8 @@ private:
GrCoordTransform fCoordTransform;
GrTextureDomain fTextureDomain;
TextureSampler fTextureSampler;
sk_sp<GrColorSpaceXform> fColorSpaceXform;
GrTextureDomainEffect(sk_sp<GrTextureProxy>,
sk_sp<GrColorSpaceXform>,
const SkMatrix&,
const SkRect& domain,
GrTextureDomain::Mode,
@ -198,8 +192,6 @@ private:
bool onIsEqual(const GrFragmentProcessor&) const override;
const GrColorSpaceXform* colorSpaceXform() const { return fColorSpaceXform.get(); }
GR_DECLARE_FRAGMENT_PROCESSOR_TEST
typedef GrFragmentProcessor INHERITED;

View File

@ -1029,7 +1029,7 @@ sk_sp<SkImage> SkImage_Gpu::onMakeColorSpace(sk_sp<SkColorSpace> target, SkColor
GrPaint paint;
paint.setPorterDuffXPFactory(SkBlendMode::kSrc);
paint.addColorTextureProcessor(fProxy, nullptr, SkMatrix::I());
paint.addColorTextureProcessor(fProxy, SkMatrix::I());
paint.addColorFragmentProcessor(std::move(xform));
const SkRect rect = SkRect::MakeIWH(this->width(), this->height());

View File

@ -225,7 +225,7 @@ std::unique_ptr<GrFragmentProcessor> SkImageShader::asFragmentProcessor(
if (doBicubic) {
inner = GrBicubicEffect::Make(std::move(proxy), lmInverse, wrapModes);
} else {
inner = GrSimpleTextureEffect::Make(std::move(proxy), nullptr, lmInverse, samplerState);
inner = GrSimpleTextureEffect::Make(std::move(proxy), lmInverse, samplerState);
}
inner = GrColorSpaceXformEffect::Make(std::move(inner), texColorSpace.get(),
args.fDstColorSpace);

View File

@ -256,7 +256,7 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(IntTexture, reporter, ctxInfo) {
{GrSamplerState::Filter::kMipMap, "filter-mipmap"}};
for (auto filter : kNamedFilters) {
auto fp = GrSimpleTextureEffect::Make(sContext->asTextureProxyRef(), nullptr, SkMatrix::I(),
auto fp = GrSimpleTextureEffect::Make(sContext->asTextureProxyRef(), SkMatrix::I(),
filter.fMode);
REPORTER_ASSERT(reporter, fp);
if (!fp) {

View File

@ -416,7 +416,7 @@ static sk_sp<GrTextureProxy> make_upstream_image(GrContext* context, AtlasObject
// TODO: here is the blocker for deferring creation of the atlas. The TextureSamplers
// created here currently require a hard GrTexture.
auto fp = GrSimpleTextureEffect::Make(fakeAtlas, nullptr, SkMatrix::I());
auto fp = GrSimpleTextureEffect::Make(fakeAtlas, SkMatrix::I());
GrPaint paint;
paint.addColorFragmentProcessor(std::move(fp));
paint.setPorterDuffXPFactory(SkBlendMode::kSrc);
@ -551,7 +551,7 @@ DEF_GPUTEST_FOR_GL_RENDERING_CONTEXTS(OnFlushCallbackTest, reporter, ctxInfo) {
SkMatrix t = SkMatrix::MakeTrans(-i*3*kDrawnTileSize, 0);
GrPaint paint;
auto fp = GrSimpleTextureEffect::Make(std::move(proxies[i]), nullptr, t);
auto fp = GrSimpleTextureEffect::Make(std::move(proxies[i]), t);
paint.setPorterDuffXPFactory(SkBlendMode::kSrc);
paint.addColorFragmentProcessor(std::move(fp));

View File

@ -329,7 +329,7 @@ static GrColor4f input_texel_color4f(int i, int j) {
void test_draw_op(GrRenderTargetContext* rtc, std::unique_ptr<GrFragmentProcessor> fp,
sk_sp<GrTextureProxy> inputDataProxy) {
GrPaint paint;
paint.addColorTextureProcessor(std::move(inputDataProxy), nullptr, SkMatrix::I());
paint.addColorTextureProcessor(std::move(inputDataProxy), SkMatrix::I());
paint.addColorFragmentProcessor(std::move(fp));
paint.setPorterDuffXPFactory(SkBlendMode::kSrc);

View File

@ -29,7 +29,7 @@ static void test_basic_draw_as_src(skiatest::Reporter* reporter, GrContext* cont
GrSamplerState::Filter::kBilerp,
GrSamplerState::Filter::kMipMap}) {
rtContext->clear(nullptr, 0xDDCCBBAA, true);
auto fp = GrSimpleTextureEffect::Make(rectProxy, nullptr, SkMatrix::I(), filter);
auto fp = GrSimpleTextureEffect::Make(rectProxy, SkMatrix::I(), filter);
GrPaint paint;
paint.setPorterDuffXPFactory(SkBlendMode::kSrc);
paint.addColorFragmentProcessor(std::move(fp));

View File

@ -147,8 +147,7 @@ DEF_GPUTEST_FOR_GL_RENDERING_CONTEXTS(SRGBMipMaps, reporter, ctxInfo) {
paint.setPorterDuffXPFactory(SkBlendMode::kSrc);
GrSamplerState mipMapSamplerState(GrSamplerState::WrapMode::kRepeat,
GrSamplerState::Filter::kMipMap);
paint.addColorTextureProcessor(std::move(proxy), nullptr, SkMatrix::MakeScale(rtS),
mipMapSamplerState);
paint.addColorTextureProcessor(std::move(proxy), SkMatrix::MakeScale(rtS), mipMapSamplerState);
// 1) Draw texture to S32 surface (should generate/use sRGB mips)
paint.setGammaCorrect(true);