diff options
Diffstat (limited to 'src/gpu')
-rw-r--r-- | src/gpu/GrBlurUtils.cpp | 6 | ||||
-rw-r--r-- | src/gpu/GrContext.cpp | 10 | ||||
-rw-r--r-- | src/gpu/GrCoordTransform.cpp | 10 | ||||
-rw-r--r-- | src/gpu/GrFragmentProcessor.cpp | 2 | ||||
-rw-r--r-- | src/gpu/GrSWMaskHelper.cpp | 6 | ||||
-rw-r--r-- | src/gpu/GrTextureAdjuster.cpp | 1 | ||||
-rw-r--r-- | src/gpu/GrTextureMaker.cpp | 4 | ||||
-rw-r--r-- | src/gpu/GrTextureProducer.cpp | 9 | ||||
-rw-r--r-- | src/gpu/GrTextureToYUVPlanes.cpp | 4 | ||||
-rw-r--r-- | src/gpu/GrYUVProvider.cpp | 2 | ||||
-rw-r--r-- | src/gpu/SkGpuDevice.cpp | 12 | ||||
-rw-r--r-- | src/gpu/effects/Gr1DKernelEffect.h | 2 | ||||
-rw-r--r-- | src/gpu/effects/GrBicubicEffect.cpp | 3 | ||||
-rw-r--r-- | src/gpu/effects/GrConfigConversionEffect.cpp | 2 | ||||
-rw-r--r-- | src/gpu/effects/GrMatrixConvolutionEffect.cpp | 2 | ||||
-rw-r--r-- | src/gpu/effects/GrYUVEffect.cpp | 23 | ||||
-rw-r--r-- | src/gpu/glsl/GrGLSLPrimitiveProcessor.cpp | 5 |
17 files changed, 38 insertions, 65 deletions
diff --git a/src/gpu/GrBlurUtils.cpp b/src/gpu/GrBlurUtils.cpp index 23a3c6ce0b..61290b0fdf 100644 --- a/src/gpu/GrBlurUtils.cpp +++ b/src/gpu/GrBlurUtils.cpp @@ -46,10 +46,8 @@ static bool draw_mask(GrRenderTargetContext* renderTargetContext, return false; } - 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()); + SkMatrix matrix = SkMatrix::MakeTrans(-SkIntToScalar(maskRect.fLeft), + -SkIntToScalar(maskRect.fTop)); matrix.preConcat(viewMatrix); paint.addCoverageFragmentProcessor(GrSimpleTextureEffect::Make(maskTex, nullptr, matrix)); diff --git a/src/gpu/GrContext.cpp b/src/gpu/GrContext.cpp index 12560584ba..1e2bdc7eee 100644 --- a/src/gpu/GrContext.cpp +++ b/src/gpu/GrContext.cpp @@ -308,10 +308,8 @@ bool GrContext::writeSurfacePixels(GrSurface* surface, SkColorSpace* dstColorSpa 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, textureMatrix); + fp = this->createUPMToPMEffect(tempTexture.get(), tempDrawInfo.fSwizzle, SkMatrix::I()); // If premultiplying was the only reason for the draw, fall back to a straight write. if (!fp) { if (GrGpu::kCallerPrefersDraw_DrawPreference == drawPreference) { @@ -325,7 +323,7 @@ bool GrContext::writeSurfacePixels(GrSurface* surface, SkColorSpace* dstColorSpa if (!fp) { fp = GrConfigConversionEffect::Make(tempTexture.get(), tempDrawInfo.fSwizzle, GrConfigConversionEffect::kNone_PMConversion, - textureMatrix); + SkMatrix::I()); if (!fp) { return false; } @@ -463,9 +461,7 @@ bool GrContext::readSurfacePixels(GrSurface* src, SkColorSpace* srcColorSpace, tempDrawInfo.fTempSurfaceDesc.fSampleCnt, tempDrawInfo.fTempSurfaceDesc.fOrigin); if (tempRTC) { - SkMatrix textureMatrix; - textureMatrix.setTranslate(SkIntToScalar(left), SkIntToScalar(top)); - textureMatrix.postIDiv(src->width(), src->height()); + SkMatrix textureMatrix = SkMatrix::MakeTrans(SkIntToScalar(left), SkIntToScalar(top)); 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 63d91a810f..4afd0efbce 100644 --- a/src/gpu/GrCoordTransform.cpp +++ b/src/gpu/GrCoordTransform.cpp @@ -11,11 +11,13 @@ #include "GrGpu.h" void GrCoordTransform::reset(const SkMatrix& m, const GrTexture* texture, - GrSamplerParams::FilterMode filter) { + GrSamplerParams::FilterMode filter, bool normalize) { 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 @@ -52,9 +54,3 @@ void GrCoordTransform::reset(const SkMatrix& m, const GrTexture* texture, } } -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 977974d78d..8a710e5c5f 100644 --- a/src/gpu/GrFragmentProcessor.cpp +++ b/src/gpu/GrFragmentProcessor.cpp @@ -92,7 +92,7 @@ bool GrFragmentProcessor::hasSameTransforms(const GrFragmentProcessor& that) con } int count = this->numCoordTransforms(); for (int i = 0; i < count; ++i) { - if (this->coordTransform(i) != that.coordTransform(i)) { + if (!this->coordTransform(i).hasSameEffectAs(that.coordTransform(i))) { return false; } } diff --git a/src/gpu/GrSWMaskHelper.cpp b/src/gpu/GrSWMaskHelper.cpp index 240f9f9c3c..5dbbaf0c61 100644 --- a/src/gpu/GrSWMaskHelper.cpp +++ b/src/gpu/GrSWMaskHelper.cpp @@ -176,10 +176,8 @@ void GrSWMaskHelper::DrawToTargetWithShapeMask(GrTexture* texture, // 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; - maskMatrix.setIDiv(texture->width(), texture->height()); - maskMatrix.preTranslate(SkIntToScalar(-textureOriginInDeviceSpace.fX), - SkIntToScalar(-textureOriginInDeviceSpace.fY)); + SkMatrix maskMatrix = SkMatrix::MakeTrans(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 7142ab9bac..db9bbde2e5 100644 --- a/src/gpu/GrTextureAdjuster.cpp +++ b/src/gpu/GrTextureAdjuster.cpp @@ -156,7 +156,6 @@ sk_sp<GrFragmentProcessor> GrTextureAdjuster::createFragmentProcessor( } 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 37272be4c9..cc6c703dc2 100644 --- a/src/gpu/GrTextureMaker.cpp +++ b/src/gpu/GrTextureMaker.cpp @@ -87,12 +87,10 @@ sk_sp<GrFragmentProcessor> GrTextureMaker::createFragmentProcessor( 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), - normalizedTextureMatrix, domainMode, domain, + textureMatrix, domainMode, domain, filterOrNullForBicubic); } diff --git a/src/gpu/GrTextureProducer.cpp b/src/gpu/GrTextureProducer.cpp index 0adae8c750..496dbb2d0b 100644 --- a/src/gpu/GrTextureProducer.cpp +++ b/src/gpu/GrTextureProducer.cpp @@ -52,16 +52,9 @@ GrTexture* GrTextureProducer::CopyOnGpu(GrTexture* inputTexture, const SkIRect* 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(1.f, 1.f); + localRect = SkRect::MakeWH(inputTexture->width(), inputTexture->height()); } SkRect dstRect = SkRect::MakeIWH(copyParams.fWidth, copyParams.fHeight); diff --git a/src/gpu/GrTextureToYUVPlanes.cpp b/src/gpu/GrTextureToYUVPlanes.cpp index b9252fa733..132b680626 100644 --- a/src/gpu/GrTextureToYUVPlanes.cpp +++ b/src/gpu/GrTextureToYUVPlanes.cpp @@ -22,8 +22,8 @@ namespace { static bool convert_texture(GrTexture* src, GrRenderTargetContext* dst, int dstW, int dstH, SkYUVColorSpace colorSpace, MakeFPProc proc) { - SkScalar xScale = SkIntToScalar(src->width()) / dstW / src->width(); - SkScalar yScale = SkIntToScalar(src->height()) / dstH / src->height(); + SkScalar xScale = SkIntToScalar(src->width()) / dstW; + SkScalar yScale = SkIntToScalar(src->height()) / dstH; 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 1330cfea34..2f75d92b46 100644 --- a/src/gpu/GrYUVProvider.cpp +++ b/src/gpu/GrYUVProvider.cpp @@ -146,7 +146,7 @@ sk_sp<GrTexture> GrYUVProvider::refAsTexture(GrContext* ctx, 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 1dec0f6371..25ad78176a 100644 --- a/src/gpu/SkGpuDevice.cpp +++ b/src/gpu/SkGpuDevice.cpp @@ -1048,13 +1048,8 @@ void SkGpuDevice::drawBitmapTile(const SkBitmap& bitmap, 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. - texMatrix.setRectToRect(dstRect, srcRect, SkMatrix::kFill_ScaleToFit); - texMatrix.postScale(iw, ih); + SkMatrix texMatrix = SkMatrix::MakeRectToRect(dstRect, srcRect, SkMatrix::kFill_ScaleToFit); // Construct a GrPaint by setting the bitmap texture as the first effect and then configuring // the rest from the SkPaint. @@ -1200,10 +1195,7 @@ void SkGpuDevice::drawSpecial(const SkDraw& draw, SkMatrix::I(), SkRect::Make(SkIRect::MakeXYWH( left + offset.fX, top + offset.fY, subset.width(), subset.height())), - SkRect::MakeXYWH(SkIntToScalar(subset.fLeft) / texture->width(), - SkIntToScalar(subset.fTop) / texture->height(), - SkIntToScalar(subset.width()) / texture->width(), - SkIntToScalar(subset.height()) / texture->height())); + SkRect::Make(subset)); } void SkGpuDevice::drawBitmapRect(const SkDraw& draw, const SkBitmap& bitmap, diff --git a/src/gpu/effects/Gr1DKernelEffect.h b/src/gpu/effects/Gr1DKernelEffect.h index d7402e8c45..29e0e5dec2 100644 --- a/src/gpu/effects/Gr1DKernelEffect.h +++ b/src/gpu/effects/Gr1DKernelEffect.h @@ -31,7 +31,7 @@ public: Gr1DKernelEffect(GrTexture* texture, Direction direction, int radius) - : INHERITED(texture, nullptr, GrCoordTransform::MakeDivByTextureWHMatrix(texture)) + : INHERITED(texture, nullptr, SkMatrix::I()) , fDirection(direction) , fRadius(radius) {} diff --git a/src/gpu/effects/GrBicubicEffect.cpp b/src/gpu/effects/GrBicubicEffect.cpp index 50a2a5d3e4..07d1c53011 100644 --- a/src/gpu/effects/GrBicubicEffect.cpp +++ b/src/gpu/effects/GrBicubicEffect.cpp @@ -181,8 +181,7 @@ sk_sp<GrFragmentProcessor> GrBicubicEffect::TestCreate(GrProcessorTestData* d) { static const SkShader::TileMode kClampClamp[] = { SkShader::kClamp_TileMode, SkShader::kClamp_TileMode }; return GrBicubicEffect::Make(d->fTextures[texIdx], colorSpaceXform, - GrCoordTransform::MakeDivByTextureWHMatrix(d->fTextures[texIdx]), - kClampClamp); + SkMatrix::I(), kClampClamp); } ////////////////////////////////////////////////////////////////////////////// diff --git a/src/gpu/effects/GrConfigConversionEffect.cpp b/src/gpu/effects/GrConfigConversionEffect.cpp index 8405fcbaf7..e6b3b28535 100644 --- a/src/gpu/effects/GrConfigConversionEffect.cpp +++ b/src/gpu/effects/GrConfigConversionEffect.cpp @@ -216,7 +216,7 @@ void GrConfigConversionEffect::TestForPreservingPMConversions(GrContext* context *upmToPMRule = kConversionRules[i][1]; static const SkRect kDstRect = SkRect::MakeIWH(kSize, kSize); - static const SkRect kSrcRect = SkRect::MakeIWH(1, 1); + static const SkRect kSrcRect = SkRect::MakeIWH(kSize, kSize); // 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 8b98d0b32f..01fc6cec9c 100644 --- a/src/gpu/effects/GrMatrixConvolutionEffect.cpp +++ b/src/gpu/effects/GrMatrixConvolutionEffect.cpp @@ -156,7 +156,7 @@ GrMatrixConvolutionEffect::GrMatrixConvolutionEffect(GrTexture* texture, const SkIPoint& kernelOffset, GrTextureDomain::Mode tileMode, bool convolveAlpha) - : INHERITED(texture, nullptr, GrCoordTransform::MakeDivByTextureWHMatrix(texture)), + : INHERITED(texture, nullptr, SkMatrix::I()), 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 6d1fac2f32..41bab180ba 100644 --- a/src/gpu/effects/GrYUVEffect.cpp +++ b/src/gpu/effects/GrYUVEffect.cpp @@ -66,18 +66,17 @@ public: GrTexture* vTexture, const SkISize sizes[3], SkYUVColorSpace colorSpace, bool nv12) { SkScalar w[3], h[3]; - 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]); + 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]) + }; 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 24f21ffe7a..f39fff2a07 100644 --- a/src/gpu/glsl/GrGLSLPrimitiveProcessor.cpp +++ b/src/gpu/glsl/GrGLSLPrimitiveProcessor.cpp @@ -16,6 +16,11 @@ SkMatrix GrGLSLPrimitiveProcessor::GetTransformMatrix(const SkMatrix& localMatri 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); |