SurfaceFlinger and libgui: Switch Z-order to signed type.
In preparation for SurfaceFlinger child layers. In that model
children's Z order will be relative to their parent. We need
negative Z values to represent children stacking below their
parent (e.g. SurfaceView). Java side already uses signed types
strangely enough.
Test: Basically a refactoring. SurfaceFlinger still works.
Change-Id: Ifcece69f6f9d917cbf5238a59f8e5de1e8ba6a25
diff --git a/libs/gui/ISurfaceComposer.cpp b/libs/gui/ISurfaceComposer.cpp
index fa2f59a..74c3bed 100644
--- a/libs/gui/ISurfaceComposer.cpp
+++ b/libs/gui/ISurfaceComposer.cpp
@@ -104,7 +104,7 @@
virtual status_t captureScreen(const sp<IBinder>& display,
const sp<IGraphicBufferProducer>& producer,
Rect sourceCrop, uint32_t reqWidth, uint32_t reqHeight,
- uint32_t minLayerZ, uint32_t maxLayerZ,
+ int32_t minLayerZ, int32_t maxLayerZ,
bool useIdentityTransform,
ISurfaceComposer::Rotation rotation)
{
@@ -115,8 +115,8 @@
data.write(sourceCrop);
data.writeUint32(reqWidth);
data.writeUint32(reqHeight);
- data.writeUint32(minLayerZ);
- data.writeUint32(maxLayerZ);
+ data.writeInt32(minLayerZ);
+ data.writeInt32(maxLayerZ);
data.writeInt32(static_cast<int32_t>(useIdentityTransform));
data.writeInt32(static_cast<int32_t>(rotation));
remote()->transact(BnSurfaceComposer::CAPTURE_SCREEN, data, &reply);
@@ -544,8 +544,8 @@
data.read(sourceCrop);
uint32_t reqWidth = data.readUint32();
uint32_t reqHeight = data.readUint32();
- uint32_t minLayerZ = data.readUint32();
- uint32_t maxLayerZ = data.readUint32();
+ int32_t minLayerZ = data.readInt32();
+ int32_t maxLayerZ = data.readInt32();
bool useIdentityTransform = static_cast<bool>(data.readInt32());
int32_t rotation = data.readInt32();
diff --git a/libs/gui/LayerState.cpp b/libs/gui/LayerState.cpp
index 3949186..16bf324 100644
--- a/libs/gui/LayerState.cpp
+++ b/libs/gui/LayerState.cpp
@@ -28,7 +28,7 @@
output.writeUint32(what);
output.writeFloat(x);
output.writeFloat(y);
- output.writeUint32(z);
+ output.writeInt32(z);
output.writeUint32(w);
output.writeUint32(h);
output.writeUint32(layerStack);
@@ -54,7 +54,7 @@
what = input.readUint32();
x = input.readFloat();
y = input.readFloat();
- z = input.readUint32();
+ z = input.readInt32();
w = input.readUint32();
h = input.readUint32();
layerStack = input.readUint32();
diff --git a/libs/gui/SurfaceComposerClient.cpp b/libs/gui/SurfaceComposerClient.cpp
index 3346a83..540dbd9 100644
--- a/libs/gui/SurfaceComposerClient.cpp
+++ b/libs/gui/SurfaceComposerClient.cpp
@@ -148,7 +148,7 @@
status_t setSize(const sp<SurfaceComposerClient>& client, const sp<IBinder>& id,
uint32_t w, uint32_t h);
status_t setLayer(const sp<SurfaceComposerClient>& client, const sp<IBinder>& id,
- uint32_t z);
+ int32_t z);
status_t setLayerInfo(const sp<SurfaceComposerClient>& client, const sp<IBinder>& id,
uint32_t type, uint32_t appid);
status_t setFlags(const sp<SurfaceComposerClient>& client, const sp<IBinder>& id,
@@ -327,7 +327,7 @@
}
status_t Composer::setLayer(const sp<SurfaceComposerClient>& client,
- const sp<IBinder>& id, uint32_t z) {
+ const sp<IBinder>& id, int32_t z) {
Mutex::Autolock _l(mLock);
layer_state_t* s = getLayerStateLocked(client, id);
if (!s)
@@ -714,7 +714,7 @@
return getComposer().setSize(this, id, w, h);
}
-status_t SurfaceComposerClient::setLayer(const sp<IBinder>& id, uint32_t z) {
+status_t SurfaceComposerClient::setLayer(const sp<IBinder>& id, int32_t z) {
return getComposer().setLayer(this, id, z);
}
@@ -871,7 +871,7 @@
const sp<IBinder>& display,
const sp<IGraphicBufferProducer>& producer,
Rect sourceCrop, uint32_t reqWidth, uint32_t reqHeight,
- uint32_t minLayerZ, uint32_t maxLayerZ, bool useIdentityTransform) {
+ int32_t minLayerZ, int32_t maxLayerZ, bool useIdentityTransform) {
sp<ISurfaceComposer> s(ComposerService::getComposerService());
if (s == NULL) return NO_INIT;
return s->captureScreen(display, producer, sourceCrop,
@@ -880,7 +880,7 @@
status_t ScreenshotClient::captureToBuffer(const sp<IBinder>& display,
Rect sourceCrop, uint32_t reqWidth, uint32_t reqHeight,
- uint32_t minLayerZ, uint32_t maxLayerZ, bool useIdentityTransform,
+ int32_t minLayerZ, int32_t maxLayerZ, bool useIdentityTransform,
uint32_t rotation,
sp<GraphicBuffer>* outBuffer) {
sp<ISurfaceComposer> s(ComposerService::getComposerService());
@@ -926,7 +926,7 @@
status_t ScreenshotClient::update(const sp<IBinder>& display,
Rect sourceCrop, uint32_t reqWidth, uint32_t reqHeight,
- uint32_t minLayerZ, uint32_t maxLayerZ,
+ int32_t minLayerZ, int32_t maxLayerZ,
bool useIdentityTransform, uint32_t rotation) {
sp<ISurfaceComposer> s(ComposerService::getComposerService());
if (s == NULL) return NO_INIT;
@@ -953,7 +953,7 @@
status_t ScreenshotClient::update(const sp<IBinder>& display,
Rect sourceCrop, uint32_t reqWidth, uint32_t reqHeight,
- uint32_t minLayerZ, uint32_t maxLayerZ,
+ int32_t minLayerZ, int32_t maxLayerZ,
bool useIdentityTransform) {
return ScreenshotClient::update(display, sourceCrop, reqWidth, reqHeight,
@@ -962,14 +962,16 @@
status_t ScreenshotClient::update(const sp<IBinder>& display, Rect sourceCrop,
bool useIdentityTransform) {
- return ScreenshotClient::update(display, sourceCrop, 0, 0, 0, -1U,
+ return ScreenshotClient::update(display, sourceCrop, 0, 0,
+ INT32_MIN, INT32_MAX,
useIdentityTransform, ISurfaceComposer::eRotateNone);
}
status_t ScreenshotClient::update(const sp<IBinder>& display, Rect sourceCrop,
uint32_t reqWidth, uint32_t reqHeight, bool useIdentityTransform) {
return ScreenshotClient::update(display, sourceCrop, reqWidth, reqHeight,
- 0, -1U, useIdentityTransform, ISurfaceComposer::eRotateNone);
+ INT32_MIN, INT32_MAX,
+ useIdentityTransform, ISurfaceComposer::eRotateNone);
}
void ScreenshotClient::release() {
diff --git a/libs/gui/SurfaceControl.cpp b/libs/gui/SurfaceControl.cpp
index b47e434..c82f6a7 100644
--- a/libs/gui/SurfaceControl.cpp
+++ b/libs/gui/SurfaceControl.cpp
@@ -102,7 +102,7 @@
if (err < 0) return err;
return mClient->setLayerStack(mHandle, layerStack);
}
-status_t SurfaceControl::setLayer(uint32_t layer) {
+status_t SurfaceControl::setLayer(int32_t layer) {
status_t err = validate();
if (err < 0) return err;
return mClient->setLayer(mHandle, layer);
diff --git a/libs/gui/tests/Surface_test.cpp b/libs/gui/tests/Surface_test.cpp
index e40b4eb..7b78175 100644
--- a/libs/gui/tests/Surface_test.cpp
+++ b/libs/gui/tests/Surface_test.cpp
@@ -398,7 +398,7 @@
status_t captureScreen(const sp<IBinder>& /*display*/,
const sp<IGraphicBufferProducer>& /*producer*/,
Rect /*sourceCrop*/, uint32_t /*reqWidth*/, uint32_t /*reqHeight*/,
- uint32_t /*minLayerZ*/, uint32_t /*maxLayerZ*/,
+ int32_t /*minLayerZ*/, int32_t /*maxLayerZ*/,
bool /*useIdentityTransform*/,
Rotation /*rotation*/) override { return NO_ERROR; }
status_t clearAnimationFrameStats() override { return NO_ERROR; }