summaryrefslogtreecommitdiffstats
path: root/libs/hwui
diff options
context:
space:
mode:
Diffstat (limited to 'libs/hwui')
-rw-r--r--libs/hwui/AssetAtlas.cpp6
-rw-r--r--libs/hwui/AssetAtlas.h26
-rw-r--r--libs/hwui/DisplayList.cpp5
-rw-r--r--libs/hwui/DisplayListCanvas.h7
-rw-r--r--libs/hwui/ResourceCache.cpp70
-rw-r--r--libs/hwui/ResourceCache.h40
-rw-r--r--libs/hwui/renderthread/RenderProxy.cpp1
7 files changed, 10 insertions, 145 deletions
diff --git a/libs/hwui/AssetAtlas.cpp b/libs/hwui/AssetAtlas.cpp
index 882826e..2889d2f 100644
--- a/libs/hwui/AssetAtlas.cpp
+++ b/libs/hwui/AssetAtlas.cpp
@@ -112,9 +112,6 @@ private:
Texture* const mDelegate;
}; // struct DelegateTexture
-/**
- * TODO: This method does not take the rotation flag into account
- */
void AssetAtlas::createEntries(Caches& caches, int64_t* map, int count) {
const float width = float(mTexture->width);
const float height = float(mTexture->height);
@@ -128,7 +125,6 @@ void AssetAtlas::createEntries(Caches& caches, int64_t* map, int count) {
// pointers on 64 bit architectures.
const int x = static_cast<int>(map[i++]);
const int y = static_cast<int>(map[i++]);
- bool rotated = map[i++] > 0;
// Bitmaps should never be null, we're just extra paranoid
if (!pixelRef) continue;
@@ -142,7 +138,7 @@ void AssetAtlas::createEntries(Caches& caches, int64_t* map, int count) {
texture->width = pixelRef->info().width();
texture->height = pixelRef->info().height();
- Entry* entry = new Entry(pixelRef, x, y, rotated, texture, mapper, *this);
+ Entry* entry = new Entry(pixelRef, texture, mapper, *this);
texture->uvMapper = &entry->uvMapper;
mEntries.add(entry->pixelRef, entry);
diff --git a/libs/hwui/AssetAtlas.h b/libs/hwui/AssetAtlas.h
index 17c5281..f1cd0b4 100644
--- a/libs/hwui/AssetAtlas.h
+++ b/libs/hwui/AssetAtlas.h
@@ -45,8 +45,8 @@ class Image;
class AssetAtlas {
public:
/**
- * Entry representing the position and rotation of a
- * bitmap inside the atlas.
+ * Entry representing the texture and uvMapper of a PixelRef in the
+ * atlas
*/
class Entry {
public:
@@ -78,30 +78,15 @@ public:
SkPixelRef* pixelRef;
/**
- * Location of the bitmap inside the atlas, in pixels.
- */
- int x;
- int y;
-
- /**
- * If set, the bitmap is rotated 90 degrees (clockwise)
- * inside the atlas.
- */
- bool rotated;
-
- /**
* Atlas this entry belongs to.
*/
const AssetAtlas& atlas;
- Entry(SkPixelRef* pixelRef, int x, int y, bool rotated,
- Texture* texture, const UvMapper& mapper, const AssetAtlas& atlas)
+ Entry(SkPixelRef* pixelRef, Texture* texture, const UvMapper& mapper,
+ const AssetAtlas& atlas)
: texture(texture)
, uvMapper(mapper)
, pixelRef(pixelRef)
- , x(x)
- , y(y)
- , rotated(rotated)
, atlas(atlas) {
}
@@ -120,8 +105,7 @@ public:
* Initializes the atlas with the specified buffer and
* map. The buffer is a gralloc'd texture that will be
* used as an EGLImage. The map is a list of SkBitmap*
- * and their (x, y) positions as well as their rotation
- * flags.
+ * and their (x, y) positions
*
* This method returns immediately if the atlas is already
* initialized. To re-initialize the atlas, you must
diff --git a/libs/hwui/DisplayList.cpp b/libs/hwui/DisplayList.cpp
index 4540bec..e679bff 100644
--- a/libs/hwui/DisplayList.cpp
+++ b/libs/hwui/DisplayList.cpp
@@ -41,10 +41,6 @@ void DisplayListData::cleanupResources() {
ResourceCache& resourceCache = ResourceCache::getInstance();
resourceCache.lock();
- for (size_t i = 0; i < bitmapResources.size(); i++) {
- resourceCache.decrementRefcountLocked(bitmapResources.itemAt(i));
- }
-
for (size_t i = 0; i < patchResources.size(); i++) {
resourceCache.decrementRefcountLocked(patchResources.itemAt(i));
}
@@ -59,7 +55,6 @@ void DisplayListData::cleanupResources() {
delete path;
}
- bitmapResources.clear();
patchResources.clear();
pathResources.clear();
paints.clear();
diff --git a/libs/hwui/DisplayListCanvas.h b/libs/hwui/DisplayListCanvas.h
index 0064236..d997ef4 100644
--- a/libs/hwui/DisplayListCanvas.h
+++ b/libs/hwui/DisplayListCanvas.h
@@ -350,9 +350,10 @@ private:
// correctly, such as creating the bitmap from scratch, drawing with it, changing its
// contents, and drawing again. The only fix would be to always copy it the first time,
// which doesn't seem worth the extra cycles for this unlikely case.
- const SkBitmap* cachedBitmap = mResourceCache.insert(bitmap);
- mDisplayListData->bitmapResources.add(cachedBitmap);
- return cachedBitmap;
+ SkBitmap* localBitmap = new (alloc()) SkBitmap(bitmap);
+ alloc().autoDestroy(localBitmap);
+ mDisplayListData->bitmapResources.push_back(localBitmap);
+ return localBitmap;
}
inline const Res_png_9patch* refPatch(const Res_png_9patch* patch) {
diff --git a/libs/hwui/ResourceCache.cpp b/libs/hwui/ResourceCache.cpp
index 454fedc..75d8134 100644
--- a/libs/hwui/ResourceCache.cpp
+++ b/libs/hwui/ResourceCache.cpp
@@ -59,21 +59,6 @@ void ResourceCache::unlock() {
mLock.unlock();
}
-const SkBitmap* ResourceCache::insert(const SkBitmap& bitmapResource) {
- Mutex::Autolock _l(mLock);
-
- BitmapKey bitmapKey(bitmapResource);
- ssize_t index = mBitmapCache.indexOfKey(bitmapKey);
- if (index == NAME_NOT_FOUND) {
- SkBitmap* cachedBitmap = new SkBitmap(bitmapResource);
- index = mBitmapCache.add(bitmapKey, cachedBitmap);
- return cachedBitmap;
- }
-
- mBitmapCache.keyAt(index).mRefCount++;
- return mBitmapCache.valueAt(index);
-}
-
void ResourceCache::incrementRefcount(void* resource, ResourceType resourceType) {
Mutex::Autolock _l(mLock);
incrementRefcountLocked(resource, resourceType);
@@ -98,11 +83,6 @@ void ResourceCache::decrementRefcount(void* resource) {
decrementRefcountLocked(resource);
}
-void ResourceCache::decrementRefcount(const SkBitmap* bitmapResource) {
- Mutex::Autolock _l(mLock);
- decrementRefcountLocked(bitmapResource);
-}
-
void ResourceCache::decrementRefcount(const Res_png_9patch* patchResource) {
decrementRefcount((void*) patchResource);
}
@@ -120,23 +100,6 @@ void ResourceCache::decrementRefcountLocked(void* resource) {
}
}
-void ResourceCache::decrementRefcountLocked(const SkBitmap* bitmapResource) {
- BitmapKey bitmapKey(*bitmapResource);
- ssize_t index = mBitmapCache.indexOfKey(bitmapKey);
-
- LOG_ALWAYS_FATAL_IF(index == NAME_NOT_FOUND,
- "Decrementing the reference of an untracked Bitmap");
-
- const BitmapKey& cacheEntry = mBitmapCache.keyAt(index);
- if (cacheEntry.mRefCount == 1) {
- // delete the bitmap and remove it from the cache
- delete mBitmapCache.valueAt(index);
- mBitmapCache.removeItemsAt(index);
- } else {
- cacheEntry.mRefCount--;
- }
-}
-
void ResourceCache::decrementRefcountLocked(const Res_png_9patch* patchResource) {
decrementRefcountLocked((void*) patchResource);
}
@@ -190,38 +153,5 @@ void ResourceCache::deleteResourceReferenceLocked(const void* resource, Resource
delete ref;
}
-///////////////////////////////////////////////////////////////////////////////
-// Bitmap Key
-///////////////////////////////////////////////////////////////////////////////
-
-void BitmapKey::operator=(const BitmapKey& other) {
- this->mRefCount = other.mRefCount;
- this->mBitmapDimensions = other.mBitmapDimensions;
- this->mPixelRefOrigin = other.mPixelRefOrigin;
- this->mPixelRefStableID = other.mPixelRefStableID;
-}
-
-bool BitmapKey::operator==(const BitmapKey& other) const {
- return mPixelRefStableID == other.mPixelRefStableID &&
- mPixelRefOrigin == other.mPixelRefOrigin &&
- mBitmapDimensions == other.mBitmapDimensions;
-}
-
-bool BitmapKey::operator<(const BitmapKey& other) const {
- if (mPixelRefStableID != other.mPixelRefStableID) {
- return mPixelRefStableID < other.mPixelRefStableID;
- }
- if (mPixelRefOrigin.x() != other.mPixelRefOrigin.x()) {
- return mPixelRefOrigin.x() < other.mPixelRefOrigin.x();
- }
- if (mPixelRefOrigin.y() != other.mPixelRefOrigin.y()) {
- return mPixelRefOrigin.y() < other.mPixelRefOrigin.y();
- }
- if (mBitmapDimensions.width() != other.mBitmapDimensions.width()) {
- return mBitmapDimensions.width() < other.mBitmapDimensions.width();
- }
- return mBitmapDimensions.height() < other.mBitmapDimensions.height();
-}
-
}; // namespace uirenderer
}; // namespace android
diff --git a/libs/hwui/ResourceCache.h b/libs/hwui/ResourceCache.h
index 6c483fa..4583c8d 100644
--- a/libs/hwui/ResourceCache.h
+++ b/libs/hwui/ResourceCache.h
@@ -51,37 +51,6 @@ public:
ResourceType resourceType;
};
-class BitmapKey {
-public:
- BitmapKey(const SkBitmap& bitmap)
- : mRefCount(1)
- , mBitmapDimensions(bitmap.dimensions())
- , mPixelRefOrigin(bitmap.pixelRefOrigin())
- , mPixelRefStableID(bitmap.pixelRef()->getStableID()) { }
-
- void operator=(const BitmapKey& other);
- bool operator==(const BitmapKey& other) const;
- bool operator<(const BitmapKey& other) const;
-
-private:
- // This constructor is only used by the KeyedVector implementation
- BitmapKey()
- : mRefCount(-1)
- , mBitmapDimensions(SkISize::Make(0,0))
- , mPixelRefOrigin(SkIPoint::Make(0,0))
- , mPixelRefStableID(0) { }
-
- // reference count of all HWUI object using this bitmap
- mutable int mRefCount;
-
- SkISize mBitmapDimensions;
- SkIPoint mPixelRefOrigin;
- uint32_t mPixelRefStableID;
-
- friend class ResourceCache;
- friend struct android::key_value_pair_t<BitmapKey, SkBitmap*>;
-};
-
class ANDROID_API ResourceCache: public Singleton<ResourceCache> {
ResourceCache();
~ResourceCache();
@@ -97,18 +66,10 @@ public:
void lock();
void unlock();
- /**
- * The cache stores a copy of the provided resource or refs an existing resource
- * if the bitmap has previously been inserted and returns the cached copy.
- */
- const SkBitmap* insert(const SkBitmap& resource);
-
void incrementRefcount(const Res_png_9patch* resource);
- void decrementRefcount(const SkBitmap* resource);
void decrementRefcount(const Res_png_9patch* resource);
- void decrementRefcountLocked(const SkBitmap* resource);
void decrementRefcountLocked(const Res_png_9patch* resource);
void destructor(Res_png_9patch* resource);
@@ -134,7 +95,6 @@ private:
mutable Mutex mLock;
KeyedVector<const void*, ResourceReference*>* mCache;
- KeyedVector<BitmapKey, SkBitmap*> mBitmapCache;
};
}; // namespace uirenderer
diff --git a/libs/hwui/renderthread/RenderProxy.cpp b/libs/hwui/renderthread/RenderProxy.cpp
index c643e1d..17e47b9 100644
--- a/libs/hwui/renderthread/RenderProxy.cpp
+++ b/libs/hwui/renderthread/RenderProxy.cpp
@@ -353,7 +353,6 @@ CREATE_BRIDGE2(overrideProperty, const char* name, const char* value) {
}
void RenderProxy::overrideProperty(const char* name, const char* value) {
- RenderThread& thread = RenderThread::getInstance();
SETUP_TASK(overrideProperty);
args->name = name;
args->value = value;