more clean-up of Surfaceflinger's client management
SurfaceComposerClient now only exist on the WindowManager side,
the client side uses the new SurfaceClient class, which only
exposes what a client needs.
also instead of keeping mappings from IBinder to SurfaceComposerClients
we have a SurfaceClient per Surface (referring to the same IBinder), this
is made possible by the fact that SurfaceClient is very light.
Change-Id: I6a1f7015424f07871632a25ed6a502c55abfcfa6
diff --git a/include/surfaceflinger/SurfaceComposerClient.h b/include/surfaceflinger/SurfaceComposerClient.h
index 8396038..102aebc 100644
--- a/include/surfaceflinger/SurfaceComposerClient.h
+++ b/include/surfaceflinger/SurfaceComposerClient.h
@@ -40,7 +40,9 @@
class ISurfaceComposer;
class DisplayInfo;
-class SurfaceComposerClient : virtual public RefBase
+// ---------------------------------------------------------------------------
+
+class SurfaceComposerClient : public RefBase
{
public:
SurfaceComposerClient();
@@ -52,10 +54,6 @@
// Return the connection of this client
sp<IBinder> connection() const;
- // Retrieve a client for an existing connection.
- static sp<SurfaceComposerClient>
- clientForConnection(const sp<IBinder>& conn);
-
// Forcibly remove connection before all references have gone away.
void dispose();
@@ -135,36 +133,45 @@
status_t setMatrix(SurfaceID id, float dsdx, float dtdx, float dsdy, float dtdy);
status_t setPosition(SurfaceID id, int32_t x, int32_t y);
status_t setSize(SurfaceID id, uint32_t w, uint32_t h);
- void signalServer();
status_t destroySurface(SurfaceID sid);
- SharedClient* getSharedClient() const;
-
private:
- SurfaceComposerClient(const sp<ISurfaceComposer>& sm,
- const sp<IBinder>& conn);
-
- void init(const sp<ISurfaceComposer>& sm,
- const sp<ISurfaceFlingerClient>& conn);
-
+ virtual void onFirstRef();
inline layer_state_t* get_state_l(SurfaceID id);
layer_state_t* lockLayerState(SurfaceID id);
inline void unlockLayerState();
mutable Mutex mLock;
- layer_state_t* mPrebuiltLayerState;
SortedVector<layer_state_t> mStates;
int32_t mTransactionOpen;
+ layer_state_t* mPrebuiltLayerState;
// these don't need to be protected because they never change
// after assignment
status_t mStatus;
- SharedClient* mControl;
- sp<IMemoryHeap> mControlMemory;
sp<ISurfaceFlingerClient> mClient;
- sp<ISurfaceComposer> mSignalServer;
};
+// ---------------------------------------------------------------------------
+
+class SurfaceClient : public RefBase
+{
+ // all these attributes are constants
+ status_t mStatus;
+ SharedClient* mControl;
+ sp<IMemoryHeap> mControlMemory;
+ sp<IBinder> mConnection;
+ sp<ISurfaceComposer> mSignalServer;
+ void init(const sp<IBinder>& conn);
+public:
+ explicit SurfaceClient(const sp<IBinder>& conn);
+ explicit SurfaceClient(const sp<SurfaceComposerClient>& client);
+ status_t initCheck() const;
+ SharedClient* getSharedClient() const;
+ void signalServer() const;
+};
+
+// ---------------------------------------------------------------------------
}; // namespace android
#endif // ANDROID_SF_SURFACE_COMPOSER_CLIENT_H