* commit 'aecb8c43d0c6c3d2b55f88abeaa0e3197be59301': Fix graphics corruption caused by HWUI caches
This commit is contained in:
@ -129,7 +129,11 @@ void PatchCache::clearGarbage() {
|
|||||||
Mutex::Autolock _l(mLock);
|
Mutex::Autolock _l(mLock);
|
||||||
size_t count = mGarbage.size();
|
size_t count = mGarbage.size();
|
||||||
for (size_t i = 0; i < count; i++) {
|
for (size_t i = 0; i < count; i++) {
|
||||||
remove(patchesToRemove, mGarbage[i]);
|
Res_png_9patch* patch = mGarbage[i];
|
||||||
|
remove(patchesToRemove, patch);
|
||||||
|
// A Res_png_9patch is actually an array of byte that's larger
|
||||||
|
// than sizeof(Res_png_9patch). It must be freed as an array.
|
||||||
|
delete[] (int8_t*) patch;
|
||||||
}
|
}
|
||||||
mGarbage.clear();
|
mGarbage.clear();
|
||||||
}
|
}
|
||||||
|
@ -395,7 +395,9 @@ void PathCache::clearGarbage() {
|
|||||||
Mutex::Autolock l(mLock);
|
Mutex::Autolock l(mLock);
|
||||||
size_t count = mGarbage.size();
|
size_t count = mGarbage.size();
|
||||||
for (size_t i = 0; i < count; i++) {
|
for (size_t i = 0; i < count; i++) {
|
||||||
remove(pathsToRemove, mGarbage.itemAt(i));
|
const path_pair_t& pair = mGarbage.itemAt(i);
|
||||||
|
remove(pathsToRemove, pair);
|
||||||
|
delete pair.getFirst();
|
||||||
}
|
}
|
||||||
mGarbage.clear();
|
mGarbage.clear();
|
||||||
}
|
}
|
||||||
|
@ -213,8 +213,9 @@ void ResourceCache::destructorLocked(SkPath* resource) {
|
|||||||
// If we're not tracking this resource, just delete it
|
// If we're not tracking this resource, just delete it
|
||||||
if (Caches::hasInstance()) {
|
if (Caches::hasInstance()) {
|
||||||
Caches::getInstance().pathCache.removeDeferred(resource);
|
Caches::getInstance().pathCache.removeDeferred(resource);
|
||||||
}
|
} else {
|
||||||
delete resource;
|
delete resource;
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
ref->destroyed = true;
|
ref->destroyed = true;
|
||||||
@ -235,8 +236,9 @@ void ResourceCache::destructorLocked(SkBitmap* resource) {
|
|||||||
// If we're not tracking this resource, just delete it
|
// If we're not tracking this resource, just delete it
|
||||||
if (Caches::hasInstance()) {
|
if (Caches::hasInstance()) {
|
||||||
Caches::getInstance().textureCache.removeDeferred(resource);
|
Caches::getInstance().textureCache.removeDeferred(resource);
|
||||||
}
|
} else {
|
||||||
delete resource;
|
delete resource;
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
ref->destroyed = true;
|
ref->destroyed = true;
|
||||||
@ -292,13 +294,14 @@ void ResourceCache::destructorLocked(Res_png_9patch* resource) {
|
|||||||
ssize_t index = mCache->indexOfKey(resource);
|
ssize_t index = mCache->indexOfKey(resource);
|
||||||
ResourceReference* ref = index >= 0 ? mCache->valueAt(index) : NULL;
|
ResourceReference* ref = index >= 0 ? mCache->valueAt(index) : NULL;
|
||||||
if (ref == NULL) {
|
if (ref == NULL) {
|
||||||
|
// If we're not tracking this resource, just delete it
|
||||||
if (Caches::hasInstance()) {
|
if (Caches::hasInstance()) {
|
||||||
Caches::getInstance().patchCache.removeDeferred(resource);
|
Caches::getInstance().patchCache.removeDeferred(resource);
|
||||||
}
|
} else {
|
||||||
// If we're not tracking this resource, just delete it
|
|
||||||
// A Res_png_9patch is actually an array of byte that's larger
|
// A Res_png_9patch is actually an array of byte that's larger
|
||||||
// than sizeof(Res_png_9patch). It must be freed as an array.
|
// than sizeof(Res_png_9patch). It must be freed as an array.
|
||||||
delete[] (int8_t*) resource;
|
delete[] (int8_t*) resource;
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
ref->destroyed = true;
|
ref->destroyed = true;
|
||||||
@ -355,17 +358,19 @@ void ResourceCache::deleteResourceReferenceLocked(void* resource, ResourceRefere
|
|||||||
SkBitmap* bitmap = (SkBitmap*) resource;
|
SkBitmap* bitmap = (SkBitmap*) resource;
|
||||||
if (Caches::hasInstance()) {
|
if (Caches::hasInstance()) {
|
||||||
Caches::getInstance().textureCache.removeDeferred(bitmap);
|
Caches::getInstance().textureCache.removeDeferred(bitmap);
|
||||||
}
|
} else {
|
||||||
delete bitmap;
|
delete bitmap;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case kPath: {
|
case kPath: {
|
||||||
SkPath* path = (SkPath*) resource;
|
SkPath* path = (SkPath*) resource;
|
||||||
if (Caches::hasInstance()) {
|
if (Caches::hasInstance()) {
|
||||||
Caches::getInstance().pathCache.removeDeferred(path);
|
Caches::getInstance().pathCache.removeDeferred(path);
|
||||||
}
|
} else {
|
||||||
delete path;
|
delete path;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case kShader: {
|
case kShader: {
|
||||||
SkiaShader* shader = (SkiaShader*) resource;
|
SkiaShader* shader = (SkiaShader*) resource;
|
||||||
@ -380,12 +385,13 @@ void ResourceCache::deleteResourceReferenceLocked(void* resource, ResourceRefere
|
|||||||
case kNinePatch: {
|
case kNinePatch: {
|
||||||
if (Caches::hasInstance()) {
|
if (Caches::hasInstance()) {
|
||||||
Caches::getInstance().patchCache.removeDeferred((Res_png_9patch*) resource);
|
Caches::getInstance().patchCache.removeDeferred((Res_png_9patch*) resource);
|
||||||
}
|
} else {
|
||||||
// A Res_png_9patch is actually an array of byte that's larger
|
// A Res_png_9patch is actually an array of byte that's larger
|
||||||
// than sizeof(Res_png_9patch). It must be freed as an array.
|
// than sizeof(Res_png_9patch). It must be freed as an array.
|
||||||
int8_t* patch = (int8_t*) resource;
|
int8_t* patch = (int8_t*) resource;
|
||||||
delete[] patch;
|
delete[] patch;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case kLayer: {
|
case kLayer: {
|
||||||
Layer* layer = (Layer*) resource;
|
Layer* layer = (Layer*) resource;
|
||||||
|
@ -184,7 +184,9 @@ void TextureCache::clearGarbage() {
|
|||||||
Mutex::Autolock _l(mLock);
|
Mutex::Autolock _l(mLock);
|
||||||
size_t count = mGarbage.size();
|
size_t count = mGarbage.size();
|
||||||
for (size_t i = 0; i < count; i++) {
|
for (size_t i = 0; i < count; i++) {
|
||||||
mCache.remove(mGarbage.itemAt(i));
|
const SkBitmap* bitmap = mGarbage.itemAt(i);
|
||||||
|
mCache.remove(bitmap);
|
||||||
|
delete bitmap;
|
||||||
}
|
}
|
||||||
mGarbage.clear();
|
mGarbage.clear();
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user