Skip to content

Commit

Permalink
am 561ff8a: Merge "Skip eglSwapBuffers() call when we do not draw to …
Browse files Browse the repository at this point in the history
…GL" into jb-dev

* commit '561ff8a74e3d9ea15f58d9b6534da9ea5a63d84b':
  Skip eglSwapBuffers() call when we do not draw to GL
  • Loading branch information
chethaase authored and Android Git Automerger committed Jun 1, 2012
2 parents c389525 + 561ff8a commit d014006
Show file tree
Hide file tree
Showing 7 changed files with 235 additions and 162 deletions.
7 changes: 7 additions & 0 deletions core/java/android/view/DisplayList.java
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,13 @@ public abstract class DisplayList {
*/
public static final int STATUS_INVOKE = 0x2;

/**
* Indicates that the display list performed GL drawing operations.
*
* @see HardwareCanvas#drawDisplayList(DisplayList, android.graphics.Rect, int)
*/
public static final int STATUS_DREW = 0x4;

/**
* Starts recording the display list. All operations performed on the
* returned canvas are recorded and stored in this display list.
Expand Down
32 changes: 18 additions & 14 deletions core/java/android/view/HardwareRenderer.java
Original file line number Diff line number Diff line change
Expand Up @@ -1104,6 +1104,7 @@ boolean draw(View view, View.AttachInfo attachInfo, HardwareDrawCallbacks callba

onPreDraw(dirty);

int status = DisplayList.STATUS_DONE;
int saveCount = canvas.save();
callbacks.onHardwarePreDraw(canvas);

Expand Down Expand Up @@ -1137,7 +1138,7 @@ boolean draw(View view, View.AttachInfo attachInfo, HardwareDrawCallbacks callba
drawDisplayListStartTime = System.nanoTime();
}

int status = canvas.drawDisplayList(displayList, mRedrawClip,
status = canvas.drawDisplayList(displayList, mRedrawClip,
DisplayList.FLAG_CLIP_CHILDREN);

if (mProfileEnabled) {
Expand Down Expand Up @@ -1173,22 +1174,25 @@ boolean draw(View view, View.AttachInfo attachInfo, HardwareDrawCallbacks callba
onPostDraw();

attachInfo.mIgnoreDirtyState = false;

if ((status & DisplayList.STATUS_DREW) == DisplayList.STATUS_DREW) {

long eglSwapBuffersStartTime = 0;
if (mProfileEnabled) {
eglSwapBuffersStartTime = System.nanoTime();
}

sEgl.eglSwapBuffers(sEglDisplay, mEglSurface);

if (mProfileEnabled) {
long now = System.nanoTime();
float total = (now - eglSwapBuffersStartTime) * 0.000001f;
mProfileData[mProfileCurrentFrame + 2] = total;
long eglSwapBuffersStartTime = 0;
if (mProfileEnabled) {
eglSwapBuffersStartTime = System.nanoTime();
}

sEgl.eglSwapBuffers(sEglDisplay, mEglSurface);

if (mProfileEnabled) {
long now = System.nanoTime();
float total = (now - eglSwapBuffersStartTime) * 0.000001f;
mProfileData[mProfileCurrentFrame + 2] = total;
}

checkEglErrors();
}

checkEglErrors();

return dirty == null;
}
}
Expand Down
9 changes: 8 additions & 1 deletion include/private/hwui/DrawGlInfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,14 @@ struct DrawGlInfo {
// The functor needs to be invoked again but will
// not redraw. Only the functor is invoked again
// (unless another functor requests a redraw.)
kStatusInvoke = 0x2
kStatusInvoke = 0x2,
// DisplayList actually issued GL drawing commands.
// This is used to signal the HardwareRenderer that the
// buffers should be flipped - otherwise, there were no
// changes to the buffer, so no need to flip. Some hardware
// has issues with stale buffer contents when no GL
// commands are issued.
kStatusDrew = 0x4
};
}; // struct DrawGlInfo

Expand Down
Loading

0 comments on commit d014006

Please sign in to comment.