Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(282)

Unified Diff: src/gpu/SkGpuDevice.cpp

Issue 1399763002: Fix gpu drawBitmap to work when BM is A8 and we have a shader (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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,
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698