OSDN Git Service

VR: Add API to plumb surface type and owner through to SurfaceFlinger
authorAlbert Chaulk <achaulk@google.com>
Tue, 22 Nov 2016 18:52:43 +0000 (13:52 -0500)
committerDaniel Nicoara <dnicoara@google.com>
Tue, 24 Jan 2017 15:59:40 +0000 (10:59 -0500)
This is a cherry-pick of
https://googleplex-android-review.git.corp.google.com/c/1648886/

Test: None
Bug: None
Change-Id: I338c84c2576ab85fa4f6d8e759c9e7ce912cdd61

include/gui/SurfaceComposerClient.h
include/gui/SurfaceControl.h
include/private/gui/LayerState.h
libs/gui/LayerState.cpp
libs/gui/SurfaceComposerClient.cpp
libs/gui/SurfaceControl.cpp

index b86c72c..183b42d 100644 (file)
@@ -143,6 +143,7 @@ public:
     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);
index 5e731c3..456bde4 100644 (file)
@@ -62,6 +62,7 @@ public:
 
     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();
index 292dd3b..b648751 100644 (file)
@@ -56,6 +56,7 @@ struct layer_state_t {
         eFinalCropChanged           = 0x00000400,
         eOverrideScalingModeChanged = 0x00000800,
         eGeometryAppliesWithResize  = 0x00001000,
+        eLayerInfoChanged           = 0x00002000,
     };
 
     layer_state_t()
@@ -64,7 +65,7 @@ struct layer_state_t {
             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 @@ struct layer_state_t {
             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;
 };
index d1c576e..3949186 100644 (file)
@@ -42,6 +42,8 @@ status_t layer_state_t::write(Parcel& output) const
     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 @@ status_t layer_state_t::read(const Parcel& input)
     handle = input.readStrongBinder();
     frameNumber = input.readUint64();
     overrideScalingMode = input.readInt32();
+    type = input.readUint32();
+    appid = input.readUint32();
     input.read(transparentRegion);
     return NO_ERROR;
 }
index 58b2a87..3346a83 100644 (file)
@@ -149,6 +149,8 @@ public:
             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 @@ status_t Composer::setLayer(const sp<SurfaceComposerClient>& client,
     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 @@ status_t SurfaceComposerClient::setLayer(const sp<IBinder>& id, uint32_t z) {
     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,
index 33c1d90..b47e434 100644 (file)
@@ -107,6 +107,11 @@ status_t SurfaceControl::setLayer(uint32_t layer) {
     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;