diff options
author | 2015-05-04 08:09:30 -0700 | |
---|---|---|
committer | 2015-05-04 08:09:30 -0700 | |
commit | ab622c7b8cc8c39f0a594e4392b9e31b7e1ddb26 (patch) | |
tree | 37f3f06f49ac232382c691d09df3a8da0aada0ba /src/gpu/effects | |
parent | f15132fdcf5aabb874f1c151a872efe54ee95118 (diff) |
Move instanced index buffer creation to flush time
Review URL: https://codereview.chromium.org/1116943004
Diffstat (limited to 'src/gpu/effects')
-rw-r--r-- | src/gpu/effects/GrDashingEffect.cpp | 16 | ||||
-rw-r--r-- | src/gpu/effects/GrDashingEffect.h | 3 |
2 files changed, 9 insertions, 10 deletions
diff --git a/src/gpu/effects/GrDashingEffect.cpp b/src/gpu/effects/GrDashingEffect.cpp index 3f0df67377..fa8b3a2dcf 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,16 +536,17 @@ public: draw.fHasEndRect = hasEndRect; } + 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 || !batchTarget->quadIndexBuffer()) { + if (!vertices || !indexBuffer) { SkDebugf("Could not allocate buffers\n"); return; } @@ -607,8 +609,6 @@ public: rectIndex++; } - const GrIndexBuffer* dashIndexBuffer = batchTarget->quadIndexBuffer(); - GrDrawTarget::DrawInfo drawInfo; drawInfo.setPrimitiveType(kTriangles_GrPrimitiveType); drawInfo.setStartVertex(0); @@ -617,9 +617,9 @@ public: drawInfo.setIndicesPerInstance(kIndicesPerDash); drawInfo.adjustStartVertex(firstVertex); drawInfo.setVertexBuffer(vertexBuffer); - drawInfo.setIndexBuffer(dashIndexBuffer); + drawInfo.setIndexBuffer(indexBuffer); - int maxInstancesPerDraw = dashIndexBuffer->maxQuads(); + int maxInstancesPerDraw = indexBuffer->maxQuads(); while (totalRectCount) { drawInfo.setInstanceCount(SkTMin(totalRectCount, maxInstancesPerDraw)); drawInfo.setVertexCount(drawInfo.instanceCount() * drawInfo.verticesPerInstance()); @@ -761,7 +761,7 @@ static GrBatch* create_batch(GrColor color, const SkMatrix& viewMatrix, const Sk return DashBatch::Create(geometry, cap, aaMode, fullDash); } -bool GrDashingEffect::DrawDashLine(GrGpu* gpu, GrDrawTarget* target, +bool GrDashingEffect::DrawDashLine(GrDrawTarget* target, GrPipelineBuilder* pipelineBuilder, GrColor color, const SkMatrix& viewMatrix, const SkPoint pts[2], bool useAA, const GrStrokeInfo& strokeInfo) { diff --git a/src/gpu/effects/GrDashingEffect.h b/src/gpu/effects/GrDashingEffect.h index 999abb23d8..05b1c90205 100644 --- a/src/gpu/effects/GrDashingEffect.h +++ b/src/gpu/effects/GrDashingEffect.h @@ -15,13 +15,12 @@ class GrClip; class GrDrawTarget; -class GrGpu; class GrPaint; class GrPipelineBuilder; class GrStrokeInfo; namespace GrDashingEffect { - bool DrawDashLine(GrGpu*, GrDrawTarget*, GrPipelineBuilder*, GrColor, + bool DrawDashLine(GrDrawTarget*, GrPipelineBuilder*, GrColor, const SkMatrix& viewMatrix, const SkPoint pts[2], bool useAA, const GrStrokeInfo& strokeInfo); bool CanDrawDashLine(const SkPoint pts[2], const GrStrokeInfo& strokeInfo, |