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

Commit 37c56b94 authored by Mathias Agopian's avatar Mathias Agopian Committed by Android (Google) Code Review
Browse files

Merge changes Ib6b6da1d,I6d9a466a

* changes:
  improve SurfaceFlinger dumpsys
  hack up frame latency measurement
parents c49da051 1d99795d
Loading
Loading
Loading
Loading
+12 −0
Original line number Diff line number Diff line
@@ -237,6 +237,15 @@ public abstract class HardwareRenderer {

    private static native void nSetupShadersDiskCache(String cacheFile);

    /**
     * Notifies EGL that the frame is about to be rendered.
     */
    private static void beginFrame() {
        nBeginFrame();
    }

    private static native void nBeginFrame();

    /**
     * Interface used to receive callbacks whenever a view is drawn by
     * a hardware renderer instance.
@@ -808,6 +817,7 @@ public abstract class HardwareRenderer {
        }        
        
        void onPreDraw(Rect dirty) {
            
        }

        void onPostDraw() {
@@ -832,6 +842,8 @@ public abstract class HardwareRenderer {
                        dirty = null;
                    }

                    beginFrame();

                    onPreDraw(dirty);

                    HardwareCanvas canvas = mCanvas;
+10 −0
Original line number Diff line number Diff line
@@ -22,6 +22,8 @@

#include <EGL/egl_cache.h>

EGLAPI void EGLAPIENTRY eglBeginFrame(EGLDisplay dpy, EGLSurface surface);

namespace android {

// ----------------------------------------------------------------------------
@@ -36,6 +38,12 @@ static void android_view_HardwareRenderer_setupShadersDiskCache(JNIEnv* env, job
    env->ReleaseStringUTFChars(diskCachePath, cacheArray);
}

static void android_view_HardwareRenderer_beginFrame(JNIEnv* env, jobject clazz) {
    EGLDisplay dpy = eglGetCurrentDisplay();
    EGLSurface surf = eglGetCurrentSurface(EGL_DRAW);
    eglBeginFrame(dpy, surf);
}

// ----------------------------------------------------------------------------
// JNI Glue
// ----------------------------------------------------------------------------
@@ -45,6 +53,8 @@ const char* const kClassPathName = "android/view/HardwareRenderer";
static JNINativeMethod gMethods[] = {
    { "nSetupShadersDiskCache", "(Ljava/lang/String;)V",
            (void*) android_view_HardwareRenderer_setupShadersDiskCache },
    { "nBeginFrame", "()V",
            (void*) android_view_HardwareRenderer_beginFrame },
};

int register_android_view_HardwareRenderer(JNIEnv* env) {
+20 −0
Original line number Diff line number Diff line
@@ -477,6 +477,26 @@ EGLBoolean eglQuerySurface( EGLDisplay dpy, EGLSurface surface,
    return result;
}

void EGLAPI eglBeginFrame(EGLDisplay dpy, EGLSurface surface) {
    clearError();

    egl_display_t const * const dp = validate_display(dpy);
    if (!dp) {
        return;
    }

    SurfaceRef _s(dp, surface);
    if (!_s.get()) {
        setError(EGL_BAD_SURFACE, EGL_FALSE);
        return;
    }

    int64_t timestamp = systemTime(SYSTEM_TIME_MONOTONIC);

    egl_surface_t const * const s = get_surface(surface);
    native_window_set_buffers_timestamp(s->win.get(), timestamp);
}

// ----------------------------------------------------------------------------
// Contexts
// ----------------------------------------------------------------------------
+14 −1
Original line number Diff line number Diff line
@@ -350,15 +350,28 @@ uint32_t DisplayHardware::getPageFlipCount() const {
}

// this needs to be thread safe
nsecs_t DisplayHardware::waitForVSync() const {
nsecs_t DisplayHardware::waitForRefresh() const {
    nsecs_t timestamp;
    if (mVSync.wait(&timestamp) < 0) {
        // vsync not supported!
        usleep( getDelayToNextVSyncUs(&timestamp) );
    }
    mLastHwVSync = timestamp; // FIXME: Not thread safe
    return timestamp;
}

nsecs_t DisplayHardware::getRefreshTimestamp() const {
    // this returns the last refresh timestamp.
    // if the last one is not available, we estimate it based on
    // the refresh period and whatever closest timestamp we have.
    nsecs_t now = systemTime();
    return now - ((now - mLastHwVSync) %  mRefreshPeriod);
}

nsecs_t DisplayHardware::getRefreshPeriod() const {
    return mRefreshPeriod;
}

int32_t DisplayHardware::getDelayToNextVSyncUs(nsecs_t* timestamp) const {
    Mutex::Autolock _l(mFakeVSyncMutex);
    const nsecs_t period = mRefreshPeriod;
+4 −1
Original line number Diff line number Diff line
@@ -76,7 +76,9 @@ public:
    uint32_t    getMaxViewportDims() const;

    // waits for the next vsync and returns the timestamp of when it happened
    nsecs_t        waitForVSync() const;
    nsecs_t     waitForRefresh() const;
    nsecs_t     getRefreshPeriod() const;
    nsecs_t     getRefreshTimestamp() const;

    uint32_t getPageFlipCount() const;
    EGLDisplay getEGLDisplay() const { return mDisplay; }
@@ -119,6 +121,7 @@ private:
    mutable Mutex   mFakeVSyncMutex;
    mutable nsecs_t mNextFakeVSync;
    nsecs_t         mRefreshPeriod;
    mutable nsecs_t mLastHwVSync;

    HWComposer*     mHwc;

Loading