diff options
author | 2012-08-13 17:47:59 +0000 | |
---|---|---|
committer | 2012-08-13 17:47:59 +0000 | |
commit | 9c2ea846351a29208cb4a36301ee611e7fb384ea (patch) | |
tree | cf61ae05b74705a6ae7d579e50410dd026ec780a /include/gpu | |
parent | 62e41903a70e0bebf875cd0fa5c94f804fad582a (diff) |
Split cache-specific fields out of GrTextureDesc
http://codereview.appspot.com/6448143/
git-svn-id: http://skia.googlecode.com/svn/trunk@5065 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'include/gpu')
-rw-r--r-- | include/gpu/GrCacheID.h | 2 | ||||
-rw-r--r-- | include/gpu/GrContext.h | 5 | ||||
-rw-r--r-- | include/gpu/GrTexture.h | 12 | ||||
-rw-r--r-- | include/gpu/GrTypes.h | 42 |
4 files changed, 35 insertions, 26 deletions
diff --git a/include/gpu/GrCacheID.h b/include/gpu/GrCacheID.h index 231304d1ed..e6f5f752d1 100644 --- a/include/gpu/GrCacheID.h +++ b/include/gpu/GrCacheID.h @@ -75,7 +75,7 @@ public: GrCacheID(uint8_t resourceType) : fPublicID(kDefaultPublicCacheID) - , fDomain(kUnrestricted_ResourceDomain) + , fDomain(GrCacheData::kScratch_ResourceDomain) , fResourceType(resourceType) { } diff --git a/include/gpu/GrContext.h b/include/gpu/GrContext.h index 52dafd0597..abe745384c 100644 --- a/include/gpu/GrContext.h +++ b/include/gpu/GrContext.h @@ -125,12 +125,14 @@ public: * for different wrap modes on GPUs with limited NPOT * texture support). NULL implies clamp wrap modes. * @param desc Description of the texture properties. + * @param cacheData Cache-specific properties (e.g., texture gen ID) * @param srcData Pointer to the pixel values. * @param rowBytes The number of bytes between rows of the texture. Zero * implies tightly packed rows. */ TextureCacheEntry createAndLockTexture(const GrTextureParams* params, const GrTextureDesc& desc, + const GrCacheData& cacheData, void* srcData, size_t rowBytes); /** @@ -139,12 +141,14 @@ public: * Must be balanced with an unlockTexture() call. * * @param desc Description of the texture properties. + * @param cacheData Cache-specific properties (e.g., texture gen ID) * @param params The tex 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. */ TextureCacheEntry findAndLockTexture(const GrTextureDesc& desc, + const GrCacheData& cacheData, const GrTextureParams* params); /** * Determines whether a texture is in the cache. If the texture is found it @@ -152,6 +156,7 @@ public: * the texture for deletion. */ bool isTextureInCache(const GrTextureDesc& desc, + const GrCacheData& cacheData, const GrTextureParams* params) const; /** diff --git a/include/gpu/GrTexture.h b/include/gpu/GrTexture.h index 2ccd3014f8..a1b7eabd85 100644 --- a/include/gpu/GrTexture.h +++ b/include/gpu/GrTexture.h @@ -16,17 +16,6 @@ class GrRenderTarget; class GrResourceKey; class GrTextureParams; -/* - * 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 GrSurface { public: @@ -166,6 +155,7 @@ public: static GrResourceKey ComputeKey(const GrGpu* gpu, const GrTextureParams* sampler, const GrTextureDesc& desc, + const GrCacheData& cacheData, bool scratch); static bool NeedsResizing(const GrResourceKey& key); diff --git a/include/gpu/GrTypes.h b/include/gpu/GrTypes.h index a3f0059a59..9fbdb741ab 100644 --- a/include/gpu/GrTypes.h +++ b/include/gpu/GrTypes.h @@ -468,17 +468,6 @@ enum { kGrColorTableSize = 256 * 4 //sizeof(GrColor) }; -/* - * Default value for fClientCacheID - */ -static const uint64_t kDefault_CacheID = 0; - -/** - * All scratch resources should be Unrestricted so they can be used - * by any domain. - */ -static const uint8_t kUnrestricted_ResourceDomain = 0; - /** * Describes a texture to be created. @@ -489,9 +478,7 @@ struct GrTextureDesc { , fWidth(0) , fHeight(0) , fConfig(kUnknown_GrPixelConfig) - , fSampleCnt(0) - , fClientCacheID(kDefault_CacheID) - , fResourceDomain(kUnrestricted_ResourceDomain) { + , fSampleCnt(0) { } GrTextureFlags fFlags; //!< bitfield of TextureFlags @@ -512,6 +499,33 @@ struct GrTextureDesc { * max supportex count. */ int fSampleCnt; +}; + +/** + * GrCacheData holds user-provided cache-specific data. It is used in + * combination with the GrTextureDesc to construct a cache key for texture + * resources. + */ +struct GrCacheData { + /* + * Scratch textures should all have this value as their fClientCacheID + */ + static const uint64_t kScratch_CacheID = 0xBBBBBBBB; + + /** + * Resources in the "scratch" domain can be used by any domain. All + * scratch textures will have this as their domain. + */ + static const uint8_t kScratch_ResourceDomain = 0; + + + // No default constructor is provided since, if you are creating one + // of these, you should definitely have a key (or be using the scratch + // key). + GrCacheData(uint64_t key) + : fClientCacheID(key) + , fResourceDomain(kScratch_ResourceDomain) { + } /** * A user-provided texture ID. It should be unique to the texture data and |