summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Nader Jawad <njawad@google.com> 2021-05-10 17:30:30 +0000
committer Android (Google) Code Review <android-gerrit@google.com> 2021-05-10 17:30:30 +0000
commitd16d3a03fcab524ace2e27c3bdb8b0dd8510e940 (patch)
treeac610526a48fb76dcf96ae264e4a5a76f153729f
parent01351e12487f1ecc2a188810ff1c31af7e9b69c9 (diff)
parent63644d347d30ffd7dbe852997b953a9ae7ff19eb (diff)
Merge "Updated SkiaGLRenderEngine to no longer adjust stretch bounds" into sc-dev
-rw-r--r--libs/renderengine/skia/SkiaGLRenderEngine.cpp45
-rw-r--r--libs/renderengine/skia/filters/StretchShaderFactory.cpp9
2 files changed, 10 insertions, 44 deletions
diff --git a/libs/renderengine/skia/SkiaGLRenderEngine.cpp b/libs/renderengine/skia/SkiaGLRenderEngine.cpp
index 40a24ccc98..0bc7f939db 100644
--- a/libs/renderengine/skia/SkiaGLRenderEngine.cpp
+++ b/libs/renderengine/skia/SkiaGLRenderEngine.cpp
@@ -560,7 +560,11 @@ sk_sp<SkShader> SkiaGLRenderEngine::createRuntimeEffectShader(
const LayerSettings* layer, const DisplaySettings& display, bool undoPremultipliedAlpha,
bool requiresLinearEffect) {
const auto stretchEffect = layer->stretchEffect;
- if (stretchEffect.hasEffect()) {
+ // The given surface will be stretched by HWUI via matrix transformation
+ // which gets similar results for most surfaces
+ // Determine later on if we need to leverage the stertch shader within
+ // surface flinger
+ if (stretchEffect.hasEffect() && /* DISABLES CODE */ (false)) {
const auto targetBuffer = layer->source.buffer.buffer;
const auto graphicsBuffer = targetBuffer ? targetBuffer->getBuffer() : nullptr;
if (graphicsBuffer && shader) {
@@ -653,33 +657,6 @@ private:
int mSaveCount;
};
-void drawStretch(const SkRect& bounds, const StretchEffect& stretchEffect,
- SkCanvas* canvas, const SkPaint& paint) {
- float top = bounds.top();
- float left = bounds.left();
- float bottom = bounds.bottom();
- float right = bounds.right();
- // Adjust the drawing bounds based on the stretch itself.
- float stretchOffsetX =
- round(bounds.width() * stretchEffect.getStretchWidthMultiplier());
- float stretchOffsetY =
- round(bounds.height() * stretchEffect.getStretchHeightMultiplier());
- if (stretchEffect.vectorY < 0.f) {
- top -= stretchOffsetY;
- } else if (stretchEffect.vectorY > 0.f){
- bottom += stretchOffsetY;
- }
-
- if (stretchEffect.vectorX < 0.f) {
- left -= stretchOffsetX;
- } else if (stretchEffect.vectorX > 0.f) {
- right += stretchOffsetX;
- }
-
- auto stretchBounds = SkRect::MakeLTRB(left, top, right, bottom);
- canvas->drawRect(stretchBounds, paint);
-}
-
static SkRRect getBlurRRect(const BlurRegion& region) {
const auto rect = SkRect::MakeLTRB(region.left, region.top, region.right, region.bottom);
const SkVector radii[4] = {SkVector::Make(region.cornerRadiusTL, region.cornerRadiusTL),
@@ -1053,17 +1030,7 @@ status_t SkiaGLRenderEngine::drawLayers(const DisplaySettings& display,
paint.setAntiAlias(true);
canvas->drawRRect(bounds, paint);
} else {
- auto& stretchEffect = layer->stretchEffect;
- // TODO (njawad) temporarily disable manipulation of geometry
- // the layer bounds will be updated in HWUI instead of RenderEngine
- // in a subsequent CL
- // Keep the method call in a dead code path to make -Werror happy
- // with unused methods
- if (stretchEffect.hasEffect() && /* DISABLES CODE */ (false)) {
- drawStretch(bounds.rect(), stretchEffect, canvas, paint);
- } else {
- canvas->drawRect(bounds.rect(), paint);
- }
+ canvas->drawRect(bounds.rect(), paint);
}
if (kFlushAfterEveryLayer) {
ATRACE_NAME("flush surface");
diff --git a/libs/renderengine/skia/filters/StretchShaderFactory.cpp b/libs/renderengine/skia/filters/StretchShaderFactory.cpp
index 9b62789159..4ac5c4028b 100644
--- a/libs/renderengine/skia/filters/StretchShaderFactory.cpp
+++ b/libs/renderengine/skia/filters/StretchShaderFactory.cpp
@@ -69,9 +69,8 @@ static const SkString stretchShader = SkString(R"(
// and the other way around.
uniform float uInterpolationStrength;
- float easeInCubic(float t, float d) {
- float tmp = t * d;
- return tmp * tmp * tmp;
+ float easeIn(float t, float d) {
+ return t * d;
}
float computeOverscrollStart(
@@ -84,7 +83,7 @@ static const SkString stretchShader = SkString(R"(
) {
float offsetPos = uStretchAffectedDist - inPos;
float posBasedVariation = mix(
- 1. ,easeInCubic(offsetPos, uInverseStretchAffectedDist), interpolationStrength);
+ 1. ,easeIn(offsetPos, uInverseStretchAffectedDist), interpolationStrength);
float stretchIntensity = overscroll * posBasedVariation;
return distanceStretched - (offsetPos / (1. + stretchIntensity));
}
@@ -100,7 +99,7 @@ static const SkString stretchShader = SkString(R"(
) {
float offsetPos = inPos - reverseStretchDist;
float posBasedVariation = mix(
- 1. ,easeInCubic(offsetPos, uInverseStretchAffectedDist), interpolationStrength);
+ 1. ,easeIn(offsetPos, uInverseStretchAffectedDist), interpolationStrength);
float stretchIntensity = (-overscroll) * posBasedVariation;
return 1 - (distanceStretched - (offsetPos / (1. + stretchIntensity)));
}