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

Unified Diff: include/gpu/GrContext.h

Issue 882223003: Move npot resizing out of GrContext and simplify GrContext texture functions. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: rebase Created 5 years, 11 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
« no previous file with comments | « no previous file | include/gpu/GrPaint.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: include/gpu/GrContext.h
diff --git a/include/gpu/GrContext.h b/include/gpu/GrContext.h
index e6fdeb89f7771db4c0f18b15241abe76c13a1927..88a31484ed7c1c7d1d9078f4d9f5db437f7145c3 100644
--- a/include/gpu/GrContext.h
+++ b/include/gpu/GrContext.h
@@ -169,10 +169,10 @@ public:
*/
void purgeAllUnlockedResources();
- /**
- * Stores a custom resource in the cache, based on the specified key.
+ /** Sets a content key on the resource. The resource must not already have a content key and
+ * the key must not already be in use for this to succeed.
*/
- void addResourceToCache(const GrContentKey&, GrGpuResource*);
+ bool addResourceToCache(const GrContentKey&, GrGpuResource*);
/**
* Finds a resource in the cache, based on the specified key. This is intended for use in
@@ -181,6 +181,25 @@ public:
*/
GrGpuResource* findAndRefCachedResource(const GrContentKey&);
+ /** Helper for casting resource to a texture. Caller must be sure that the resource cached
+ with the key is either NULL or a texture and not another resource type. */
+ GrTexture* findAndRefCachedTexture(const GrContentKey& key) {
+ GrGpuResource* resource = this->findAndRefCachedResource(key);
+ if (resource) {
+ GrTexture* texture = static_cast<GrSurface*>(resource)->asTexture();
+ SkASSERT(texture);
+ return texture;
+ }
+ return NULL;
+ }
+
+ /**
+ * Determines whether a resource is in the cache. If the resource is found it
+ * will not be locked or returned. This call does not affect the priority of
+ * the resource for deletion.
+ */
+ bool isResourceInCache(const GrContentKey& key) const;
+
/**
* Creates a new text rendering context that is optimal for the
* render target and the context. Caller assumes the ownership
@@ -195,57 +214,28 @@ public:
// Textures
/**
- * Creates a new entry, based on the specified key and texture and returns it. The caller owns a
+ * Creates a new texture in the resource cache and returns it. The caller owns a
* ref on the returned texture which must be balanced by a call to unref.
*
- * TODO: Move resizing logic out of GrContext and have the caller set the content key on the
- * returned texture rather than take it as a param.
- *
- * @param params The texture params used to draw a texture may help determine
- * the cache entry used. (e.g. different versions may exist
- * for different wrap modes on GPUs with limited NPOT
- * texture support). NULL implies clamp wrap modes.
* @param desc Description of the texture properties.
- * @param key Key to associate with the texture.
* @param srcData Pointer to the pixel values.
* @param rowBytes The number of bytes between rows of the texture. Zero
* implies tightly packed rows. For compressed pixel configs, this
* field is ignored.
- * @param outKey (optional) If non-NULL, we'll write the cache key we used to cacheKey. this
- * may differ from key on GPUs that don't support tiling NPOT textures.
- */
- GrTexture* createTexture(const GrTextureParams* params,
- const GrSurfaceDesc& desc,
- const GrContentKey& key,
- const void* srcData,
- size_t rowBytes,
- GrContentKey* outKey = NULL);
- /**
- * Search for an entry based on key and dimensions. If found, ref it and return it. The return
- * value will be NULL if not found. The caller must balance with a call to unref.
- *
- * TODO: Remove this function and do lookups generically.
- *
- * @param desc Description of the texture properties.
- * @param key key to use for texture look up.
- * @param params The texture params used to draw a texture may help determine
- * the cache entry used. (e.g. different versions may exist
- * for different wrap modes on GPUs with limited NPOT
- * texture support). NULL implies clamp wrap modes.
- */
- GrTexture* findAndRefTexture(const GrSurfaceDesc& desc,
- const GrContentKey& key,
- const GrTextureParams* params);
- /**
- * Determines whether a texture is in the cache. If the texture is found it
- * will not be locked or returned. This call does not affect the priority of
- * the texture for deletion.
+ */
+ GrTexture* createTexture(const GrSurfaceDesc& desc, const void* srcData, size_t rowBytes);
+
+ GrTexture* createTexture(const GrSurfaceDesc& desc) {
+ return this->createTexture(desc, NULL, 0);
+ }
+
+ /**
+ * Creates a texture that is outside the cache. Does not count against
+ * cache's budget.
*
- * TODO: Remove this function and do cache checks generically.
+ * TODO: Add a budgeted param to createTexture and remove this function.
*/
- bool isTextureInCache(const GrSurfaceDesc& desc,
- const GrContentKey& key,
- const GrTextureParams* params) const;
+ GrTexture* createUncachedTexture(const GrSurfaceDesc& desc, void* srcData, size_t rowBytes);
/**
* Enum that determines how closely a returned scratch texture must match
@@ -284,26 +274,9 @@ public:
bool internalFlag = false);
/**
- * Creates a texture that is outside the cache. Does not count against
- * cache's budget.
- *
- * Textures created by createTexture() hide the complications of
- * tiling non-power-of-two textures on APIs that don't support this (e.g.
- * unextended GLES2). NPOT uncached textures are not tilable on such APIs.
- */
- GrTexture* createUncachedTexture(const GrSurfaceDesc& desc,
- void* srcData,
- size_t rowBytes);
-
- /**
- * Returns true if the specified use of an indexed texture is supported.
- * Support may depend upon whether the texture params indicate that the
- * texture will be tiled. Passing NULL for the texture params indicates
- * clamp mode.
+ * Returns true if index8 textures are supported.
*/
- bool supportsIndex8PixelConfig(const GrTextureParams*,
- int width,
- int height) const;
+ bool supportsIndex8PixelConfig() const;
/**
* Return the max width or height of a texture supported by the current GPU.
« no previous file with comments | « no previous file | include/gpu/GrPaint.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698