diff options
| -rw-r--r-- | include/utils/RefBase.h | 62 | ||||
| -rw-r--r-- | libs/ui/GraphicBufferAllocator.cpp | 2 | ||||
| -rw-r--r-- | libs/ui/InputDispatcher.cpp | 10 | ||||
| -rw-r--r-- | opengl/libs/EGL/egl.cpp | 51 | ||||
| -rw-r--r-- | services/surfaceflinger/LayerBase.cpp | 12 | ||||
| -rw-r--r-- | services/surfaceflinger/LayerBase.h | 2 | ||||
| -rw-r--r-- | services/surfaceflinger/SurfaceFlinger.cpp | 47 | ||||
| -rw-r--r-- | services/surfaceflinger/SurfaceFlinger.h | 1 |
8 files changed, 88 insertions, 99 deletions
diff --git a/include/utils/RefBase.h b/include/utils/RefBase.h index 9c64ac0443..c24c0dbcb2 100644 --- a/include/utils/RefBase.h +++ b/include/utils/RefBase.h @@ -31,13 +31,10 @@ template<typename T> class wp; // --------------------------------------------------------------------------- -#define COMPARE(_op_) \ +#define COMPARE_WEAK(_op_) \ inline bool operator _op_ (const sp<T>& o) const { \ return m_ptr _op_ o.m_ptr; \ } \ -inline bool operator _op_ (const wp<T>& o) const { \ - return m_ptr _op_ o.m_ptr; \ -} \ inline bool operator _op_ (const T* o) const { \ return m_ptr _op_ o; \ } \ @@ -46,12 +43,18 @@ inline bool operator _op_ (const sp<U>& o) const { \ return m_ptr _op_ o.m_ptr; \ } \ template<typename U> \ -inline bool operator _op_ (const wp<U>& o) const { \ +inline bool operator _op_ (const U* o) const { \ + return m_ptr _op_ o; \ +} + +#define COMPARE(_op_) \ +COMPARE_WEAK(_op_) \ +inline bool operator _op_ (const wp<T>& o) const { \ return m_ptr _op_ o.m_ptr; \ } \ template<typename U> \ -inline bool operator _op_ (const U* o) const { \ - return m_ptr _op_ o; \ +inline bool operator _op_ (const wp<U>& o) const { \ + return m_ptr _op_ o.m_ptr; \ } // --------------------------------------------------------------------------- @@ -274,13 +277,43 @@ public: inline T* unsafe_get() const { return m_ptr; } // Operators - - COMPARE(==) - COMPARE(!=) - COMPARE(>) - COMPARE(<) - COMPARE(<=) - COMPARE(>=) + + COMPARE_WEAK(==) + COMPARE_WEAK(!=) + COMPARE_WEAK(>) + COMPARE_WEAK(<) + COMPARE_WEAK(<=) + COMPARE_WEAK(>=) + + inline bool operator == (const wp<T>& o) const { + return (m_ptr == o.m_ptr) && (m_refs == o.m_refs); + } + template<typename U> + inline bool operator == (const wp<U>& o) const { + return m_ptr == o.m_ptr; + } + + inline bool operator > (const wp<T>& o) const { + return (m_ptr == o.m_ptr) ? (m_refs > o.m_refs) : (m_ptr > o.m_ptr); + } + template<typename U> + inline bool operator > (const wp<U>& o) const { + return (m_ptr == o.m_ptr) ? (m_refs > o.m_refs) : (m_ptr > o.m_ptr); + } + + inline bool operator < (const wp<T>& o) const { + return (m_ptr == o.m_ptr) ? (m_refs < o.m_refs) : (m_ptr < o.m_ptr); + } + template<typename U> + inline bool operator < (const wp<U>& o) const { + return (m_ptr == o.m_ptr) ? (m_refs < o.m_refs) : (m_ptr < o.m_ptr); + } + inline bool operator != (const wp<T>& o) const { return m_refs != o.m_refs; } + template<typename U> inline bool operator != (const wp<U>& o) const { return !operator == (o); } + inline bool operator <= (const wp<T>& o) const { return !operator > (o); } + template<typename U> inline bool operator <= (const wp<U>& o) const { return !operator > (o); } + inline bool operator >= (const wp<T>& o) const { return !operator < (o); } + template<typename U> inline bool operator >= (const wp<U>& o) const { return !operator < (o); } private: template<typename Y> friend class sp; @@ -294,6 +327,7 @@ template <typename T> TextOutput& operator<<(TextOutput& to, const wp<T>& val); #undef COMPARE +#undef COMPARE_WEAK // --------------------------------------------------------------------------- // No user serviceable parts below here. diff --git a/libs/ui/GraphicBufferAllocator.cpp b/libs/ui/GraphicBufferAllocator.cpp index 9847a5fab7..fa46ab7b33 100644 --- a/libs/ui/GraphicBufferAllocator.cpp +++ b/libs/ui/GraphicBufferAllocator.cpp @@ -63,7 +63,7 @@ void GraphicBufferAllocator::dump(String8& result) const const size_t c = list.size(); for (size_t i=0 ; i<c ; i++) { const alloc_rec_t& rec(list.valueAt(i)); - snprintf(buffer, SIZE, "%10p: %7.2f KiB | %4u (%4u) x %4u | %8X | 0x%08x\n", + snprintf(buffer, SIZE, "%10p: %7.2f KiB | %4u (%4u) x %4u | %2d | 0x%08x\n", list.keyAt(i), rec.size/1024.0f, rec.w, rec.s, rec.h, rec.format, rec.usage); result.append(buffer); diff --git a/libs/ui/InputDispatcher.cpp b/libs/ui/InputDispatcher.cpp index 421ad663f8..46baf9d14f 100644 --- a/libs/ui/InputDispatcher.cpp +++ b/libs/ui/InputDispatcher.cpp @@ -592,10 +592,6 @@ InputDispatcher::KeyEntry* InputDispatcher::synthesizeKeyRepeatLocked( // mKeyRepeatState.lastKeyEntry in addition to the one we return. entry->refCount += 1; - if (entry->repeatCount == 1) { - entry->flags |= AKEY_EVENT_FLAG_LONG_PRESS; - } - mKeyRepeatState.nextRepeatTime = currentTime + keyRepeatDelay; return entry; } @@ -645,6 +641,12 @@ bool InputDispatcher::dispatchKeyLocked( resetKeyRepeatLocked(); } + if (entry->repeatCount == 1) { + entry->flags |= AKEY_EVENT_FLAG_LONG_PRESS; + } else { + entry->flags &= ~AKEY_EVENT_FLAG_LONG_PRESS; + } + entry->dispatchInProgress = true; resetTargetsLocked(); diff --git a/opengl/libs/EGL/egl.cpp b/opengl/libs/EGL/egl.cpp index 6d349274ea..d26d13eeb0 100644 --- a/opengl/libs/EGL/egl.cpp +++ b/opengl/libs/EGL/egl.cpp @@ -814,7 +814,7 @@ EGLBoolean eglTerminate(EGLDisplay dpy) dp->refs--; dp->numTotalConfigs = 0; delete [] dp->configs; - clearTLS(); + return res; } @@ -1150,6 +1150,27 @@ EGLBoolean eglDestroyContext(EGLDisplay dpy, EGLContext ctx) return result; } +static void loseCurrent(egl_context_t * cur_c) +{ + if (cur_c) { + egl_surface_t * cur_r = get_surface(cur_c->read); + egl_surface_t * cur_d = get_surface(cur_c->draw); + + // by construction, these are either 0 or valid (possibly terminated) + // it should be impossible for these to be invalid + ContextRef _cur_c(cur_c); + SurfaceRef _cur_r(cur_r); + SurfaceRef _cur_d(cur_d); + + cur_c->read = NULL; + cur_c->draw = NULL; + + _cur_c.release(); + _cur_r.release(); + _cur_d.release(); + } +} + EGLBoolean eglMakeCurrent( EGLDisplay dpy, EGLSurface draw, EGLSurface read, EGLContext ctx) { @@ -1178,13 +1199,9 @@ EGLBoolean eglMakeCurrent( EGLDisplay dpy, EGLSurface draw, // these are the current objects structs egl_context_t * cur_c = get_context(getContext()); - egl_surface_t * cur_r = NULL; - egl_surface_t * cur_d = NULL; if (ctx != EGL_NO_CONTEXT) { c = get_context(ctx); - cur_r = get_surface(c->read); - cur_d = get_surface(c->draw); impl_ctx = c->context; } else { // no context given, use the implementation of the current context @@ -1230,30 +1247,21 @@ EGLBoolean eglMakeCurrent( EGLDisplay dpy, EGLSurface draw, } if (result == EGL_TRUE) { - // by construction, these are either 0 or valid (possibly terminated) - // it should be impossible for these to be invalid - ContextRef _cur_c(cur_c); - SurfaceRef _cur_r(cur_r); - SurfaceRef _cur_d(cur_d); - // cur_c has to be valid here (but could be terminated) + loseCurrent(cur_c); + if (ctx != EGL_NO_CONTEXT) { setGlThreadSpecific(c->cnx->hooks[c->version]); setContext(ctx); _c.acquire(); + _r.acquire(); + _d.acquire(); + c->read = read; + c->draw = draw; } else { setGlThreadSpecific(&gHooksNoContext); setContext(EGL_NO_CONTEXT); } - _cur_c.release(); - - _r.acquire(); - _cur_r.release(); - if (c) c->read = read; - - _d.acquire(); - _cur_d.release(); - if (c) c->draw = draw; } return result; } @@ -1637,6 +1645,9 @@ EGLenum eglQueryAPI(void) EGLBoolean eglReleaseThread(void) { + // If there is context bound to the thread, release it + loseCurrent(get_context(getContext())); + for (int i=0 ; i<IMPL_NUM_IMPLEMENTATIONS ; i++) { egl_connection_t* const cnx = &gEGLImpl[i]; if (cnx->dso) { diff --git a/services/surfaceflinger/LayerBase.cpp b/services/surfaceflinger/LayerBase.cpp index 916d420ca4..21c36e1848 100644 --- a/services/surfaceflinger/LayerBase.cpp +++ b/services/surfaceflinger/LayerBase.cpp @@ -515,12 +515,6 @@ void LayerBase::dump(String8& result, char* buffer, size_t SIZE) const result.append(buffer); } -void LayerBase::shortDump(String8& result, char* scratch, size_t size) const -{ - LayerBase::dump(result, scratch, size); -} - - // --------------------------------------------------------------------------- int32_t LayerBaseClient::sIdentity = 1; @@ -572,12 +566,6 @@ void LayerBaseClient::dump(String8& result, char* buffer, size_t SIZE) const result.append(buffer); } - -void LayerBaseClient::shortDump(String8& result, char* scratch, size_t size) const -{ - LayerBaseClient::dump(result, scratch, size); -} - // --------------------------------------------------------------------------- LayerBaseClient::Surface::Surface( diff --git a/services/surfaceflinger/LayerBase.h b/services/surfaceflinger/LayerBase.h index 1470729357..afc5ec8d50 100644 --- a/services/surfaceflinger/LayerBase.h +++ b/services/surfaceflinger/LayerBase.h @@ -206,7 +206,6 @@ public: /** always call base class first */ virtual void dump(String8& result, char* scratch, size_t size) const; - virtual void shortDump(String8& result, char* scratch, size_t size) const; enum { // flags for doTransaction() @@ -326,7 +325,6 @@ public: protected: virtual void dump(String8& result, char* scratch, size_t size) const; - virtual void shortDump(String8& result, char* scratch, size_t size) const; private: mutable Mutex mLock; diff --git a/services/surfaceflinger/SurfaceFlinger.cpp b/services/surfaceflinger/SurfaceFlinger.cpp index 4876946f2b..c08e2c9412 100644 --- a/services/surfaceflinger/SurfaceFlinger.cpp +++ b/services/surfaceflinger/SurfaceFlinger.cpp @@ -1066,12 +1066,8 @@ status_t SurfaceFlinger::removeLayer_l(const sp<LayerBase>& layerBase) status_t SurfaceFlinger::purgatorizeLayer_l(const sp<LayerBase>& layerBase) { - // First add the layer to the purgatory list, which makes sure it won't - // go away, then remove it from the main list (through a transaction). + // remove the layer from the main list (through a transaction). ssize_t err = removeLayer_l(layerBase); - if (err >= 0) { - mLayerPurgatory.add(layerBase); - } layerBase->onRemoved(); @@ -1342,19 +1338,6 @@ status_t SurfaceFlinger::destroySurface(const sp<LayerBaseClient>& layer) * to use the purgatory. */ status_t err = flinger->removeLayer_l(l); - if (err == NAME_NOT_FOUND) { - // The surface wasn't in the current list, which means it was - // removed already, which means it is in the purgatory, - // and need to be removed from there. - // This needs to happen from the main thread since its dtor - // must run from there (b/c of OpenGL ES). Additionally, we - // can't really acquire our internal lock from - // destroySurface() -- see postMessage() below. - ssize_t idx = flinger->mLayerPurgatory.remove(l); - LOGE_IF(idx < 0, - "layer=%p is not in the purgatory list", l.get()); - } - LOGE_IF(err<0 && err != NAME_NOT_FOUND, "error removing layer=%p (%s)", l.get(), strerror(-err)); return true; @@ -1470,13 +1453,8 @@ status_t SurfaceFlinger::dump(int fd, const Vector<String16>& args) result.append(buffer); } - /* - * Dump the visible layer list - */ const LayerVector& currentLayers = mCurrentState.layersSortedByZ; const size_t count = currentLayers.size(); - snprintf(buffer, SIZE, "Visible layers (count = %d)\n", count); - result.append(buffer); for (size_t i=0 ; i<count ; i++) { const sp<LayerBase>& layer(currentLayers[i]); layer->dump(result, buffer, SIZE); @@ -1486,24 +1464,6 @@ status_t SurfaceFlinger::dump(int fd, const Vector<String16>& args) layer->visibleRegionScreen.dump(result, "visibleRegionScreen"); } - /* - * Dump the layers in the purgatory - */ - - const size_t purgatorySize = mLayerPurgatory.size(); - snprintf(buffer, SIZE, "Purgatory state (%d entries)\n", purgatorySize); - result.append(buffer); - for (size_t i=0 ; i<purgatorySize ; i++) { - const sp<LayerBase>& layer(mLayerPurgatory.itemAt(i)); - layer->shortDump(result, buffer, SIZE); - } - - /* - * Dump SurfaceFlinger global state - */ - - snprintf(buffer, SIZE, "SurfaceFlinger global state\n"); - result.append(buffer); mWormholeRegion.dump(result, "WormholeRegion"); const DisplayHardware& hw(graphicPlane(0).displayHardware()); snprintf(buffer, SIZE, @@ -1529,9 +1489,6 @@ status_t SurfaceFlinger::dump(int fd, const Vector<String16>& args) result.append(buffer); } - /* - * Dump gralloc state - */ const GraphicBufferAllocator& alloc(GraphicBufferAllocator::get()); alloc.dump(result); @@ -2427,7 +2384,7 @@ ssize_t UserClient::getTokenForSurface(const sp<ISurface>& sur) const } break; } - if (++name > 31) + if (++name >= SharedBufferStack::NUM_LAYERS_MAX) name = NO_MEMORY; } while(name >= 0); diff --git a/services/surfaceflinger/SurfaceFlinger.h b/services/surfaceflinger/SurfaceFlinger.h index a023347f0d..df1ca4892c 100644 --- a/services/surfaceflinger/SurfaceFlinger.h +++ b/services/surfaceflinger/SurfaceFlinger.h @@ -370,7 +370,6 @@ private: volatile int32_t mTransactionFlags; volatile int32_t mTransactionCount; Condition mTransactionCV; - SortedVector< sp<LayerBase> > mLayerPurgatory; bool mResizeTransationPending; // protected by mStateLock (but we could use another lock) |