Loading core/java/android/service/wallpaper/WallpaperService.java +3 −0 Original line number Diff line number Diff line Loading @@ -70,6 +70,7 @@ import android.graphics.drawable.Drawable; import android.hardware.HardwareBuffer; import android.hardware.display.DisplayManager; import android.hardware.display.DisplayManager.DisplayListener; import android.os.Binder; import android.os.Build; import android.os.Bundle; import android.os.Handler; Loading Loading @@ -370,6 +371,7 @@ public abstract class WallpaperService extends Service { private float mDefaultDimAmount = 0.05f; SurfaceControl mBbqSurfaceControl; BLASTBufferQueue mBlastBufferQueue; IBinder mBbqApplyToken = new Binder(); private SurfaceControl mScreenshotSurfaceControl; private Point mScreenshotSize = new Point(); Loading Loading @@ -2390,6 +2392,7 @@ public abstract class WallpaperService extends Service { if (mBlastBufferQueue == null) { mBlastBufferQueue = new BLASTBufferQueue("Wallpaper", mBbqSurfaceControl, width, height, format); mBlastBufferQueue.setApplyToken(mBbqApplyToken); // We only return the Surface the first time, as otherwise // it hasn't changed and there is no need to update. ret = mBlastBufferQueue.createSurface(); Loading core/java/android/view/ViewRootImpl.java +5 −0 Original line number Diff line number Diff line Loading @@ -829,6 +829,7 @@ public final class ViewRootImpl implements ViewParent, private final SurfaceControl mSurfaceControl = new SurfaceControl(); private BLASTBufferQueue mBlastBufferQueue; private IBinder mBbqApplyToken = new Binder(); private final HdrRenderState mHdrRenderState = new HdrRenderState(this); Loading Loading @@ -2743,6 +2744,10 @@ public final class ViewRootImpl implements ViewParent, mBlastBufferQueue = new BLASTBufferQueue(mTag, mSurfaceControl, mSurfaceSize.x, mSurfaceSize.y, mWindowAttributes.format); mBlastBufferQueue.setTransactionHangCallback(sTransactionHangCallback); // If we create and destroy BBQ without recreating the SurfaceControl, we can end up // queuing buffers on multiple apply tokens causing out of order buffer submissions. We // fix this by setting the same apply token on all BBQs created by this VRI. mBlastBufferQueue.setApplyToken(mBbqApplyToken); Surface blastSurface; if (addSchandleToVriSurface()) { blastSurface = mBlastBufferQueue.createSurfaceWithHandle(); Loading core/jni/android_graphics_BLASTBufferQueue.cpp +12 −5 Original line number Diff line number Diff line Loading @@ -16,16 +16,16 @@ #define LOG_TAG "BLASTBufferQueue" #include <nativehelper/JNIHelp.h> #include <android_runtime/AndroidRuntime.h> #include <android_runtime/android_view_Surface.h> #include <utils/Log.h> #include <utils/RefBase.h> #include <android_util_Binder.h> #include <gui/BLASTBufferQueue.h> #include <gui/Surface.h> #include <gui/SurfaceComposerClient.h> #include <nativehelper/JNIHelp.h> #include <utils/Log.h> #include <utils/RefBase.h> #include "core_jni_helpers.h" namespace android { Loading Loading @@ -209,6 +209,12 @@ static jobject nativeGatherPendingTransactions(JNIEnv* env, jclass clazz, jlong reinterpret_cast<jlong>(transaction)); } static void nativeSetApplyToken(JNIEnv* env, jclass clazz, jlong ptr, jobject applyTokenObject) { sp<BLASTBufferQueue> queue = reinterpret_cast<BLASTBufferQueue*>(ptr); sp<IBinder> token(ibinderForJavaObject(env, applyTokenObject)); return queue->setApplyToken(std::move(token)); } static const JNINativeMethod gMethods[] = { /* name, signature, funcPtr */ // clang-format off Loading @@ -227,6 +233,7 @@ static const JNINativeMethod gMethods[] = { {"nativeSetTransactionHangCallback", "(JLandroid/graphics/BLASTBufferQueue$TransactionHangCallback;)V", (void*)nativeSetTransactionHangCallback}, {"nativeSetApplyToken", "(JLandroid/os/IBinder;)V", (void*)nativeSetApplyToken}, // clang-format on }; Loading graphics/java/android/graphics/BLASTBufferQueue.java +6 −0 Original line number Diff line number Diff line Loading @@ -17,6 +17,7 @@ package android.graphics; import android.annotation.NonNull; import android.os.IBinder; import android.view.Surface; import android.view.SurfaceControl; Loading Loading @@ -47,6 +48,7 @@ public final class BLASTBufferQueue { long frameNumber); private static native void nativeSetTransactionHangCallback(long ptr, TransactionHangCallback callback); private static native void nativeSetApplyToken(long ptr, IBinder applyToken); public interface TransactionHangCallback { void onTransactionHang(String reason); Loading Loading @@ -204,4 +206,8 @@ public final class BLASTBufferQueue { public void setTransactionHangCallback(TransactionHangCallback hangCallback) { nativeSetTransactionHangCallback(mNativeObject, hangCallback); } public void setApplyToken(IBinder applyToken) { nativeSetApplyToken(mNativeObject, applyToken); } } Loading
core/java/android/service/wallpaper/WallpaperService.java +3 −0 Original line number Diff line number Diff line Loading @@ -70,6 +70,7 @@ import android.graphics.drawable.Drawable; import android.hardware.HardwareBuffer; import android.hardware.display.DisplayManager; import android.hardware.display.DisplayManager.DisplayListener; import android.os.Binder; import android.os.Build; import android.os.Bundle; import android.os.Handler; Loading Loading @@ -370,6 +371,7 @@ public abstract class WallpaperService extends Service { private float mDefaultDimAmount = 0.05f; SurfaceControl mBbqSurfaceControl; BLASTBufferQueue mBlastBufferQueue; IBinder mBbqApplyToken = new Binder(); private SurfaceControl mScreenshotSurfaceControl; private Point mScreenshotSize = new Point(); Loading Loading @@ -2390,6 +2392,7 @@ public abstract class WallpaperService extends Service { if (mBlastBufferQueue == null) { mBlastBufferQueue = new BLASTBufferQueue("Wallpaper", mBbqSurfaceControl, width, height, format); mBlastBufferQueue.setApplyToken(mBbqApplyToken); // We only return the Surface the first time, as otherwise // it hasn't changed and there is no need to update. ret = mBlastBufferQueue.createSurface(); Loading
core/java/android/view/ViewRootImpl.java +5 −0 Original line number Diff line number Diff line Loading @@ -829,6 +829,7 @@ public final class ViewRootImpl implements ViewParent, private final SurfaceControl mSurfaceControl = new SurfaceControl(); private BLASTBufferQueue mBlastBufferQueue; private IBinder mBbqApplyToken = new Binder(); private final HdrRenderState mHdrRenderState = new HdrRenderState(this); Loading Loading @@ -2743,6 +2744,10 @@ public final class ViewRootImpl implements ViewParent, mBlastBufferQueue = new BLASTBufferQueue(mTag, mSurfaceControl, mSurfaceSize.x, mSurfaceSize.y, mWindowAttributes.format); mBlastBufferQueue.setTransactionHangCallback(sTransactionHangCallback); // If we create and destroy BBQ without recreating the SurfaceControl, we can end up // queuing buffers on multiple apply tokens causing out of order buffer submissions. We // fix this by setting the same apply token on all BBQs created by this VRI. mBlastBufferQueue.setApplyToken(mBbqApplyToken); Surface blastSurface; if (addSchandleToVriSurface()) { blastSurface = mBlastBufferQueue.createSurfaceWithHandle(); Loading
core/jni/android_graphics_BLASTBufferQueue.cpp +12 −5 Original line number Diff line number Diff line Loading @@ -16,16 +16,16 @@ #define LOG_TAG "BLASTBufferQueue" #include <nativehelper/JNIHelp.h> #include <android_runtime/AndroidRuntime.h> #include <android_runtime/android_view_Surface.h> #include <utils/Log.h> #include <utils/RefBase.h> #include <android_util_Binder.h> #include <gui/BLASTBufferQueue.h> #include <gui/Surface.h> #include <gui/SurfaceComposerClient.h> #include <nativehelper/JNIHelp.h> #include <utils/Log.h> #include <utils/RefBase.h> #include "core_jni_helpers.h" namespace android { Loading Loading @@ -209,6 +209,12 @@ static jobject nativeGatherPendingTransactions(JNIEnv* env, jclass clazz, jlong reinterpret_cast<jlong>(transaction)); } static void nativeSetApplyToken(JNIEnv* env, jclass clazz, jlong ptr, jobject applyTokenObject) { sp<BLASTBufferQueue> queue = reinterpret_cast<BLASTBufferQueue*>(ptr); sp<IBinder> token(ibinderForJavaObject(env, applyTokenObject)); return queue->setApplyToken(std::move(token)); } static const JNINativeMethod gMethods[] = { /* name, signature, funcPtr */ // clang-format off Loading @@ -227,6 +233,7 @@ static const JNINativeMethod gMethods[] = { {"nativeSetTransactionHangCallback", "(JLandroid/graphics/BLASTBufferQueue$TransactionHangCallback;)V", (void*)nativeSetTransactionHangCallback}, {"nativeSetApplyToken", "(JLandroid/os/IBinder;)V", (void*)nativeSetApplyToken}, // clang-format on }; Loading
graphics/java/android/graphics/BLASTBufferQueue.java +6 −0 Original line number Diff line number Diff line Loading @@ -17,6 +17,7 @@ package android.graphics; import android.annotation.NonNull; import android.os.IBinder; import android.view.Surface; import android.view.SurfaceControl; Loading Loading @@ -47,6 +48,7 @@ public final class BLASTBufferQueue { long frameNumber); private static native void nativeSetTransactionHangCallback(long ptr, TransactionHangCallback callback); private static native void nativeSetApplyToken(long ptr, IBinder applyToken); public interface TransactionHangCallback { void onTransactionHang(String reason); Loading Loading @@ -204,4 +206,8 @@ public final class BLASTBufferQueue { public void setTransactionHangCallback(TransactionHangCallback hangCallback) { nativeSetTransactionHangCallback(mNativeObject, hangCallback); } public void setApplyToken(IBinder applyToken) { nativeSetApplyToken(mNativeObject, applyToken); } }