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

Unified Diff: src/gpu/effects/GrDashingEffect.cpp

Issue 1124633003: Revert of Start on simplifying generateGeometry() overrides (Closed) Base URL: https://skia.googlesource.com/skia.git@ibcache
Patch Set: Created 5 years, 8 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 | « src/gpu/GrTessellatingPathRenderer.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/gpu/effects/GrDashingEffect.cpp
diff --git a/src/gpu/effects/GrDashingEffect.cpp b/src/gpu/effects/GrDashingEffect.cpp
index b941d8be7db30addb20fac010cb01c326bfb3e0e..fa8b3a2dcf941bfc6c29b2fa27e39f6bcb1c49f8 100644
--- a/src/gpu/effects/GrDashingEffect.cpp
+++ b/src/gpu/effects/GrDashingEffect.cpp
@@ -19,6 +19,7 @@
#include "GrDrawTargetCaps.h"
#include "GrInvariantOutput.h"
#include "GrProcessor.h"
+#include "GrResourceProvider.h"
#include "GrStrokeInfo.h"
#include "GrVertexBuffer.h"
#include "SkGr.h"
@@ -535,29 +536,38 @@
draw.fHasEndRect = hasEndRect;
}
- QuadHelper helper;
- void* vertices = helper.init(batchTarget, gp->getVertexStride(), instanceCount);
- if (!vertices) {
+ SkAutoTUnref<const GrIndexBuffer> indexBuffer(
+ batchTarget->resourceProvider()->refQuadIndexBuffer());
+
+ const GrVertexBuffer* vertexBuffer;
+ int firstVertex;
+ size_t vertexStride = gp->getVertexStride();
+ void* vertices = batchTarget->vertexPool()->makeSpace(vertexStride,
+ totalRectCount * kVertsPerDash,
+ &vertexBuffer,
+ &firstVertex);
+ if (!vertices || !indexBuffer) {
+ SkDebugf("Could not allocate buffers\n");
return;
}
int curVIdx = 0;
int rectIndex = 0;
for (int i = 0; i < instanceCount; i++) {
- Geometry& geom = fGeoData[i];
+ Geometry& args = fGeoData[i];
if (!draws[i].fLineDone) {
if (fullDash) {
- setup_dashed_rect(rects[rectIndex], vertices, curVIdx, geom.fSrcRotInv,
+ setup_dashed_rect(rects[rectIndex], vertices, curVIdx, args.fSrcRotInv,
draws[i].fStartOffset, draws[i].fDevBloatX,
draws[i].fDevBloatY, draws[i].fLineLength,
- draws[i].fHalfDevStroke, geom.fIntervals[0],
- geom.fIntervals[1], draws[i].fStrokeWidth,
+ draws[i].fHalfDevStroke, args.fIntervals[0],
+ args.fIntervals[1], draws[i].fStrokeWidth,
capType, gp->getVertexStride());
} else {
SkPoint* verts = reinterpret_cast<SkPoint*>(vertices);
SkASSERT(gp->getVertexStride() == sizeof(SkPoint));
- setup_dashed_rect_pos(rects[rectIndex], curVIdx, geom.fSrcRotInv, verts);
+ setup_dashed_rect_pos(rects[rectIndex], curVIdx, args.fSrcRotInv, verts);
}
curVIdx += 4;
}
@@ -565,16 +575,16 @@
if (draws[i].fHasStartRect) {
if (fullDash) {
- setup_dashed_rect(rects[rectIndex], vertices, curVIdx, geom.fSrcRotInv,
+ setup_dashed_rect(rects[rectIndex], vertices, curVIdx, args.fSrcRotInv,
draws[i].fStartOffset, draws[i].fDevBloatX,
- draws[i].fDevBloatY, geom.fIntervals[0],
- draws[i].fHalfDevStroke, geom.fIntervals[0],
- geom.fIntervals[1], draws[i].fStrokeWidth, capType,
+ draws[i].fDevBloatY, args.fIntervals[0],
+ draws[i].fHalfDevStroke, args.fIntervals[0],
+ args.fIntervals[1], draws[i].fStrokeWidth, capType,
gp->getVertexStride());
} else {
SkPoint* verts = reinterpret_cast<SkPoint*>(vertices);
SkASSERT(gp->getVertexStride() == sizeof(SkPoint));
- setup_dashed_rect_pos(rects[rectIndex], curVIdx, geom.fSrcRotInv, verts);
+ setup_dashed_rect_pos(rects[rectIndex], curVIdx, args.fSrcRotInv, verts);
}
curVIdx += 4;
@@ -583,22 +593,43 @@
if (draws[i].fHasEndRect) {
if (fullDash) {
- setup_dashed_rect(rects[rectIndex], vertices, curVIdx, geom.fSrcRotInv,
+ setup_dashed_rect(rects[rectIndex], vertices, curVIdx, args.fSrcRotInv,
draws[i].fStartOffset, draws[i].fDevBloatX,
- draws[i].fDevBloatY, geom.fIntervals[0],
- draws[i].fHalfDevStroke, geom.fIntervals[0],
- geom.fIntervals[1], draws[i].fStrokeWidth, capType,
+ draws[i].fDevBloatY, args.fIntervals[0],
+ draws[i].fHalfDevStroke, args.fIntervals[0],
+ args.fIntervals[1], draws[i].fStrokeWidth, capType,
gp->getVertexStride());
} else {
SkPoint* verts = reinterpret_cast<SkPoint*>(vertices);
SkASSERT(gp->getVertexStride() == sizeof(SkPoint));
- setup_dashed_rect_pos(rects[rectIndex], curVIdx, geom.fSrcRotInv, verts);
+ setup_dashed_rect_pos(rects[rectIndex], curVIdx, args.fSrcRotInv, verts);
}
curVIdx += 4;
}
rectIndex++;
}
- helper.issueDraws(batchTarget);
+
+ GrDrawTarget::DrawInfo drawInfo;
+ drawInfo.setPrimitiveType(kTriangles_GrPrimitiveType);
+ drawInfo.setStartVertex(0);
+ drawInfo.setStartIndex(0);
+ drawInfo.setVerticesPerInstance(kVertsPerDash);
+ drawInfo.setIndicesPerInstance(kIndicesPerDash);
+ drawInfo.adjustStartVertex(firstVertex);
+ drawInfo.setVertexBuffer(vertexBuffer);
+ drawInfo.setIndexBuffer(indexBuffer);
+
+ int maxInstancesPerDraw = indexBuffer->maxQuads();
+ while (totalRectCount) {
+ drawInfo.setInstanceCount(SkTMin(totalRectCount, maxInstancesPerDraw));
+ drawInfo.setVertexCount(drawInfo.instanceCount() * drawInfo.verticesPerInstance());
+ drawInfo.setIndexCount(drawInfo.instanceCount() * drawInfo.indicesPerInstance());
+
+ batchTarget->draw(drawInfo);
+
+ drawInfo.setStartVertex(drawInfo.startVertex() + drawInfo.vertexCount());
+ totalRectCount -= drawInfo.instanceCount();
+ }
}
SkSTArray<1, Geometry, true>* geoData() { return &fGeoData; }
« no previous file with comments | « src/gpu/GrTessellatingPathRenderer.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698