Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 77e67cf9 authored by Romain Guy's avatar Romain Guy
Browse files

Add extra systrace tracing

This change shows how much time is spent updating and executing
framework display lists within a frame.
This change also fixes a crash that happnes if you attempt to
perform a dumpsys gfxinfo while the app is drawing (we are telling
developers to use this new tool.)

Change-Id: Ia4047a78a42b545ab77176ef4f371c300686548c
parent 54ab347f
Loading
Loading
Loading
Loading
+43 −12
Original line number Original line Diff line number Diff line
@@ -27,6 +27,7 @@ import android.os.Handler;
import android.os.Looper;
import android.os.Looper;
import android.os.SystemClock;
import android.os.SystemClock;
import android.os.SystemProperties;
import android.os.SystemProperties;
import android.os.Trace;
import android.util.Log;
import android.util.Log;
import com.google.android.gles_jni.EGLImpl;
import com.google.android.gles_jni.EGLImpl;


@@ -40,6 +41,7 @@ import javax.microedition.khronos.opengles.GL;


import java.io.File;
import java.io.File;
import java.io.PrintWriter;
import java.io.PrintWriter;
import java.util.concurrent.locks.ReentrantLock;


import static javax.microedition.khronos.egl.EGL10.*;
import static javax.microedition.khronos.egl.EGL10.*;


@@ -623,6 +625,7 @@ public abstract class HardwareRenderer {


        final boolean mProfileEnabled;
        final boolean mProfileEnabled;
        final float[] mProfileData;
        final float[] mProfileData;
        final ReentrantLock mProfileLock;
        int mProfileCurrentFrame = -PROFILE_FRAME_DATA_COUNT;
        int mProfileCurrentFrame = -PROFILE_FRAME_DATA_COUNT;
        
        
        final boolean mDebugDirtyRegions;
        final boolean mDebugDirtyRegions;
@@ -663,8 +666,11 @@ public abstract class HardwareRenderer {
                for (int i = 0; i < mProfileData.length; i += PROFILE_FRAME_DATA_COUNT) {
                for (int i = 0; i < mProfileData.length; i += PROFILE_FRAME_DATA_COUNT) {
                    mProfileData[i] = mProfileData[i + 1] = mProfileData[i + 2] = -1;
                    mProfileData[i] = mProfileData[i + 1] = mProfileData[i + 2] = -1;
                }
                }

                mProfileLock = new ReentrantLock();
            } else {
            } else {
                mProfileData = null;
                mProfileData = null;
                mProfileLock = null;
            }
            }


            property = SystemProperties.get(DEBUG_DIRTY_REGIONS_PROPERTY, "false");
            property = SystemProperties.get(DEBUG_DIRTY_REGIONS_PROPERTY, "false");
@@ -678,6 +684,9 @@ public abstract class HardwareRenderer {
        void dumpGfxInfo(PrintWriter pw) {
        void dumpGfxInfo(PrintWriter pw) {
            if (mProfileEnabled) {
            if (mProfileEnabled) {
                pw.printf("\n\tDraw\tProcess\tExecute\n");
                pw.printf("\n\tDraw\tProcess\tExecute\n");

                mProfileLock.lock();
                try {
                    for (int i = 0; i < mProfileData.length; i += PROFILE_FRAME_DATA_COUNT) {
                    for (int i = 0; i < mProfileData.length; i += PROFILE_FRAME_DATA_COUNT) {
                        if (mProfileData[i] < 0) {
                        if (mProfileData[i] < 0) {
                            break;
                            break;
@@ -687,6 +696,9 @@ public abstract class HardwareRenderer {
                        mProfileData[i] = mProfileData[i + 1] = mProfileData[i + 2] = -1;
                        mProfileData[i] = mProfileData[i + 1] = mProfileData[i + 2] = -1;
                    }
                    }
                    mProfileCurrentFrame = mProfileData.length;
                    mProfileCurrentFrame = mProfileData.length;
                } finally {
                    mProfileLock.unlock();
                }
            }
            }
        }
        }


@@ -1084,6 +1096,10 @@ public abstract class HardwareRenderer {
                    HardwareCanvas canvas = mCanvas;
                    HardwareCanvas canvas = mCanvas;
                    attachInfo.mHardwareCanvas = canvas;
                    attachInfo.mHardwareCanvas = canvas;


                    if (mProfileEnabled) {
                        mProfileLock.lock();
                    }

                    // We had to change the current surface and/or context, redraw everything
                    // We had to change the current surface and/or context, redraw everything
                    if (surfaceState == SURFACE_STATE_UPDATED) {
                    if (surfaceState == SURFACE_STATE_UPDATED) {
                        dirty = null;
                        dirty = null;
@@ -1121,7 +1137,14 @@ public abstract class HardwareRenderer {
                            getDisplayListStartTime = System.nanoTime();
                            getDisplayListStartTime = System.nanoTime();
                        }
                        }


                        DisplayList displayList = view.getDisplayList();
                        DisplayList displayList;

                        Trace.traceBegin(Trace.TRACE_TAG_VIEW, "getDisplayList");
                        try {
                            displayList = view.getDisplayList();
                        } finally {
                            Trace.traceEnd(Trace.TRACE_TAG_VIEW);
                        }


                        if (mProfileEnabled) {
                        if (mProfileEnabled) {
                            long now = System.nanoTime();
                            long now = System.nanoTime();
@@ -1136,8 +1159,13 @@ public abstract class HardwareRenderer {
                                drawDisplayListStartTime = System.nanoTime();
                                drawDisplayListStartTime = System.nanoTime();
                            }
                            }


                            Trace.traceBegin(Trace.TRACE_TAG_VIEW, "drawDisplayList");
                            try {
                                status |= canvas.drawDisplayList(displayList, mRedrawClip,
                                status |= canvas.drawDisplayList(displayList, mRedrawClip,
                                        DisplayList.FLAG_CLIP_CHILDREN);
                                        DisplayList.FLAG_CLIP_CHILDREN);
                            } finally {
                                Trace.traceEnd(Trace.TRACE_TAG_VIEW);
                            }


                            if (mProfileEnabled) {
                            if (mProfileEnabled) {
                                long now = System.nanoTime();
                                long now = System.nanoTime();
@@ -1174,7 +1202,6 @@ public abstract class HardwareRenderer {
                    attachInfo.mIgnoreDirtyState = false;
                    attachInfo.mIgnoreDirtyState = false;
                    
                    
                    if ((status & DisplayList.STATUS_DREW) == DisplayList.STATUS_DREW) {
                    if ((status & DisplayList.STATUS_DREW) == DisplayList.STATUS_DREW) {

                        long eglSwapBuffersStartTime = 0;
                        long eglSwapBuffersStartTime = 0;
                        if (mProfileEnabled) {
                        if (mProfileEnabled) {
                            eglSwapBuffersStartTime = System.nanoTime();
                            eglSwapBuffersStartTime = System.nanoTime();
@@ -1191,6 +1218,10 @@ public abstract class HardwareRenderer {
                        checkEglErrors();
                        checkEglErrors();
                    }
                    }


                    if (mProfileEnabled) {
                        mProfileLock.unlock();
                    }

                    return dirty == null;
                    return dirty == null;
                }
                }
            }
            }