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

Unified Diff: src/gpu/GrResourceProvider.h

Issue 1261643004: Some cleanup in GrTextureProvider and GrResourceProvider (Closed) Base URL: https://skia.googlesource.com/skia.git@pathargs
Patch Set: fix Created 5 years, 5 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
Index: src/gpu/GrResourceProvider.h
diff --git a/src/gpu/GrResourceProvider.h b/src/gpu/GrResourceProvider.h
index f0b79b97f5ebbf8d60aa62091aaeeec23a7fecf8..9ba1426fb6e73c425dfedaf4250e1033ef060ded 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,

Powered by Google App Engine
This is Rietveld 408576698