summaryrefslogtreecommitdiffstats
path: root/libs
diff options
context:
space:
mode:
authorRob Tsuk <robtsuk@google.com>2014-11-12 21:41:58 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2014-11-12 21:42:00 +0000
commit41a8043b30a289bdba55a2469e598b3fe67c3bf1 (patch)
treeb12a667d1c85a19a4722c111fdc63adc30cd6d5a /libs
parent10ece9c9d5c2134a6ea04bf593a2b76d167dbd7a (diff)
parent4678dcc5524258908eadc5fe1e5e1874768967eb (diff)
downloadframeworks_base-41a8043b30a289bdba55a2469e598b3fe67c3bf1.zip
frameworks_base-41a8043b30a289bdba55a2469e598b3fe67c3bf1.tar.gz
frameworks_base-41a8043b30a289bdba55a2469e598b3fe67c3bf1.tar.bz2
Merge "Add a way to override Xfermode DO NOT MERGE" into lmp-mr1-dev
Diffstat (limited to 'libs')
-rw-r--r--libs/hwui/DisplayListRenderer.cpp1
-rw-r--r--libs/hwui/DisplayListRenderer.h45
2 files changed, 34 insertions, 12 deletions
diff --git a/libs/hwui/DisplayListRenderer.cpp b/libs/hwui/DisplayListRenderer.cpp
index c2cb76e..3ec5e40 100644
--- a/libs/hwui/DisplayListRenderer.cpp
+++ b/libs/hwui/DisplayListRenderer.cpp
@@ -39,6 +39,7 @@ DisplayListRenderer::DisplayListRenderer()
, mTranslateY(0.0f)
, mDeferredBarrierType(kBarrier_None)
, mHighContrastText(false)
+ , mOverrideXfermode(-1)
, mRestoreSaveCount(-1) {
}
diff --git a/libs/hwui/DisplayListRenderer.h b/libs/hwui/DisplayListRenderer.h
index 2cc2be3..f93a798 100644
--- a/libs/hwui/DisplayListRenderer.h
+++ b/libs/hwui/DisplayListRenderer.h
@@ -20,6 +20,7 @@
#include <SkMatrix.h>
#include <SkPaint.h>
#include <SkPath.h>
+#include <SkPorterDuff.h>
#include <cutils/compiler.h>
#include "DisplayListLogBuffer.h"
@@ -161,6 +162,15 @@ public:
void setHighContrastText(bool highContrastText) {
mHighContrastText = highContrastText;
}
+
+ void setOverrideXfermode(int xfermode) {
+ if (xfermode != -1) {
+ SkPorterDuff::Mode porterDuffMode = static_cast<SkPorterDuff::Mode>(xfermode);
+ xfermode = SkPorterDuff::ToXfermodeMode(porterDuffMode);
+ }
+ mOverrideXfermode = xfermode;
+ };
+
private:
enum DeferredBarrierType {
kBarrier_None,
@@ -220,18 +230,26 @@ private:
inline const SkPaint* refPaint(const SkPaint* paint) {
if (!paint) return NULL;
- const SkPaint* paintCopy = mPaintMap.valueFor(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);
+ const SkPaint* paintCopy;
+
+ if (mOverrideXfermode != -1) {
+ SkPaint* overriddenPaint = copyPaint(paint);
+ overriddenPaint->setXfermodeMode(static_cast<SkXfermode::Mode>(mOverrideXfermode));
+ paintCopy = overriddenPaint;
+ } else {
+ paintCopy = mPaintMap.valueFor(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);
+ }
}
return paintCopy;
@@ -304,6 +322,9 @@ private:
DeferredBarrierType mDeferredBarrierType;
bool mHighContrastText;
+ // -1 if unset, or SkXfermode::Mode value if set
+ int mOverrideXfermode;
+
int mRestoreSaveCount;
friend class RenderNode;