summaryrefslogtreecommitdiffstats
path: root/libs
diff options
context:
space:
mode:
authorRomain Guy <romainguy@google.com>2012-03-27 16:33:45 -0700
committerChris Craik <ccraik@google.com>2012-04-02 15:15:07 -0700
commit8f3b8e32993d190a26c70c839a63d8ce4c3b16d9 (patch)
tree8e49ffa8f5405f22b8bb12be9e5607ec6a0fc00a /libs
parente6c966caa3aff3099e6fb00caefa10387f57b9c3 (diff)
downloadframeworks_base-8f3b8e32993d190a26c70c839a63d8ce4c3b16d9.zip
frameworks_base-8f3b8e32993d190a26c70c839a63d8ce4c3b16d9.tar.gz
frameworks_base-8f3b8e32993d190a26c70c839a63d8ce4c3b16d9.tar.bz2
Allow fine-grained control over functors execution
Adds non-drawing execution mode Change-Id: I82f92cf1b9a3b9ff2ca6d7427c4e02b73e04e6bf
Diffstat (limited to 'libs')
-rw-r--r--libs/hwui/OpenGLRenderer.cpp43
-rw-r--r--libs/hwui/OpenGLRenderer.h7
2 files changed, 45 insertions, 5 deletions
diff --git a/libs/hwui/OpenGLRenderer.cpp b/libs/hwui/OpenGLRenderer.cpp
index eb4b83b..39be5ed 100644
--- a/libs/hwui/OpenGLRenderer.cpp
+++ b/libs/hwui/OpenGLRenderer.cpp
@@ -166,6 +166,7 @@ void OpenGLRenderer::prepare(bool opaque) {
void OpenGLRenderer::prepareDirty(float left, float top, float right, float bottom, bool opaque) {
mCaches.clearGarbage();
+ mFunctors.clear();
mSnapshot = new Snapshot(mFirstSnapshot,
SkCanvas::kMatrix_SaveFlag | SkCanvas::kClip_SaveFlag);
@@ -236,7 +237,39 @@ void OpenGLRenderer::resume() {
glBlendEquation(GL_FUNC_ADD);
}
-status_t OpenGLRenderer::callDrawGLFunction(Functor *functor, Rect& dirty) {
+status_t OpenGLRenderer::invokeFunctors(Rect& dirty) {
+ status_t result = DrawGlInfo::kStatusDone;
+
+ Vector<Functor*> functors(mFunctors);
+ mFunctors.clear();
+
+ DrawGlInfo info;
+ info.clipLeft = 0;
+ info.clipTop = 0;
+ info.clipRight = 0;
+ info.clipBottom = 0;
+ info.isLayer = false;
+ memset(info.transform, 0, sizeof(float) * 16);
+
+ size_t count = functors.size();
+ for (size_t i = 0; i < count; i++) {
+ Functor* f = functors.itemAt(i);
+ result |= (*f)(DrawGlInfo::kModeProcess, &info);
+
+ if (result != DrawGlInfo::kStatusDone) {
+ Rect localDirty(info.dirtyLeft, info.dirtyTop, info.dirtyRight, info.dirtyBottom);
+ dirty.unionWith(localDirty);
+
+ if (result == DrawGlInfo::kStatusInvoke) {
+ mFunctors.push(f);
+ }
+ }
+ }
+
+ return result;
+}
+
+status_t OpenGLRenderer::callDrawGLFunction(Functor* functor, Rect& dirty) {
interrupt();
if (mDirtyClip) {
setScissorFromClip();
@@ -261,11 +294,15 @@ status_t OpenGLRenderer::callDrawGLFunction(Functor *functor, Rect& dirty) {
info.isLayer = hasLayer();
getSnapshot()->transform->copyTo(&info.transform[0]);
- status_t result = (*functor)(0, &info);
+ status_t result = (*functor)(DrawGlInfo::kModeDraw, &info);
- if (result != 0) {
+ if (result != DrawGlInfo::kStatusDone) {
Rect localDirty(info.dirtyLeft, info.dirtyTop, info.dirtyRight, info.dirtyBottom);
dirty.unionWith(localDirty);
+
+ if (result == DrawGlInfo::kStatusInvoke) {
+ mFunctors.push(functor);
+ }
}
resume();
diff --git a/libs/hwui/OpenGLRenderer.h b/libs/hwui/OpenGLRenderer.h
index 3ba6202..b651904 100644
--- a/libs/hwui/OpenGLRenderer.h
+++ b/libs/hwui/OpenGLRenderer.h
@@ -72,7 +72,8 @@ public:
virtual void interrupt();
virtual void resume();
- virtual status_t callDrawGLFunction(Functor *functor, Rect& dirty);
+ ANDROID_API status_t invokeFunctors(Rect& dirty);
+ virtual status_t callDrawGLFunction(Functor* functor, Rect& dirty);
ANDROID_API int getSaveCount() const;
virtual int save(int flags);
@@ -602,8 +603,10 @@ private:
// Various caches
Caches& mCaches;
- // List of rectagnles to clear after saveLayer() is invoked
+ // List of rectangles to clear after saveLayer() is invoked
Vector<Rect*> mLayers;
+ // List of functors to invoke after a frame is drawn
+ Vector<Functor*> mFunctors;
// Indentity matrix
const mat4 mIdentity;