From 1c97d2ebe1f035beabd90089bfc78326b73d7864 Mon Sep 17 00:00:00 2001 From: Mathias Agopian Date: Wed, 19 Aug 2009 17:46:26 -0700 Subject: [PATCH] fix a bug that caused the PixelFormat viewed by Surface to be wrong. what happened is that the efective pixel format is calculated by SF but Surface nevew had access to it directly. in particular this caused query(FORMAT) to return the requested format instead of the effective format. --- include/ui/ISurfaceFlingerClient.h | 3 +++ libs/surfaceflinger/LayerBase.cpp | 8 -------- libs/surfaceflinger/LayerBase.h | 5 ++--- libs/surfaceflinger/SurfaceFlinger.cpp | 18 +++++++++++++----- libs/surfaceflinger/SurfaceFlinger.h | 4 ++-- libs/ui/ISurfaceFlingerClient.cpp | 10 ++++++++-- libs/ui/Surface.cpp | 3 ++- 7 files changed, 30 insertions(+), 21 deletions(-) diff --git a/include/ui/ISurfaceFlingerClient.h b/include/ui/ISurfaceFlingerClient.h index 932a70a85..5d231e6d9 100644 --- a/include/ui/ISurfaceFlingerClient.h +++ b/include/ui/ISurfaceFlingerClient.h @@ -52,6 +52,9 @@ public: struct surface_data_t { int32_t token; int32_t identity; + uint32_t width; + uint32_t height; + uint32_t format; status_t readFromParcel(const Parcel& parcel); status_t writeToParcel(Parcel* parcel) const; }; diff --git a/libs/surfaceflinger/LayerBase.cpp b/libs/surfaceflinger/LayerBase.cpp index 419574c7d..fd54e353a 100644 --- a/libs/surfaceflinger/LayerBase.cpp +++ b/libs/surfaceflinger/LayerBase.cpp @@ -730,14 +730,6 @@ sp LayerBaseClient::Surface::getOwner() const { return owner; } - -void LayerBaseClient::Surface::getSurfaceData( - ISurfaceFlingerClient::surface_data_t* params) const -{ - params->token = mToken; - params->identity = mIdentity; -} - status_t LayerBaseClient::Surface::onTransact( uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags) { diff --git a/libs/surfaceflinger/LayerBase.h b/libs/surfaceflinger/LayerBase.h index 65bf55b51..7791941a1 100644 --- a/libs/surfaceflinger/LayerBase.h +++ b/libs/surfaceflinger/LayerBase.h @@ -321,10 +321,9 @@ public: class Surface : public BnSurface { public: + int32_t getToken() const { return mToken; } + int32_t getIdentity() const { return mIdentity; } - virtual void getSurfaceData( - ISurfaceFlingerClient::surface_data_t* params) const; - protected: Surface(const sp& flinger, SurfaceID id, int identity, diff --git a/libs/surfaceflinger/SurfaceFlinger.cpp b/libs/surfaceflinger/SurfaceFlinger.cpp index 102899c56..3824024a3 100644 --- a/libs/surfaceflinger/SurfaceFlinger.cpp +++ b/libs/surfaceflinger/SurfaceFlinger.cpp @@ -1239,9 +1239,11 @@ sp SurfaceFlinger::createSurface(ClientID clientId, int pid, switch (flags & eFXSurfaceMask) { case eFXSurfaceNormal: if (UNLIKELY(flags & ePushBuffers)) { - layer = createPushBuffersSurfaceLocked(client, d, id, w, h, flags); + layer = createPushBuffersSurfaceLocked(client, d, id, + w, h, flags); } else { - layer = createNormalSurfaceLocked(client, d, id, w, h, format, flags); + layer = createNormalSurfaceLocked(client, d, id, + w, h, flags, format); } break; case eFXSurfaceBlur: @@ -1255,8 +1257,13 @@ sp SurfaceFlinger::createSurface(ClientID clientId, int pid, if (layer != 0) { setTransactionFlags(eTransactionNeeded); surfaceHandle = layer->getSurface(); - if (surfaceHandle != 0) - surfaceHandle->getSurfaceData(params); + if (surfaceHandle != 0) { + params->token = surfaceHandle->getToken(); + params->identity = surfaceHandle->getIdentity(); + params->width = w; + params->height = h; + params->format = format; + } } return surfaceHandle; @@ -1264,7 +1271,8 @@ sp SurfaceFlinger::createSurface(ClientID clientId, int pid, sp SurfaceFlinger::createNormalSurfaceLocked( const sp& client, DisplayID display, - int32_t id, uint32_t w, uint32_t h, PixelFormat format, uint32_t flags) + int32_t id, uint32_t w, uint32_t h, uint32_t flags, + PixelFormat& format) { // initialize the surfaces switch (format) { // TODO: take h/w into account diff --git a/libs/surfaceflinger/SurfaceFlinger.h b/libs/surfaceflinger/SurfaceFlinger.h index 2569a0f1c..56ea97a4b 100644 --- a/libs/surfaceflinger/SurfaceFlinger.h +++ b/libs/surfaceflinger/SurfaceFlinger.h @@ -195,8 +195,8 @@ private: sp createNormalSurfaceLocked( const sp& client, DisplayID display, - int32_t id, uint32_t w, uint32_t h, - PixelFormat format, uint32_t flags); + int32_t id, uint32_t w, uint32_t h, uint32_t flags, + PixelFormat& format); sp createBlurSurfaceLocked( const sp& client, DisplayID display, diff --git a/libs/ui/ISurfaceFlingerClient.cpp b/libs/ui/ISurfaceFlingerClient.cpp index 51e842260..4a6a1d701 100644 --- a/libs/ui/ISurfaceFlingerClient.cpp +++ b/libs/ui/ISurfaceFlingerClient.cpp @@ -189,8 +189,11 @@ status_t BnSurfaceFlingerClient::onTransact( status_t ISurfaceFlingerClient::surface_data_t::readFromParcel(const Parcel& parcel) { - token = parcel.readInt32(); - identity = parcel.readInt32(); + token = parcel.readInt32(); + identity = parcel.readInt32(); + width = parcel.readInt32(); + height = parcel.readInt32(); + format = parcel.readInt32(); return NO_ERROR; } @@ -198,6 +201,9 @@ status_t ISurfaceFlingerClient::surface_data_t::writeToParcel(Parcel* parcel) co { parcel->writeInt32(token); parcel->writeInt32(identity); + parcel->writeInt32(width); + parcel->writeInt32(height); + parcel->writeInt32(format); return NO_ERROR; } diff --git a/libs/ui/Surface.cpp b/libs/ui/Surface.cpp index 0ba0a6574..36a10cfa6 100644 --- a/libs/ui/Surface.cpp +++ b/libs/ui/Surface.cpp @@ -197,7 +197,8 @@ SurfaceControl::SurfaceControl( uint32_t w, uint32_t h, PixelFormat format, uint32_t flags) : mClient(client), mSurface(surface), mToken(data.token), mIdentity(data.identity), - mWidth(w), mHeight(h), mFormat(format), mFlags(flags) + mWidth(data.width), mHeight(data.height), mFormat(data.format), + mFlags(flags) { }