diff options
author | John Reck <jreck@google.com> | 2014-10-03 23:57:09 +0000 |
---|---|---|
committer | Android Git Automerger <android-git-automerger@android.com> | 2014-10-03 23:57:09 +0000 |
commit | b0d6cd236ce84085c6f19955b4f4610d1a754411 (patch) | |
tree | d82c289cc502d116b4c946d79055d8ee2b8b88e9 /libs | |
parent | 865acc74395a56287ab7bec58947327b5790aa70 (diff) | |
parent | d988a45d60cd2ff05e41a44c78cb09d307bd90cb (diff) | |
download | frameworks_base-b0d6cd236ce84085c6f19955b4f4610d1a754411.zip frameworks_base-b0d6cd236ce84085c6f19955b4f4610d1a754411.tar.gz frameworks_base-b0d6cd236ce84085c6f19955b4f4610d1a754411.tar.bz2 |
am d988a45d: Merge "Cleanup DeferredLayerUpdater" into lmp-dev
* commit 'd988a45d60cd2ff05e41a44c78cb09d307bd90cb':
Cleanup DeferredLayerUpdater
Diffstat (limited to 'libs')
-rw-r--r-- | libs/hwui/DeferredLayerUpdater.cpp | 41 | ||||
-rw-r--r-- | libs/hwui/DeferredLayerUpdater.h | 8 | ||||
-rw-r--r-- | libs/hwui/renderthread/CanvasContext.cpp | 5 | ||||
-rw-r--r-- | libs/hwui/renderthread/CanvasContext.h | 1 | ||||
-rw-r--r-- | libs/hwui/renderthread/RenderProxy.cpp | 21 | ||||
-rw-r--r-- | libs/hwui/renderthread/RenderProxy.h | 1 |
6 files changed, 36 insertions, 41 deletions
diff --git a/libs/hwui/DeferredLayerUpdater.cpp b/libs/hwui/DeferredLayerUpdater.cpp index 836de45..a6d7e78 100644 --- a/libs/hwui/DeferredLayerUpdater.cpp +++ b/libs/hwui/DeferredLayerUpdater.cpp @@ -18,38 +18,52 @@ #include "OpenGLRenderer.h" #include "LayerRenderer.h" +#include "renderthread/EglManager.h" +#include "renderthread/RenderTask.h" namespace android { namespace uirenderer { -static void defaultLayerDestroyer(Layer* layer) { - Caches::getInstance().resourceCache.decrementRefcount(layer); -} +class DeleteLayerTask : public renderthread::RenderTask { +public: + DeleteLayerTask(renderthread::EglManager& eglManager, Layer* layer) + : mEglManager(eglManager) + , mLayer(layer) + {} + + virtual void run() { + mEglManager.requireGlContext(); + LayerRenderer::destroyLayer(mLayer); + mLayer = 0; + delete this; + } -DeferredLayerUpdater::DeferredLayerUpdater(Layer* layer, LayerDestroyer destroyer) +private: + renderthread::EglManager& mEglManager; + Layer* mLayer; +}; + +DeferredLayerUpdater::DeferredLayerUpdater(renderthread::RenderThread& thread, Layer* layer) : mSurfaceTexture(0) , mTransform(0) , mNeedsGLContextAttach(false) , mUpdateTexImage(false) , mLayer(layer) , mCaches(Caches::getInstance()) - , mDestroyer(destroyer) { + , mRenderThread(thread) { mWidth = mLayer->layer.getWidth(); mHeight = mLayer->layer.getHeight(); mBlend = mLayer->isBlend(); mColorFilter = SkSafeRef(mLayer->getColorFilter()); mAlpha = mLayer->getAlpha(); mMode = mLayer->getMode(); - - if (!mDestroyer) { - mDestroyer = defaultLayerDestroyer; - } } DeferredLayerUpdater::~DeferredLayerUpdater() { SkSafeUnref(mColorFilter); setTransform(0); - mDestroyer(mLayer); + mRenderThread.queue(new DeleteLayerTask(mRenderThread.eglManager(), mLayer)); + mLayer = 0; } void DeferredLayerUpdater::setPaint(const SkPaint* paint) { @@ -121,7 +135,12 @@ void DeferredLayerUpdater::doUpdateTexImage() { void DeferredLayerUpdater::detachSurfaceTexture() { if (mSurfaceTexture.get()) { - mSurfaceTexture->detachFromContext(); + mRenderThread.eglManager().requireGlContext(); + status_t err = mSurfaceTexture->detachFromContext(); + if (err != 0) { + // TODO: Elevate to fatal exception + ALOGE("Failed to detach SurfaceTexture from context %d", err); + } mSurfaceTexture = 0; mLayer->clearTexture(); } diff --git a/libs/hwui/DeferredLayerUpdater.h b/libs/hwui/DeferredLayerUpdater.h index c838c32..dda3e89 100644 --- a/libs/hwui/DeferredLayerUpdater.h +++ b/libs/hwui/DeferredLayerUpdater.h @@ -25,19 +25,18 @@ #include "Layer.h" #include "Rect.h" #include "RenderNode.h" +#include "renderthread/RenderThread.h" namespace android { namespace uirenderer { -typedef void (*LayerDestroyer)(Layer* layer); - // Container to hold the properties a layer should be set to at the start // of a render pass class DeferredLayerUpdater : public VirtualLightRefBase { public: // Note that DeferredLayerUpdater assumes it is taking ownership of the layer // and will not call incrementRef on it as a result. - ANDROID_API DeferredLayerUpdater(Layer* layer, LayerDestroyer = 0); + ANDROID_API DeferredLayerUpdater(renderthread::RenderThread& thread, Layer* layer); ANDROID_API ~DeferredLayerUpdater(); ANDROID_API bool setSize(uint32_t width, uint32_t height) { @@ -99,8 +98,7 @@ private: Layer* mLayer; Caches& mCaches; - - LayerDestroyer mDestroyer; + renderthread::RenderThread& mRenderThread; void doUpdateTexImage(); }; diff --git a/libs/hwui/renderthread/CanvasContext.cpp b/libs/hwui/renderthread/CanvasContext.cpp index 1c416a7..b50a433 100644 --- a/libs/hwui/renderthread/CanvasContext.cpp +++ b/libs/hwui/renderthread/CanvasContext.cpp @@ -344,11 +344,6 @@ void CanvasContext::runWithGlContext(RenderTask* task) { task->run(); } -Layer* CanvasContext::createRenderLayer(int width, int height) { - requireSurface(); - return LayerRenderer::createRenderLayer(mRenderThread.renderState(), width, height); -} - Layer* CanvasContext::createTextureLayer() { requireSurface(); return LayerRenderer::createTextureLayer(mRenderThread.renderState()); diff --git a/libs/hwui/renderthread/CanvasContext.h b/libs/hwui/renderthread/CanvasContext.h index 2460f6b..d4282fa 100644 --- a/libs/hwui/renderthread/CanvasContext.h +++ b/libs/hwui/renderthread/CanvasContext.h @@ -83,7 +83,6 @@ public: void runWithGlContext(RenderTask* task); - Layer* createRenderLayer(int width, int height); Layer* createTextureLayer(); ANDROID_API static void setTextureAtlas(RenderThread& thread, diff --git a/libs/hwui/renderthread/RenderProxy.cpp b/libs/hwui/renderthread/RenderProxy.cpp index 9528874..047819d 100644 --- a/libs/hwui/renderthread/RenderProxy.cpp +++ b/libs/hwui/renderthread/RenderProxy.cpp @@ -257,31 +257,16 @@ void RenderProxy::enqueueDestroyLayer(Layer* layer) { RenderThread::getInstance().queue(task); } -CREATE_BRIDGE3(createDisplayListLayer, CanvasContext* context, int width, int height) { - Layer* layer = args->context->createRenderLayer(args->width, args->height); - if (!layer) return 0; - return new DeferredLayerUpdater(layer, RenderProxy::enqueueDestroyLayer); -} - -DeferredLayerUpdater* RenderProxy::createDisplayListLayer(int width, int height) { - SETUP_TASK(createDisplayListLayer); - args->width = width; - args->height = height; - args->context = mContext; - void* retval = postAndWait(task); - DeferredLayerUpdater* layer = reinterpret_cast<DeferredLayerUpdater*>(retval); - return layer; -} - -CREATE_BRIDGE1(createTextureLayer, CanvasContext* context) { +CREATE_BRIDGE2(createTextureLayer, RenderThread* thread, CanvasContext* context) { Layer* layer = args->context->createTextureLayer(); if (!layer) return 0; - return new DeferredLayerUpdater(layer, RenderProxy::enqueueDestroyLayer); + return new DeferredLayerUpdater(*args->thread, layer); } DeferredLayerUpdater* RenderProxy::createTextureLayer() { SETUP_TASK(createTextureLayer); args->context = mContext; + args->thread = &mRenderThread; void* retval = postAndWait(task); DeferredLayerUpdater* layer = reinterpret_cast<DeferredLayerUpdater*>(retval); return layer; diff --git a/libs/hwui/renderthread/RenderProxy.h b/libs/hwui/renderthread/RenderProxy.h index 8b8d99c..678e7e2 100644 --- a/libs/hwui/renderthread/RenderProxy.h +++ b/libs/hwui/renderthread/RenderProxy.h @@ -80,7 +80,6 @@ public: ANDROID_API void runWithGlContext(RenderTask* task); static void enqueueDestroyLayer(Layer* layer); - ANDROID_API DeferredLayerUpdater* createDisplayListLayer(int width, int height); ANDROID_API DeferredLayerUpdater* createTextureLayer(); ANDROID_API void buildLayer(RenderNode* node); ANDROID_API bool copyLayerInto(DeferredLayerUpdater* layer, SkBitmap* bitmap); |