Chromium Code Reviews| Index: src/gpu/SkGpuDevice.cpp |
| diff --git a/src/gpu/SkGpuDevice.cpp b/src/gpu/SkGpuDevice.cpp |
| index 1af4929ae41d296d171a1be4c560a19c9b27e62e..275cd62b805a60213b6096f0f826dc480466a2cd 100644 |
| --- a/src/gpu/SkGpuDevice.cpp |
| +++ b/src/gpu/SkGpuDevice.cpp |
| @@ -1301,6 +1301,12 @@ void SkGpuDevice::internalDrawBitmap(const SkBitmap& bitmap, |
| SkScalarMul(srcRect.fRight, wInv), |
| SkScalarMul(srcRect.fBottom, hInv)); |
| + SkMatrix texMatrix; |
| + texMatrix.reset(); |
| + if (kAlpha_8_SkColorType == bitmap.colorType() && paint.getShader()) { |
|
bsalomon
2015/10/09 17:07:09
Could use a comment here
egdaniel
2015/10/09 17:20:26
Done.
|
| + texMatrix.setScale(wInv, hInv); |
| + } |
| + |
| SkRect textureDomain = SkRect::MakeEmpty(); |
| // Construct a GrPaint by setting the bitmap texture as the first effect and then configuring |
| @@ -1327,10 +1333,10 @@ void SkGpuDevice::internalDrawBitmap(const SkBitmap& bitmap, |
| } |
| textureDomain.setLTRB(left, top, right, bottom); |
| if (bicubic) { |
| - fp.reset(GrBicubicEffect::Create(texture, SkMatrix::I(), textureDomain)); |
| + fp.reset(GrBicubicEffect::Create(texture, texMatrix, textureDomain)); |
| } else { |
| fp.reset(GrTextureDomainEffect::Create(texture, |
| - SkMatrix::I(), |
| + texMatrix, |
| textureDomain, |
| GrTextureDomain::kClamp_Mode, |
| params.filterMode())); |
| @@ -1338,13 +1344,24 @@ void SkGpuDevice::internalDrawBitmap(const SkBitmap& bitmap, |
| } else if (bicubic) { |
| SkASSERT(GrTextureParams::kNone_FilterMode == params.filterMode()); |
| SkShader::TileMode tileModes[2] = { params.getTileModeX(), params.getTileModeY() }; |
| - fp.reset(GrBicubicEffect::Create(texture, SkMatrix::I(), tileModes)); |
| + fp.reset(GrBicubicEffect::Create(texture, texMatrix, tileModes)); |
| } else { |
| - fp.reset(GrSimpleTextureEffect::Create(texture, SkMatrix::I(), params)); |
| + fp.reset(GrSimpleTextureEffect::Create(texture, texMatrix, params)); |
| } |
| + SkAutoTUnref<const GrFragmentProcessor> shaderFP; |
| + |
| if (kAlpha_8_SkColorType == bitmap.colorType()) { |
| - fp.reset(GrFragmentProcessor::MulOutputByInputUnpremulColor(fp)); |
| + if (const SkShader* shader = paint.getShader()) { |
| + shaderFP.reset(shader->asFragmentProcessor(this->context(), |
| + viewMatrix, |
| + nullptr, |
| + paint.getFilterQuality())); |
| + const GrFragmentProcessor* fpSeries[] = { shaderFP.get(), fp.get() }; |
|
bsalomon
2015/10/09 17:07:09
if (!shaderFP) { return }
egdaniel
2015/10/09 17:20:26
Done.
|
| + fp.reset(GrFragmentProcessor::RunInSeries(fpSeries, 2)); |
| + } else { |
| + fp.reset(GrFragmentProcessor::MulOutputByInputUnpremulColor(fp)); |
| + } |
| } else { |
| fp.reset(GrFragmentProcessor::MulOutputByInputAlpha(fp)); |
| } |
| @@ -1353,8 +1370,12 @@ void SkGpuDevice::internalDrawBitmap(const SkBitmap& bitmap, |
| return; |
| } |
| - fDrawContext->drawNonAARectToRect(fRenderTarget, fClip, grPaint, viewMatrix, dstRect, |
| - paintRect); |
| + if (kAlpha_8_SkColorType == bitmap.colorType() && paint.getShader()) { |
| + fDrawContext->drawRect(fRenderTarget, fClip, grPaint, viewMatrix, dstRect); |
| + } else { |
| + fDrawContext->drawNonAARectToRect(fRenderTarget, fClip, grPaint, viewMatrix, dstRect, |
| + paintRect); |
| + } |
| } |
| bool SkGpuDevice::filterTexture(GrContext* context, GrTexture* texture, |