Add findOrMakeStaticBuffer method to GrResourceProvider
Bug: skia:
Change-Id: Ie47f00bf8542462d719df0d08972794861ec4a2b
Reviewed-on: https://skia-review.googlesource.com/86283
Reviewed-by: Chris Dalton <csmartdalton@google.com>
Reviewed-by: Brian Salomon <bsalomon@google.com>
Commit-Queue: Chris Dalton <csmartdalton@google.com>
diff --git a/src/gpu/ccpr/GrCCPRPathProcessor.cpp b/src/gpu/ccpr/GrCCPRPathProcessor.cpp
index c99a010..2f0c023 100644
--- a/src/gpu/ccpr/GrCCPRPathProcessor.cpp
+++ b/src/gpu/ccpr/GrCCPRPathProcessor.cpp
@@ -36,6 +36,12 @@
GR_DECLARE_STATIC_UNIQUE_KEY(gVertexBufferKey);
+sk_sp<const GrBuffer> GrCCPRPathProcessor::FindVertexBuffer(GrOnFlushResourceProvider* onFlushRP) {
+ GR_DEFINE_STATIC_UNIQUE_KEY(gVertexBufferKey);
+ return onFlushRP->findOrMakeStaticBuffer(kVertex_GrBufferType, sizeof(kOctoEdgeNorms),
+ kOctoEdgeNorms, gVertexBufferKey);
+}
+
// Index buffer for the octagon defined above.
static uint16_t kOctoIndices[GrCCPRPathProcessor::kPerInstanceIndexCount] = {
0, 4, 2,
@@ -48,6 +54,12 @@
GR_DECLARE_STATIC_UNIQUE_KEY(gIndexBufferKey);
+sk_sp<const GrBuffer> GrCCPRPathProcessor::FindIndexBuffer(GrOnFlushResourceProvider* onFlushRP) {
+ GR_DEFINE_STATIC_UNIQUE_KEY(gIndexBufferKey);
+ return onFlushRP->findOrMakeStaticBuffer(kIndex_GrBufferType, sizeof(kOctoIndices),
+ kOctoIndices, gIndexBufferKey);
+}
+
GrCCPRPathProcessor::GrCCPRPathProcessor(GrResourceProvider* rp, sk_sp<GrTextureProxy> atlas,
SkPath::FillType fillType, const GrShaderCaps& shaderCaps)
: INHERITED(kGrCCPRPathProcessor_ClassID)
@@ -190,15 +202,3 @@
f->codeAppendf("%s = half4(1 - abs(t - 1));", args.fOutputCoverage);
}
}
-
-sk_sp<GrBuffer> GrCCPRPathProcessor::FindOrMakeIndexBuffer(GrOnFlushResourceProvider* onFlushRP) {
- GR_DEFINE_STATIC_UNIQUE_KEY(gIndexBufferKey);
- return onFlushRP->findOrMakeStaticBuffer(gIndexBufferKey, kIndex_GrBufferType,
- sizeof(kOctoIndices), kOctoIndices);
-}
-
-sk_sp<GrBuffer> GrCCPRPathProcessor::FindOrMakeVertexBuffer(GrOnFlushResourceProvider* onFlushRP) {
- GR_DEFINE_STATIC_UNIQUE_KEY(gVertexBufferKey);
- return onFlushRP->findOrMakeStaticBuffer(gVertexBufferKey, kVertex_GrBufferType,
- sizeof(kOctoEdgeNorms), kOctoEdgeNorms);
-}
diff --git a/src/gpu/ccpr/GrCCPRPathProcessor.h b/src/gpu/ccpr/GrCCPRPathProcessor.h
index 7ad314e..97daefe 100644
--- a/src/gpu/ccpr/GrCCPRPathProcessor.h
+++ b/src/gpu/ccpr/GrCCPRPathProcessor.h
@@ -27,8 +27,6 @@
class GrCCPRPathProcessor : public GrGeometryProcessor {
public:
static constexpr int kPerInstanceIndexCount = 6 * 3;
- static sk_sp<GrBuffer> FindOrMakeIndexBuffer(GrOnFlushResourceProvider*);
- static sk_sp<GrBuffer> FindOrMakeVertexBuffer(GrOnFlushResourceProvider*);
enum class InstanceAttribs {
kDevBounds,
@@ -54,6 +52,9 @@
GR_STATIC_ASSERT(4 * 16 == sizeof(Instance));
+ static sk_sp<const GrBuffer> FindIndexBuffer(GrOnFlushResourceProvider*);
+ static sk_sp<const GrBuffer> FindVertexBuffer(GrOnFlushResourceProvider*);
+
GrCCPRPathProcessor(GrResourceProvider*, sk_sp<GrTextureProxy> atlas, SkPath::FillType,
const GrShaderCaps&);
diff --git a/src/gpu/ccpr/GrCoverageCountingPathRenderer.cpp b/src/gpu/ccpr/GrCoverageCountingPathRenderer.cpp
index 937fd48..a239569 100644
--- a/src/gpu/ccpr/GrCoverageCountingPathRenderer.cpp
+++ b/src/gpu/ccpr/GrCoverageCountingPathRenderer.cpp
@@ -324,13 +324,13 @@
}
// Allocate GPU buffers.
- fPerFlushIndexBuffer = GrCCPRPathProcessor::FindOrMakeIndexBuffer(onFlushRP);
+ fPerFlushIndexBuffer = GrCCPRPathProcessor::FindIndexBuffer(onFlushRP);
if (!fPerFlushIndexBuffer) {
SkDebugf("WARNING: failed to allocate ccpr path index buffer.\n");
return;
}
- fPerFlushVertexBuffer = GrCCPRPathProcessor::FindOrMakeVertexBuffer(onFlushRP);
+ fPerFlushVertexBuffer = GrCCPRPathProcessor::FindVertexBuffer(onFlushRP);
if (!fPerFlushVertexBuffer) {
SkDebugf("WARNING: failed to allocate ccpr path vertex buffer.\n");
return;
diff --git a/src/gpu/ccpr/GrCoverageCountingPathRenderer.h b/src/gpu/ccpr/GrCoverageCountingPathRenderer.h
index 1d08f38..8446af6 100644
--- a/src/gpu/ccpr/GrCoverageCountingPathRenderer.h
+++ b/src/gpu/ccpr/GrCoverageCountingPathRenderer.h
@@ -217,8 +217,8 @@
std::map<uint32_t, RTPendingPaths> fRTPendingPathsMap;
SkDEBUGCODE(int fPendingDrawOpsCount = 0;)
- sk_sp<GrBuffer> fPerFlushIndexBuffer;
- sk_sp<GrBuffer> fPerFlushVertexBuffer;
+ sk_sp<const GrBuffer> fPerFlushIndexBuffer;
+ sk_sp<const GrBuffer> fPerFlushVertexBuffer;
sk_sp<GrBuffer> fPerFlushInstanceBuffer;
GrSTAllocator<4, GrCCPRAtlas> fPerFlushAtlases;
bool fPerFlushResourcesAreValid;