summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author John Reck <jreck@google.com> 2014-08-26 14:53:33 +0000
committer Android (Google) Code Review <android-gerrit@google.com> 2014-08-26 14:53:34 +0000
commit1698297daf8068bc9e6971d43744d48f1672bab2 (patch)
tree5634c55db241efe43e0e4ebaf242baad4e6c8f68
parentc931cc085091345f9667bf1e0ed8afd58e721a62 (diff)
parentc1469f39b571f5660346fc837ac30b19d7651a43 (diff)
Merge "DO NOT MERGE Copy shaders" into lmp-dev
-rw-r--r--core/jni/android/graphics/Shader.cpp1
-rw-r--r--libs/hwui/DisplayListRenderer.h21
2 files changed, 18 insertions, 4 deletions
diff --git a/core/jni/android/graphics/Shader.cpp b/core/jni/android/graphics/Shader.cpp
index e02aa5e5560c..6146fff58d50 100644
--- a/core/jni/android/graphics/Shader.cpp
+++ b/core/jni/android/graphics/Shader.cpp
@@ -66,6 +66,7 @@ static void Shader_setLocalMatrix(JNIEnv* env, jobject o, jlong shaderHandle, jl
} else {
shader->resetLocalMatrix();
}
+ shader->setGenerationID(shader->getGenerationID() + 1);
}
}
diff --git a/libs/hwui/DisplayListRenderer.h b/libs/hwui/DisplayListRenderer.h
index 7350082bdad7..e9c937cbeb0c 100644
--- a/libs/hwui/DisplayListRenderer.h
+++ b/libs/hwui/DisplayListRenderer.h
@@ -215,11 +215,17 @@ private:
if (!paint) return NULL;
const SkPaint* paintCopy = mPaintMap.valueFor(paint);
- if (paintCopy == NULL || paintCopy->getGenerationID() != paint->getGenerationID()) {
- paintCopy = new SkPaint(*paint);
+ if (paintCopy == NULL
+ || paintCopy->getGenerationID() != paint->getGenerationID()
+ // We can't compare shader pointers because that will always
+ // change as we do partial copying via wrapping. However, if the
+ // shader changes the paint generationID will have changed and
+ // so we don't hit this comparison anyway
+ || !(paint->getShader() && paintCopy->getShader()
+ && paint->getShader()->getGenerationID() == paintCopy->getShader()->getGenerationID())) {
+ paintCopy = copyPaint(paint);
// replaceValueFor() performs an add if the entry doesn't exist
mPaintMap.replaceValueFor(paint, paintCopy);
- mDisplayListData->paints.add(paintCopy);
}
return paintCopy;
@@ -228,8 +234,15 @@ private:
inline SkPaint* copyPaint(const SkPaint* paint) {
if (!paint) return NULL;
SkPaint* paintCopy = new SkPaint(*paint);
+ if (paint->getShader()) {
+ SkShader* shaderCopy = SkShader::CreateLocalMatrixShader(
+ paint->getShader(), paint->getShader()->getLocalMatrix());
+ paintCopy->setShader(shaderCopy);
+ paintCopy->setGenerationID(paint->getGenerationID());
+ shaderCopy->setGenerationID(paint->getShader()->getGenerationID());
+ shaderCopy->unref();
+ }
mDisplayListData->paints.add(paintCopy);
-
return paintCopy;
}