Update SurfaceFlinger to handle stretching
of surfaces that are part of a scrolling container
Bug: 184297961
Test: In progress
Change-Id: I959df097ae1fc833fb755f1fb2d759d79f260963
diff --git a/libs/gui/LayerDebugInfo.cpp b/libs/gui/LayerDebugInfo.cpp
index e707684..0827bbe 100644
--- a/libs/gui/LayerDebugInfo.cpp
+++ b/libs/gui/LayerDebugInfo.cpp
@@ -119,9 +119,11 @@
info.mSurfaceDamageRegion.dump(result, "SurfaceDamageRegion");
if (info.mStretchEffect.hasEffect()) {
const auto& se = info.mStretchEffect;
- StringAppendF(&result, " StretchEffect area=[%f, %f, %f, %f] vec=(%f, %f) maxAmount=%f\n",
- se.area.left, se.area.top, se.area.right, se.area.bottom, se.vectorX,
- se.vectorY, se.maxAmount);
+ StringAppendF(&result,
+ " StretchEffect width = %f, height = %f vec=(%f, %f) "
+ "maxAmount=(%f, %f)\n",
+ se.width, se.height,
+ se.vectorX, se.vectorY, se.maxAmountX, se.maxAmountY);
}
StringAppendF(&result, " layerStack=%4d, z=%9d, pos=(%g,%g), size=(%4d,%4d), ",
diff --git a/libs/gui/SurfaceComposerClient.cpp b/libs/gui/SurfaceComposerClient.cpp
index 808b731..11b8eba 100644
--- a/libs/gui/SurfaceComposerClient.cpp
+++ b/libs/gui/SurfaceComposerClient.cpp
@@ -1648,8 +1648,7 @@
}
SurfaceComposerClient::Transaction& SurfaceComposerClient::Transaction::setStretchEffect(
- const sp<SurfaceControl>& sc, float left, float top, float right, float bottom, float vecX,
- float vecY, float maxAmount) {
+ const sp<SurfaceControl>& sc, const StretchEffect& stretchEffect) {
layer_state_t* s = getLayerState(sc);
if (!s) {
mStatus = BAD_INDEX;
@@ -1657,10 +1656,7 @@
}
s->what |= layer_state_t::eStretchChanged;
- s->stretchEffect = StretchEffect{.area = {left, top, right, bottom},
- .vectorX = vecX,
- .vectorY = vecY,
- .maxAmount = maxAmount};
+ s->stretchEffect = stretchEffect;
return *this;
}
diff --git a/libs/gui/include/gui/SurfaceComposerClient.h b/libs/gui/include/gui/SurfaceComposerClient.h
index f3439c4..35757be 100644
--- a/libs/gui/include/gui/SurfaceComposerClient.h
+++ b/libs/gui/include/gui/SurfaceComposerClient.h
@@ -538,9 +538,20 @@
// transactions from blocking each other.
Transaction& setApplyToken(const sp<IBinder>& token);
- Transaction& setStretchEffect(const sp<SurfaceControl>& sc, float left, float top,
- float right, float bottom, float vecX, float vecY,
- float maxAmount);
+ /**
+ * Provides the stretch effect configured on a container that the
+ * surface is rendered within.
+ * @param sc target surface the stretch should be applied to
+ * @param stretchEffect the corresponding stretch effect to be applied
+ * to the surface. This can be directly on the surface itself or
+ * configured from a parent of the surface in which case the
+ * StretchEffect provided has parameters mapping the position of
+ * the surface within the container that has the stretch configured
+ * on it
+ * @return The transaction being constructed
+ */
+ Transaction& setStretchEffect(const sp<SurfaceControl>& sc,
+ const StretchEffect& stretchEffect);
Transaction& setBufferCrop(const sp<SurfaceControl>& sc, const Rect& bufferCrop);