aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/gpu/GrResourceProvider.h
diff options
context:
space:
mode:
authorGravatar bsalomon <bsalomon@google.com>2015-07-31 13:59:30 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2015-07-31 13:59:31 -0700
commiteae6200acbec2255ac00ab363ffbe16758ec9076 (patch)
treea37be1fb02820c40d0ad99366b557997d6b78831 /src/gpu/GrResourceProvider.h
parent77d89f7dd243a17452d3a5f16a98622993e6bdd9 (diff)
Some cleanup in GrTextureProvider and GrResourceProvider.
Diffstat (limited to 'src/gpu/GrResourceProvider.h')
-rw-r--r--src/gpu/GrResourceProvider.h44
1 files changed, 34 insertions, 10 deletions
diff --git a/src/gpu/GrResourceProvider.h b/src/gpu/GrResourceProvider.h
index f0b79b97f5..9ba1426fb6 100644
--- a/src/gpu/GrResourceProvider.h
+++ b/src/gpu/GrResourceProvider.h
@@ -24,10 +24,13 @@ class SkTypeface;
* An extension of the texture provider for arbitrary resource types. This class is intended for
* use within the Gr code base, not by clients or extensions (e.g. third party GrProcessor
* derivatives).
+ *
+ * This currently inherits from GrTextureProvider non-publically to force callers to provider
+ * make a flags (pendingIO) decision and not use the GrTP methods that don't take flags. This
+ * can be relaxed once http://skbug.com/4156 is fixed.
*/
-class GrResourceProvider : public GrTextureProvider {
+class GrResourceProvider : protected GrTextureProvider {
public:
-
GrResourceProvider(GrGpu* gpu, GrResourceCache* cache);
template <typename T> T* findAndRefTByUniqueKey(const GrUniqueKey& key) {
@@ -47,11 +50,11 @@ public:
*
* @return The index buffer if successful, otherwise NULL.
*/
- const GrIndexBuffer* refOrCreateInstancedIndexBuffer(const uint16_t* pattern,
- int patternSize,
- int reps,
- int vertCount,
- const GrUniqueKey& key) {
+ const GrIndexBuffer* findOrCreateInstancedIndexBuffer(const uint16_t* pattern,
+ int patternSize,
+ int reps,
+ int vertCount,
+ const GrUniqueKey& key) {
if (GrIndexBuffer* buffer = this->findAndRefTByUniqueKey<GrIndexBuffer>(key)) {
return buffer;
}
@@ -81,13 +84,34 @@ public:
GrPathRange* createPathRange(GrPathRange::PathGenerator*, const GrStrokeInfo&);
GrPathRange* createGlyphs(const SkTypeface*, const SkDescriptor*, const GrStrokeInfo&);
-
using GrTextureProvider::assignUniqueKeyToResource;
using GrTextureProvider::findAndRefResourceByUniqueKey;
using GrTextureProvider::abandon;
- GrIndexBuffer* getIndexBuffer(size_t size, bool dynamic, bool calledDuringFlush);
- GrVertexBuffer* getVertexBuffer(size_t size, bool dynamic, bool calledDuringFlush);
+ enum Flags {
+ /** If the caller intends to do direct reads/writes to/from the CPU then this flag must be
+ * set when accessing resources during a GrDrawTarget flush. This includes the execution of
+ * GrBatch objects. The reason is that these memory operations are done immediately and
+ * will occur out of order WRT the operations being flushed.
+ * Make this automatic: http://skbug.com/4156
+ */
+ kNoPendingIO_Flag = kNoPendingIO_ScratchTextureFlag,
+ };
+
+ enum BufferUsage {
+ /** Caller intends to specify the buffer data rarely with respect to the number of draws
+ that read the data. */
+ kStatic_BufferUsage,
+ /** Caller intends to respecify the buffer data frequently between draws. */
+ kDynamic_BufferUsage,
+ };
+ GrIndexBuffer* createIndexBuffer(size_t size, BufferUsage, uint32_t flags);
+ GrVertexBuffer* createVertexBuffer(size_t size, BufferUsage, uint32_t flags);
+
+ GrTexture* createApproxTexture(const GrSurfaceDesc& desc, uint32_t flags) {
+ SkASSERT(0 == flags || kNoPendingIO_Flag == flags);
+ return this->internalCreateApproxTexture(desc, flags);
+ }
private:
const GrIndexBuffer* createInstancedIndexBuffer(const uint16_t* pattern,