Respect ImageSetEntry alpha in one-at-a-time code path
Previously it was ignored. Update GM with test case that covers this.
Change-Id: I93e7de285a9d4020dd48e14e09e55fdfb346fff7
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/242083
Reviewed-by: Michael Ludwig <michaelludwig@google.com>
Commit-Queue: Brian Salomon <bsalomon@google.com>
diff --git a/src/gpu/SkGpuDevice_drawTexture.cpp b/src/gpu/SkGpuDevice_drawTexture.cpp
index 25804eb..5ee6a42 100644
--- a/src/gpu/SkGpuDevice_drawTexture.cpp
+++ b/src/gpu/SkGpuDevice_drawTexture.cpp
@@ -467,12 +467,18 @@
SkASSERT(!set[i].fHasClip || dstClips);
SkASSERT(set[i].fMatrixIndex < 0 || preViewMatrices);
+ SkTCopyOnFirstWrite<SkPaint> entryPaint(paint);
+ if (set[i].fAlpha != 1.f) {
+ auto paintAlpha = paint.getAlphaf();
+ entryPaint.writable()->setAlphaf(paintAlpha * set[i].fAlpha);
+ }
// Always send GrAA::kYes to preserve seaming across tiling in MSAA
- this->drawImageQuad(set[i].fImage.get(), &set[i].fSrcRect, &set[i].fDstRect,
- set[i].fHasClip ? dstClips + dstClipIndex : nullptr,
- GrAA::kYes, SkToGrQuadAAFlags(set[i].fAAFlags),
+ this->drawImageQuad(
+ set[i].fImage.get(), &set[i].fSrcRect, &set[i].fDstRect,
+ set[i].fHasClip ? dstClips + dstClipIndex : nullptr, GrAA::kYes,
+ SkToGrQuadAAFlags(set[i].fAAFlags),
set[i].fMatrixIndex < 0 ? nullptr : preViewMatrices + set[i].fMatrixIndex,
- paint, constraint);
+ *entryPaint, constraint);
dstClipIndex += 4 * set[i].fHasClip;
}
return;
@@ -534,10 +540,16 @@
draw();
base = i + 1;
n = 0;
- this->drawImageQuad(image, &set[i].fSrcRect, &set[i].fDstRect, clip, GrAA::kYes,
+ SkTCopyOnFirstWrite<SkPaint> entryPaint(paint);
+ if (set[i].fAlpha != 1.f) {
+ auto paintAlpha = paint.getAlphaf();
+ entryPaint.writable()->setAlphaf(paintAlpha * set[i].fAlpha);
+ }
+ this->drawImageQuad(
+ image, &set[i].fSrcRect, &set[i].fDstRect, clip, GrAA::kYes,
SkToGrQuadAAFlags(set[i].fAAFlags),
set[i].fMatrixIndex < 0 ? nullptr : preViewMatrices + set[i].fMatrixIndex,
- paint, constraint);
+ *entryPaint, constraint);
continue;
}