Use const where possible for drawing parameters
They should never be modified by a Renderer, only read and copied.
Change-Id: I9d8d55dca19115ee9dfeb2bb3f092ba2fb327cd4
diff --git a/libs/hwui/TextureCache.h b/libs/hwui/TextureCache.h
index 57fc19a..e33c60d 100644
--- a/libs/hwui/TextureCache.h
+++ b/libs/hwui/TextureCache.h
@@ -49,7 +49,7 @@
* Any texture added to the cache causing the cache to grow beyond the maximum
* allowed size will also cause the oldest texture to be kicked out.
*/
-class TextureCache: public OnEntryRemoved<SkBitmap*, Texture*> {
+class TextureCache: public OnEntryRemoved<const SkBitmap*, Texture*> {
public:
TextureCache();
TextureCache(uint32_t maxByteSize);
@@ -59,28 +59,28 @@
* Used as a callback when an entry is removed from the cache.
* Do not invoke directly.
*/
- void operator()(SkBitmap*& bitmap, Texture*& texture);
+ void operator()(const SkBitmap*& bitmap, Texture*& texture);
/**
* Returns the texture associated with the specified bitmap. If the texture
* cannot be found in the cache, a new texture is generated.
*/
- Texture* get(SkBitmap* bitmap);
+ Texture* get(const SkBitmap* bitmap);
/**
* Returns the texture associated with the specified bitmap. The generated
* texture is not kept in the cache. The caller must destroy the texture.
*/
- Texture* getTransient(SkBitmap* bitmap);
+ Texture* getTransient(const SkBitmap* bitmap);
/**
* Removes the texture associated with the specified bitmap.
* Upon remove the texture is freed.
*/
- void remove(SkBitmap* bitmap);
+ void remove(const SkBitmap* bitmap);
/**
* Removes the texture associated with the specified bitmap. This is meant
* to be called from threads that are not the EGL context thread.
*/
- void removeDeferred(SkBitmap* bitmap);
+ void removeDeferred(const SkBitmap* bitmap);
/**
* Process deferred removals.
*/
@@ -122,15 +122,15 @@
* @param regenerate If true, the bitmap data is reuploaded into the texture, but
* no new texture is generated.
*/
- void generateTexture(SkBitmap* bitmap, Texture* texture, bool regenerate = false);
+ void generateTexture(const SkBitmap* bitmap, Texture* texture, bool regenerate = false);
- void uploadLoFiTexture(bool resize, SkBitmap* bitmap, uint32_t width, uint32_t height);
+ void uploadLoFiTexture(bool resize, const SkBitmap* bitmap, uint32_t width, uint32_t height);
void uploadToTexture(bool resize, GLenum format, GLsizei stride,
GLsizei width, GLsizei height, GLenum type, const GLvoid * data);
void init();
- LruCache<SkBitmap*, Texture*> mCache;
+ LruCache<const SkBitmap*, Texture*> mCache;
uint32_t mSize;
uint32_t mMaxSize;
@@ -140,7 +140,7 @@
bool mDebugEnabled;
- Vector<SkBitmap*> mGarbage;
+ Vector<const SkBitmap*> mGarbage;
mutable Mutex mLock;
}; // class TextureCache