Fence on draws that are reported

Change-Id: Ib2ec16cbda40f40df1710bdc868869ea8301f17e
diff --git a/libs/hwui/renderthread/RenderProxy.cpp b/libs/hwui/renderthread/RenderProxy.cpp
index cd711b0..0b6be19 100644
--- a/libs/hwui/renderthread/RenderProxy.cpp
+++ b/libs/hwui/renderthread/RenderProxy.cpp
@@ -252,6 +252,16 @@
     post(task);
 }
 
+CREATE_BRIDGE0(fence) {
+    // Intentionally empty
+    return NULL;
+}
+
+void RenderProxy::fence() {
+    SETUP_TASK(fence);
+    postAndWait(task);
+}
+
 MethodInvokeRenderTask* RenderProxy::createTask(RunnableMethod method) {
     // TODO: Consider having a small pool of these to avoid alloc churn
     return new MethodInvokeRenderTask(method);
diff --git a/libs/hwui/renderthread/RenderProxy.h b/libs/hwui/renderthread/RenderProxy.h
index f1ca534..fc51d21 100644
--- a/libs/hwui/renderthread/RenderProxy.h
+++ b/libs/hwui/renderthread/RenderProxy.h
@@ -78,6 +78,8 @@
     ANDROID_API bool copyLayerInto(DeferredLayerUpdater* layer, SkBitmap* bitmap);
     ANDROID_API void destroyLayer(DeferredLayerUpdater* layer);
 
+    ANDROID_API void fence();
+
 private:
     RenderThread& mRenderThread;
     CanvasContext* mContext;