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

Unified Diff: src/gpu/SkGpuDevice.cpp

Issue 1382753002: Fix drawVertices when there is a paint alpha (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Address comment Created 5 years, 3 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 | src/gpu/SkGr.cpp » ('j') | 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 5289019cc9703aab9aeb5a0794cdd880250fcaef..e2feefc31e4823278e8b61aeba157f85d186c772 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,
« no previous file with comments | « no previous file | src/gpu/SkGr.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698