PDF backend: don't apply paint alpha twice when we have a shader
Uncovers related bug in pdfium:
https://bugs.chromium.org/p/pdfium/issues/detail?id=1693
Bug: skia:11863
Change-Id: I764ccbfb5464f0288c66086826a1fd8bcf2ff8f7
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/418544
Commit-Queue: Mike Reed <reed@google.com>
Reviewed-by: Ben Wagner <bungeman@google.com>
diff --git a/src/pdf/SkPDFDevice.cpp b/src/pdf/SkPDFDevice.cpp
index 6be5ab7..c9a7426 100644
--- a/src/pdf/SkPDFDevice.cpp
+++ b/src/pdf/SkPDFDevice.cpp
@@ -1155,6 +1155,8 @@
// PDF treats a shader as a color, so we only set one or the other.
SkShader* shader = paint.getShader();
if (shader) {
+ // note: we always present the alpha as 1 for the shader, knowing that it will be
+ // accounted for when we create our newGraphicsState (below)
if (SkShader::kColor_GradientType == shader->asAGradient(nullptr)) {
// We don't have to set a shader just for a color.
SkShader::GradientInfo gradientInfo;
@@ -1183,8 +1185,9 @@
SkIRect bounds;
clipStackBounds.roundOut(&bounds);
- SkPDFIndirectReference pdfShader
- = SkPDFMakeShader(doc, shader, transform, bounds, paint.getColor4f());
+ auto c = paint.getColor4f();
+ SkPDFIndirectReference pdfShader = SkPDFMakeShader(doc, shader, transform, bounds,
+ {c.fR, c.fG, c.fB, 1.0f});
if (pdfShader) {
// pdfShader has been canonicalized so we can directly compare pointers.