summaryrefslogtreecommitdiff
path: root/libs
diff options
context:
space:
mode:
author chaviw <chaviw@google.com> 2021-04-27 15:54:02 -0500
committer chaviw <chaviw@google.com> 2021-04-27 16:47:34 -0500
commitf3f40fefdd67eab97aefdd62a08ab99eef442039 (patch)
tree5adf1f76d5fee836786a956f212ed05c0414aa20 /libs
parentcfd247d31873412d6369d63033a57f1741b9230d (diff)
Added setBufferCrop
Added setBufferCrop to handle setGeometry calls from the public SurfaceControl. This is because setGeometry gets crop in buffer space, but setCrop can only handle layer space crop. Added setBufferCrop to handle this case Test: ASurfaceControlTest Fixes: 186266903 Change-Id: I14fb329d2d6f504ca8fa8e330c8a036cbde56f28
Diffstat (limited to 'libs')
-rw-r--r--libs/gui/LayerState.cpp8
-rw-r--r--libs/gui/SurfaceComposerClient.cpp15
-rw-r--r--libs/gui/include/gui/LayerState.h4
-rw-r--r--libs/gui/include/gui/SurfaceComposerClient.h2
4 files changed, 26 insertions, 3 deletions
diff --git a/libs/gui/LayerState.cpp b/libs/gui/LayerState.cpp
index 517b49e6b5..267db7686a 100644
--- a/libs/gui/LayerState.cpp
+++ b/libs/gui/LayerState.cpp
@@ -98,7 +98,6 @@ status_t layer_state_t::write(Parcel& output) const
SAFE_PARCEL(output.write, transparentRegion);
SAFE_PARCEL(output.writeUint32, transform);
SAFE_PARCEL(output.writeBool, transformToDisplayInverse);
- SAFE_PARCEL(output.write, crop);
SAFE_PARCEL(output.write, orientedDisplaySpaceRect);
if (buffer) {
@@ -167,6 +166,7 @@ status_t layer_state_t::write(Parcel& output) const
}
SAFE_PARCEL(output.write, stretchEffect);
+ SAFE_PARCEL(output.write, bufferCrop);
return NO_ERROR;
}
@@ -209,7 +209,6 @@ status_t layer_state_t::read(const Parcel& input)
SAFE_PARCEL(input.read, transparentRegion);
SAFE_PARCEL(input.readUint32, &transform);
SAFE_PARCEL(input.readBool, &transformToDisplayInverse);
- SAFE_PARCEL(input.read, crop);
SAFE_PARCEL(input.read, orientedDisplaySpaceRect);
bool tmpBool = false;
@@ -296,6 +295,7 @@ status_t layer_state_t::read(const Parcel& input)
}
SAFE_PARCEL(input.read, stretchEffect);
+ SAFE_PARCEL(input.read, bufferCrop);
return NO_ERROR;
}
@@ -539,6 +539,10 @@ void layer_state_t::merge(const layer_state_t& other) {
what |= eStretchChanged;
stretchEffect = other.stretchEffect;
}
+ if (other.what & eBufferCropChanged) {
+ what |= eBufferCropChanged;
+ bufferCrop = other.bufferCrop;
+ }
if ((other.what & what) != other.what) {
ALOGE("Unmerged SurfaceComposer Transaction properties. LayerState::merge needs updating? "
"other.what=0x%" PRIu64 " what=0x%" PRIu64,
diff --git a/libs/gui/SurfaceComposerClient.cpp b/libs/gui/SurfaceComposerClient.cpp
index 5db0eae416..808b731d8f 100644
--- a/libs/gui/SurfaceComposerClient.cpp
+++ b/libs/gui/SurfaceComposerClient.cpp
@@ -1664,6 +1664,21 @@ SurfaceComposerClient::Transaction& SurfaceComposerClient::Transaction::setStret
return *this;
}
+SurfaceComposerClient::Transaction& SurfaceComposerClient::Transaction::setBufferCrop(
+ const sp<SurfaceControl>& sc, const Rect& bufferCrop) {
+ layer_state_t* s = getLayerState(sc);
+ if (!s) {
+ mStatus = BAD_INDEX;
+ return *this;
+ }
+
+ s->what |= layer_state_t::eBufferCropChanged;
+ s->bufferCrop = bufferCrop;
+
+ registerSurfaceControlForCallback(sc);
+ return *this;
+}
+
// ---------------------------------------------------------------------------
DisplayState& SurfaceComposerClient::Transaction::getDisplayState(const sp<IBinder>& token) {
diff --git a/libs/gui/include/gui/LayerState.h b/libs/gui/include/gui/LayerState.h
index b4f62f2206..3947f22462 100644
--- a/libs/gui/include/gui/LayerState.h
+++ b/libs/gui/include/gui/LayerState.h
@@ -85,7 +85,7 @@ struct layer_state_t {
eReleaseBufferListenerChanged = 0x00000400,
eShadowRadiusChanged = 0x00000800,
eLayerCreated = 0x00001000,
- /* was eDetachChildren, now available 0x00002000, */
+ eBufferCropChanged = 0x00002000,
eRelativeLayerChanged = 0x00004000,
eReparent = 0x00008000,
eColorChanged = 0x00010000,
@@ -227,6 +227,8 @@ struct layer_state_t {
// Stretch effect to be applied to this layer
StretchEffect stretchEffect;
+ Rect bufferCrop;
+
// Listens to when the buffer is safe to be released. This is used for blast
// layers only. The callback includes a release fence as well as the graphic
// buffer id to identify the buffer.
diff --git a/libs/gui/include/gui/SurfaceComposerClient.h b/libs/gui/include/gui/SurfaceComposerClient.h
index 5bbd8e3d85..f3439c4c84 100644
--- a/libs/gui/include/gui/SurfaceComposerClient.h
+++ b/libs/gui/include/gui/SurfaceComposerClient.h
@@ -542,6 +542,8 @@ public:
float right, float bottom, float vecX, float vecY,
float maxAmount);
+ Transaction& setBufferCrop(const sp<SurfaceControl>& sc, const Rect& bufferCrop);
+
status_t setDisplaySurface(const sp<IBinder>& token,
const sp<IGraphicBufferProducer>& bufferProducer);