diff options
author | 2021-05-17 18:12:29 -0700 | |
---|---|---|
committer | 2021-05-17 22:42:15 -0700 | |
commit | 93d6e248de0fc4afc266e9a3b19c9add3944e09b (patch) | |
tree | 71e4b5269ebe869aee1de14d2dc5045c6b97ec3f | |
parent | 72ac81f5dfe3349e20ecb52ea00a0583cb20ae77 (diff) |
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
-rw-r--r-- | graphics/java/android/graphics/HardwareRenderer.java | 3 | ||||
-rw-r--r-- | libs/hwui/DamageAccumulator.cpp | 2 | ||||
-rw-r--r-- | libs/hwui/Properties.cpp | 4 | ||||
-rw-r--r-- | libs/hwui/Properties.h | 21 | ||||
-rw-r--r-- | libs/hwui/RenderNode.cpp | 2 | ||||
-rw-r--r-- | libs/hwui/effects/StretchEffect.h | 2 | ||||
-rw-r--r-- | libs/hwui/jni/android_graphics_HardwareRenderer.cpp | 6 | ||||
-rw-r--r-- | libs/hwui/jni/android_graphics_RenderNode.cpp | 5 | ||||
-rw-r--r-- | libs/hwui/pipeline/skia/RenderNodeDrawable.cpp | 4 | ||||
-rw-r--r-- | libs/hwui/tests/common/scenes/StretchyListViewAnimation.cpp | 2 |
10 files changed, 36 insertions, 15 deletions
diff --git a/graphics/java/android/graphics/HardwareRenderer.java b/graphics/java/android/graphics/HardwareRenderer.java index 8f1223b5eeaf..954d062b55e9 100644 --- a/graphics/java/android/graphics/HardwareRenderer.java +++ b/graphics/java/android/graphics/HardwareRenderer.java @@ -1195,6 +1195,7 @@ public class HardwareRenderer { // so not checking for isolated process here. initHintSession(); + nSetIsHighEndGfx(ActivityManager.isHighEndGfx()); // Defensively clear out the context in case we were passed a context that can leak // if we live longer than it, e.g. an activity context. mContext = null; @@ -1315,6 +1316,8 @@ public class HardwareRenderer { private static native void nSetSdrWhitePoint(long nativeProxy, float whitePoint); + private static native void nSetIsHighEndGfx(boolean isHighEndGfx); + private static native int nSyncAndDrawFrame(long nativeProxy, long[] frameInfo, int size); private static native void nDestroy(long nativeProxy, long rootRenderNode); diff --git a/libs/hwui/DamageAccumulator.cpp b/libs/hwui/DamageAccumulator.cpp index 0adc0f64ee95..9db47c3ba090 100644 --- a/libs/hwui/DamageAccumulator.cpp +++ b/libs/hwui/DamageAccumulator.cpp @@ -157,7 +157,7 @@ static inline void applyMatrix(const SkMatrix& transform, SkRect* rect) { 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 a4614a9076c8..f0995c4f324b 100644 --- a/libs/hwui/Properties.cpp +++ b/libs/hwui/Properties.cpp @@ -137,10 +137,6 @@ bool Properties::load() { 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 9964254581df..f5fd0036f7be 100644 --- a/libs/hwui/Properties.h +++ b/libs/hwui/Properties.h @@ -171,8 +171,6 @@ enum DebugLevel { */ #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 @@ public: 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 ad2cd8c4508f..ded79940c934 100644 --- a/libs/hwui/RenderNode.cpp +++ b/libs/hwui/RenderNode.cpp @@ -478,7 +478,7 @@ void RenderNode::applyViewPropertyTransforms(mat4& matrix, bool true3dTransform) } } - 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 0e1a654e8c9a..a92ef5bfe658 100644 --- a/libs/hwui/effects/StretchEffect.h +++ b/libs/hwui/effects/StretchEffect.h @@ -111,7 +111,7 @@ public: 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 dd78d5869314..82bc5a1193e4 100644 --- a/libs/hwui/jni/android_graphics_HardwareRenderer.cpp +++ b/libs/hwui/jni/android_graphics_HardwareRenderer.cpp @@ -324,6 +324,11 @@ static void android_view_ThreadedRenderer_setSdrWhitePoint(JNIEnv* env, jobject 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 @@ static const JNINativeMethod gMethods[] = { {"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 a096ed0c63bb..002bd83cf6e6 100644 --- a/libs/hwui/jni/android_graphics_RenderNode.cpp +++ b/libs/hwui/jni/android_graphics_RenderNode.cpp @@ -574,7 +574,7 @@ static void android_view_RenderNode_requestPositionUpdates(JNIEnv* env, jobject, 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 @@ static void android_view_RenderNode_requestPositionUpdates(JNIEnv* env, jobject, 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 1c5515c7deee..c8247e76d288 100644 --- a/libs/hwui/pipeline/skia/RenderNodeDrawable.cpp +++ b/libs/hwui/pipeline/skia/RenderNodeDrawable.cpp @@ -248,7 +248,7 @@ void RenderNodeDrawable::drawContent(SkCanvas* canvas) const { 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 @@ void RenderNodeDrawable::setViewProperties(const RenderProperties& properties, S 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 c45111274396..e677549b7894 100644 --- a/libs/hwui/tests/common/scenes/StretchyListViewAnimation.cpp +++ b/libs/hwui/tests/common/scenes/StretchyListViewAnimation.cpp @@ -186,7 +186,7 @@ private: void doFrame(int frameNr) override { if (frameNr == 0) { - Properties::stretchEffectBehavior = stretchBehavior(); + Properties::setStretchEffectBehavior(stretchBehavior()); if (forceLayer()) { mListView->mutateStagingProperties().mutateLayerProperties().setType( LayerType::RenderLayer); |