Merge "Add support to toggle different shader behaviors" into sc-dev
This commit is contained in:
@@ -1195,6 +1195,7 @@ public class HardwareRenderer {
|
|||||||
// so not checking for isolated process here.
|
// so not checking for isolated process here.
|
||||||
initHintSession();
|
initHintSession();
|
||||||
|
|
||||||
|
nSetIsHighEndGfx(ActivityManager.isHighEndGfx());
|
||||||
// Defensively clear out the context in case we were passed a context that can leak
|
// 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.
|
// if we live longer than it, e.g. an activity context.
|
||||||
mContext = null;
|
mContext = null;
|
||||||
@@ -1315,6 +1316,8 @@ public class HardwareRenderer {
|
|||||||
|
|
||||||
private static native void nSetSdrWhitePoint(long nativeProxy, float whitePoint);
|
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 int nSyncAndDrawFrame(long nativeProxy, long[] frameInfo, int size);
|
||||||
|
|
||||||
private static native void nDestroy(long nativeProxy, long rootRenderNode);
|
private static native void nDestroy(long nativeProxy, long rootRenderNode);
|
||||||
|
|||||||
@@ -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) {
|
static inline void mapRect(const RenderProperties& props, const SkRect& in, SkRect* out) {
|
||||||
if (in.isEmpty()) return;
|
if (in.isEmpty()) return;
|
||||||
SkRect temp(in);
|
SkRect temp(in);
|
||||||
if (Properties::stretchEffectBehavior == StretchEffectBehavior::UniformScale) {
|
if (Properties::getStretchEffectBehavior() == StretchEffectBehavior::UniformScale) {
|
||||||
const StretchEffect& stretch = props.layerProperties().getStretchEffect();
|
const StretchEffect& stretch = props.layerProperties().getStretchEffect();
|
||||||
if (!stretch.isEmpty()) {
|
if (!stretch.isEmpty()) {
|
||||||
applyMatrix(stretch.makeLinearStretch(props.getWidth(), props.getHeight()), &temp);
|
applyMatrix(stretch.makeLinearStretch(props.getWidth(), props.getHeight()), &temp);
|
||||||
|
|||||||
@@ -137,10 +137,6 @@ bool Properties::load() {
|
|||||||
targetCpuTimePercentage = base::GetIntProperty(PROPERTY_TARGET_CPU_TIME_PERCENTAGE, 70);
|
targetCpuTimePercentage = base::GetIntProperty(PROPERTY_TARGET_CPU_TIME_PERCENTAGE, 70);
|
||||||
if (targetCpuTimePercentage <= 0 || targetCpuTimePercentage > 100) targetCpuTimePercentage = 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);
|
return (prevDebugLayersUpdates != debugLayersUpdates) || (prevDebugOverdraw != debugOverdraw);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -171,8 +171,6 @@ enum DebugLevel {
|
|||||||
*/
|
*/
|
||||||
#define PROPERTY_TARGET_CPU_TIME_PERCENTAGE "debug.hwui.target_cpu_time_percent"
|
#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.
|
* Property for whether this is running in the emulator.
|
||||||
*/
|
*/
|
||||||
@@ -278,9 +276,26 @@ public:
|
|||||||
static bool useHintManager;
|
static bool useHintManager;
|
||||||
static int targetCpuTimePercentage;
|
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:
|
private:
|
||||||
|
static StretchEffectBehavior stretchEffectBehavior;
|
||||||
static ProfileType sProfileType;
|
static ProfileType sProfileType;
|
||||||
static bool sDisableProfileBars;
|
static bool sDisableProfileBars;
|
||||||
static RenderPipelineType sRenderPipelineType;
|
static RenderPipelineType sRenderPipelineType;
|
||||||
|
|||||||
@@ -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();
|
const StretchEffect& stretch = properties().layerProperties().getStretchEffect();
|
||||||
if (!stretch.isEmpty()) {
|
if (!stretch.isEmpty()) {
|
||||||
matrix.multiply(
|
matrix.multiply(
|
||||||
|
|||||||
@@ -111,7 +111,7 @@ public:
|
|||||||
|
|
||||||
bool requiresLayer() const {
|
bool requiresLayer() const {
|
||||||
return !(isEmpty() ||
|
return !(isEmpty() ||
|
||||||
Properties::stretchEffectBehavior == StretchEffectBehavior::UniformScale);
|
Properties::getStretchEffectBehavior() == StretchEffectBehavior::UniformScale);
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|||||||
@@ -324,6 +324,11 @@ static void android_view_ThreadedRenderer_setSdrWhitePoint(JNIEnv* env, jobject
|
|||||||
Properties::defaultSdrWhitePoint = sdrWhitePoint;
|
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,
|
static int android_view_ThreadedRenderer_syncAndDrawFrame(JNIEnv* env, jobject clazz,
|
||||||
jlong proxyPtr, jlongArray frameInfo, jint frameInfoSize) {
|
jlong proxyPtr, jlongArray frameInfo, jint frameInfoSize) {
|
||||||
LOG_ALWAYS_FATAL_IF(frameInfoSize != UI_THREAD_FRAME_INFO_SIZE,
|
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},
|
{"nSetOpaque", "(JZ)V", (void*)android_view_ThreadedRenderer_setOpaque},
|
||||||
{"nSetColorMode", "(JI)V", (void*)android_view_ThreadedRenderer_setColorMode},
|
{"nSetColorMode", "(JI)V", (void*)android_view_ThreadedRenderer_setColorMode},
|
||||||
{"nSetSdrWhitePoint", "(JF)V", (void*)android_view_ThreadedRenderer_setSdrWhitePoint},
|
{"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},
|
{"nSyncAndDrawFrame", "(J[JI)I", (void*)android_view_ThreadedRenderer_syncAndDrawFrame},
|
||||||
{"nDestroy", "(JJ)V", (void*)android_view_ThreadedRenderer_destroy},
|
{"nDestroy", "(JJ)V", (void*)android_view_ThreadedRenderer_destroy},
|
||||||
{"nRegisterAnimatingRenderNode", "(JJ)V",
|
{"nRegisterAnimatingRenderNode", "(JJ)V",
|
||||||
|
|||||||
@@ -574,7 +574,7 @@ static void android_view_RenderNode_requestPositionUpdates(JNIEnv* env, jobject,
|
|||||||
|
|
||||||
uirenderer::Rect bounds(props.getWidth(), props.getHeight());
|
uirenderer::Rect bounds(props.getWidth(), props.getHeight());
|
||||||
bool useStretchShader =
|
bool useStretchShader =
|
||||||
Properties::stretchEffectBehavior != StretchEffectBehavior::UniformScale;
|
Properties::getStretchEffectBehavior() != StretchEffectBehavior::UniformScale;
|
||||||
if (useStretchShader && info.stretchEffectCount) {
|
if (useStretchShader && info.stretchEffectCount) {
|
||||||
handleStretchEffect(info, bounds);
|
handleStretchEffect(info, bounds);
|
||||||
}
|
}
|
||||||
@@ -680,7 +680,8 @@ static void android_view_RenderNode_requestPositionUpdates(JNIEnv* env, jobject,
|
|||||||
stretchTargetBounds(*effect, result.width, result.height,
|
stretchTargetBounds(*effect, result.width, result.height,
|
||||||
childRelativeBounds,targetBounds);
|
childRelativeBounds,targetBounds);
|
||||||
|
|
||||||
if (Properties::stretchEffectBehavior == StretchEffectBehavior::Shader) {
|
if (Properties::getStretchEffectBehavior() ==
|
||||||
|
StretchEffectBehavior::Shader) {
|
||||||
JNIEnv* env = jnienv();
|
JNIEnv* env = jnienv();
|
||||||
|
|
||||||
jobject localref = env->NewLocalRef(mWeakRef);
|
jobject localref = env->NewLocalRef(mWeakRef);
|
||||||
|
|||||||
@@ -248,7 +248,7 @@ void RenderNodeDrawable::drawContent(SkCanvas* canvas) const {
|
|||||||
|
|
||||||
const StretchEffect& stretch = properties.layerProperties().getStretchEffect();
|
const StretchEffect& stretch = properties.layerProperties().getStretchEffect();
|
||||||
if (stretch.isEmpty() ||
|
if (stretch.isEmpty() ||
|
||||||
Properties::stretchEffectBehavior == StretchEffectBehavior::UniformScale) {
|
Properties::getStretchEffectBehavior() == StretchEffectBehavior::UniformScale) {
|
||||||
// If we don't have any stretch effects, issue the filtered
|
// If we don't have any stretch effects, issue the filtered
|
||||||
// canvas draw calls to make sure we still punch a hole
|
// canvas draw calls to make sure we still punch a hole
|
||||||
// with the same canvas transformation + clip into the target
|
// with the same canvas transformation + clip into the target
|
||||||
@@ -327,7 +327,7 @@ void RenderNodeDrawable::setViewProperties(const RenderProperties& properties, S
|
|||||||
canvas->concat(*properties.getTransformMatrix());
|
canvas->concat(*properties.getTransformMatrix());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (Properties::stretchEffectBehavior == StretchEffectBehavior::UniformScale) {
|
if (Properties::getStretchEffectBehavior() == StretchEffectBehavior::UniformScale) {
|
||||||
const StretchEffect& stretch = properties.layerProperties().getStretchEffect();
|
const StretchEffect& stretch = properties.layerProperties().getStretchEffect();
|
||||||
if (!stretch.isEmpty()) {
|
if (!stretch.isEmpty()) {
|
||||||
canvas->concat(
|
canvas->concat(
|
||||||
|
|||||||
@@ -186,7 +186,7 @@ private:
|
|||||||
|
|
||||||
void doFrame(int frameNr) override {
|
void doFrame(int frameNr) override {
|
||||||
if (frameNr == 0) {
|
if (frameNr == 0) {
|
||||||
Properties::stretchEffectBehavior = stretchBehavior();
|
Properties::setStretchEffectBehavior(stretchBehavior());
|
||||||
if (forceLayer()) {
|
if (forceLayer()) {
|
||||||
mListView->mutateStagingProperties().mutateLayerProperties().setType(
|
mListView->mutateStagingProperties().mutateLayerProperties().setType(
|
||||||
LayerType::RenderLayer);
|
LayerType::RenderLayer);
|
||||||
|
|||||||
Reference in New Issue
Block a user