summaryrefslogtreecommitdiffstats
path: root/services/surfaceflinger
diff options
context:
space:
mode:
authorMathias Agopian <mathias@google.com>2011-08-11 18:18:50 -0700
committerMathias Agopian <mathias@google.com>2011-08-11 22:33:02 -0700
commit91b539801833012798b1998c30440136add7e7d4 (patch)
tree737ec453d22c309e022fbe9a1506847d9dec0ecd /services/surfaceflinger
parent0642fed2a226c2ccc85ca1058bb875d3077a41ef (diff)
downloadframeworks_base-91b539801833012798b1998c30440136add7e7d4.zip
frameworks_base-91b539801833012798b1998c30440136add7e7d4.tar.gz
frameworks_base-91b539801833012798b1998c30440136add7e7d4.tar.bz2
SurfaceFlinger doesn't rely on having a custom RefBase destructor
we just use a message to the main thread to destroy our GLES state.
Diffstat (limited to 'services/surfaceflinger')
-rw-r--r--services/surfaceflinger/Layer.cpp16
-rw-r--r--services/surfaceflinger/Layer.h3
-rw-r--r--services/surfaceflinger/SurfaceFlinger.cpp28
-rw-r--r--services/surfaceflinger/SurfaceFlinger.h2
4 files changed, 11 insertions, 38 deletions
diff --git a/services/surfaceflinger/Layer.cpp b/services/surfaceflinger/Layer.cpp
index 505c843..55b354d 100644
--- a/services/surfaceflinger/Layer.cpp
+++ b/services/surfaceflinger/Layer.cpp
@@ -65,14 +65,9 @@ Layer::Layer(SurfaceFlinger* flinger,
glGenTextures(1, &mTextureName);
}
-void Layer::destroy(RefBase const* base) {
- mFlinger->destroyLayer(static_cast<LayerBase const*>(base));
-}
-
void Layer::onFirstRef()
{
LayerBaseClient::onFirstRef();
- setDestroyer(this);
struct FrameQueuedListener : public SurfaceTexture::FrameAvailableListener {
FrameQueuedListener(Layer* layer) : mLayer(layer) { }
@@ -93,7 +88,16 @@ void Layer::onFirstRef()
Layer::~Layer()
{
- glDeleteTextures(1, &mTextureName);
+ class MessageDestroyGLState : public MessageBase {
+ GLuint texture;
+ public:
+ MessageDestroyGLState(GLuint texture) : texture(texture) { }
+ virtual bool handler() {
+ glDeleteTextures(1, &texture);
+ return true;
+ }
+ };
+ mFlinger->postMessageAsync( new MessageDestroyGLState(mTextureName) );
}
void Layer::onFrameQueued() {
diff --git a/services/surfaceflinger/Layer.h b/services/surfaceflinger/Layer.h
index ddfc666..d3ddab4 100644
--- a/services/surfaceflinger/Layer.h
+++ b/services/surfaceflinger/Layer.h
@@ -45,7 +45,7 @@ class GLExtensions;
// ---------------------------------------------------------------------------
-class Layer : public LayerBaseClient, private RefBase::Destroyer
+class Layer : public LayerBaseClient
{
public:
Layer(SurfaceFlinger* flinger, DisplayID display,
@@ -78,7 +78,6 @@ public:
inline const sp<FreezeLock>& getFreezeLock() const { return mFreezeLock; }
protected:
- virtual void destroy(RefBase const* base);
virtual void onFirstRef();
virtual void dump(String8& result, char* scratch, size_t size) const;
diff --git a/services/surfaceflinger/SurfaceFlinger.cpp b/services/surfaceflinger/SurfaceFlinger.cpp
index 4a27701..082effe 100644
--- a/services/surfaceflinger/SurfaceFlinger.cpp
+++ b/services/surfaceflinger/SurfaceFlinger.cpp
@@ -402,9 +402,6 @@ bool SurfaceFlinger::threadLoop()
{
waitForEvent();
- // call Layer's destructor
- handleDestroyLayers();
-
// check for transactions
if (UNLIKELY(mConsoleSignals)) {
handleConsoleEvents();
@@ -597,31 +594,6 @@ void SurfaceFlinger::handleTransactionLocked(uint32_t transactionFlags)
commitTransaction();
}
-void SurfaceFlinger::destroyLayer(LayerBase const* layer)
-{
- Mutex::Autolock _l(mDestroyedLayerLock);
- mDestroyedLayers.add(layer);
- signalEvent();
-}
-
-void SurfaceFlinger::handleDestroyLayers()
-{
- Vector<LayerBase const *> destroyedLayers;
-
- { // scope for the lock
- Mutex::Autolock _l(mDestroyedLayerLock);
- destroyedLayers = mDestroyedLayers;
- mDestroyedLayers.clear();
- }
-
- // call destructors without a lock held
- const size_t count = destroyedLayers.size();
- for (size_t i=0 ; i<count ; i++) {
- //LOGD("destroying %s", destroyedLayers[i]->getName().string());
- delete destroyedLayers[i];
- }
-}
-
sp<FreezeLock> SurfaceFlinger::getFreezeLock() const
{
return new FreezeLock(const_cast<SurfaceFlinger *>(this));
diff --git a/services/surfaceflinger/SurfaceFlinger.h b/services/surfaceflinger/SurfaceFlinger.h
index 15661f0..6f93f5b 100644
--- a/services/surfaceflinger/SurfaceFlinger.h
+++ b/services/surfaceflinger/SurfaceFlinger.h
@@ -189,7 +189,6 @@ public:
status_t addLayer(const sp<LayerBase>& layer);
status_t invalidateLayerVisibility(const sp<LayerBase>& layer);
void invalidateHwcGeometry();
- void destroyLayer(LayerBase const* layer);
sp<Layer> getLayer(const sp<ISurface>& sur) const;
@@ -266,7 +265,6 @@ private:
void handleConsoleEvents();
void handleTransaction(uint32_t transactionFlags);
void handleTransactionLocked(uint32_t transactionFlags);
- void handleDestroyLayers();
void computeVisibleRegions(
const LayerVector& currentLayers,