diff options
author | John Reck <jreck@google.com> | 2014-05-28 16:02:06 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2014-05-28 16:02:06 +0000 |
commit | 45d01929291eba56e1bce582192941446b86bf5a (patch) | |
tree | f8afff902e21c27d6e3e0858765f83e86322f143 | |
parent | 10f6de686e68c6cbb7bed8c9550ea5f43c19d104 (diff) | |
parent | e1628b7c6fc3822fa83cf02028ce8ad67abb0afe (diff) | |
download | frameworks_base-45d01929291eba56e1bce582192941446b86bf5a.zip frameworks_base-45d01929291eba56e1bce582192941446b86bf5a.tar.gz frameworks_base-45d01929291eba56e1bce582192941446b86bf5a.tar.bz2 |
Merge "Implement FlushCaches TODO" into lmp-preview-dev
-rw-r--r-- | core/java/android/view/ThreadedRenderer.java | 6 | ||||
-rw-r--r-- | core/jni/android_view_ThreadedRenderer.cpp | 7 | ||||
-rw-r--r-- | libs/hwui/renderthread/CanvasContext.cpp | 7 | ||||
-rw-r--r-- | libs/hwui/renderthread/CanvasContext.h | 2 | ||||
-rw-r--r-- | libs/hwui/renderthread/RenderProxy.cpp | 12 | ||||
-rw-r--r-- | libs/hwui/renderthread/RenderProxy.h | 3 |
6 files changed, 34 insertions, 3 deletions
diff --git a/core/java/android/view/ThreadedRenderer.java b/core/java/android/view/ThreadedRenderer.java index 8417887..9c9a939 100644 --- a/core/java/android/view/ThreadedRenderer.java +++ b/core/java/android/view/ThreadedRenderer.java @@ -33,8 +33,6 @@ import java.io.PrintWriter; /** * Hardware renderer that proxies the rendering to a render thread. Most calls * are currently synchronous. - * TODO: Make draw() async. - * TODO: Figure out how to share the DisplayList between two threads (global lock?) * * The UI thread can block on the RenderThread, but RenderThread must never * block on the UI thread. @@ -117,7 +115,7 @@ public class ThreadedRenderer extends HardwareRenderer { @Override void destroyHardwareResources(View view) { destroyResources(view); - // TODO: GLES20Canvas.flushCaches(GLES20Canvas.FLUSH_CACHES_LAYERS); + nFlushCaches(mNativeProxy, GLES20Canvas.FLUSH_CACHES_LAYERS); } private static void destroyResources(View view) { @@ -368,6 +366,8 @@ public class ThreadedRenderer extends HardwareRenderer { private static native boolean nCopyLayerInto(long nativeProxy, long layer, long bitmap); private static native void nDestroyLayer(long nativeProxy, long layer); + private static native void nFlushCaches(long nativeProxy, int flushMode); + private static native void nFence(long nativeProxy); private static native void nNotifyFramePending(long nativeProxy); } diff --git a/core/jni/android_view_ThreadedRenderer.cpp b/core/jni/android_view_ThreadedRenderer.cpp index 5bc0f62..6f256f0 100644 --- a/core/jni/android_view_ThreadedRenderer.cpp +++ b/core/jni/android_view_ThreadedRenderer.cpp @@ -293,6 +293,12 @@ static void android_view_ThreadedRenderer_destroyLayer(JNIEnv* env, jobject claz proxy->destroyLayer(layer); } +static void android_view_ThreadedRenderer_flushCaches(JNIEnv* env, jobject clazz, + jlong proxyPtr, jint flushMode) { + RenderProxy* proxy = reinterpret_cast<RenderProxy*>(proxyPtr); + proxy->flushCaches(static_cast<Caches::FlushMode>(flushMode)); +} + static void android_view_ThreadedRenderer_fence(JNIEnv* env, jobject clazz, jlong proxyPtr) { RenderProxy* proxy = reinterpret_cast<RenderProxy*>(proxyPtr); @@ -334,6 +340,7 @@ static JNINativeMethod gMethods[] = { { "nCreateTextureLayer", "(J)J", (void*) android_view_ThreadedRenderer_createTextureLayer }, { "nCopyLayerInto", "(JJJ)Z", (void*) android_view_ThreadedRenderer_copyLayerInto }, { "nDestroyLayer", "(JJ)V", (void*) android_view_ThreadedRenderer_destroyLayer }, + { "nFlushCaches", "(JI)V", (void*) android_view_ThreadedRenderer_flushCaches }, { "nFence", "(J)V", (void*) android_view_ThreadedRenderer_fence }, { "nNotifyFramePending", "(J)V", (void*) android_view_ThreadedRenderer_notifyFramePending }, #endif diff --git a/libs/hwui/renderthread/CanvasContext.cpp b/libs/hwui/renderthread/CanvasContext.cpp index b6b3428..160fbea 100644 --- a/libs/hwui/renderthread/CanvasContext.cpp +++ b/libs/hwui/renderthread/CanvasContext.cpp @@ -556,6 +556,13 @@ bool CanvasContext::copyLayerInto(DeferredLayerUpdater* layer, SkBitmap* bitmap) return LayerRenderer::copyLayer(layer->backingLayer(), bitmap); } +void CanvasContext::flushCaches(Caches::FlushMode flushMode) { + if (mGlobalContext->hasContext()) { + requireGlContext(); + Caches::getInstance().flush(flushMode); + } +} + void CanvasContext::runWithGlContext(RenderTask* task) { requireGlContext(); task->run(); diff --git a/libs/hwui/renderthread/CanvasContext.h b/libs/hwui/renderthread/CanvasContext.h index a54b33e..da85d44 100644 --- a/libs/hwui/renderthread/CanvasContext.h +++ b/libs/hwui/renderthread/CanvasContext.h @@ -63,6 +63,8 @@ public: bool copyLayerInto(DeferredLayerUpdater* layer, SkBitmap* bitmap); + void flushCaches(Caches::FlushMode flushMode); + void invokeFunctor(Functor* functor); void runWithGlContext(RenderTask* task); diff --git a/libs/hwui/renderthread/RenderProxy.cpp b/libs/hwui/renderthread/RenderProxy.cpp index 2e103d8..8e772f2 100644 --- a/libs/hwui/renderthread/RenderProxy.cpp +++ b/libs/hwui/renderthread/RenderProxy.cpp @@ -282,6 +282,18 @@ void RenderProxy::destroyLayer(DeferredLayerUpdater* layer) { post(task); } +CREATE_BRIDGE2(flushCaches, CanvasContext* context, Caches::FlushMode flushMode) { + args->context->flushCaches(args->flushMode); + return NULL; +} + +void RenderProxy::flushCaches(Caches::FlushMode flushMode) { + SETUP_TASK(flushCaches); + args->context = mContext; + args->flushMode = flushMode; + post(task); +} + CREATE_BRIDGE0(fence) { // Intentionally empty return NULL; diff --git a/libs/hwui/renderthread/RenderProxy.h b/libs/hwui/renderthread/RenderProxy.h index 8aeb264..22d4e22 100644 --- a/libs/hwui/renderthread/RenderProxy.h +++ b/libs/hwui/renderthread/RenderProxy.h @@ -29,6 +29,7 @@ #include <utils/StrongPointer.h> #include <utils/Vector.h> +#include "../Caches.h" #include "DrawFrameTask.h" namespace android { @@ -81,6 +82,8 @@ public: ANDROID_API bool copyLayerInto(DeferredLayerUpdater* layer, SkBitmap* bitmap); ANDROID_API void destroyLayer(DeferredLayerUpdater* layer); + ANDROID_API void flushCaches(Caches::FlushMode flushMode); + ANDROID_API void fence(); ANDROID_API void notifyFramePending(); |