Merge "Updated StretchEffect types" into sc-dev
This commit is contained in:
@@ -84,7 +84,7 @@ float Properties::defaultSdrWhitePoint = 200.f;
|
|||||||
bool Properties::useHintManager = true;
|
bool Properties::useHintManager = true;
|
||||||
int Properties::targetCpuTimePercentage = 70;
|
int Properties::targetCpuTimePercentage = 70;
|
||||||
|
|
||||||
StretchEffectBehavior Properties::stretchEffectBehavior = StretchEffectBehavior::Shader;
|
StretchEffectBehavior Properties::stretchEffectBehavior = StretchEffectBehavior::ShaderHWUI;
|
||||||
|
|
||||||
bool Properties::load() {
|
bool Properties::load() {
|
||||||
bool prevDebugLayersUpdates = debugLayersUpdates;
|
bool prevDebugLayersUpdates = debugLayersUpdates;
|
||||||
|
|||||||
@@ -200,8 +200,9 @@ enum class OverdrawColorSet { Default = 0, Deuteranomaly };
|
|||||||
enum class RenderPipelineType { SkiaGL, SkiaVulkan, NotInitialized = 128 };
|
enum class RenderPipelineType { SkiaGL, SkiaVulkan, NotInitialized = 128 };
|
||||||
|
|
||||||
enum class StretchEffectBehavior {
|
enum class StretchEffectBehavior {
|
||||||
Shader,
|
ShaderHWUI, // Stretch shader in HWUI only, matrix scale in SF
|
||||||
LinearScale,
|
Shader, // Stretch shader in both HWUI and SF
|
||||||
|
LinearScale // Linear stretch everywhere
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -573,8 +573,9 @@ static void android_view_RenderNode_requestPositionUpdates(JNIEnv* env, jobject,
|
|||||||
const RenderProperties& props = node.properties();
|
const RenderProperties& props = node.properties();
|
||||||
|
|
||||||
uirenderer::Rect bounds(props.getWidth(), props.getHeight());
|
uirenderer::Rect bounds(props.getWidth(), props.getHeight());
|
||||||
if (Properties::stretchEffectBehavior == StretchEffectBehavior::Shader &&
|
bool useStretchShader = Properties::stretchEffectBehavior !=
|
||||||
info.stretchEffectCount) {
|
StretchEffectBehavior::LinearScale;
|
||||||
|
if (useStretchShader && info.stretchEffectCount) {
|
||||||
handleStretchEffect(info, bounds);
|
handleStretchEffect(info, bounds);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -679,30 +680,32 @@ 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);
|
||||||
|
|
||||||
JNIEnv* env = jnienv();
|
if (Properties::stretchEffectBehavior == StretchEffectBehavior::Shader) {
|
||||||
|
JNIEnv* env = jnienv();
|
||||||
|
|
||||||
jobject localref = env->NewLocalRef(mWeakRef);
|
jobject localref = env->NewLocalRef(mWeakRef);
|
||||||
if (CC_UNLIKELY(!localref)) {
|
if (CC_UNLIKELY(!localref)) {
|
||||||
env->DeleteWeakGlobalRef(mWeakRef);
|
env->DeleteWeakGlobalRef(mWeakRef);
|
||||||
mWeakRef = nullptr;
|
mWeakRef = nullptr;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
#ifdef __ANDROID__ // Layoutlib does not support CanvasContext
|
#ifdef __ANDROID__ // Layoutlib does not support CanvasContext
|
||||||
SkVector stretchDirection = effect->getStretchDirection();
|
SkVector stretchDirection = effect->getStretchDirection();
|
||||||
env->CallVoidMethod(localref, gPositionListener_ApplyStretchMethod,
|
env->CallVoidMethod(localref, gPositionListener_ApplyStretchMethod,
|
||||||
info.canvasContext.getFrameNumber(),
|
info.canvasContext.getFrameNumber(),
|
||||||
result.width,
|
result.width,
|
||||||
result.height,
|
result.height,
|
||||||
stretchDirection.fX,
|
stretchDirection.fX,
|
||||||
stretchDirection.fY,
|
stretchDirection.fY,
|
||||||
effect->maxStretchAmountX,
|
effect->maxStretchAmountX,
|
||||||
effect->maxStretchAmountY,
|
effect->maxStretchAmountY,
|
||||||
childRelativeBounds.left(),
|
childRelativeBounds.left(),
|
||||||
childRelativeBounds.top(),
|
childRelativeBounds.top(),
|
||||||
childRelativeBounds.right(),
|
childRelativeBounds.right(),
|
||||||
childRelativeBounds.bottom());
|
childRelativeBounds.bottom());
|
||||||
#endif
|
#endif
|
||||||
env->DeleteLocalRef(localref);
|
env->DeleteLocalRef(localref);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void doUpdatePositionAsync(jlong frameNumber, jint left, jint top,
|
void doUpdatePositionAsync(jlong frameNumber, jint left, jint top,
|
||||||
|
|||||||
@@ -172,7 +172,7 @@ void RenderNodeDrawable::forceDraw(SkCanvas* canvas) const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static bool stretchNeedsLayer(const LayerProperties& properties) {
|
static bool stretchNeedsLayer(const LayerProperties& properties) {
|
||||||
return Properties::stretchEffectBehavior == StretchEffectBehavior::Shader &&
|
return Properties::stretchEffectBehavior != StretchEffectBehavior::LinearScale &&
|
||||||
!properties.getStretchEffect().isEmpty();
|
!properties.getStretchEffect().isEmpty();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -253,7 +253,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::Shader) {
|
Properties::stretchEffectBehavior == StretchEffectBehavior::LinearScale) {
|
||||||
// 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
|
||||||
|
|||||||
Reference in New Issue
Block a user