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

Unified Diff: src/gpu/SkGpuDevice.cpp

Issue 387113002: drawVertices bug on gpu side (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: calculate index count based on the number of traingles determined by the primitive type Created 6 years, 5 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 | no next file » | 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 3f1908be20f9d3dc191082369af97a064f50118c..f92e198c86308d594423d8fe8ed78d8963da3c22 100644
--- a/src/gpu/SkGpuDevice.cpp
+++ b/src/gpu/SkGpuDevice.cpp
@@ -1612,38 +1612,61 @@ void SkGpuDevice::drawVertices(const SkDraw& draw, SkCanvas::VertexMode vmode,
CHECK_SHOULD_DRAW(draw, false);
GR_CREATE_TRACE_MARKER_CONTEXT("SkGpuDevice::drawVertices", fContext);
+
+ uint16_t* idx;
+ GrPrimitiveType primType;
+ SkPaint copy(paint);
jvanverth1 2014/07/14 14:29:19 I don't think we'd want to copy the paint all the
dandov 2014/07/14 15:31:33 Done.
+
// If both textures and vertex-colors are NULL, strokes hairlines with the paint's color.
if ((NULL == texs || NULL == paint.getShader()) && NULL == colors) {
+
texs = NULL;
- SkPaint copy(paint);
+
copy.setStyle(SkPaint::kStroke_Style);
copy.setStrokeWidth(0);
+ primType = kLines_GrPrimitiveType;
+ int triangleCount = 0;
+ switch (vmode) {
+ case SkCanvas::kTriangles_VertexMode:
+ triangleCount = indexCount / 3;
+ break;
+ case SkCanvas::kTriangleStrip_VertexMode:
+ case SkCanvas::kTriangleFan_VertexMode:
+ triangleCount = indexCount - 2;
+ break;
+ }
+
VertState state(vertexCount, indices, indexCount);
VertState::Proc vertProc = state.chooseProc(vmode);
-
- SkPoint* pts = new SkPoint[vertexCount * 6];
+
+ //number of lines per triangle with kLines
+ indexCount = triangleCount * 6;
+ idx = SkNEW_ARRAY(uint16_t, indexCount);
int i = 0;
while (vertProc(&state)) {
- pts[i] = vertices[state.f0];
- pts[i + 1] = vertices[state.f1];
- pts[i + 2] = vertices[state.f1];
- pts[i + 3] = vertices[state.f2];
- pts[i + 4] = vertices[state.f2];
- pts[i + 5] = vertices[state.f0];
+ idx[i] = state.f0;
+ idx[i + 1] = state.f1;
+ idx[i + 2] = state.f1;
+ idx[i + 3] = state.f2;
+ idx[i + 4] = state.f2;
+ idx[i + 5] = state.f0;
i += 6;
}
- draw.drawPoints(SkCanvas::kLines_PointMode, i, pts, copy, true);
- return;
+ } else {
+ idx = SkNEW_ARRAY(uint16_t, indexCount);
+ memcpy(idx, indices, indexCount * sizeof(uint16_t));
+ primType = gVertexMode2PrimitiveType[vmode];
}
- GrPaint grPaint;
+
// we ignore the shader if texs is null.
+ GrPaint grPaint;
if (NULL == texs) {
- SkPaint2GrPaintNoShader(this->context(), paint, SkColor2GrColor(paint.getColor()),
+ SkPaint2GrPaintNoShader(this->context(), copy, SkColor2GrColor(copy.getColor()),
NULL == colors, &grPaint);
} else {
- SkPaint2GrPaintShader(this->context(), paint, NULL == colors, &grPaint);
+ SkPaint2GrPaintShader(this->context(), copy, NULL == colors, &grPaint);
}
#if 0
@@ -1662,21 +1685,22 @@ void SkGpuDevice::drawVertices(const SkDraw& draw, SkCanvas::VertexMode vmode,
SkColor color;
for (int i = 0; i < vertexCount; ++i) {
color = colors[i];
- if (paint.getAlpha() != 255) {
- color = SkColorSetA(color, SkMulDiv255Round(SkColorGetA(color), paint.getAlpha()));
+ if (copy.getAlpha() != 255) {
jvanverth1 2014/07/14 14:29:20 The paint color doesn't change in the hairline cas
dandov 2014/07/14 15:31:33 Done.
+ color = SkColorSetA(color, SkMulDiv255Round(SkColorGetA(color), copy.getAlpha()));
}
convertedColors[i] = SkColor2GrColor(color);
}
colors = convertedColors.get();
}
fContext->drawVertices(grPaint,
- gVertexMode2PrimitiveType[vmode],
+ primType,
vertexCount,
vertices,
texs,
colors,
- indices,
+ idx,
indexCount);
+
}
///////////////////////////////////////////////////////////////////////////////
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698