summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Nader Jawad <njawad@google.com> 2021-05-11 05:22:15 +0000
committer Android (Google) Code Review <android-gerrit@google.com> 2021-05-11 05:22:15 +0000
commitfdccce02ba686f769715616de6b6edb08991ed0b (patch)
treeb4638d3594078d400ea6cc527bef94457e27d1f7
parentd011237d39bd56f30aebd2c7b3771a76892e9d0a (diff)
parent9272f2161230ab3fae0051e90131648da55aa0ad (diff)
Merge "Updated StretchEffect types" into sc-dev
-rw-r--r--libs/hwui/Properties.cpp2
-rw-r--r--libs/hwui/Properties.h5
-rw-r--r--libs/hwui/jni/android_graphics_RenderNode.cpp49
-rw-r--r--libs/hwui/pipeline/skia/RenderNodeDrawable.cpp4
4 files changed, 32 insertions, 28 deletions
diff --git a/libs/hwui/Properties.cpp b/libs/hwui/Properties.cpp
index c58c888b8a21..9ed801baf5ea 100644
--- a/libs/hwui/Properties.cpp
+++ b/libs/hwui/Properties.cpp
@@ -84,7 +84,7 @@ float Properties::defaultSdrWhitePoint = 200.f;
bool Properties::useHintManager = true;
int Properties::targetCpuTimePercentage = 70;
-StretchEffectBehavior Properties::stretchEffectBehavior = StretchEffectBehavior::Shader;
+StretchEffectBehavior Properties::stretchEffectBehavior = StretchEffectBehavior::ShaderHWUI;
bool Properties::load() {
bool prevDebugLayersUpdates = debugLayersUpdates;
diff --git a/libs/hwui/Properties.h b/libs/hwui/Properties.h
index 82ce5c6fb979..9d2b6173021d 100644
--- a/libs/hwui/Properties.h
+++ b/libs/hwui/Properties.h
@@ -200,8 +200,9 @@ enum class OverdrawColorSet { Default = 0, Deuteranomaly };
enum class RenderPipelineType { SkiaGL, SkiaVulkan, NotInitialized = 128 };
enum class StretchEffectBehavior {
- Shader,
- LinearScale,
+ ShaderHWUI, // Stretch shader in HWUI only, matrix scale in SF
+ Shader, // Stretch shader in both HWUI and SF
+ LinearScale // Linear stretch everywhere
};
/**
diff --git a/libs/hwui/jni/android_graphics_RenderNode.cpp b/libs/hwui/jni/android_graphics_RenderNode.cpp
index 6123c05fb22a..cd0783f75106 100644
--- a/libs/hwui/jni/android_graphics_RenderNode.cpp
+++ b/libs/hwui/jni/android_graphics_RenderNode.cpp
@@ -573,8 +573,9 @@ static void android_view_RenderNode_requestPositionUpdates(JNIEnv* env, jobject,
const RenderProperties& props = node.properties();
uirenderer::Rect bounds(props.getWidth(), props.getHeight());
- if (Properties::stretchEffectBehavior == StretchEffectBehavior::Shader &&
- info.stretchEffectCount) {
+ bool useStretchShader = Properties::stretchEffectBehavior !=
+ StretchEffectBehavior::LinearScale;
+ if (useStretchShader && info.stretchEffectCount) {
handleStretchEffect(info, bounds);
}
@@ -679,30 +680,32 @@ static void android_view_RenderNode_requestPositionUpdates(JNIEnv* env, jobject,
stretchTargetBounds(*effect, result.width, result.height,
childRelativeBounds,targetBounds);
- JNIEnv* env = jnienv();
+ if (Properties::stretchEffectBehavior == StretchEffectBehavior::Shader) {
+ JNIEnv* env = jnienv();
- jobject localref = env->NewLocalRef(mWeakRef);
- if (CC_UNLIKELY(!localref)) {
- env->DeleteWeakGlobalRef(mWeakRef);
- mWeakRef = nullptr;
- return;
- }
+ jobject localref = env->NewLocalRef(mWeakRef);
+ if (CC_UNLIKELY(!localref)) {
+ env->DeleteWeakGlobalRef(mWeakRef);
+ mWeakRef = nullptr;
+ return;
+ }
#ifdef __ANDROID__ // Layoutlib does not support CanvasContext
- SkVector stretchDirection = effect->getStretchDirection();
- env->CallVoidMethod(localref, gPositionListener_ApplyStretchMethod,
- info.canvasContext.getFrameNumber(),
- result.width,
- result.height,
- stretchDirection.fX,
- stretchDirection.fY,
- effect->maxStretchAmountX,
- effect->maxStretchAmountY,
- childRelativeBounds.left(),
- childRelativeBounds.top(),
- childRelativeBounds.right(),
- childRelativeBounds.bottom());
+ SkVector stretchDirection = effect->getStretchDirection();
+ env->CallVoidMethod(localref, gPositionListener_ApplyStretchMethod,
+ info.canvasContext.getFrameNumber(),
+ result.width,
+ result.height,
+ stretchDirection.fX,
+ stretchDirection.fY,
+ effect->maxStretchAmountX,
+ effect->maxStretchAmountY,
+ childRelativeBounds.left(),
+ childRelativeBounds.top(),
+ childRelativeBounds.right(),
+ childRelativeBounds.bottom());
#endif
- env->DeleteLocalRef(localref);
+ env->DeleteLocalRef(localref);
+ }
}
void doUpdatePositionAsync(jlong frameNumber, jint left, jint top,
diff --git a/libs/hwui/pipeline/skia/RenderNodeDrawable.cpp b/libs/hwui/pipeline/skia/RenderNodeDrawable.cpp
index 509884e23c26..57cdde2e8f10 100644
--- a/libs/hwui/pipeline/skia/RenderNodeDrawable.cpp
+++ b/libs/hwui/pipeline/skia/RenderNodeDrawable.cpp
@@ -172,7 +172,7 @@ void RenderNodeDrawable::forceDraw(SkCanvas* canvas) const {
}
static bool stretchNeedsLayer(const LayerProperties& properties) {
- return Properties::stretchEffectBehavior == StretchEffectBehavior::Shader &&
+ return Properties::stretchEffectBehavior != StretchEffectBehavior::LinearScale &&
!properties.getStretchEffect().isEmpty();
}
@@ -253,7 +253,7 @@ void RenderNodeDrawable::drawContent(SkCanvas* canvas) const {
const StretchEffect& stretch = properties.layerProperties().getStretchEffect();
if (stretch.isEmpty() ||
- Properties::stretchEffectBehavior != StretchEffectBehavior::Shader) {
+ Properties::stretchEffectBehavior == StretchEffectBehavior::LinearScale) {
// 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