diff options
author | robertphillips@google.com <robertphillips@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2012-06-07 12:08:45 +0000 |
---|---|---|
committer | robertphillips@google.com <robertphillips@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2012-06-07 12:08:45 +0000 |
commit | 75b3c9633cb9a594dab0ccf51dab1e694c149a18 (patch) | |
tree | ec4669cda6d54e286bf9b92f6495d733cfd58033 /include/gpu | |
parent | 93b4375fd4d87d3502d14d5e6a98383993b2600c (diff) |
Move clientID into texture desc
http://codereview.appspot.com/6305044/
git-svn-id: http://skia.googlecode.com/svn/trunk@4201 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'include/gpu')
-rw-r--r-- | include/gpu/GrContext.h | 30 | ||||
-rw-r--r-- | include/gpu/GrTexture.h | 19 | ||||
-rw-r--r-- | include/gpu/GrTypes.h | 24 | ||||
-rw-r--r-- | include/gpu/SkGr.h | 3 |
4 files changed, 44 insertions, 32 deletions
diff --git a/include/gpu/GrContext.h b/include/gpu/GrContext.h index 33a3abf41d..7f47c4fdba 100644 --- a/include/gpu/GrContext.h +++ b/include/gpu/GrContext.h @@ -111,9 +111,6 @@ public: * Create a new entry, based on the specified key and texture, and return * its "locked" entry. Must call be balanced with an unlockTexture() call. * - * @param key A client-generated key that identifies the contents - * of the texture. Respecified to findAndLockTexture - * for subsequent uses of the texture. * @param sampler The sampler state used to draw a texture may be used * to determine how to store the pixel data in the texture * cache. (e.g. different versions may exist for different @@ -125,8 +122,7 @@ public: * @param rowBytes The number of bytes between rows of the texture. Zero * implies tightly packed rows. */ - TextureCacheEntry createAndLockTexture(GrTexture::TextureKey key, - const GrSamplerState* sampler, + TextureCacheEntry createAndLockTexture(const GrSamplerState* sampler, const GrTextureDesc& desc, void* srcData, size_t rowBytes); @@ -135,14 +131,7 @@ public: * return it. The entry's texture() function will return NULL if not found. * Must be balanced with an unlockTexture() call. * - * @param key A client-generated key that identifies the contents - * of the texture. - * @param width The width of the texture in pixels as specifed in - * the GrTextureDesc originally passed to - * createAndLockTexture - * @param width The height of the texture in pixels as specifed in - * the GrTextureDesc originally passed to - * createAndLockTexture + * @param desc Description of the texture properties. * @param sampler The sampler state used to draw a texture may be used * to determine the cache entry used. (e.g. different * versions may exist for different wrap modes on GPUs with @@ -150,17 +139,15 @@ public: * filter fields are used. NULL implies clamp wrap modes * and nearest filtering. */ - TextureCacheEntry findAndLockTexture(GrTexture::TextureKey key, - const GrTextureDesc& desc, + TextureCacheEntry findAndLockTexture(const GrTextureDesc& desc, const GrSamplerState* sampler); /** * 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. */ - bool isTextureInCache(GrTexture::TextureKey key, - const GrTextureDesc& desc, - const GrSamplerState*) const; + bool isTextureInCache(const GrTextureDesc& desc, + const GrSamplerState* sampler) const; /** * Enum that determines how closely a returned scratch texture must match @@ -194,7 +181,8 @@ public: * such an API will create gaps in the tiling pattern. This includes clamp * mode. (This may be addressed in a future update.) */ - TextureCacheEntry lockScratchTexture(const GrTextureDesc& desc, ScratchTexMatch match); + TextureCacheEntry lockScratchTexture(const GrTextureDesc& desc, + ScratchTexMatch match); /** * When done with an entry, call unlockTexture(entry) on it, which returns @@ -206,14 +194,14 @@ public: * Creates a texture that is outside the cache. Does not count against * cache's budget. */ - GrTexture* createUncachedTexture(const GrTextureDesc&, + GrTexture* createUncachedTexture(const GrTextureDesc& desc, void* srcData, size_t rowBytes); /** * Returns true if the specified use of an indexed texture is supported. */ - bool supportsIndex8PixelConfig(const GrSamplerState*, + bool supportsIndex8PixelConfig(const GrSamplerState* sampler, int width, int height) const; diff --git a/include/gpu/GrTexture.h b/include/gpu/GrTexture.h index c3e2946f76..17d4e1e40d 100644 --- a/include/gpu/GrTexture.h +++ b/include/gpu/GrTexture.h @@ -17,17 +17,21 @@ class GrRenderTarget; class GrResourceKey; class GrSamplerState; +/* + * All uncached textures should have this value as their fClientCacheID + */ +static const uint64_t kUncached_CacheID = 0xAAAAAAAA; + +/* + * Scratch textures should all have this value as their fClientCacheID + */ +static const uint64_t kScratch_CacheID = 0xBBBBBBBB; + + class GrTexture : public GrResource { public: /** - * Key generated by client. Should be a unique key on the texture data. - * Does not need to consider that width and height of the texture. Two - * textures with the same TextureKey but different bounds will not collide. - */ - typedef uint64_t TextureKey; - - /** * Retrieves the width of the texture. * * @return the width in texels @@ -141,7 +145,6 @@ public: static GrResourceKey ComputeKey(const GrGpu* gpu, const GrSamplerState* sampler, - TextureKey clientKey, const GrTextureDesc& desc, bool scratch); diff --git a/include/gpu/GrTypes.h b/include/gpu/GrTypes.h index c3f659c6c6..a5d85498fc 100644 --- a/include/gpu/GrTypes.h +++ b/include/gpu/GrTypes.h @@ -459,10 +459,24 @@ enum { kGrColorTableSize = 256 * 4 //sizeof(GrColor) }; +/* + * Default value for fClientCacheID + */ +static const uint64_t kDefault_CacheID = 0; + /** * Describes a texture to be created. */ struct GrTextureDesc { + GrTextureDesc() + : fFlags(kNone_GrTextureFlags) + , fWidth(0) + , fHeight(0) + , fConfig(kUnknown_GrPixelConfig) + , fSampleCnt(0) + , fClientCacheID(kDefault_CacheID) { + } + GrTextureFlags fFlags; //!< bitfield of TextureFlags int fWidth; //!< Width of the texture int fHeight; //!< Height of the texture @@ -480,7 +494,15 @@ struct GrTextureDesc { * up to the next supported sample count, or down if it is larger than the * max supportex count. */ - int fSampleCnt; + int fSampleCnt; + + /** + * A user-provided texture ID. It should be unique to the texture data and + * does not need to take into account the width or height. Two textures + * with the same ID but different dimensions will not collide. This field + * is only relevant for textures that will be cached. + */ + uint64_t fClientCacheID; }; /** diff --git a/include/gpu/SkGr.h b/include/gpu/SkGr.h index 1a5cc936c3..44a351eb74 100644 --- a/include/gpu/SkGr.h +++ b/include/gpu/SkGr.h @@ -152,9 +152,8 @@ private: //////////////////////////////////////////////////////////////////////////////// // Helper functions -static const GrTexture::TextureKey gUNCACHED_KEY = ~0U; GrContext::TextureCacheEntry sk_gr_create_bitmap_texture(GrContext* ctx, - GrTexture::TextureKey key, + uint64_t key, const GrSamplerState* sampler, const SkBitmap& bitmap); |