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

Commit faa3969d authored by Vishnu Nair's avatar Vishnu Nair
Browse files

Add debug logs to BlastBufferQueue

Bug: 168917217
Test: Enable logs and check logcat
Change-Id: Ie7aa4a9fb60924589f8efccc1a64a46f85d6dde3
parent 5d5f71ee
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -1245,7 +1245,7 @@ public class SurfaceView extends View implements ViewRootImpl.SurfaceChangedCall
     * of the old SurfaceControl alive.
     */
    private SurfaceControl createSurfaceControls(ViewRootImpl viewRoot) {
        final String name = "SurfaceView - " + viewRoot.getTitle().toString();
        final String name = "SurfaceView[" + viewRoot.getTitle().toString() + "]";

        SurfaceControl.Builder builder = new SurfaceControl.Builder(mSurfaceSession)
                .setName(name)
@@ -1270,7 +1270,7 @@ public class SurfaceView extends View implements ViewRootImpl.SurfaceChangedCall
                    .setBLASTLayer()
                    .setCallsite("SurfaceView.updateSurface")
                    .build();
            mBlastBufferQueue = new BLASTBufferQueue(
            mBlastBufferQueue = new BLASTBufferQueue(name,
                    mBlastSurfaceControl, mSurfaceWidth, mSurfaceHeight, true /* TODO */);
        } else {
            previousSurfaceControl = mSurfaceControl;
+1 −1
Original line number Diff line number Diff line
@@ -1826,7 +1826,7 @@ public final class ViewRootImpl implements ViewParent,

        Surface ret = null;
        if (mBlastBufferQueue == null) {
            mBlastBufferQueue = new BLASTBufferQueue(
            mBlastBufferQueue = new BLASTBufferQueue(mTag,
                mBlastSurfaceControl, width, height, mEnableTripleBuffering);
            // We only return the Surface the first time, as otherwise
            // it hasn't changed and there is no need to update.
+21 −16
Original line number Diff line number Diff line
@@ -29,10 +29,21 @@

namespace android {

static jlong nativeCreate(JNIEnv* env, jclass clazz, jlong surfaceControl, jlong width, jlong height,
                          jboolean enableTripleBuffering) {
    sp<BLASTBufferQueue> queue = new BLASTBufferQueue(
            reinterpret_cast<SurfaceControl*>(surfaceControl), width, height, enableTripleBuffering);
static jlong nativeCreate(JNIEnv* env, jclass clazz, jstring jName, jlong surfaceControl,
                          jlong width, jlong height, jboolean enableTripleBuffering) {
    String8 str8;
    if (jName) {
        const jchar* str16 = env->GetStringCritical(jName, nullptr);
        if (str16) {
            str8 = String8(reinterpret_cast<const char16_t*>(str16), env->GetStringLength(jName));
            env->ReleaseStringCritical(jName, str16);
            str16 = nullptr;
        }
    }
    std::string name = str8.string();
    sp<BLASTBufferQueue> queue =
            new BLASTBufferQueue(name, reinterpret_cast<SurfaceControl*>(surfaceControl), width,
                                 height, enableTripleBuffering);
    queue->incStrong((void*)nativeCreate);
    return reinterpret_cast<jlong>(queue.get());
}
@@ -60,17 +71,11 @@ static void nativeUpdate(JNIEnv*env, jclass clazz, jlong ptr, jlong surfaceContr

static const JNINativeMethod gMethods[] = {
        /* name, signature, funcPtr */
    { "nativeCreate", "(JJJZ)J",
            (void*)nativeCreate },
    {  "nativeGetSurface", "(J)Landroid/view/Surface;",
       (void*)nativeGetSurface },
    { "nativeDestroy", "(J)V",
            (void*)nativeDestroy },
    { "nativeSetNextTransaction", "(JJ)V",
      (void*)nativeSetNextTransaction },
    { "nativeUpdate", "(JJJJ)V",
      (void*)nativeUpdate }
};
        {"nativeCreate", "(Ljava/lang/String;JJJZ)J", (void*)nativeCreate},
        {"nativeGetSurface", "(J)Landroid/view/Surface;", (void*)nativeGetSurface},
        {"nativeDestroy", "(J)V", (void*)nativeDestroy},
        {"nativeSetNextTransaction", "(JJ)V", (void*)nativeSetNextTransaction},
        {"nativeUpdate", "(JJJJ)V", (void*)nativeUpdate}};

int register_android_graphics_BLASTBufferQueue(JNIEnv* env) {
    int res = jniRegisterNativeMethods(env, "android/graphics/BLASTBufferQueue",
+4 −4
Original line number Diff line number Diff line
@@ -26,17 +26,17 @@ public final class BLASTBufferQueue {
    // Note: This field is accessed by native code.
    public long mNativeObject; // BLASTBufferQueue*

    private static native long nativeCreate(long surfaceControl, long width, long height,
            boolean tripleBufferingEnabled);
    private static native long nativeCreate(String name, long surfaceControl, long width,
                                            long height, boolean tripleBufferingEnabled);
    private static native void nativeDestroy(long ptr);
    private static native Surface nativeGetSurface(long ptr);
    private static native void nativeSetNextTransaction(long ptr, long transactionPtr);
    private static native void nativeUpdate(long ptr, long surfaceControl, long width, long height);

    /** Create a new connection with the surface flinger. */
    public BLASTBufferQueue(SurfaceControl sc, int width, int height,
    public BLASTBufferQueue(String name, SurfaceControl sc, int width, int height,
            boolean tripleBufferingEnabled) {
        mNativeObject = nativeCreate(sc.mNativeObject, width, height, tripleBufferingEnabled);
        mNativeObject = nativeCreate(name, sc.mNativeObject, width, height, tripleBufferingEnabled);
    }

    public void destroy() {