Merge "Fix HWUI Path Cache dangling pointer"
am: 37bf3ec9d2
* commit '37bf3ec9d2fb3dfdccfe043e51723e4e543f0703':
Fix HWUI Path Cache dangling pointer
This commit is contained in:
@@ -2325,12 +2325,15 @@ void OpenGLRenderer::drawPath(const SkPath* path, const SkPaint* paint) {
|
|||||||
|
|
||||||
PathTexture* texture = mCaches.pathCache.get(path, paint);
|
PathTexture* texture = mCaches.pathCache.get(path, paint);
|
||||||
if (!texture) return;
|
if (!texture) return;
|
||||||
const AutoTexture autoCleanup(texture);
|
|
||||||
|
|
||||||
const float x = texture->left - texture->offset;
|
const float x = texture->left - texture->offset;
|
||||||
const float y = texture->top - texture->offset;
|
const float y = texture->top - texture->offset;
|
||||||
|
|
||||||
drawPathTexture(texture, x, y, paint);
|
drawPathTexture(texture, x, y, paint);
|
||||||
|
|
||||||
|
if (texture->cleanup) {
|
||||||
|
mCaches.pathCache.remove(path, paint);
|
||||||
|
}
|
||||||
mDirty = true;
|
mDirty = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -400,6 +400,13 @@ PathTexture* PathCache::get(const SkPath* path, const SkPaint* paint) {
|
|||||||
return texture;
|
return texture;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void PathCache::remove(const SkPath* path, const SkPaint* paint)
|
||||||
|
{
|
||||||
|
PathDescription entry(kShapePath, paint);
|
||||||
|
entry.shape.path.mGenerationID = path->getGenerationID();
|
||||||
|
mCache.remove(entry);
|
||||||
|
}
|
||||||
|
|
||||||
void PathCache::precache(const SkPath* path, const SkPaint* paint) {
|
void PathCache::precache(const SkPath* path, const SkPaint* paint) {
|
||||||
if (!Caches::getInstance().tasks.canRunTasks()) {
|
if (!Caches::getInstance().tasks.canRunTasks()) {
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -201,6 +201,7 @@ public:
|
|||||||
PathTexture* getArc(float width, float height, float startAngle, float sweepAngle,
|
PathTexture* getArc(float width, float height, float startAngle, float sweepAngle,
|
||||||
bool useCenter, const SkPaint* paint);
|
bool useCenter, const SkPaint* paint);
|
||||||
PathTexture* get(const SkPath* path, const SkPaint* paint);
|
PathTexture* get(const SkPath* path, const SkPaint* paint);
|
||||||
|
void remove(const SkPath* path, const SkPaint* paint);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Removes the specified path. This is meant to be called from threads
|
* Removes the specified path. This is meant to be called from threads
|
||||||
|
|||||||
Reference in New Issue
Block a user