Add support to toggle different shader
behaviors
Updated HWUI to toggle overscroll stretch
implementation based on whether the
device supports high end graphics
or not
Bug: 187718492
Test: manual
Change-Id: I13a91a8861c07bec8af43268ba22d0f5b7060b4f
diff --git a/libs/hwui/DamageAccumulator.cpp b/libs/hwui/DamageAccumulator.cpp
index 0adc0f6..9db47c3 100644
--- a/libs/hwui/DamageAccumulator.cpp
+++ b/libs/hwui/DamageAccumulator.cpp
@@ -157,7 +157,7 @@
static inline void mapRect(const RenderProperties& props, const SkRect& in, SkRect* out) {
if (in.isEmpty()) return;
SkRect temp(in);
- if (Properties::stretchEffectBehavior == StretchEffectBehavior::UniformScale) {
+ if (Properties::getStretchEffectBehavior() == StretchEffectBehavior::UniformScale) {
const StretchEffect& stretch = props.layerProperties().getStretchEffect();
if (!stretch.isEmpty()) {
applyMatrix(stretch.makeLinearStretch(props.getWidth(), props.getHeight()), &temp);
diff --git a/libs/hwui/Properties.cpp b/libs/hwui/Properties.cpp
index a4614a9..f0995c4 100644
--- a/libs/hwui/Properties.cpp
+++ b/libs/hwui/Properties.cpp
@@ -137,10 +137,6 @@
targetCpuTimePercentage = base::GetIntProperty(PROPERTY_TARGET_CPU_TIME_PERCENTAGE, 70);
if (targetCpuTimePercentage <= 0 || targetCpuTimePercentage > 100) targetCpuTimePercentage = 70;
- int stretchType = base::GetIntProperty(PROPERTY_STRETCH_EFFECT_TYPE, 0);
- stretchType = std::clamp(stretchType, 0, static_cast<int>(StretchEffectBehavior::UniformScale));
- stretchEffectBehavior = static_cast<StretchEffectBehavior>(stretchType);
-
return (prevDebugLayersUpdates != debugLayersUpdates) || (prevDebugOverdraw != debugOverdraw);
}
diff --git a/libs/hwui/Properties.h b/libs/hwui/Properties.h
index 9964254..f5fd003 100644
--- a/libs/hwui/Properties.h
+++ b/libs/hwui/Properties.h
@@ -171,8 +171,6 @@
*/
#define PROPERTY_TARGET_CPU_TIME_PERCENTAGE "debug.hwui.target_cpu_time_percent"
-#define PROPERTY_STRETCH_EFFECT_TYPE "debug.hwui.stretch_mode"
-
/**
* Property for whether this is running in the emulator.
*/
@@ -278,9 +276,26 @@
static bool useHintManager;
static int targetCpuTimePercentage;
- static StretchEffectBehavior stretchEffectBehavior;
+ static StretchEffectBehavior getStretchEffectBehavior() {
+ return stretchEffectBehavior;
+ }
+
+ static void setIsHighEndGfx(bool isHighEndGfx) {
+ stretchEffectBehavior = isHighEndGfx ?
+ StretchEffectBehavior::ShaderHWUI :
+ StretchEffectBehavior::UniformScale;
+ }
+
+ /**
+ * Used for testing. Typical configuration of stretch behavior is done
+ * through setIsHighEndGfx
+ */
+ static void setStretchEffectBehavior(StretchEffectBehavior behavior) {
+ stretchEffectBehavior = behavior;
+ }
private:
+ static StretchEffectBehavior stretchEffectBehavior;
static ProfileType sProfileType;
static bool sDisableProfileBars;
static RenderPipelineType sRenderPipelineType;
diff --git a/libs/hwui/RenderNode.cpp b/libs/hwui/RenderNode.cpp
index ad2cd8c..ded7994 100644
--- a/libs/hwui/RenderNode.cpp
+++ b/libs/hwui/RenderNode.cpp
@@ -478,7 +478,7 @@
}
}
- if (Properties::stretchEffectBehavior == StretchEffectBehavior::UniformScale) {
+ if (Properties::getStretchEffectBehavior() == StretchEffectBehavior::UniformScale) {
const StretchEffect& stretch = properties().layerProperties().getStretchEffect();
if (!stretch.isEmpty()) {
matrix.multiply(
diff --git a/libs/hwui/effects/StretchEffect.h b/libs/hwui/effects/StretchEffect.h
index 0e1a654..a92ef5b 100644
--- a/libs/hwui/effects/StretchEffect.h
+++ b/libs/hwui/effects/StretchEffect.h
@@ -111,7 +111,7 @@
bool requiresLayer() const {
return !(isEmpty() ||
- Properties::stretchEffectBehavior == StretchEffectBehavior::UniformScale);
+ Properties::getStretchEffectBehavior() == StretchEffectBehavior::UniformScale);
}
private:
diff --git a/libs/hwui/jni/android_graphics_HardwareRenderer.cpp b/libs/hwui/jni/android_graphics_HardwareRenderer.cpp
index dd78d58..82bc5a1 100644
--- a/libs/hwui/jni/android_graphics_HardwareRenderer.cpp
+++ b/libs/hwui/jni/android_graphics_HardwareRenderer.cpp
@@ -324,6 +324,11 @@
Properties::defaultSdrWhitePoint = sdrWhitePoint;
}
+static void android_view_ThreadedRenderer_setIsHighEndGfx(JNIEnv* env, jobject clazz,
+ jboolean jIsHighEndGfx) {
+ Properties::setIsHighEndGfx(jIsHighEndGfx);
+}
+
static int android_view_ThreadedRenderer_syncAndDrawFrame(JNIEnv* env, jobject clazz,
jlong proxyPtr, jlongArray frameInfo, jint frameInfoSize) {
LOG_ALWAYS_FATAL_IF(frameInfoSize != UI_THREAD_FRAME_INFO_SIZE,
@@ -795,6 +800,7 @@
{"nSetOpaque", "(JZ)V", (void*)android_view_ThreadedRenderer_setOpaque},
{"nSetColorMode", "(JI)V", (void*)android_view_ThreadedRenderer_setColorMode},
{"nSetSdrWhitePoint", "(JF)V", (void*)android_view_ThreadedRenderer_setSdrWhitePoint},
+ {"nSetIsHighEndGfx", "(Z)V", (void*)android_view_ThreadedRenderer_setIsHighEndGfx},
{"nSyncAndDrawFrame", "(J[JI)I", (void*)android_view_ThreadedRenderer_syncAndDrawFrame},
{"nDestroy", "(JJ)V", (void*)android_view_ThreadedRenderer_destroy},
{"nRegisterAnimatingRenderNode", "(JJ)V",
diff --git a/libs/hwui/jni/android_graphics_RenderNode.cpp b/libs/hwui/jni/android_graphics_RenderNode.cpp
index a096ed0..002bd83 100644
--- a/libs/hwui/jni/android_graphics_RenderNode.cpp
+++ b/libs/hwui/jni/android_graphics_RenderNode.cpp
@@ -574,7 +574,7 @@
uirenderer::Rect bounds(props.getWidth(), props.getHeight());
bool useStretchShader =
- Properties::stretchEffectBehavior != StretchEffectBehavior::UniformScale;
+ Properties::getStretchEffectBehavior() != StretchEffectBehavior::UniformScale;
if (useStretchShader && info.stretchEffectCount) {
handleStretchEffect(info, bounds);
}
@@ -680,7 +680,8 @@
stretchTargetBounds(*effect, result.width, result.height,
childRelativeBounds,targetBounds);
- if (Properties::stretchEffectBehavior == StretchEffectBehavior::Shader) {
+ if (Properties::getStretchEffectBehavior() ==
+ StretchEffectBehavior::Shader) {
JNIEnv* env = jnienv();
jobject localref = env->NewLocalRef(mWeakRef);
diff --git a/libs/hwui/pipeline/skia/RenderNodeDrawable.cpp b/libs/hwui/pipeline/skia/RenderNodeDrawable.cpp
index 1c5515c7d..c8247e7 100644
--- a/libs/hwui/pipeline/skia/RenderNodeDrawable.cpp
+++ b/libs/hwui/pipeline/skia/RenderNodeDrawable.cpp
@@ -248,7 +248,7 @@
const StretchEffect& stretch = properties.layerProperties().getStretchEffect();
if (stretch.isEmpty() ||
- Properties::stretchEffectBehavior == StretchEffectBehavior::UniformScale) {
+ Properties::getStretchEffectBehavior() == StretchEffectBehavior::UniformScale) {
// If we don't have any stretch effects, issue the filtered
// canvas draw calls to make sure we still punch a hole
// with the same canvas transformation + clip into the target
@@ -327,7 +327,7 @@
canvas->concat(*properties.getTransformMatrix());
}
}
- if (Properties::stretchEffectBehavior == StretchEffectBehavior::UniformScale) {
+ if (Properties::getStretchEffectBehavior() == StretchEffectBehavior::UniformScale) {
const StretchEffect& stretch = properties.layerProperties().getStretchEffect();
if (!stretch.isEmpty()) {
canvas->concat(
diff --git a/libs/hwui/tests/common/scenes/StretchyListViewAnimation.cpp b/libs/hwui/tests/common/scenes/StretchyListViewAnimation.cpp
index c451112..e677549 100644
--- a/libs/hwui/tests/common/scenes/StretchyListViewAnimation.cpp
+++ b/libs/hwui/tests/common/scenes/StretchyListViewAnimation.cpp
@@ -186,7 +186,7 @@
void doFrame(int frameNr) override {
if (frameNr == 0) {
- Properties::stretchEffectBehavior = stretchBehavior();
+ Properties::setStretchEffectBehavior(stretchBehavior());
if (forceLayer()) {
mListView->mutateStagingProperties().mutateLayerProperties().setType(
LayerType::RenderLayer);