aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorGravatar Brian Osman <brianosman@google.com>2017-05-25 15:10:38 -0400
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2017-05-25 19:47:07 +0000
commit33fa454b1645610f5d69f635e35831e4344a9eb0 (patch)
tree1bb8ed6b498eaf44c1b4b0915b0d2a6c572d6bca /src
parent6eca90fea6548bfb2f5c30f391cc0caa6b1de04f (diff)
Fix two bugs with drawVertices on GPU
1) In SkGpuDevice.cpp, the SkVertices refactor had a copy-paste error when moving the paint initialization code into the helper function. This caused draws with texs (but no colors, and no shader) to fail to draw. Previously (and with this change) that draws solid filled triangles. This is still different from CPU (which draws outlines). This is an odd edge case, but it's also the easiest way to create the second bug... 2) In GrDrawVerticesOp.cpp, we always claimed to have SkColor colors. That's only true if the SkVertices has colors, otherwise we use the paint's color, which is GrColor. Normally, this doesn't matter, because we'll use uniform color which is always GrColor. But if you induce batching (and the meshes have different colors), we expand the per-mesh color to a per-vertex color. Then, the geo proc code thinks that those per-vertex colors are SkColors, and swaps the red and blue channels, leading to incorrect results. Bug: skia: Change-Id: I3401e030d4ffea8666efd02e20a5fdedcfbd8485 Reviewed-on: https://skia-review.googlesource.com/17986 Reviewed-by: Greg Daniel <egdaniel@google.com> Commit-Queue: Brian Osman <brianosman@google.com>
Diffstat (limited to 'src')
-rw-r--r--src/gpu/SkGpuDevice.cpp2
-rw-r--r--src/gpu/ops/GrDrawVerticesOp.cpp6
2 files changed, 5 insertions, 3 deletions
diff --git a/src/gpu/SkGpuDevice.cpp b/src/gpu/SkGpuDevice.cpp
index 87a4f99c7a..c48e8d59dd 100644
--- a/src/gpu/SkGpuDevice.cpp
+++ b/src/gpu/SkGpuDevice.cpp
@@ -1573,7 +1573,7 @@ static bool init_vertices_paint(GrContext* context, GrRenderTargetContext* rtc,
return SkPaintToGrPaintWithPrimitiveColor(context, rtc, skPaint, grPaint);
} else {
// No colors and no shaders. Just draw with the paint color.
- return (!SkPaintToGrPaintNoShader(context, rtc, skPaint, grPaint));
+ return SkPaintToGrPaintNoShader(context, rtc, skPaint, grPaint);
}
}
}
diff --git a/src/gpu/ops/GrDrawVerticesOp.cpp b/src/gpu/ops/GrDrawVerticesOp.cpp
index dafd4dc7c7..73d29ea81f 100644
--- a/src/gpu/ops/GrDrawVerticesOp.cpp
+++ b/src/gpu/ops/GrDrawVerticesOp.cpp
@@ -36,9 +36,11 @@ std::unique_ptr<GrLegacyMeshDrawOp> GrDrawVerticesOp::Make(GrColor color,
const SkMatrix& viewMatrix) {
SkASSERT(vertices);
GrPrimitiveType primType = SkVertexModeToGrPrimitiveType(vertices->mode());
+ GrRenderTargetContext::ColorArrayType colorArrayType =
+ vertices->hasColors() ? GrRenderTargetContext::ColorArrayType::kSkColor
+ : GrRenderTargetContext::ColorArrayType::kPremulGrColor;
return std::unique_ptr<GrLegacyMeshDrawOp>(
- new GrDrawVerticesOp(std::move(vertices), primType, color,
- GrRenderTargetContext::ColorArrayType::kSkColor, viewMatrix));
+ new GrDrawVerticesOp(std::move(vertices), primType, color, colorArrayType, viewMatrix));
}
GrDrawVerticesOp::GrDrawVerticesOp(sk_sp<SkVertices> vertices, GrPrimitiveType primitiveType,