Merge latest Skia into master (3 commits)
https://skia.googlesource.com/skia.git/+log/652ecb5..a7d61a6
Test: Presubmit checks will test this change.
Change-Id: I7a5f991c6f4708af40755dc19f049f52973f4950
diff --git a/gm/texdata.cpp b/gm/texdata.cpp
index 372ff5d..8520d28 100644
--- a/gm/texdata.cpp
+++ b/gm/texdata.cpp
@@ -97,7 +97,10 @@
} else {
vm.reset();
}
- paint.addColorTextureProcessor(texture, nullptr, vm);
+ SkMatrix tm;
+ tm = vm;
+ tm.postIDiv(2*S, 2*S);
+ paint.addColorTextureProcessor(texture, nullptr, tm);
renderTargetContext->drawRect(clip, GrPaint(paint), GrAA::kNo, vm,
SkRect::MakeWH(2 * S, 2 * S));
diff --git a/gm/texturedomaineffect.cpp b/gm/texturedomaineffect.cpp
index cc3e1c9..32042aa 100644
--- a/gm/texturedomaineffect.cpp
+++ b/gm/texturedomaineffect.cpp
@@ -89,10 +89,11 @@
}
SkTArray<SkMatrix> textureMatrices;
- textureMatrices.push_back() = SkMatrix::I();
- textureMatrices.push_back() = SkMatrix::MakeScale(1.5f, 0.85f);
- textureMatrices.push_back();
- textureMatrices.back().setRotate(45.f, texture->width() / 2.f, texture->height() / 2.f);
+ textureMatrices.push_back().setIDiv(texture->width(), texture->height());
+ textureMatrices.push_back() = textureMatrices[0];
+ textureMatrices.back().postScale(1.5f, 0.85f);
+ textureMatrices.push_back() = textureMatrices[0];
+ textureMatrices.back().preRotate(45.f, texture->width() / 2.f, texture->height() / 2.f);
const SkIRect texelDomains[] = {
fBmp.bounds(),
diff --git a/include/gpu/GrCoordTransform.h b/include/gpu/GrCoordTransform.h
index 5c16c89..1f1cac7 100644
--- a/include/gpu/GrCoordTransform.h
+++ b/include/gpu/GrCoordTransform.h
@@ -20,11 +20,7 @@
*/
class GrCoordTransform : SkNoncopyable {
public:
- GrCoordTransform()
- : fTexture(nullptr)
- , fNormalize(false) {
- SkDEBUGCODE(fInProcessor = false);
- }
+ GrCoordTransform() { SkDEBUGCODE(fInProcessor = false); }
/**
* Create a transformation that maps [0, 1] to a texture's boundaries. The precision is inferred
@@ -34,7 +30,7 @@
GrCoordTransform(const GrTexture* texture, GrSamplerParams::FilterMode filter) {
SkASSERT(texture);
SkDEBUGCODE(fInProcessor = false);
- this->reset(SkMatrix::I(), texture, filter);
+ this->reset(texture, filter);
}
/**
@@ -56,23 +52,18 @@
this->reset(m, precision);
}
- void reset(const SkMatrix&, const GrTexture*, GrSamplerParams::FilterMode filter,
- bool normalize = true);
-
- void reset(const SkMatrix& m, GrSLPrecision precision = kDefault_GrSLPrecision) {
+ void reset(const GrTexture* texture, GrSamplerParams::FilterMode filter) {
SkASSERT(!fInProcessor);
- fMatrix = m;
- fTexture = nullptr;
- fNormalize = false;
- fReverseY = false;
- fPrecision = precision;
+ SkASSERT(texture);
+ this->reset(MakeDivByTextureWHMatrix(texture), texture, filter);
}
+ void reset(const SkMatrix&, const GrTexture*, GrSamplerParams::FilterMode filter);
+ void reset(const SkMatrix& m, GrSLPrecision precision = kDefault_GrSLPrecision);
+
GrCoordTransform& operator= (const GrCoordTransform& that) {
SkASSERT(!fInProcessor);
fMatrix = that.fMatrix;
- fTexture = that.fTexture;
- fNormalize = that.fNormalize;
fReverseY = that.fReverseY;
fPrecision = that.fPrecision;
return *this;
@@ -87,38 +78,29 @@
return &fMatrix;
}
- bool hasSameEffectAs(const GrCoordTransform& that) const {
- if (fNormalize != that.fNormalize ||
- fReverseY != that.fReverseY ||
- fPrecision != that.fPrecision ||
- !fMatrix.cheapEqualTo(that.fMatrix)) {
- return false;
- }
-
- if (fNormalize) {
- SkASSERT(fTexture && that.fTexture);
- return fTexture->width() == that.fTexture->width() &&
- fTexture->height() == that.fTexture->height();
- }
-
- return true;
+ bool operator==(const GrCoordTransform& that) const {
+ return fMatrix.cheapEqualTo(that.fMatrix) &&
+ fReverseY == that.fReverseY &&
+ fPrecision == that.fPrecision;
}
+ bool operator!=(const GrCoordTransform& that) const { return !(*this == that); }
+
const SkMatrix& getMatrix() const { return fMatrix; }
- const GrTexture* texture() const { return fTexture; }
- bool normalize() const { return fNormalize; }
bool reverseY() const { return fReverseY; }
GrSLPrecision precision() const { return fPrecision; }
-private:
- // The textures' effect is to optionally normalize the final matrix, so a blind
- // equality check could be misleading
- bool operator==(const GrCoordTransform& that) const;
- bool operator!=(const GrCoordTransform& that) const;
+ /** Useful for effects that want to insert a texture matrix that is implied by the texture
+ dimensions */
+ static inline SkMatrix MakeDivByTextureWHMatrix(const GrTexture* texture) {
+ SkASSERT(texture);
+ SkMatrix mat;
+ (void)mat.setIDiv(texture->width(), texture->height());
+ return mat;
+ }
+private:
SkMatrix fMatrix;
- const GrTexture* fTexture;
- bool fNormalize;
bool fReverseY;
GrSLPrecision fPrecision;
typedef SkNoncopyable INHERITED;
diff --git a/src/core/SkGpuBlurUtils.cpp b/src/core/SkGpuBlurUtils.cpp
index 6ac5abe..b3b523a 100644
--- a/src/core/SkGpuBlurUtils.cpp
+++ b/src/core/SkGpuBlurUtils.cpp
@@ -262,6 +262,10 @@
for (int i = 1; i < scaleFactorX || i < scaleFactorY; i *= 2) {
GrPaint paint;
paint.setGammaCorrect(dstRenderTargetContext->isGammaCorrect());
+ // TODO: this matrix relies on the final instantiated size of the texture. This
+ // will have to be deferred for TextureProxys
+ SkMatrix matrix;
+ matrix.setIDiv(srcTexture->width(), srcTexture->height());
SkIRect dstRect(srcRect);
if (srcBounds && i == 1) {
SkRect domain = SkRect::Make(*srcBounds);
@@ -270,7 +274,7 @@
sk_sp<GrFragmentProcessor> fp(GrTextureDomainEffect::Make(
srcTexture.get(),
nullptr,
- SkMatrix::I(),
+ matrix,
domain,
GrTextureDomain::kDecal_Mode,
GrSamplerParams::kBilerp_FilterMode));
@@ -279,7 +283,7 @@
srcOffset.set(0, 0);
} else {
GrSamplerParams params(SkShader::kClamp_TileMode, GrSamplerParams::kBilerp_FilterMode);
- paint.addColorTextureProcessor(srcTexture.get(), nullptr, SkMatrix::I(), params);
+ paint.addColorTextureProcessor(srcTexture.get(), nullptr, matrix, params);
}
paint.setPorterDuffXPFactory(SkBlendMode::kSrc);
shrink_irect_by_2(&dstRect, i < scaleFactorX, i < scaleFactorY);
@@ -365,7 +369,12 @@
return nullptr;
}
- paint.addColorTextureProcessor(tex.get(), nullptr, SkMatrix::I(), params);
+ // TODO: this matrix relies on the final instantiated size of the texture. This
+ // will have to be deferred for TextureProxys
+ SkMatrix matrix;
+ matrix.setIDiv(tex->width(), tex->height());
+
+ paint.addColorTextureProcessor(tex.get(), nullptr, matrix, params);
paint.setPorterDuffXPFactory(SkBlendMode::kSrc);
SkIRect dstRect(srcRect);
diff --git a/src/core/SkImageInfoPriv.h b/src/core/SkImageInfoPriv.h
index 029aa93..72138ae 100644
--- a/src/core/SkImageInfoPriv.h
+++ b/src/core/SkImageInfoPriv.h
@@ -69,11 +69,9 @@
return false;
}
- // FIXME (msarett): This is commented out until a fix to Chrome's gfx_unittest lands.
- // In those tests, they write kPremul pixels to a kOpaque canvas.
- //if (kOpaque_SkAlphaType == dst.alphaType() && kOpaque_SkAlphaType != src.alphaType()) {
- // return false;
- //}
+ if (kOpaque_SkAlphaType == dst.alphaType() && kOpaque_SkAlphaType != src.alphaType()) {
+ return false;
+ }
return true;
}
diff --git a/src/core/SkMatrix.cpp b/src/core/SkMatrix.cpp
index 390ebe0..a05ae0a 100644
--- a/src/core/SkMatrix.cpp
+++ b/src/core/SkMatrix.cpp
@@ -1038,7 +1038,7 @@
const SkMatrix::MapPtsProc SkMatrix::gMapPtsProcs[] = {
SkMatrix::Identity_pts, SkMatrix::Trans_pts,
- SkMatrix::Scale_pts, SkMatrix::Scale_pts,
+ SkMatrix::Scale_pts, SkMatrix::Scale_pts,
SkMatrix::Affine_vpts, SkMatrix::Affine_vpts,
SkMatrix::Affine_vpts, SkMatrix::Affine_vpts,
// repeat the persp proc 8 times
diff --git a/src/effects/GrAlphaThresholdFragmentProcessor.cpp b/src/effects/GrAlphaThresholdFragmentProcessor.cpp
index a259607..afafe08 100644
--- a/src/effects/GrAlphaThresholdFragmentProcessor.cpp
+++ b/src/effects/GrAlphaThresholdFragmentProcessor.cpp
@@ -32,6 +32,12 @@
bounds));
}
+static SkMatrix make_div_and_translate_matrix(GrTexture* texture, int x, int y) {
+ SkMatrix matrix = GrCoordTransform::MakeDivByTextureWHMatrix(texture);
+ matrix.preTranslate(SkIntToScalar(x), SkIntToScalar(y));
+ return matrix;
+}
+
GrAlphaThresholdFragmentProcessor::GrAlphaThresholdFragmentProcessor(
GrTexture* texture,
sk_sp<GrColorSpaceXform> colorSpaceXform,
@@ -41,11 +47,11 @@
const SkIRect& bounds)
: fInnerThreshold(innerThreshold)
, fOuterThreshold(outerThreshold)
- , fImageCoordTransform(SkMatrix::I(), texture, GrSamplerParams::kNone_FilterMode)
+ , fImageCoordTransform(GrCoordTransform::MakeDivByTextureWHMatrix(texture), texture,
+ GrSamplerParams::kNone_FilterMode)
, fImageTextureSampler(texture)
, fColorSpaceXform(std::move(colorSpaceXform))
- , fMaskCoordTransform(SkMatrix::MakeTrans(SkIntToScalar(-bounds.x()),
- SkIntToScalar(-bounds.y())),
+ , fMaskCoordTransform(make_div_and_translate_matrix(maskTexture, -bounds.x(), -bounds.y()),
maskTexture,
GrSamplerParams::kNone_FilterMode)
, fMaskTextureSampler(maskTexture) {
diff --git a/src/effects/SkArithmeticImageFilter.cpp b/src/effects/SkArithmeticImageFilter.cpp
index d33a9dc..3e4d48f 100644
--- a/src/effects/SkArithmeticImageFilter.cpp
+++ b/src/effects/SkArithmeticImageFilter.cpp
@@ -348,8 +348,10 @@
sk_sp<GrFragmentProcessor> bgFP;
if (backgroundTex) {
- SkMatrix backgroundMatrix = SkMatrix::MakeTrans(-SkIntToScalar(backgroundOffset.fX),
- -SkIntToScalar(backgroundOffset.fY));
+ SkMatrix backgroundMatrix;
+ backgroundMatrix.setIDiv(backgroundTex->width(), backgroundTex->height());
+ backgroundMatrix.preTranslate(-SkIntToScalar(backgroundOffset.fX),
+ -SkIntToScalar(backgroundOffset.fY));
sk_sp<GrColorSpaceXform> bgXform =
GrColorSpaceXform::Make(background->getColorSpace(), outputProperties.colorSpace());
bgFP = GrTextureDomainEffect::Make(
@@ -362,8 +364,10 @@
}
if (foregroundTex) {
- SkMatrix foregroundMatrix = SkMatrix::MakeTrans(-SkIntToScalar(foregroundOffset.fX),
- -SkIntToScalar(foregroundOffset.fY));
+ SkMatrix foregroundMatrix;
+ foregroundMatrix.setIDiv(foregroundTex->width(), foregroundTex->height());
+ foregroundMatrix.preTranslate(-SkIntToScalar(foregroundOffset.fX),
+ -SkIntToScalar(foregroundOffset.fY));
sk_sp<GrColorSpaceXform> fgXform =
GrColorSpaceXform::Make(foreground->getColorSpace(), outputProperties.colorSpace());
sk_sp<GrFragmentProcessor> foregroundFP;
diff --git a/src/effects/SkBlurMaskFilter.cpp b/src/effects/SkBlurMaskFilter.cpp
index 70afd91..fa4cb33 100644
--- a/src/effects/SkBlurMaskFilter.cpp
+++ b/src/effects/SkBlurMaskFilter.cpp
@@ -1520,9 +1520,10 @@
if (!isNormalBlur) {
GrPaint paint;
+ SkMatrix matrix;
+ matrix.setIDiv(src->width(), src->height());
// Blend pathTexture over blurTexture.
- paint.addCoverageFragmentProcessor(
- GrSimpleTextureEffect::Make(src, nullptr, SkMatrix::I()));
+ paint.addCoverageFragmentProcessor(GrSimpleTextureEffect::Make(src, nullptr, matrix));
if (kInner_SkBlurStyle == fBlurStyle) {
// inner: dst = dst * src
paint.setCoverageSetOpXPFactory(SkRegion::kIntersect_Op);
diff --git a/src/effects/SkDisplacementMapEffect.cpp b/src/effects/SkDisplacementMapEffect.cpp
index 0d39403..28483bd 100644
--- a/src/effects/SkDisplacementMapEffect.cpp
+++ b/src/effects/SkDisplacementMapEffect.cpp
@@ -336,8 +336,9 @@
return nullptr;
}
- SkMatrix offsetMatrix = SkMatrix::MakeTrans(SkIntToScalar(colorOffset.fX - displOffset.fX),
- SkIntToScalar(colorOffset.fY - displOffset.fY));
+ SkMatrix offsetMatrix = GrCoordTransform::MakeDivByTextureWHMatrix(displTexture.get());
+ offsetMatrix.preTranslate(SkIntToScalar(colorOffset.fX - displOffset.fX),
+ SkIntToScalar(colorOffset.fY - displOffset.fY));
SkColorSpace* colorSpace = ctx.outputProperties().colorSpace();
sk_sp<GrColorSpaceXform> colorSpaceXform = GrColorSpaceXform::Make(color->getColorSpace(),
colorSpace);
diff --git a/src/effects/SkLightingImageFilter.cpp b/src/effects/SkLightingImageFilter.cpp
index 67ded34..1d710bf 100644
--- a/src/effects/SkLightingImageFilter.cpp
+++ b/src/effects/SkLightingImageFilter.cpp
@@ -1707,7 +1707,7 @@
const SkMatrix& matrix,
BoundaryMode boundaryMode,
const SkIRect* srcBounds)
- : INHERITED(texture, nullptr, SkMatrix::I())
+ : INHERITED(texture, nullptr, GrCoordTransform::MakeDivByTextureWHMatrix(texture))
, fLight(light)
, fSurfaceScale(surfaceScale)
, fFilterMatrix(matrix)
diff --git a/src/effects/SkMagnifierImageFilter.cpp b/src/effects/SkMagnifierImageFilter.cpp
index c8b32ae..2b04532 100644
--- a/src/effects/SkMagnifierImageFilter.cpp
+++ b/src/effects/SkMagnifierImageFilter.cpp
@@ -71,7 +71,8 @@
float yInvZoom,
float xInvInset,
float yInvInset)
- : INHERITED(texture, std::move(colorSpaceXform), SkMatrix::I())
+ : INHERITED(texture, std::move(colorSpaceXform),
+ GrCoordTransform::MakeDivByTextureWHMatrix(texture))
, fBounds(bounds)
, fXOffset(xOffset)
, fYOffset(yOffset)
diff --git a/src/effects/SkPerlinNoiseShader.cpp b/src/effects/SkPerlinNoiseShader.cpp
index f5a8b87..dc3d9a6 100644
--- a/src/effects/SkPerlinNoiseShader.cpp
+++ b/src/effects/SkPerlinNoiseShader.cpp
@@ -515,6 +515,7 @@
bool stitchTiles() const { return fStitchTiles; }
const SkVector& baseFrequency() const { return fPaintingData->fBaseFrequency; }
int numOctaves() const { return fNumOctaves; }
+ const SkMatrix& matrix() const { return fCoordTransform.getMatrix(); }
private:
GrGLSLFragmentProcessor* onCreateGLSLInstance() const override {
@@ -545,7 +546,6 @@
GrTexture* permutationsTexture, GrTexture* noiseTexture,
const SkMatrix& matrix)
: fType(type)
- , fCoordTransform(matrix)
, fNumOctaves(numOctaves)
, fStitchTiles(stitchTiles)
, fPermutationsSampler(permutationsTexture)
@@ -554,6 +554,7 @@
this->initClassID<GrPerlinNoiseEffect>();
this->addTextureSampler(&fPermutationsSampler);
this->addTextureSampler(&fNoiseSampler);
+ fCoordTransform.reset(matrix);
this->addCoordTransform(&fCoordTransform);
}
diff --git a/src/effects/SkXfermodeImageFilter.cpp b/src/effects/SkXfermodeImageFilter.cpp
index c52eeba..7f91df3 100644
--- a/src/effects/SkXfermodeImageFilter.cpp
+++ b/src/effects/SkXfermodeImageFilter.cpp
@@ -249,8 +249,10 @@
sk_sp<GrFragmentProcessor> bgFP;
if (backgroundTex) {
- SkMatrix backgroundMatrix = SkMatrix::MakeTrans(-SkIntToScalar(backgroundOffset.fX),
- -SkIntToScalar(backgroundOffset.fY));
+ SkMatrix backgroundMatrix;
+ backgroundMatrix.setIDiv(backgroundTex->width(), backgroundTex->height());
+ backgroundMatrix.preTranslate(-SkIntToScalar(backgroundOffset.fX),
+ -SkIntToScalar(backgroundOffset.fY));
sk_sp<GrColorSpaceXform> bgXform = GrColorSpaceXform::Make(background->getColorSpace(),
outputProperties.colorSpace());
bgFP = GrTextureDomainEffect::Make(
@@ -264,8 +266,10 @@
}
if (foregroundTex) {
- SkMatrix foregroundMatrix = SkMatrix::MakeTrans(-SkIntToScalar(foregroundOffset.fX),
- -SkIntToScalar(foregroundOffset.fY));
+ SkMatrix foregroundMatrix;
+ foregroundMatrix.setIDiv(foregroundTex->width(), foregroundTex->height());
+ foregroundMatrix.preTranslate(-SkIntToScalar(foregroundOffset.fX),
+ -SkIntToScalar(foregroundOffset.fY));
sk_sp<GrColorSpaceXform> fgXform = GrColorSpaceXform::Make(foreground->getColorSpace(),
outputProperties.colorSpace());
sk_sp<GrFragmentProcessor> foregroundFP;
diff --git a/src/effects/gradients/SkGradientShader.cpp b/src/effects/gradients/SkGradientShader.cpp
index 1d2c01e..ca64cb7 100644
--- a/src/effects/gradients/SkGradientShader.cpp
+++ b/src/effects/gradients/SkGradientShader.cpp
@@ -1659,17 +1659,14 @@
fRow = fAtlas->lockRow(bitmap);
if (-1 != fRow) {
fYCoord = fAtlas->getYOffset(fRow)+SK_ScalarHalf*fAtlas->getNormalizedTexelHeight();
- // This is 1/2 places where auto-normalization is disabled
- fCoordTransform.reset(*args.fMatrix, fAtlas->getTexture(),
- params.filterMode(), false);
+ fCoordTransform.reset(*args.fMatrix, fAtlas->getTexture(), params.filterMode());
fTextureSampler.reset(fAtlas->getTexture(), params);
} else {
sk_sp<GrTexture> texture(GrRefCachedBitmapTexture(args.fContext, bitmap, params));
if (!texture) {
return;
}
- // This is 2/2 places where auto-normalization is disabled
- fCoordTransform.reset(*args.fMatrix, texture.get(), params.filterMode(), false);
+ fCoordTransform.reset(*args.fMatrix, texture.get(), params.filterMode());
fTextureSampler.reset(texture.get(), params);
fYCoord = SK_ScalarHalf;
}
diff --git a/src/gpu/GrBlurUtils.cpp b/src/gpu/GrBlurUtils.cpp
index 61290b0..23a3c6c 100644
--- a/src/gpu/GrBlurUtils.cpp
+++ b/src/gpu/GrBlurUtils.cpp
@@ -46,8 +46,10 @@
return false;
}
- SkMatrix matrix = SkMatrix::MakeTrans(-SkIntToScalar(maskRect.fLeft),
- -SkIntToScalar(maskRect.fTop));
+ SkMatrix matrix;
+ matrix.setTranslate(-SkIntToScalar(maskRect.fLeft), -SkIntToScalar(maskRect.fTop));
+ // TODO: this divide relies on the instantiated texture's size!
+ matrix.postIDiv(maskTex->width(), maskTex->height());
matrix.preConcat(viewMatrix);
paint.addCoverageFragmentProcessor(GrSimpleTextureEffect::Make(maskTex, nullptr, matrix));
diff --git a/src/gpu/GrContext.cpp b/src/gpu/GrContext.cpp
index 1e2bdc7..1256058 100644
--- a/src/gpu/GrContext.cpp
+++ b/src/gpu/GrContext.cpp
@@ -308,8 +308,10 @@
SkAutoSTMalloc<128 * 128, uint32_t> tmpPixels(0);
if (tempTexture) {
sk_sp<GrFragmentProcessor> fp;
+ SkMatrix textureMatrix;
+ textureMatrix.setIDiv(tempTexture->width(), tempTexture->height());
if (applyPremulToSrc) {
- fp = this->createUPMToPMEffect(tempTexture.get(), tempDrawInfo.fSwizzle, SkMatrix::I());
+ fp = this->createUPMToPMEffect(tempTexture.get(), tempDrawInfo.fSwizzle, textureMatrix);
// If premultiplying was the only reason for the draw, fall back to a straight write.
if (!fp) {
if (GrGpu::kCallerPrefersDraw_DrawPreference == drawPreference) {
@@ -323,7 +325,7 @@
if (!fp) {
fp = GrConfigConversionEffect::Make(tempTexture.get(), tempDrawInfo.fSwizzle,
GrConfigConversionEffect::kNone_PMConversion,
- SkMatrix::I());
+ textureMatrix);
if (!fp) {
return false;
}
@@ -461,7 +463,9 @@
tempDrawInfo.fTempSurfaceDesc.fSampleCnt,
tempDrawInfo.fTempSurfaceDesc.fOrigin);
if (tempRTC) {
- SkMatrix textureMatrix = SkMatrix::MakeTrans(SkIntToScalar(left), SkIntToScalar(top));
+ SkMatrix textureMatrix;
+ textureMatrix.setTranslate(SkIntToScalar(left), SkIntToScalar(top));
+ textureMatrix.postIDiv(src->width(), src->height());
sk_sp<GrFragmentProcessor> fp;
if (unpremul) {
fp = this->createPMToUPMEffect(src->asTexture(), tempDrawInfo.fSwizzle,
diff --git a/src/gpu/GrCoordTransform.cpp b/src/gpu/GrCoordTransform.cpp
index 4afd0ef..63d91a8 100644
--- a/src/gpu/GrCoordTransform.cpp
+++ b/src/gpu/GrCoordTransform.cpp
@@ -11,13 +11,11 @@
#include "GrGpu.h"
void GrCoordTransform::reset(const SkMatrix& m, const GrTexture* texture,
- GrSamplerParams::FilterMode filter, bool normalize) {
+ GrSamplerParams::FilterMode filter) {
SkASSERT(texture);
SkASSERT(!fInProcessor);
fMatrix = m;
- fTexture = texture;
- fNormalize = normalize;
fReverseY = kBottomLeft_GrSurfaceOrigin == texture->origin();
// Always start at kDefault. Then if precisions differ we see if the precision needs to be
@@ -54,3 +52,9 @@
}
}
+void GrCoordTransform::reset(const SkMatrix& m, GrSLPrecision precision) {
+ SkASSERT(!fInProcessor);
+ fMatrix = m;
+ fReverseY = false;
+ fPrecision = precision;
+}
diff --git a/src/gpu/GrFragmentProcessor.cpp b/src/gpu/GrFragmentProcessor.cpp
index 8a710e5..977974d 100644
--- a/src/gpu/GrFragmentProcessor.cpp
+++ b/src/gpu/GrFragmentProcessor.cpp
@@ -92,7 +92,7 @@
}
int count = this->numCoordTransforms();
for (int i = 0; i < count; ++i) {
- if (!this->coordTransform(i).hasSameEffectAs(that.coordTransform(i))) {
+ if (this->coordTransform(i) != that.coordTransform(i)) {
return false;
}
}
diff --git a/src/gpu/GrSWMaskHelper.cpp b/src/gpu/GrSWMaskHelper.cpp
index 5dbbaf0..240f9f9 100644
--- a/src/gpu/GrSWMaskHelper.cpp
+++ b/src/gpu/GrSWMaskHelper.cpp
@@ -176,8 +176,10 @@
// We use device coords to compute the texture coordinates. We take the device coords and apply
// a translation so that the top-left of the device bounds maps to 0,0, and then a scaling
// matrix to normalized coords.
- SkMatrix maskMatrix = SkMatrix::MakeTrans(SkIntToScalar(-textureOriginInDeviceSpace.fX),
- SkIntToScalar(-textureOriginInDeviceSpace.fY));
+ SkMatrix maskMatrix;
+ maskMatrix.setIDiv(texture->width(), texture->height());
+ maskMatrix.preTranslate(SkIntToScalar(-textureOriginInDeviceSpace.fX),
+ SkIntToScalar(-textureOriginInDeviceSpace.fY));
maskMatrix.preConcat(viewMatrix);
std::unique_ptr<GrDrawOp> op = GrRectOpFactory::MakeNonAAFill(paint.getColor(), SkMatrix::I(),
dstRect, nullptr, &invert);
diff --git a/src/gpu/GrTextureAdjuster.cpp b/src/gpu/GrTextureAdjuster.cpp
index db9bbde..7142ab9 100644
--- a/src/gpu/GrTextureAdjuster.cpp
+++ b/src/gpu/GrTextureAdjuster.cpp
@@ -156,6 +156,7 @@
}
SkASSERT(kNoDomain_DomainMode == domainMode ||
(domain.fLeft <= domain.fRight && domain.fTop <= domain.fBottom));
+ textureMatrix.postIDiv(texture->width(), texture->height());
sk_sp<GrColorSpaceXform> colorSpaceXform = GrColorSpaceXform::Make(fColorSpace,
dstColorSpace);
return CreateFragmentProcessorForDomainAndFilter(texture.get(), std::move(colorSpaceXform),
diff --git a/src/gpu/GrTextureMaker.cpp b/src/gpu/GrTextureMaker.cpp
index cc6c703..37272be 100644
--- a/src/gpu/GrTextureMaker.cpp
+++ b/src/gpu/GrTextureMaker.cpp
@@ -87,10 +87,12 @@
texture->width(), texture->height(),
nullptr, fmForDetermineDomain, &domain);
SkASSERT(kTightCopy_DomainMode != domainMode);
+ SkMatrix normalizedTextureMatrix = textureMatrix;
+ normalizedTextureMatrix.postIDiv(texture->width(), texture->height());
sk_sp<GrColorSpaceXform> colorSpaceXform = GrColorSpaceXform::Make(texColorSpace.get(),
dstColorSpace);
return CreateFragmentProcessorForDomainAndFilter(texture.get(), std::move(colorSpaceXform),
- textureMatrix, domainMode, domain,
+ normalizedTextureMatrix, domainMode, domain,
filterOrNullForBicubic);
}
diff --git a/src/gpu/GrTextureProducer.cpp b/src/gpu/GrTextureProducer.cpp
index 496dbb2..0adae8c 100644
--- a/src/gpu/GrTextureProducer.cpp
+++ b/src/gpu/GrTextureProducer.cpp
@@ -52,9 +52,16 @@
SkRect localRect;
if (subset) {
+ SkScalar sx = SK_Scalar1 / inputTexture->width();
+ SkScalar sy = SK_Scalar1 / inputTexture->height();
+
localRect = SkRect::Make(*subset);
+ localRect.fLeft *= sx;
+ localRect.fTop *= sy;
+ localRect.fRight *= sx;
+ localRect.fBottom *= sy;
} else {
- localRect = SkRect::MakeWH(inputTexture->width(), inputTexture->height());
+ localRect = SkRect::MakeWH(1.f, 1.f);
}
SkRect dstRect = SkRect::MakeIWH(copyParams.fWidth, copyParams.fHeight);
diff --git a/src/gpu/GrTextureToYUVPlanes.cpp b/src/gpu/GrTextureToYUVPlanes.cpp
index 132b680..b9252fa 100644
--- a/src/gpu/GrTextureToYUVPlanes.cpp
+++ b/src/gpu/GrTextureToYUVPlanes.cpp
@@ -22,8 +22,8 @@
static bool convert_texture(GrTexture* src, GrRenderTargetContext* dst, int dstW, int dstH,
SkYUVColorSpace colorSpace, MakeFPProc proc) {
- SkScalar xScale = SkIntToScalar(src->width()) / dstW;
- SkScalar yScale = SkIntToScalar(src->height()) / dstH;
+ SkScalar xScale = SkIntToScalar(src->width()) / dstW / src->width();
+ SkScalar yScale = SkIntToScalar(src->height()) / dstH / src->height();
GrSamplerParams::FilterMode filter;
if (dstW == src->width() && dstW == src->height()) {
filter = GrSamplerParams::kNone_FilterMode;
diff --git a/src/gpu/GrYUVProvider.cpp b/src/gpu/GrYUVProvider.cpp
index 2f75d92..1330cfe 100644
--- a/src/gpu/GrYUVProvider.cpp
+++ b/src/gpu/GrYUVProvider.cpp
@@ -146,7 +146,7 @@
paint.setPorterDuffXPFactory(SkBlendMode::kSrc);
const SkRect r = SkRect::MakeIWH(yuvInfo.fSizeInfo.fSizes[SkYUVSizeInfo::kY].fWidth,
- yuvInfo.fSizeInfo.fSizes[SkYUVSizeInfo::kY].fHeight);
+ yuvInfo.fSizeInfo.fSizes[SkYUVSizeInfo::kY].fHeight);
renderTargetContext->drawRect(GrNoClip(), std::move(paint), GrAA::kNo, SkMatrix::I(), r);
diff --git a/src/gpu/SkGpuDevice.cpp b/src/gpu/SkGpuDevice.cpp
index 25ad781..1dec0f6 100644
--- a/src/gpu/SkGpuDevice.cpp
+++ b/src/gpu/SkGpuDevice.cpp
@@ -1048,8 +1048,13 @@
sk_sp<GrColorSpaceXform> colorSpaceXform =
GrColorSpaceXform::Make(bitmap.colorSpace(), fRenderTargetContext->getColorSpace());
+ SkScalar iw = 1.f / texture->width();
+ SkScalar ih = 1.f / texture->height();
+
+ SkMatrix texMatrix;
// Compute a matrix that maps the rect we will draw to the src rect.
- SkMatrix texMatrix = SkMatrix::MakeRectToRect(dstRect, srcRect, SkMatrix::kFill_ScaleToFit);
+ texMatrix.setRectToRect(dstRect, srcRect, SkMatrix::kFill_ScaleToFit);
+ texMatrix.postScale(iw, ih);
// Construct a GrPaint by setting the bitmap texture as the first effect and then configuring
// the rest from the SkPaint.
@@ -1195,7 +1200,10 @@
SkMatrix::I(),
SkRect::Make(SkIRect::MakeXYWH(
left + offset.fX, top + offset.fY, subset.width(), subset.height())),
- SkRect::Make(subset));
+ SkRect::MakeXYWH(SkIntToScalar(subset.fLeft) / texture->width(),
+ SkIntToScalar(subset.fTop) / texture->height(),
+ SkIntToScalar(subset.width()) / texture->width(),
+ SkIntToScalar(subset.height()) / texture->height()));
}
void SkGpuDevice::drawBitmapRect(const SkDraw& draw, const SkBitmap& bitmap,
diff --git a/src/gpu/effects/Gr1DKernelEffect.h b/src/gpu/effects/Gr1DKernelEffect.h
index 29e0e5d..d7402e8 100644
--- a/src/gpu/effects/Gr1DKernelEffect.h
+++ b/src/gpu/effects/Gr1DKernelEffect.h
@@ -31,7 +31,7 @@
Gr1DKernelEffect(GrTexture* texture,
Direction direction,
int radius)
- : INHERITED(texture, nullptr, SkMatrix::I())
+ : INHERITED(texture, nullptr, GrCoordTransform::MakeDivByTextureWHMatrix(texture))
, fDirection(direction)
, fRadius(radius) {}
diff --git a/src/gpu/effects/GrBicubicEffect.cpp b/src/gpu/effects/GrBicubicEffect.cpp
index 07d1c53..50a2a5d 100644
--- a/src/gpu/effects/GrBicubicEffect.cpp
+++ b/src/gpu/effects/GrBicubicEffect.cpp
@@ -181,7 +181,8 @@
static const SkShader::TileMode kClampClamp[] =
{ SkShader::kClamp_TileMode, SkShader::kClamp_TileMode };
return GrBicubicEffect::Make(d->fTextures[texIdx], colorSpaceXform,
- SkMatrix::I(), kClampClamp);
+ GrCoordTransform::MakeDivByTextureWHMatrix(d->fTextures[texIdx]),
+ kClampClamp);
}
//////////////////////////////////////////////////////////////////////////////
diff --git a/src/gpu/effects/GrConfigConversionEffect.cpp b/src/gpu/effects/GrConfigConversionEffect.cpp
index e6b3b28..8405fcb 100644
--- a/src/gpu/effects/GrConfigConversionEffect.cpp
+++ b/src/gpu/effects/GrConfigConversionEffect.cpp
@@ -216,7 +216,7 @@
*upmToPMRule = kConversionRules[i][1];
static const SkRect kDstRect = SkRect::MakeIWH(kSize, kSize);
- static const SkRect kSrcRect = SkRect::MakeIWH(kSize, kSize);
+ static const SkRect kSrcRect = SkRect::MakeIWH(1, 1);
// We do a PM->UPM draw from dataTex to readTex and read the data. Then we do a UPM->PM draw
// from readTex to tempTex followed by a PM->UPM draw to readTex and finally read the data.
// We then verify that two reads produced the same values.
diff --git a/src/gpu/effects/GrMatrixConvolutionEffect.cpp b/src/gpu/effects/GrMatrixConvolutionEffect.cpp
index 01fc6ce..8b98d0b 100644
--- a/src/gpu/effects/GrMatrixConvolutionEffect.cpp
+++ b/src/gpu/effects/GrMatrixConvolutionEffect.cpp
@@ -156,7 +156,7 @@
const SkIPoint& kernelOffset,
GrTextureDomain::Mode tileMode,
bool convolveAlpha)
- : INHERITED(texture, nullptr, SkMatrix::I()),
+ : INHERITED(texture, nullptr, GrCoordTransform::MakeDivByTextureWHMatrix(texture)),
fKernelSize(kernelSize),
fGain(SkScalarToFloat(gain)),
fBias(SkScalarToFloat(bias) / 255.0f),
diff --git a/src/gpu/effects/GrYUVEffect.cpp b/src/gpu/effects/GrYUVEffect.cpp
index 41bab18..6d1fac2 100644
--- a/src/gpu/effects/GrYUVEffect.cpp
+++ b/src/gpu/effects/GrYUVEffect.cpp
@@ -66,17 +66,18 @@
GrTexture* vTexture, const SkISize sizes[3],
SkYUVColorSpace colorSpace, bool nv12) {
SkScalar w[3], h[3];
- w[0] = SkIntToScalar(sizes[0].fWidth);
- h[0] = SkIntToScalar(sizes[0].fHeight);
- w[1] = SkIntToScalar(sizes[1].fWidth);
- h[1] = SkIntToScalar(sizes[1].fHeight);
- w[2] = SkIntToScalar(sizes[2].fWidth);
- h[2] = SkIntToScalar(sizes[2].fHeight);
- const SkMatrix yuvMatrix[3] = {
- SkMatrix::I(),
- SkMatrix::MakeScale(w[1] / w[0], h[1] / h[0]),
- SkMatrix::MakeScale(w[2] / w[0], h[2] / h[0])
- };
+ w[0] = SkIntToScalar(sizes[0].fWidth) / SkIntToScalar(yTexture->width());
+ h[0] = SkIntToScalar(sizes[0].fHeight) / SkIntToScalar(yTexture->height());
+ w[1] = SkIntToScalar(sizes[1].fWidth) / SkIntToScalar(uTexture->width());
+ h[1] = SkIntToScalar(sizes[1].fHeight) / SkIntToScalar(uTexture->height());
+ w[2] = SkIntToScalar(sizes[2].fWidth) / SkIntToScalar(vTexture->width());
+ h[2] = SkIntToScalar(sizes[2].fHeight) / SkIntToScalar(vTexture->height());
+ SkMatrix yuvMatrix[3];
+ yuvMatrix[0] = GrCoordTransform::MakeDivByTextureWHMatrix(yTexture);
+ yuvMatrix[1] = yuvMatrix[0];
+ yuvMatrix[1].preScale(w[1] / w[0], h[1] / h[0]);
+ yuvMatrix[2] = yuvMatrix[0];
+ yuvMatrix[2].preScale(w[2] / w[0], h[2] / h[0]);
GrSamplerParams::FilterMode uvFilterMode =
((sizes[1].fWidth != sizes[0].fWidth) ||
(sizes[1].fHeight != sizes[0].fHeight) ||
diff --git a/src/gpu/glsl/GrGLSLPrimitiveProcessor.cpp b/src/gpu/glsl/GrGLSLPrimitiveProcessor.cpp
index f39fff2..24f21ff 100644
--- a/src/gpu/glsl/GrGLSLPrimitiveProcessor.cpp
+++ b/src/gpu/glsl/GrGLSLPrimitiveProcessor.cpp
@@ -16,11 +16,6 @@
const GrCoordTransform& coordTransform) {
SkMatrix combined;
combined.setConcat(coordTransform.getMatrix(), localMatrix);
- if (coordTransform.normalize()) {
- SkASSERT(coordTransform.texture());
- combined.postIDiv(coordTransform.texture()->width(), coordTransform.texture()->height());
- }
-
if (coordTransform.reverseY()) {
// combined.postScale(1,-1);
// combined.postTranslate(0,1);
diff --git a/src/image/SkImageShader.cpp b/src/image/SkImageShader.cpp
index 50cc3c4..5b79fb1 100644
--- a/src/image/SkImageShader.cpp
+++ b/src/image/SkImageShader.cpp
@@ -144,6 +144,8 @@
#include "effects/GrSimpleTextureEffect.h"
sk_sp<GrFragmentProcessor> SkImageShader::asFragmentProcessor(const AsFPArgs& args) const {
+ SkMatrix matrix;
+ matrix.setIDiv(fImage->width(), fImage->height());
SkMatrix lmInverse;
if (!this->getLocalMatrix().invert(&lmInverse)) {
@@ -156,6 +158,7 @@
}
lmInverse.postConcat(inv);
}
+ matrix.preConcat(lmInverse);
SkShader::TileMode tm[] = { fTileModeX, fTileModeY };
@@ -179,10 +182,10 @@
args.fDstColorSpace);
sk_sp<GrFragmentProcessor> inner;
if (doBicubic) {
- inner = GrBicubicEffect::Make(texture.get(), std::move(colorSpaceXform), lmInverse, tm);
+ inner = GrBicubicEffect::Make(texture.get(), std::move(colorSpaceXform), matrix, tm);
} else {
inner = GrSimpleTextureEffect::Make(texture.get(), std::move(colorSpaceXform),
- lmInverse, params);
+ matrix, params);
}
if (GrPixelConfigIsAlphaOnly(texture->config())) {
diff --git a/src/splicer/SkSplicer_stages.cpp b/src/splicer/SkSplicer_stages.cpp
index 935995b..755bb5d 100644
--- a/src/splicer/SkSplicer_stages.cpp
+++ b/src/splicer/SkSplicer_stages.cpp
@@ -12,9 +12,6 @@
#error This file is not like the rest of Skia. It must be compiled with clang.
#endif
-// We have very specific inlining requirements. It helps to just take total control.
-#define AI __attribute__((always_inline)) inline
-
#if defined(__aarch64__)
#include <arm_neon.h>
@@ -25,15 +22,15 @@
using U8 = uint8_t __attribute__((ext_vector_type(4)));
// We polyfill a few routines that Clang doesn't build into ext_vector_types.
- AI static F min(F a, F b) { return vminq_f32(a,b); }
- AI static F max(F a, F b) { return vmaxq_f32(a,b); }
- AI static F fma(F f, F m, F a) { return vfmaq_f32(a,f,m); }
- AI static F rcp (F v) { auto e = vrecpeq_f32 (v); return vrecpsq_f32 (v,e ) * e; }
- AI static F rsqrt(F v) { auto e = vrsqrteq_f32(v); return vrsqrtsq_f32(v,e*e) * e; }
- AI static F if_then_else(I32 c, F t, F e) { return vbslq_f32((U32)c,t,e); }
- AI static U32 round(F v, F scale) { return vcvtnq_u32_f32(v*scale); }
+ static F min(F a, F b) { return vminq_f32(a,b); }
+ static F max(F a, F b) { return vmaxq_f32(a,b); }
+ static F fma(F f, F m, F a) { return vfmaq_f32(a,f,m); }
+ static F rcp (F v) { auto e = vrecpeq_f32 (v); return vrecpsq_f32 (v,e ) * e; }
+ static F rsqrt(F v) { auto e = vrsqrteq_f32(v); return vrsqrtsq_f32(v,e*e) * e; }
+ static F if_then_else(I32 c, F t, F e) { return vbslq_f32((U32)c,t,e); }
+ static U32 round(F v, F scale) { return vcvtnq_u32_f32(v*scale); }
- AI static F gather(const float* p, U32 ix) { return {p[ix[0]], p[ix[1]], p[ix[2]], p[ix[3]]}; }
+ static F gather(const float* p, U32 ix) { return {p[ix[0]], p[ix[1]], p[ix[2]], p[ix[3]]}; }
#elif defined(__ARM_NEON__)
#if defined(__thumb2__) || !defined(__ARM_ARCH_7A__) || !defined(__ARM_VFPV4__)
#error On ARMv7, compile with -march=armv7-a -mfpu=neon-vfp4, without -mthumb.
@@ -46,15 +43,15 @@
using U32 = uint32_t __attribute__((ext_vector_type(2)));
using U8 = uint8_t __attribute__((ext_vector_type(2)));
- AI static F min(F a, F b) { return vmin_f32(a,b); }
- AI static F max(F a, F b) { return vmax_f32(a,b); }
- AI static F fma(F f, F m, F a) { return vfma_f32(a,f,m); }
- AI static F rcp (F v) { auto e = vrecpe_f32 (v); return vrecps_f32 (v,e ) * e; }
- AI static F rsqrt(F v) { auto e = vrsqrte_f32(v); return vrsqrts_f32(v,e*e) * e; }
- AI static F if_then_else(I32 c, F t, F e) { return vbsl_f32((U32)c,t,e); }
- AI static U32 round(F v, F scale) { return vcvt_u32_f32(fma(v,scale,0.5f)); }
+ static F min(F a, F b) { return vmin_f32(a,b); }
+ static F max(F a, F b) { return vmax_f32(a,b); }
+ static F fma(F f, F m, F a) { return vfma_f32(a,f,m); }
+ static F rcp (F v) { auto e = vrecpe_f32 (v); return vrecps_f32 (v,e ) * e; }
+ static F rsqrt(F v) { auto e = vrsqrte_f32(v); return vrsqrts_f32(v,e*e) * e; }
+ static F if_then_else(I32 c, F t, F e) { return vbsl_f32((U32)c,t,e); }
+ static U32 round(F v, F scale) { return vcvt_u32_f32(fma(v,scale,0.5f)); }
- AI static F gather(const float* p, U32 ix) { return {p[ix[0]], p[ix[1]]}; }
+ static F gather(const float* p, U32 ix) { return {p[ix[0]], p[ix[1]]}; }
#else
#if !defined(__AVX2__) || !defined(__FMA__) || !defined(__F16C__)
#error On x86, compile with -mavx2 -mfma -mf16c.
@@ -67,22 +64,22 @@
using U32 = uint32_t __attribute__((ext_vector_type(8)));
using U8 = uint8_t __attribute__((ext_vector_type(8)));
- AI static F min(F a, F b) { return _mm256_min_ps (a,b); }
- AI static F max(F a, F b) { return _mm256_max_ps (a,b); }
- AI static F fma(F f, F m, F a) { return _mm256_fmadd_ps(f,m,a);}
- AI static F rcp (F v) { return _mm256_rcp_ps (v); }
- AI static F rsqrt(F v) { return _mm256_rsqrt_ps (v); }
- AI static F if_then_else(I32 c, F t, F e) { return _mm256_blendv_ps(e,t,c); }
- AI static U32 round(F v, F scale) { return _mm256_cvtps_epi32(v*scale); }
+ static F min(F a, F b) { return _mm256_min_ps (a,b); }
+ static F max(F a, F b) { return _mm256_max_ps (a,b); }
+ static F fma(F f, F m, F a) { return _mm256_fmadd_ps(f,m,a);}
+ static F rcp (F v) { return _mm256_rcp_ps (v); }
+ static F rsqrt(F v) { return _mm256_rsqrt_ps (v); }
+ static F if_then_else(I32 c, F t, F e) { return _mm256_blendv_ps(e,t,c); }
+ static U32 round(F v, F scale) { return _mm256_cvtps_epi32(v*scale); }
- AI static F gather(const float* p, U32 ix) { return _mm256_i32gather_ps(p, ix, 4); }
+ static F gather(const float* p, U32 ix) { return _mm256_i32gather_ps(p, ix, 4); }
#endif
-AI static F cast (U32 v) { return __builtin_convertvector((I32)v, F); }
-AI static U32 expand(U8 v) { return __builtin_convertvector( v, U32); }
+static F cast (U32 v) { return __builtin_convertvector((I32)v, F); }
+static U32 expand(U8 v) { return __builtin_convertvector( v, U32); }
template <typename T, typename P>
-AI static T unaligned_load(const P* p) {
+static T unaligned_load(const P* p) {
T v;
memcpy(&v, p, sizeof(v));
return v;
@@ -121,16 +118,16 @@
// This should feel familiar to anyone who's read SkRasterPipeline_opts.h.
// It's just a convenience to make a valid, spliceable Stage, nothing magic.
-#define STAGE(name) \
- AI static void name##_k(size_t x, size_t limit, void* ctx, K* k, \
- F& r, F& g, F& b, F& a, F& dr, F& dg, F& db, F& da); \
- C void name(size_t x, size_t limit, void* ctx, K* k, \
- F r, F g, F b, F a, F dr, F dg, F db, F da) { \
- name##_k(x,limit,ctx,k, r,g,b,a, dr,dg,db,da); \
- done (x,limit,ctx,k, r,g,b,a, dr,dg,db,da); \
- } \
- AI static void name##_k(size_t x, size_t limit, void* ctx, K* k, \
- F& r, F& g, F& b, F& a, F& dr, F& dg, F& db, F& da)
+#define STAGE(name) \
+ static void name##_k(size_t x, size_t limit, void* ctx, K* k, \
+ F& r, F& g, F& b, F& a, F& dr, F& dg, F& db, F& da); \
+ C void name(size_t x, size_t limit, void* ctx, K* k, \
+ F r, F g, F b, F a, F dr, F dg, F db, F da) { \
+ name##_k(x,limit,ctx,k, r,g,b,a, dr,dg,db,da); \
+ done (x,limit,ctx,k, r,g,b,a, dr,dg,db,da); \
+ } \
+ static void name##_k(size_t x, size_t limit, void* ctx, K* k, \
+ F& r, F& g, F& b, F& a, F& dr, F& dg, F& db, F& da)
// We can now define Stages!
diff --git a/tests/IntTextureTest.cpp b/tests/IntTextureTest.cpp
index 3edd4cc..a3e17bf 100644
--- a/tests/IntTextureTest.cpp
+++ b/tests/IntTextureTest.cpp
@@ -207,8 +207,9 @@
};
for (auto filter : kNamedFilters) {
- sk_sp<GrFragmentProcessor> fp(GrSimpleTextureEffect::Make(texture.get(), nullptr,
- SkMatrix::I(),
+ SkMatrix m;
+ m.setIDiv(kS, kS);
+ sk_sp<GrFragmentProcessor> fp(GrSimpleTextureEffect::Make(texture.get(), nullptr, m,
filter.fMode));
REPORTER_ASSERT(reporter, fp);
if (!fp) {
diff --git a/tests/RectangleTextureTest.cpp b/tests/RectangleTextureTest.cpp
index 6d075df..a0c5409 100644
--- a/tests/RectangleTextureTest.cpp
+++ b/tests/RectangleTextureTest.cpp
@@ -107,12 +107,14 @@
context->makeRenderTargetContext(SkBackingFit::kExact, rectangleTexture->width(),
rectangleTexture->height(), rectangleTexture->config(),
nullptr));
+ SkMatrix m;
+ m.setIDiv(rectangleTexture->width(), rectangleTexture->height());
for (auto filter : {GrSamplerParams::kNone_FilterMode,
GrSamplerParams::kBilerp_FilterMode,
GrSamplerParams::kMipMap_FilterMode}) {
rtContext->clear(nullptr, 0xDDCCBBAA, true);
- sk_sp<GrFragmentProcessor> fp(GrSimpleTextureEffect::Make(rectangleTexture, nullptr,
- SkMatrix::I(), filter));
+ sk_sp<GrFragmentProcessor> fp(GrSimpleTextureEffect::Make(rectangleTexture,
+ nullptr, m, filter));
GrPaint paint;
paint.setPorterDuffXPFactory(SkBlendMode::kSrc);
paint.addColorFragmentProcessor(std::move(fp));
diff --git a/tests/SRGBMipMapTest.cpp b/tests/SRGBMipMapTest.cpp
index 22d6890..79d8691 100644
--- a/tests/SRGBMipMapTest.cpp
+++ b/tests/SRGBMipMapTest.cpp
@@ -132,7 +132,7 @@
GrPaint paint;
paint.setPorterDuffXPFactory(SkBlendMode::kSrc);
GrSamplerParams mipMapParams(SkShader::kRepeat_TileMode, GrSamplerParams::kMipMap_FilterMode);
- paint.addColorTextureProcessor(texture.get(), nullptr, SkMatrix::MakeScale(rtS), mipMapParams);
+ paint.addColorTextureProcessor(texture.get(), nullptr, SkMatrix::MakeScale(0.5f), mipMapParams);
// 1) Draw texture to S32 surface (should generate/use sRGB mips)
paint.setGammaCorrect(true);