summaryrefslogtreecommitdiffstats
path: root/libs
diff options
context:
space:
mode:
authoryuyang <yuyang@codeaurora.org>2014-05-27 16:15:02 +0800
committerDigish Pandya <digishp@codeaurora.org>2014-05-30 08:26:37 +0530
commit7061f7d7910fdf1189ea7bf1398f6cf8b9bd0104 (patch)
tree246d80e0c3de4f2c316ef2f18940054d9e2ce194 /libs
parent9cd3ff7d61ed65e8b815155747e7bbfc99c1e861 (diff)
downloadframeworks_base-7061f7d7910fdf1189ea7bf1398f6cf8b9bd0104.zip
frameworks_base-7061f7d7910fdf1189ea7bf1398f6cf8b9bd0104.tar.gz
frameworks_base-7061f7d7910fdf1189ea7bf1398f6cf8b9bd0104.tar.bz2
Fix a resource race bug in PathCache
When enabled defer rendering, it will do precache for DrawPathOp. The paint used for creating PathTask in precache just get the address of mFilteredPaint of OpenGLRenderer. So for the following defer operation like DrawTextOp has possibility change the mFilteredPaint by getPaint while another WorkerThread in PathCache is using the paint which pointed to the same address of mFilteredPaint to generate bitmap. As a result, it will generate a wrong bitmap for generateTexture in PathCache. To fix it, do a copy of paint when creating PathTask. CRs-Fixed: 664244 Change-Id: I5516f5b143458b88d3573d15b7ebb34f688800c7
Diffstat (limited to 'libs')
-rw-r--r--libs/hwui/PathCache.cpp4
-rw-r--r--libs/hwui/PathCache.h5
2 files changed, 5 insertions, 4 deletions
diff --git a/libs/hwui/PathCache.cpp b/libs/hwui/PathCache.cpp
index cf8adf8..0794aec 100644
--- a/libs/hwui/PathCache.cpp
+++ b/libs/hwui/PathCache.cpp
@@ -346,7 +346,7 @@ void PathCache::PathProcessor::onProcess(const sp<Task<SkBitmap*> >& task) {
float left, top, offset;
uint32_t width, height;
- PathCache::computePathBounds(t->path, t->paint, left, top, offset, width, height);
+ PathCache::computePathBounds(t->path, &t->paint, left, top, offset, width, height);
PathTexture* texture = t->texture;
texture->left = left;
@@ -357,7 +357,7 @@ void PathCache::PathProcessor::onProcess(const sp<Task<SkBitmap*> >& task) {
if (width <= mMaxTextureSize && height <= mMaxTextureSize) {
SkBitmap* bitmap = new SkBitmap();
- drawPath(t->path, t->paint, *bitmap, left, top, offset, width, height);
+ drawPath(t->path, &t->paint, *bitmap, left, top, offset, width, height);
t->setResult(bitmap);
} else {
texture->width = 0;
diff --git a/libs/hwui/PathCache.h b/libs/hwui/PathCache.h
index 16d20a8..24f88f1 100644
--- a/libs/hwui/PathCache.h
+++ b/libs/hwui/PathCache.h
@@ -293,7 +293,7 @@ private:
class PathTask: public Task<SkBitmap*> {
public:
PathTask(SkPath* path, SkPaint* paint, PathTexture* texture):
- path(path), paint(paint), texture(texture) {
+ path(path), paint(*paint), texture(texture) {
}
~PathTask() {
@@ -301,7 +301,8 @@ private:
}
SkPath* path;
- SkPaint* paint;
+ //copied, since input paint may not be immutable
+ SkPaint paint;
PathTexture* texture;
};