aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/gpu/SkGpuDevice.cpp
diff options
context:
space:
mode:
authorGravatar bsalomon <bsalomon@google.com>2015-10-01 08:34:17 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2015-10-01 08:34:17 -0700
commitaa48d36397f8464dafd38c3f42fbdfb1419e8778 (patch)
treedff1a80078cfedc9f8ee4bcd532438e18820d163 /src/gpu/SkGpuDevice.cpp
parent5827653e4271e6f33d2dbd6ac088a6de80fbcea7 (diff)
Fix drawVertices when there is a paint alpha
Diffstat (limited to 'src/gpu/SkGpuDevice.cpp')
-rw-r--r--src/gpu/SkGpuDevice.cpp58
1 files changed, 33 insertions, 25 deletions
diff --git a/src/gpu/SkGpuDevice.cpp b/src/gpu/SkGpuDevice.cpp
index 5289019cc9..e2feefc31e 100644
--- a/src/gpu/SkGpuDevice.cpp
+++ b/src/gpu/SkGpuDevice.cpp
@@ -1742,42 +1742,50 @@ void SkGpuDevice::drawVertices(const SkDraw& draw, SkCanvas::VertexMode vmode,
SkAutoSTMalloc<128, GrColor> convertedColors(0);
if (colors) {
- // need to convert byte order and from non-PM to PM
+ // need to convert byte order and from non-PM to PM. TODO: Keep unpremul until after
+ // interpolation.
convertedColors.reset(vertexCount);
- SkColor color;
for (int i = 0; i < vertexCount; ++i) {
- color = colors[i];
- if (paint.getAlpha() != 255) {
- color = SkColorSetA(color, SkMulDiv255Round(SkColorGetA(color), paint.getAlpha()));
- }
- /// TODO: Perform the premul after interpolating
- convertedColors[i] = SkColorToPremulGrColor(color);
+ convertedColors[i] = SkColorToPremulGrColor(colors[i]);
}
colors = convertedColors.get();
}
GrPaint grPaint;
- if (texs && colors && paint.getShader()) {
- // When there are texs and colors the shader and colors are combined using xmode. A null
- // xmode is defined to mean modulate.
- SkXfermode::Mode colorMode;
- if (xmode) {
- if (!xmode->asMode(&colorMode)) {
+ if (texs && paint.getShader()) {
+ if (colors) {
+ // When there are texs and colors the shader and colors are combined using xmode. A null
+ // xmode is defined to mean modulate.
+ SkXfermode::Mode colorMode;
+ if (xmode) {
+ if (!xmode->asMode(&colorMode)) {
+ return;
+ }
+ } else {
+ colorMode = SkXfermode::kModulate_Mode;
+ }
+ if (!SkPaintToGrPaintWithXfermode(this->context(), paint, *draw.fMatrix, colorMode,
+ false, &grPaint)) {
return;
}
} else {
- colorMode = SkXfermode::kModulate_Mode;
- }
- if (!SkPaintToGrPaintWithXfermode(this->context(), paint, *draw.fMatrix, colorMode, false,
- &grPaint)) {
- return;
+ // We have a shader, but no colors to blend it against.
+ if (!SkPaintToGrPaint(this->context(), paint, *draw.fMatrix, &grPaint)) {
+ return;
+ }
}
- } else if (!texs) {
- // Defined to ignore the shader unless texs is provided.
- if (!SkPaintToGrPaintNoShader(this->context(), paint, &grPaint)) {
- return;
+ } else {
+ if (colors) {
+ // We have colors, but either have no shader or no texture coords (which implies that
+ // we should ignore the shader).
+ if (!SkPaintToGrPaintWithPrimitiveColor(this->context(), paint, &grPaint)) {
+ return;
+ }
+ } else {
+ // No colors and no shaders. Just draw with the paint color.
+ if (!SkPaintToGrPaintNoShader(this->context(), paint, &grPaint)) {
+ return;
+ }
}
- } else if (!SkPaintToGrPaint(this->context(), paint, *draw.fMatrix, &grPaint)) {
- return;
}
fDrawContext->drawVertices(fRenderTarget,