Merge "Add some more scenes, replace linear with uniform" into sc-dev
This commit is contained in:
@@ -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::LinearScale) {
|
||||
if (Properties::stretchEffectBehavior == StretchEffectBehavior::UniformScale) {
|
||||
const StretchEffect& stretch = props.layerProperties().getStretchEffect();
|
||||
if (!stretch.isEmpty()) {
|
||||
applyMatrix(stretch.makeLinearStretch(props.getWidth(), props.getHeight()), &temp);
|
||||
|
||||
@@ -138,7 +138,7 @@ bool Properties::load() {
|
||||
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::LinearScale));
|
||||
stretchType = std::clamp(stretchType, 0, static_cast<int>(StretchEffectBehavior::UniformScale));
|
||||
stretchEffectBehavior = static_cast<StretchEffectBehavior>(stretchType);
|
||||
|
||||
return (prevDebugLayersUpdates != debugLayersUpdates) || (prevDebugOverdraw != debugOverdraw);
|
||||
|
||||
@@ -200,9 +200,9 @@ enum class OverdrawColorSet { Default = 0, Deuteranomaly };
|
||||
enum class RenderPipelineType { SkiaGL, SkiaVulkan, NotInitialized = 128 };
|
||||
|
||||
enum class StretchEffectBehavior {
|
||||
ShaderHWUI, // Stretch shader in HWUI only, matrix scale in SF
|
||||
Shader, // Stretch shader in both HWUI and SF
|
||||
LinearScale // Linear stretch everywhere
|
||||
ShaderHWUI, // Stretch shader in HWUI only, matrix scale in SF
|
||||
Shader, // Stretch shader in both HWUI and SF
|
||||
UniformScale // Uniform scale stretch everywhere
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
@@ -478,7 +478,7 @@ void RenderNode::applyViewPropertyTransforms(mat4& matrix, bool true3dTransform)
|
||||
}
|
||||
}
|
||||
|
||||
if (Properties::stretchEffectBehavior == StretchEffectBehavior::LinearScale) {
|
||||
if (Properties::stretchEffectBehavior == StretchEffectBehavior::UniformScale) {
|
||||
const StretchEffect& stretch = properties().layerProperties().getStretchEffect();
|
||||
if (!stretch.isEmpty()) {
|
||||
matrix.multiply(
|
||||
|
||||
@@ -111,7 +111,7 @@ public:
|
||||
|
||||
bool requiresLayer() const {
|
||||
return !(isEmpty() ||
|
||||
Properties::stretchEffectBehavior == StretchEffectBehavior::LinearScale);
|
||||
Properties::stretchEffectBehavior == StretchEffectBehavior::UniformScale);
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
@@ -573,8 +573,8 @@ static void android_view_RenderNode_requestPositionUpdates(JNIEnv* env, jobject,
|
||||
const RenderProperties& props = node.properties();
|
||||
|
||||
uirenderer::Rect bounds(props.getWidth(), props.getHeight());
|
||||
bool useStretchShader = Properties::stretchEffectBehavior !=
|
||||
StretchEffectBehavior::LinearScale;
|
||||
bool useStretchShader =
|
||||
Properties::stretchEffectBehavior != StretchEffectBehavior::UniformScale;
|
||||
if (useStretchShader && info.stretchEffectCount) {
|
||||
handleStretchEffect(info, bounds);
|
||||
}
|
||||
|
||||
@@ -248,7 +248,7 @@ void RenderNodeDrawable::drawContent(SkCanvas* canvas) const {
|
||||
|
||||
const StretchEffect& stretch = properties.layerProperties().getStretchEffect();
|
||||
if (stretch.isEmpty() ||
|
||||
Properties::stretchEffectBehavior == StretchEffectBehavior::LinearScale) {
|
||||
Properties::stretchEffectBehavior == 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::LinearScale) {
|
||||
if (Properties::stretchEffectBehavior == StretchEffectBehavior::UniformScale) {
|
||||
const StretchEffect& stretch = properties.layerProperties().getStretchEffect();
|
||||
if (!stretch.isEmpty()) {
|
||||
canvas->concat(
|
||||
|
||||
@@ -22,8 +22,10 @@
|
||||
|
||||
class StretchyListViewAnimation;
|
||||
class StretchyListViewHolePunch;
|
||||
class StretchyLinearListView;
|
||||
class StretchyLinearListViewHolePunch;
|
||||
class StretchyUniformListView;
|
||||
class StretchyUniformListViewHolePunch;
|
||||
class StretchyUniformLayerListView;
|
||||
class StretchyUniformLayerListViewHolePunch;
|
||||
|
||||
static TestScene::Registrar _StretchyListViewAnimation(TestScene::Info{
|
||||
"stretchylistview",
|
||||
@@ -36,21 +38,34 @@ static TestScene::Registrar _StretchyListViewHolePunch(TestScene::Info{
|
||||
"A mock ListView of scrolling content that's stretching. Includes a hole punch",
|
||||
TestScene::simpleCreateScene<StretchyListViewHolePunch>});
|
||||
|
||||
static TestScene::Registrar _StretchyLinearListView(TestScene::Info{
|
||||
"stretchylistview_linear",
|
||||
"A mock ListView of scrolling content that's stretching using a linear stretch effect.",
|
||||
TestScene::simpleCreateScene<StretchyLinearListView>});
|
||||
static TestScene::Registrar _StretchyUniformListView(TestScene::Info{
|
||||
"stretchylistview_uniform",
|
||||
"A mock ListView of scrolling content that's stretching using a uniform stretch effect.",
|
||||
TestScene::simpleCreateScene<StretchyUniformListView>});
|
||||
|
||||
static TestScene::Registrar _StretchyLinearListViewHolePunch(TestScene::Info{
|
||||
"stretchylistview_linear_holepunch",
|
||||
"A mock ListView of scrolling content that's stretching using a linear stretch effect. "
|
||||
static TestScene::Registrar _StretchyUniformListViewHolePunch(TestScene::Info{
|
||||
"stretchylistview_uniform_holepunch",
|
||||
"A mock ListView of scrolling content that's stretching using a uniform stretch effect. "
|
||||
"Includes a hole punch",
|
||||
TestScene::simpleCreateScene<StretchyLinearListViewHolePunch>});
|
||||
TestScene::simpleCreateScene<StretchyUniformListViewHolePunch>});
|
||||
|
||||
static TestScene::Registrar _StretchyUniformLayerListView(TestScene::Info{
|
||||
"stretchylistview_uniform_layer",
|
||||
"A mock ListView of scrolling content that's stretching using a uniform stretch effect. "
|
||||
"Uses a layer",
|
||||
TestScene::simpleCreateScene<StretchyUniformLayerListView>});
|
||||
|
||||
static TestScene::Registrar _StretchyUniformLayerListViewHolePunch(TestScene::Info{
|
||||
"stretchylistview_uniform_layer_holepunch",
|
||||
"A mock ListView of scrolling content that's stretching using a uniform stretch effect. "
|
||||
"Uses a layer & includes a hole punch",
|
||||
TestScene::simpleCreateScene<StretchyUniformLayerListViewHolePunch>});
|
||||
|
||||
class StretchyListViewAnimation : public TestScene {
|
||||
protected:
|
||||
virtual StretchEffectBehavior stretchBehavior() { return StretchEffectBehavior::Shader; }
|
||||
virtual bool haveHolePunch() { return false; }
|
||||
virtual bool forceLayer() { return false; }
|
||||
|
||||
private:
|
||||
int mItemHeight;
|
||||
@@ -172,6 +187,10 @@ private:
|
||||
void doFrame(int frameNr) override {
|
||||
if (frameNr == 0) {
|
||||
Properties::stretchEffectBehavior = stretchBehavior();
|
||||
if (forceLayer()) {
|
||||
mListView->mutateStagingProperties().mutateLayerProperties().setType(
|
||||
LayerType::RenderLayer);
|
||||
}
|
||||
}
|
||||
auto& props = mListView->mutateStagingProperties();
|
||||
auto& stretch = props.mutateLayerProperties().mutableStretchEffect();
|
||||
@@ -190,11 +209,22 @@ class StretchyListViewHolePunch : public StretchyListViewAnimation {
|
||||
bool haveHolePunch() override { return true; }
|
||||
};
|
||||
|
||||
class StretchyLinearListView : public StretchyListViewAnimation {
|
||||
StretchEffectBehavior stretchBehavior() override { return StretchEffectBehavior::LinearScale; }
|
||||
class StretchyUniformListView : public StretchyListViewAnimation {
|
||||
StretchEffectBehavior stretchBehavior() override { return StretchEffectBehavior::UniformScale; }
|
||||
};
|
||||
|
||||
class StretchyLinearListViewHolePunch : public StretchyListViewAnimation {
|
||||
StretchEffectBehavior stretchBehavior() override { return StretchEffectBehavior::LinearScale; }
|
||||
class StretchyUniformListViewHolePunch : public StretchyListViewAnimation {
|
||||
StretchEffectBehavior stretchBehavior() override { return StretchEffectBehavior::UniformScale; }
|
||||
bool haveHolePunch() override { return true; }
|
||||
};
|
||||
|
||||
class StretchyUniformLayerListView : public StretchyListViewAnimation {
|
||||
StretchEffectBehavior stretchBehavior() override { return StretchEffectBehavior::UniformScale; }
|
||||
bool forceLayer() override { return true; }
|
||||
};
|
||||
|
||||
class StretchyUniformLayerListViewHolePunch : public StretchyListViewAnimation {
|
||||
StretchEffectBehavior stretchBehavior() override { return StretchEffectBehavior::UniformScale; }
|
||||
bool haveHolePunch() override { return true; }
|
||||
bool forceLayer() override { return true; }
|
||||
};
|
||||
Reference in New Issue
Block a user