diff options
author | robertphillips@google.com <robertphillips@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2012-06-04 20:05:28 +0000 |
---|---|---|
committer | robertphillips@google.com <robertphillips@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2012-06-04 20:05:28 +0000 |
commit | a1e5795279bd085496fa04c59e588f440bf30457 (patch) | |
tree | 7ad0fb599faa8cca9839b435736b9523e0690ffa /include | |
parent | 778e1635030ab77b29b592a9dcafc112ad60ce65 (diff) |
GrTexture can now create its own cache key
http://codereview.appspot.com/6269047/
git-svn-id: http://skia.googlecode.com/svn/trunk@4148 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'include')
-rw-r--r-- | include/gpu/GrContext.h | 19 | ||||
-rw-r--r-- | include/gpu/GrTexture.h | 19 | ||||
-rw-r--r-- | include/gpu/SkGr.h | 11 |
3 files changed, 27 insertions, 22 deletions
diff --git a/include/gpu/GrContext.h b/include/gpu/GrContext.h index 876852825c..adceb778c5 100644 --- a/include/gpu/GrContext.h +++ b/include/gpu/GrContext.h @@ -109,13 +109,6 @@ 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; - - /** * Create a new entry, based on the specified key and texture, and return * its "locked" entry. Must call be balanced with an unlockTexture() call. * @@ -133,7 +126,7 @@ public: * @param rowBytes The number of bytes between rows of the texture. Zero * implies tightly packed rows. */ - TextureCacheEntry createAndLockTexture(TextureKey key, + TextureCacheEntry createAndLockTexture(GrTexture::TextureKey key, const GrSamplerState* sampler, const GrTextureDesc& desc, void* srcData, size_t rowBytes); @@ -158,18 +151,16 @@ public: * filter fields are used. NULL implies clamp wrap modes * and nearest filtering. */ - TextureCacheEntry findAndLockTexture(TextureKey key, - int width, - int height, + TextureCacheEntry findAndLockTexture(GrTexture::TextureKey key, + 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(TextureKey key, - int width, - int height, + bool isTextureInCache(GrTexture::TextureKey key, + const GrTextureDesc& desc, const GrSamplerState*) const; /** diff --git a/include/gpu/GrTexture.h b/include/gpu/GrTexture.h index e5c67d674b..c3e2946f76 100644 --- a/include/gpu/GrTexture.h +++ b/include/gpu/GrTexture.h @@ -14,11 +14,20 @@ #include "GrResource.h" class GrRenderTarget; +class GrResourceKey; +class GrSamplerState; 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 @@ -130,6 +139,16 @@ public: void validate() const {} #endif + static GrResourceKey ComputeKey(const GrGpu* gpu, + const GrSamplerState* sampler, + TextureKey clientKey, + const GrTextureDesc& desc, + bool scratch); + + static bool NeedsResizing(const GrResourceKey& key); + static bool IsScratchTexture(const GrResourceKey& key); + static bool NeedsFiltering(const GrResourceKey& key); + protected: GrRenderTarget* fRenderTarget; // texture refs its rt representation // base class cons sets to NULL diff --git a/include/gpu/SkGr.h b/include/gpu/SkGr.h index 74dc2cfce4..9e6d83e03f 100644 --- a/include/gpu/SkGr.h +++ b/include/gpu/SkGr.h @@ -74,12 +74,7 @@ public: * Convert the SkBitmap::Config to the corresponding PixelConfig, or * kUnknown_PixelConfig if the conversion cannot be done. */ - static GrPixelConfig BitmapConfig2PixelConfig(SkBitmap::Config, - bool isOpaque); - - static GrPixelConfig Bitmap2PixelConfig(const SkBitmap& bm) { - return BitmapConfig2PixelConfig(bm.config(), bm.isOpaque()); - } + static GrPixelConfig BitmapConfig2PixelConfig(SkBitmap::Config); static GrColor SkColor2GrColor(SkColor c) { SkPMColor pm = SkPreMultiplyColor(c); @@ -157,9 +152,9 @@ private: //////////////////////////////////////////////////////////////////////////////// // Helper functions -static const GrContext::TextureKey gUNCACHED_KEY = ~0; +static const GrTexture::TextureKey gUNCACHED_KEY = ~0; GrContext::TextureCacheEntry sk_gr_create_bitmap_texture(GrContext* ctx, - GrContext::TextureKey key, + GrTexture::TextureKey key, const GrSamplerState* sampler, const SkBitmap& bitmap); |