diff options
| -rw-r--r-- | core/java/com/android/internal/app/ResolverActivity.java | 2 | ||||
| -rw-r--r-- | libs/hwui/FontRenderer.cpp | 3 | ||||
| -rw-r--r-- | libs/hwui/FontRenderer.h | 5 | ||||
| -rw-r--r-- | libs/hwui/GammaFontRenderer.h | 1 | ||||
| -rw-r--r-- | libs/hwui/GradientCache.cpp | 9 | ||||
| -rw-r--r-- | libs/hwui/GradientCache.h | 4 | ||||
| -rw-r--r-- | libs/hwui/ResourceCache.cpp | 23 |
7 files changed, 30 insertions, 17 deletions
diff --git a/core/java/com/android/internal/app/ResolverActivity.java b/core/java/com/android/internal/app/ResolverActivity.java index ff8a6d2d811b..84fe8cefa784 100644 --- a/core/java/com/android/internal/app/ResolverActivity.java +++ b/core/java/com/android/internal/app/ResolverActivity.java @@ -261,7 +261,7 @@ public class ResolverActivity extends AlertActivity implements AdapterView.OnIte public void onItemClick(AdapterView<?> parent, View view, int position, long id) { final int checkedPos = mGrid.getCheckedItemPosition(); final boolean hasValidSelection = checkedPos != GridView.INVALID_POSITION; - if (!hasValidSelection || (mAlwaysUseOption && mLastSelected != checkedPos)) { + if (mAlwaysUseOption && (!hasValidSelection || mLastSelected != checkedPos)) { mAlwaysButton.setEnabled(hasValidSelection); mOnceButton.setEnabled(hasValidSelection); if (hasValidSelection) { diff --git a/libs/hwui/FontRenderer.cpp b/libs/hwui/FontRenderer.cpp index 3b3691c637d1..eeb37cbe08c1 100644 --- a/libs/hwui/FontRenderer.cpp +++ b/libs/hwui/FontRenderer.cpp @@ -697,8 +697,7 @@ void FontRenderer::cacheBitmap(const SkGlyph& glyph, CachedGlyphInfo* cachedGlyp } CacheTexture* FontRenderer::createCacheTexture(int width, int height, bool allocate) { - uint8_t* textureMemory = NULL; - CacheTexture* cacheTexture = new CacheTexture(textureMemory, width, height); + CacheTexture* cacheTexture = new CacheTexture(width, height); if (allocate) { allocateTextureMemory(cacheTexture); diff --git a/libs/hwui/FontRenderer.h b/libs/hwui/FontRenderer.h index 2ab680e0e379..b7b4ec9683f9 100644 --- a/libs/hwui/FontRenderer.h +++ b/libs/hwui/FontRenderer.h @@ -61,9 +61,8 @@ class FontRenderer; class CacheTexture { public: - CacheTexture() { } - CacheTexture(uint8_t* texture, uint16_t width, uint16_t height) : - mTexture(texture), mTextureId(0), mWidth(width), mHeight(height), + CacheTexture(uint16_t width, uint16_t height) : + mTexture(NULL), mTextureId(0), mWidth(width), mHeight(height), mLinearFiltering(false) { } ~CacheTexture() { if (mTexture) { diff --git a/libs/hwui/GammaFontRenderer.h b/libs/hwui/GammaFontRenderer.h index 9180778e9aa9..c4a50bed3ad2 100644 --- a/libs/hwui/GammaFontRenderer.h +++ b/libs/hwui/GammaFontRenderer.h @@ -59,6 +59,7 @@ public: void clear() { delete mRenderer; + mRenderer = NULL; } void flush() { diff --git a/libs/hwui/GradientCache.cpp b/libs/hwui/GradientCache.cpp index 0016b8145fda..c7ab9c5ad5cd 100644 --- a/libs/hwui/GradientCache.cpp +++ b/libs/hwui/GradientCache.cpp @@ -16,8 +16,6 @@ #define LOG_TAG "OpenGLRenderer" -#include <GLES2/gl2.h> - #include <SkCanvas.h> #include <SkGradientShader.h> @@ -45,6 +43,8 @@ GradientCache::GradientCache(): INIT_LOGD(" Using default gradient cache size of %.2fMB", DEFAULT_GRADIENT_CACHE_SIZE); } + glGetIntegerv(GL_MAX_TEXTURE_SIZE, &mMaxTextureSize); + mCache.setOnEntryRemovedListener(this); } @@ -116,8 +116,11 @@ void GradientCache::clear() { Texture* GradientCache::addLinearGradient(GradientCacheEntry& gradient, uint32_t* colors, float* positions, int count, SkShader::TileMode tileMode) { + int width = 256 * (count - 1); + width = width < mMaxTextureSize ? width : mMaxTextureSize; + SkBitmap bitmap; - bitmap.setConfig(SkBitmap::kARGB_8888_Config, 256 * (count - 1), 1); + bitmap.setConfig(SkBitmap::kARGB_8888_Config, width, 1); bitmap.allocPixels(); bitmap.eraseColor(0); diff --git a/libs/hwui/GradientCache.h b/libs/hwui/GradientCache.h index ac346846ba99..59515a1ceefb 100644 --- a/libs/hwui/GradientCache.h +++ b/libs/hwui/GradientCache.h @@ -17,6 +17,8 @@ #ifndef ANDROID_HWUI_GRADIENT_CACHE_H #define ANDROID_HWUI_GRADIENT_CACHE_H +#include <GLES2/gl2.h> + #include <SkShader.h> #include <utils/Mutex.h> @@ -152,6 +154,8 @@ private: uint32_t mSize; uint32_t mMaxSize; + GLint mMaxTextureSize; + Vector<SkShader*> mGarbage; mutable Mutex mLock; }; // class GradientCache diff --git a/libs/hwui/ResourceCache.cpp b/libs/hwui/ResourceCache.cpp index cf5f82205e03..2153a8bb89ad 100644 --- a/libs/hwui/ResourceCache.cpp +++ b/libs/hwui/ResourceCache.cpp @@ -48,7 +48,8 @@ ResourceCache::~ResourceCache() { void ResourceCache::incrementRefcount(void* resource, ResourceType resourceType) { Mutex::Autolock _l(mLock); - ResourceReference* ref = mCache->indexOfKey(resource) >= 0 ? mCache->valueFor(resource) : NULL; + ssize_t index = mCache->indexOfKey(resource); + ResourceReference* ref = index >= 0 ? mCache->valueAt(index) : NULL; if (ref == NULL || mCache->size() == 0) { ref = new ResourceReference(resourceType); mCache->add(resource, ref); @@ -78,7 +79,8 @@ void ResourceCache::incrementRefcount(SkiaColorFilter* filterResource) { void ResourceCache::decrementRefcount(void* resource) { Mutex::Autolock _l(mLock); - ResourceReference* ref = mCache->indexOfKey(resource) >= 0 ? mCache->valueFor(resource) : NULL; + ssize_t index = mCache->indexOfKey(resource); + ResourceReference* ref = index >= 0 ? mCache->valueAt(index) : NULL; if (ref == NULL) { // Should not get here - shouldn't get a call to decrement if we're not yet tracking it return; @@ -111,12 +113,13 @@ void ResourceCache::decrementRefcount(SkiaColorFilter* filterResource) { void ResourceCache::recycle(SkBitmap* resource) { Mutex::Autolock _l(mLock); - if (mCache->indexOfKey(resource) < 0) { + ssize_t index = mCache->indexOfKey(resource); + if (index < 0) { // not tracking this resource; just recycle the pixel data resource->setPixels(NULL, NULL); return; } - ResourceReference* ref = mCache->indexOfKey(resource) >= 0 ? mCache->valueFor(resource) : NULL; + ResourceReference* ref = mCache->valueAt(index); if (ref == NULL) { // Should not get here - shouldn't get a call to recycle if we're not yet tracking it return; @@ -129,7 +132,8 @@ void ResourceCache::recycle(SkBitmap* resource) { void ResourceCache::destructor(SkPath* resource) { Mutex::Autolock _l(mLock); - ResourceReference* ref = mCache->indexOfKey(resource) >= 0 ? mCache->valueFor(resource) : NULL; + ssize_t index = mCache->indexOfKey(resource); + ResourceReference* ref = index >= 0 ? mCache->valueAt(index) : NULL; if (ref == NULL) { // If we're not tracking this resource, just delete it if (Caches::hasInstance()) { @@ -146,7 +150,8 @@ void ResourceCache::destructor(SkPath* resource) { void ResourceCache::destructor(SkBitmap* resource) { Mutex::Autolock _l(mLock); - ResourceReference* ref = mCache->indexOfKey(resource) >= 0 ? mCache->valueFor(resource) : NULL; + ssize_t index = mCache->indexOfKey(resource); + ResourceReference* ref = index >= 0 ? mCache->valueAt(index) : NULL; if (ref == NULL) { // If we're not tracking this resource, just delete it if (Caches::hasInstance()) { @@ -163,7 +168,8 @@ void ResourceCache::destructor(SkBitmap* resource) { void ResourceCache::destructor(SkiaShader* resource) { Mutex::Autolock _l(mLock); - ResourceReference* ref = mCache->indexOfKey(resource) >= 0 ? mCache->valueFor(resource) : NULL; + ssize_t index = mCache->indexOfKey(resource); + ResourceReference* ref = index >= 0 ? mCache->valueAt(index) : NULL; if (ref == NULL) { // If we're not tracking this resource, just delete it delete resource; @@ -177,7 +183,8 @@ void ResourceCache::destructor(SkiaShader* resource) { void ResourceCache::destructor(SkiaColorFilter* resource) { Mutex::Autolock _l(mLock); - ResourceReference* ref = mCache->indexOfKey(resource) >= 0 ? mCache->valueFor(resource) : NULL; + ssize_t index = mCache->indexOfKey(resource); + ResourceReference* ref = index >= 0 ? mCache->valueAt(index) : NULL; if (ref == NULL) { // If we're not tracking this resource, just delete it delete resource; |