aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/gpu/ccpr
diff options
context:
space:
mode:
authorGravatar Chris Dalton <csmartdalton@google.com>2018-05-07 19:19:06 -0600
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2018-05-08 15:39:04 +0000
commitd925f2d38dff377b5ef8e3f71410237de80811aa (patch)
tree77e7ec17f38b8adee98342006671b43ead437b74 /src/gpu/ccpr
parent75ce242a4662d7d7b724f55806508106349b9180 (diff)
Add a drawPaths method to GrCCPathProcessor
Bug: skia: Change-Id: I5d3762203cbe1d823ea3f3967240bcab76651f2c Reviewed-on: https://skia-review.googlesource.com/126662 Reviewed-by: Brian Salomon <bsalomon@google.com> Commit-Queue: Chris Dalton <csmartdalton@google.com>
Diffstat (limited to 'src/gpu/ccpr')
-rw-r--r--src/gpu/ccpr/GrCCPathProcessor.cpp25
-rw-r--r--src/gpu/ccpr/GrCCPathProcessor.h16
-rw-r--r--src/gpu/ccpr/GrCoverageCountingPathRenderer.cpp12
3 files changed, 32 insertions, 21 deletions
diff --git a/src/gpu/ccpr/GrCCPathProcessor.cpp b/src/gpu/ccpr/GrCCPathProcessor.cpp
index 55cbcaba6e..5dacc6a3b5 100644
--- a/src/gpu/ccpr/GrCCPathProcessor.cpp
+++ b/src/gpu/ccpr/GrCCPathProcessor.cpp
@@ -7,6 +7,7 @@
#include "GrCCPathProcessor.h"
+#include "GrGpuCommandBuffer.h"
#include "GrOnFlushResourceProvider.h"
#include "GrTexture.h"
#include "glsl/GrGLSLFragmentShaderBuilder.h"
@@ -74,11 +75,6 @@ sk_sp<const GrBuffer> GrCCPathProcessor::FindIndexBuffer(GrOnFlushResourceProvid
}
}
-int GrCCPathProcessor::NumIndicesPerInstance(const GrCaps& caps) {
- return caps.usePrimitiveRestart() ? SK_ARRAY_COUNT(kOctoIndicesAsStrips)
- : SK_ARRAY_COUNT(kOctoIndicesAsTris);
-}
-
GrCCPathProcessor::GrCCPathProcessor(GrResourceProvider* resourceProvider,
sk_sp<GrTextureProxy> atlas, SkPath::FillType fillType)
: INHERITED(kGrCCPathProcessor_ClassID)
@@ -144,6 +140,25 @@ GrGLSLPrimitiveProcessor* GrCCPathProcessor::createGLSLInstance(const GrShaderCa
return new GLSLPathProcessor();
}
+void GrCCPathProcessor::drawPaths(GrOpFlushState* flushState, const GrPipeline& pipeline,
+ const GrBuffer* indexBuffer, const GrBuffer* vertexBuffer,
+ GrBuffer* instanceBuffer, int baseInstance, int endInstance,
+ const SkRect& bounds) const {
+ const GrCaps& caps = flushState->caps();
+ GrPrimitiveType primitiveType = caps.usePrimitiveRestart()
+ ? GrPrimitiveType::kTriangleStrip
+ : GrPrimitiveType::kTriangles;
+ int numIndicesPerInstance = caps.usePrimitiveRestart()
+ ? SK_ARRAY_COUNT(kOctoIndicesAsStrips)
+ : SK_ARRAY_COUNT(kOctoIndicesAsTris);
+ GrMesh mesh(primitiveType);
+ mesh.setIndexedInstanced(indexBuffer, numIndicesPerInstance, instanceBuffer,
+ endInstance - baseInstance, baseInstance);
+ mesh.setVertexData(vertexBuffer);
+
+ flushState->rtCommandBuffer()->draw(pipeline, *this, &mesh, nullptr, 1, bounds);
+}
+
void GLSLPathProcessor::onEmitCode(EmitArgs& args, GrGPArgs* gpArgs) {
using InstanceAttribs = GrCCPathProcessor::InstanceAttribs;
using Interpolation = GrGLSLVaryingHandler::Interpolation;
diff --git a/src/gpu/ccpr/GrCCPathProcessor.h b/src/gpu/ccpr/GrCCPathProcessor.h
index 644fbbab2d..40b16a4e9d 100644
--- a/src/gpu/ccpr/GrCCPathProcessor.h
+++ b/src/gpu/ccpr/GrCCPathProcessor.h
@@ -14,6 +14,8 @@
#include <array>
class GrOnFlushResourceProvider;
+class GrOpFlushState;
+class GrPipeline;
/**
* This class draws AA paths using the coverage count masks produced by GrCCCoverageProcessor.
@@ -21,8 +23,9 @@ class GrOnFlushResourceProvider;
* Paths are drawn as bloated octagons, and coverage is derived from the coverage count mask and
* fill rule.
*
- * The caller must set up an instance buffer as detailed below, then draw indexed-instanced
- * meshes using the buffers and parameters provided by this class.
+ * To draw paths, the caller must set up an instance buffer as detailed below, then call drawPaths()
+ * providing its own instance buffer alongside the buffers found by calling FindIndexBuffer/
+ * FindVertexBuffer.
*/
class GrCCPathProcessor : public GrGeometryProcessor {
public:
@@ -50,13 +53,8 @@ public:
GR_STATIC_ASSERT(4 * 16 == sizeof(Instance));
- static GrPrimitiveType MeshPrimitiveType(const GrCaps& caps) {
- return caps.usePrimitiveRestart() ? GrPrimitiveType::kTriangleStrip
- : GrPrimitiveType::kTriangles;
- }
static sk_sp<const GrBuffer> FindVertexBuffer(GrOnFlushResourceProvider*);
static sk_sp<const GrBuffer> FindIndexBuffer(GrOnFlushResourceProvider*);
- static int NumIndicesPerInstance(const GrCaps&);
GrCCPathProcessor(GrResourceProvider*, sk_sp<GrTextureProxy> atlas, SkPath::FillType);
@@ -79,6 +77,10 @@ public:
void getGLSLProcessorKey(const GrShaderCaps&, GrProcessorKeyBuilder*) const override;
GrGLSLPrimitiveProcessor* createGLSLInstance(const GrShaderCaps&) const override;
+ void drawPaths(GrOpFlushState*, const GrPipeline&, const GrBuffer* indexBuffer,
+ const GrBuffer* vertexBuffer, GrBuffer* instanceBuffer, int baseInstance,
+ int endInstance, const SkRect& bounds) const;
+
private:
const SkPath::FillType fFillType;
const TextureSampler fAtlasAccess;
diff --git a/src/gpu/ccpr/GrCoverageCountingPathRenderer.cpp b/src/gpu/ccpr/GrCoverageCountingPathRenderer.cpp
index fa08af5dca..26348964ea 100644
--- a/src/gpu/ccpr/GrCoverageCountingPathRenderer.cpp
+++ b/src/gpu/ccpr/GrCoverageCountingPathRenderer.cpp
@@ -511,15 +511,9 @@ void CCPR::DrawPathsOp::onExecute(GrOpFlushState* flushState) {
GrCCPathProcessor pathProc(flushState->resourceProvider(),
sk_ref_sp(batch.fAtlas->textureProxy()), this->getFillType());
-
- GrMesh mesh(GrCCPathProcessor::MeshPrimitiveType(flushState->caps()));
- mesh.setIndexedInstanced(fCCPR->fPerFlushIndexBuffer.get(),
- GrCCPathProcessor::NumIndicesPerInstance(flushState->caps()),
- fCCPR->fPerFlushInstanceBuffer.get(),
- batch.fEndInstanceIdx - baseInstance, baseInstance);
- mesh.setVertexData(fCCPR->fPerFlushVertexBuffer.get());
-
- flushState->rtCommandBuffer()->draw(pipeline, pathProc, &mesh, nullptr, 1, this->bounds());
+ pathProc.drawPaths(flushState, pipeline, fCCPR->fPerFlushIndexBuffer.get(),
+ fCCPR->fPerFlushVertexBuffer.get(), fCCPR->fPerFlushInstanceBuffer.get(),
+ baseInstance, batch.fEndInstanceIdx, this->bounds());
}
SkASSERT(baseInstance == fBaseInstance + fInstanceCount - fNumSkippedInstances);