Add kModeSync
Bug: 16526750
Change-Id: I4c087160e80432739321172fd57880846c8de6e0
diff --git a/include/private/hwui/DrawGlInfo.h b/include/private/hwui/DrawGlInfo.h
index a357a01..f578513 100644
--- a/include/private/hwui/DrawGlInfo.h
+++ b/include/private/hwui/DrawGlInfo.h
@@ -58,7 +58,12 @@
kModeProcess,
// Same as kModeProcess, however there is no GL context because it was
// lost or destroyed
- kModeProcessNoContext
+ kModeProcessNoContext,
+ // Invoked every time the UI thread pushes over a frame to the render thread
+ // *and the owning view has a dirty display list*. This is a signal to sync
+ // any data that needs to be shared between the UI thread and the render thread.
+ // During this time the UI thread is blocked.
+ kModeSync
};
/**
diff --git a/libs/hwui/DisplayList.cpp b/libs/hwui/DisplayList.cpp
index e38b532..6461ee7 100644
--- a/libs/hwui/DisplayList.cpp
+++ b/libs/hwui/DisplayList.cpp
@@ -31,7 +31,6 @@
DisplayListData::DisplayListData()
: projectionReceiveIndex(-1)
- , functorCount(0)
, hasDrawOps(false) {
}
@@ -41,7 +40,7 @@
void DisplayListData::cleanupResources() {
Caches& caches = Caches::getInstance();
- caches.unregisterFunctors(functorCount);
+ caches.unregisterFunctors(functors.size());
caches.resourceCache.lock();
for (size_t i = 0; i < bitmapResources.size(); i++) {
diff --git a/libs/hwui/DisplayList.h b/libs/hwui/DisplayList.h
index bfffbb4..79a2f61 100644
--- a/libs/hwui/DisplayList.h
+++ b/libs/hwui/DisplayList.h
@@ -126,7 +126,7 @@
SortedVector<const SkPath*> sourcePaths;
Vector<const SkRegion*> regions;
Vector<Layer*> layers;
- uint32_t functorCount;
+ Vector<Functor*> functors;
bool hasDrawOps;
bool isEmpty() {
diff --git a/libs/hwui/DisplayListRenderer.cpp b/libs/hwui/DisplayListRenderer.cpp
index c7dc29b..5286ef8 100644
--- a/libs/hwui/DisplayListRenderer.cpp
+++ b/libs/hwui/DisplayListRenderer.cpp
@@ -88,7 +88,7 @@
status_t DisplayListRenderer::callDrawGLFunction(Functor *functor, Rect& dirty) {
// Ignore dirty during recording, it matters only when we replay
addDrawOp(new (alloc()) DrawFunctorOp(functor));
- mDisplayListData->functorCount++;
+ mDisplayListData->functors.add(functor);
return DrawGlInfo::kStatusDone; // No invalidate needed at record-time
}
diff --git a/libs/hwui/RenderNode.cpp b/libs/hwui/RenderNode.cpp
index 3eb779f..32304dc 100644
--- a/libs/hwui/RenderNode.cpp
+++ b/libs/hwui/RenderNode.cpp
@@ -78,7 +78,7 @@
delete mStagingDisplayListData;
mStagingDisplayListData = data;
if (mStagingDisplayListData) {
- Caches::getInstance().registerFunctors(mStagingDisplayListData->functorCount);
+ Caches::getInstance().registerFunctors(mStagingDisplayListData->functors.size());
}
}
@@ -254,6 +254,11 @@
deleteDisplayListData();
mDisplayListData = mStagingDisplayListData;
mStagingDisplayListData = NULL;
+ if (mDisplayListData) {
+ for (size_t i = 0; i < mDisplayListData->functors.size(); i++) {
+ (*mDisplayListData->functors[i])(DrawGlInfo::kModeSync, NULL);
+ }
+ }
damageSelf(info);
}
}
@@ -271,7 +276,7 @@
void RenderNode::prepareSubTree(TreeInfo& info, DisplayListData* subtree) {
if (subtree) {
TextureCache& cache = Caches::getInstance().textureCache;
- info.out.hasFunctors |= subtree->functorCount;
+ info.out.hasFunctors |= subtree->functors.size();
// TODO: Fix ownedBitmapResources to not require disabling prepareTextures
// and thus falling out of async drawing path.
if (subtree->ownedBitmapResources.size()) {