VR: Add API to plumb surface type and owner through to SurfaceFlinger
This is a cherry-pick of
https://googleplex-android-review.git.corp.google.com/c/1648886/
Test: None
Bug: None
Change-Id: I338c84c2576ab85fa4f6d8e759c9e7ce912cdd61
diff --git a/include/gui/SurfaceComposerClient.h b/include/gui/SurfaceComposerClient.h
index b86c72c..183b42d 100644
--- a/include/gui/SurfaceComposerClient.h
+++ b/include/gui/SurfaceComposerClient.h
@@ -143,6 +143,7 @@
status_t setFlags(const sp<IBinder>& id, uint32_t flags, uint32_t mask);
status_t setTransparentRegionHint(const sp<IBinder>& id, const Region& transparent);
status_t setLayer(const sp<IBinder>& id, uint32_t layer);
+ status_t setLayerInfo(const sp<IBinder>& id, uint32_t type, uint32_t appid);
status_t setAlpha(const sp<IBinder>& id, float alpha=1.0f);
status_t setMatrix(const sp<IBinder>& id, float dsdx, float dtdx, float dsdy, float dtdy);
status_t setPosition(const sp<IBinder>& id, float x, float y);
diff --git a/include/gui/SurfaceControl.h b/include/gui/SurfaceControl.h
index 5e731c3..456bde4 100644
--- a/include/gui/SurfaceControl.h
+++ b/include/gui/SurfaceControl.h
@@ -62,6 +62,7 @@
status_t setLayerStack(uint32_t layerStack);
status_t setLayer(uint32_t layer);
+ status_t setLayerInfo(uint32_t type, uint32_t appid);
status_t setPosition(float x, float y);
status_t setSize(uint32_t w, uint32_t h);
status_t hide();
diff --git a/include/private/gui/LayerState.h b/include/private/gui/LayerState.h
index 292dd3b..b648751 100644
--- a/include/private/gui/LayerState.h
+++ b/include/private/gui/LayerState.h
@@ -56,6 +56,7 @@
eFinalCropChanged = 0x00000400,
eOverrideScalingModeChanged = 0x00000800,
eGeometryAppliesWithResize = 0x00001000,
+ eLayerInfoChanged = 0x00002000,
};
layer_state_t()
@@ -64,7 +65,7 @@
alpha(0), flags(0), mask(0),
reserved(0), crop(Rect::INVALID_RECT),
finalCrop(Rect::INVALID_RECT), frameNumber(0),
- overrideScalingMode(-1)
+ overrideScalingMode(-1), type(0), appid(0)
{
matrix.dsdx = matrix.dtdy = 1.0f;
matrix.dsdy = matrix.dtdx = 0.0f;
@@ -97,6 +98,8 @@
sp<IBinder> handle;
uint64_t frameNumber;
int32_t overrideScalingMode;
+ uint32_t type;
+ uint32_t appid;
// non POD must be last. see write/read
Region transparentRegion;
};
diff --git a/libs/gui/LayerState.cpp b/libs/gui/LayerState.cpp
index d1c576e..3949186 100644
--- a/libs/gui/LayerState.cpp
+++ b/libs/gui/LayerState.cpp
@@ -42,6 +42,8 @@
output.writeStrongBinder(handle);
output.writeUint64(frameNumber);
output.writeInt32(overrideScalingMode);
+ output.writeUint32(type);
+ output.writeUint32(appid);
output.write(transparentRegion);
return NO_ERROR;
}
@@ -70,6 +72,8 @@
handle = input.readStrongBinder();
frameNumber = input.readUint64();
overrideScalingMode = input.readInt32();
+ type = input.readUint32();
+ appid = input.readUint32();
input.read(transparentRegion);
return NO_ERROR;
}
diff --git a/libs/gui/SurfaceComposerClient.cpp b/libs/gui/SurfaceComposerClient.cpp
index 58b2a87..3346a83 100644
--- a/libs/gui/SurfaceComposerClient.cpp
+++ b/libs/gui/SurfaceComposerClient.cpp
@@ -149,6 +149,8 @@
uint32_t w, uint32_t h);
status_t setLayer(const sp<SurfaceComposerClient>& client, const sp<IBinder>& id,
uint32_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,
uint32_t flags, uint32_t mask);
status_t setTransparentRegionHint(
@@ -335,6 +337,18 @@
return NO_ERROR;
}
+status_t Composer::setLayerInfo(const sp<SurfaceComposerClient>& client,
+ const sp<IBinder>& id, uint32_t type, uint32_t appid) {
+ Mutex::Autolock _l(mLock);
+ layer_state_t* s = getLayerStateLocked(client, id);
+ if (!s)
+ return BAD_INDEX;
+ s->what |= layer_state_t::eLayerInfoChanged;
+ s->type = type;
+ s->appid = appid;
+ return NO_ERROR;
+}
+
status_t Composer::setFlags(const sp<SurfaceComposerClient>& client,
const sp<IBinder>& id, uint32_t flags,
uint32_t mask) {
@@ -704,6 +718,10 @@
return getComposer().setLayer(this, id, z);
}
+status_t SurfaceComposerClient::setLayerInfo(const sp<IBinder>& id, uint32_t type, uint32_t appid) {
+ return getComposer().setLayerInfo(this, id, type, appid);
+}
+
status_t SurfaceComposerClient::hide(const sp<IBinder>& id) {
return getComposer().setFlags(this, id,
layer_state_t::eLayerHidden,
diff --git a/libs/gui/SurfaceControl.cpp b/libs/gui/SurfaceControl.cpp
index 33c1d90..b47e434 100644
--- a/libs/gui/SurfaceControl.cpp
+++ b/libs/gui/SurfaceControl.cpp
@@ -107,6 +107,11 @@
if (err < 0) return err;
return mClient->setLayer(mHandle, layer);
}
+status_t SurfaceControl::setLayerInfo(uint32_t type, uint32_t appid) {
+ status_t err = validate();
+ if (err < 0) return err;
+ return mClient->setLayerInfo(mHandle, type, appid);
+}
status_t SurfaceControl::setPosition(float x, float y) {
status_t err = validate();
if (err < 0) return err;