summaryrefslogtreecommitdiffstats
path: root/libs/hwui/DisplayListRenderer.h
diff options
context:
space:
mode:
authorRomain Guy <romainguy@google.com>2011-01-14 15:31:00 -0800
committerRomain Guy <romainguy@google.com>2011-01-14 15:31:00 -0800
commit24c00216687ac87fe531dc4d4168ac0c0ca04ea6 (patch)
tree0d6d9ed921e489065951a50f6dcab702c70df508 /libs/hwui/DisplayListRenderer.h
parentf5106847fc962d57c7d5c586099b4a382f3e1c3d (diff)
downloadframeworks_base-24c00216687ac87fe531dc4d4168ac0c0ca04ea6.zip
frameworks_base-24c00216687ac87fe531dc4d4168ac0c0ca04ea6.tar.gz
frameworks_base-24c00216687ac87fe531dc4d4168ac0c0ca04ea6.tar.bz2
Copy shaders when recording them in display lists.
Change-Id: I3f22dd35f1e31c9e5102955d76548098b7b0cd8d
Diffstat (limited to 'libs/hwui/DisplayListRenderer.h')
-rw-r--r--libs/hwui/DisplayListRenderer.h33
1 files changed, 23 insertions, 10 deletions
diff --git a/libs/hwui/DisplayListRenderer.h b/libs/hwui/DisplayListRenderer.h
index cc52309..112e455 100644
--- a/libs/hwui/DisplayListRenderer.h
+++ b/libs/hwui/DisplayListRenderer.h
@@ -206,11 +206,11 @@ private:
PathHeap* mPathHeap;
Vector<SkBitmap*> mBitmapResources;
- Vector<SkiaShader*> mShaderResources;
Vector<SkiaColorFilter*> mFilterResources;
Vector<SkPaint*> mPaints;
Vector<SkMatrix*> mMatrices;
+ Vector<SkiaShader*> mShaders;
mutable SkFlattenableReadBuffer mReader;
@@ -291,8 +291,8 @@ public:
return mBitmapResources;
}
- const Vector<SkiaShader*>& getShaderResources() const {
- return mShaderResources;
+ const Vector<SkiaShader*>& getShaders() const {
+ return mShaders;
}
const Vector<SkPaint*>& getPaints() const {
@@ -366,12 +366,12 @@ private:
}
inline void addPaint(SkPaint* paint) {
- if (paint == NULL) {
+ if (!paint) {
addInt((int) NULL);
return;
}
- SkPaint *paintCopy = mPaintMap.valueFor(paint);
+ SkPaint* paintCopy = mPaintMap.valueFor(paint);
if (paintCopy == NULL || paintCopy->getGenerationID() != paint->getGenerationID()) {
paintCopy = new SkPaint(*paint);
mPaintMap.add(paint, paintCopy);
@@ -406,10 +406,20 @@ private:
}
inline void addShader(SkiaShader* shader) {
- addInt((int) shader);
- mShaderResources.add(shader);
- Caches& caches = Caches::getInstance();
- caches.resourceCache.incrementRefcount(shader);
+ if (!shader) {
+ addInt((int) NULL);
+ return;
+ }
+
+ SkiaShader* shaderCopy = mShaderMap.valueFor(shader);
+ // TODO: We also need to handle generation ID changes in compose shaders
+ if (!shaderCopy || shaderCopy->getGenerationId() != shader->getGenerationId()) {
+ shaderCopy = shader->copy();
+ mShaderMap.add(shader, shaderCopy);
+ mShaders.add(shader);
+ }
+
+ addInt((int) shaderCopy);
}
inline void addColorFilter(SkiaColorFilter* colorFilter) {
@@ -422,11 +432,14 @@ private:
SkChunkAlloc mHeap;
Vector<SkBitmap*> mBitmapResources;
- Vector<SkiaShader*> mShaderResources;
Vector<SkiaColorFilter*> mFilterResources;
Vector<SkPaint*> mPaints;
DefaultKeyedVector<SkPaint*, SkPaint*> mPaintMap;
+
+ Vector<SkiaShader*> mShaders;
+ DefaultKeyedVector<SkiaShader*, SkiaShader*> mShaderMap;
+
Vector<SkMatrix*> mMatrices;
PathHeap* mPathHeap;