From 0d1561275e80073807ac04728951782d943f8882 Mon Sep 17 00:00:00 2001 From: Mathias Agopian Date: Tue, 25 Jan 2011 20:17:45 -0800 Subject: [PATCH] fix [3385504] Surface flinger hang when adding dim surface Change-Id: I8e0cda414bcad5854d2ca5dde8370bfd8b2e5ea4 --- services/surfaceflinger/LayerBase.cpp | 5 +++++ services/surfaceflinger/LayerBase.h | 2 ++ services/surfaceflinger/LayerDim.cpp | 10 ++++++++-- services/surfaceflinger/SurfaceFlinger.cpp | 2 +- 4 files changed, 16 insertions(+), 3 deletions(-) diff --git a/services/surfaceflinger/LayerBase.cpp b/services/surfaceflinger/LayerBase.cpp index 464841b39..8d83f0b4e 100644 --- a/services/surfaceflinger/LayerBase.cpp +++ b/services/surfaceflinger/LayerBase.cpp @@ -563,10 +563,15 @@ sp LayerBaseClient::getSurface() if (s == 0) { s = createSurface(); mClientSurface = s; + mClientSurfaceBinder = s->asBinder(); } return s; } +wp LayerBaseClient::getSurfaceBinder() const { + return mClientSurfaceBinder; +} + sp LayerBaseClient::createSurface() const { return new Surface(mFlinger, mIdentity, diff --git a/services/surfaceflinger/LayerBase.h b/services/surfaceflinger/LayerBase.h index 1a34f52ad..8ed474972 100644 --- a/services/surfaceflinger/LayerBase.h +++ b/services/surfaceflinger/LayerBase.h @@ -285,6 +285,7 @@ public: virtual ~LayerBaseClient(); sp getSurface(); + wp getSurfaceBinder() const; virtual sp createSurface() const; virtual sp getLayerBaseClient() const { return const_cast(this); } @@ -325,6 +326,7 @@ protected: private: mutable Mutex mLock; mutable wp mClientSurface; + wp mClientSurfaceBinder; const wp mClientRef; // only read const uint32_t mIdentity; diff --git a/services/surfaceflinger/LayerDim.cpp b/services/surfaceflinger/LayerDim.cpp index 80cc52c42..11f8feb1f 100644 --- a/services/surfaceflinger/LayerDim.cpp +++ b/services/surfaceflinger/LayerDim.cpp @@ -67,8 +67,14 @@ void LayerDim::onDraw(const Region& clip) const const GLfloat alpha = s.alpha/255.0f; const uint32_t fbHeight = hw.getHeight(); glDisable(GL_DITHER); - glEnable(GL_BLEND); - glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA); + + if (s.alpha == 0xFF) { + glDisable(GL_BLEND); + } else { + glEnable(GL_BLEND); + glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA); + } + glColor4f(0, 0, 0, alpha); #if defined(GL_OES_EGL_image_external) diff --git a/services/surfaceflinger/SurfaceFlinger.cpp b/services/surfaceflinger/SurfaceFlinger.cpp index 291ebc570..87b66eafa 100644 --- a/services/surfaceflinger/SurfaceFlinger.cpp +++ b/services/surfaceflinger/SurfaceFlinger.cpp @@ -1088,7 +1088,7 @@ status_t SurfaceFlinger::removeLayer_l(const sp& layerBase) { sp lbc(layerBase->getLayerBaseClient()); if (lbc != 0) { - mLayerMap.removeItem( lbc->getSurface()->asBinder() ); + mLayerMap.removeItem( lbc->getSurfaceBinder() ); } ssize_t index = mCurrentState.layersSortedByZ.remove(layerBase); if (index >= 0) {