Merge "DisplayEventDispatcher: use eConfigChangedDispatch" into qt-r1-dev
am: 619946fdc4
Change-Id: I98ecea42a933ed20ddd7b085baa88c277e53e353
This commit is contained in:
@@ -16,6 +16,7 @@
|
|||||||
|
|
||||||
package android.view;
|
package android.view;
|
||||||
|
|
||||||
|
import static android.view.DisplayEventReceiver.CONFIG_CHANGED_EVENT_SUPPRESS;
|
||||||
import static android.view.DisplayEventReceiver.VSYNC_SOURCE_APP;
|
import static android.view.DisplayEventReceiver.VSYNC_SOURCE_APP;
|
||||||
import static android.view.DisplayEventReceiver.VSYNC_SOURCE_SURFACE_FLINGER;
|
import static android.view.DisplayEventReceiver.VSYNC_SOURCE_SURFACE_FLINGER;
|
||||||
|
|
||||||
@@ -910,7 +911,7 @@ public final class Choreographer {
|
|||||||
private int mFrame;
|
private int mFrame;
|
||||||
|
|
||||||
public FrameDisplayEventReceiver(Looper looper, int vsyncSource) {
|
public FrameDisplayEventReceiver(Looper looper, int vsyncSource) {
|
||||||
super(looper, vsyncSource);
|
super(looper, vsyncSource, CONFIG_CHANGED_EVENT_SUPPRESS);
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO(b/116025192): physicalDisplayId is ignored because SF only emits VSYNC events for
|
// TODO(b/116025192): physicalDisplayId is ignored because SF only emits VSYNC events for
|
||||||
|
|||||||
@@ -53,6 +53,20 @@ public abstract class DisplayEventReceiver {
|
|||||||
*/
|
*/
|
||||||
public static final int VSYNC_SOURCE_SURFACE_FLINGER = 1;
|
public static final int VSYNC_SOURCE_SURFACE_FLINGER = 1;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Specifies to suppress config changed events from being generated from Surface Flinger.
|
||||||
|
* <p>
|
||||||
|
* Needs to be kept in sync with frameworks/native/include/gui/ISurfaceComposer.h
|
||||||
|
*/
|
||||||
|
public static final int CONFIG_CHANGED_EVENT_SUPPRESS = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Specifies to generate config changed events from Surface Flinger.
|
||||||
|
* <p>
|
||||||
|
* Needs to be kept in sync with frameworks/native/include/gui/ISurfaceComposer.h
|
||||||
|
*/
|
||||||
|
public static final int CONFIG_CHANGED_EVENT_DISPATCH = 1;
|
||||||
|
|
||||||
private static final String TAG = "DisplayEventReceiver";
|
private static final String TAG = "DisplayEventReceiver";
|
||||||
|
|
||||||
private final CloseGuard mCloseGuard = CloseGuard.get();
|
private final CloseGuard mCloseGuard = CloseGuard.get();
|
||||||
@@ -65,7 +79,7 @@ public abstract class DisplayEventReceiver {
|
|||||||
private MessageQueue mMessageQueue;
|
private MessageQueue mMessageQueue;
|
||||||
|
|
||||||
private static native long nativeInit(WeakReference<DisplayEventReceiver> receiver,
|
private static native long nativeInit(WeakReference<DisplayEventReceiver> receiver,
|
||||||
MessageQueue messageQueue, int vsyncSource);
|
MessageQueue messageQueue, int vsyncSource, int configChanged);
|
||||||
private static native void nativeDispose(long receiverPtr);
|
private static native void nativeDispose(long receiverPtr);
|
||||||
@FastNative
|
@FastNative
|
||||||
private static native void nativeScheduleVsync(long receiverPtr);
|
private static native void nativeScheduleVsync(long receiverPtr);
|
||||||
@@ -77,7 +91,7 @@ public abstract class DisplayEventReceiver {
|
|||||||
*/
|
*/
|
||||||
@UnsupportedAppUsage
|
@UnsupportedAppUsage
|
||||||
public DisplayEventReceiver(Looper looper) {
|
public DisplayEventReceiver(Looper looper) {
|
||||||
this(looper, VSYNC_SOURCE_APP);
|
this(looper, VSYNC_SOURCE_APP, CONFIG_CHANGED_EVENT_SUPPRESS);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -85,15 +99,17 @@ public abstract class DisplayEventReceiver {
|
|||||||
*
|
*
|
||||||
* @param looper The looper to use when invoking callbacks.
|
* @param looper The looper to use when invoking callbacks.
|
||||||
* @param vsyncSource The source of the vsync tick. Must be on of the VSYNC_SOURCE_* values.
|
* @param vsyncSource The source of the vsync tick. Must be on of the VSYNC_SOURCE_* values.
|
||||||
|
* @param configChanged Whether to dispatch config changed events. Must be one of the
|
||||||
|
* CONFIG_CHANGED_EVENT_* values.
|
||||||
*/
|
*/
|
||||||
public DisplayEventReceiver(Looper looper, int vsyncSource) {
|
public DisplayEventReceiver(Looper looper, int vsyncSource, int configChanged) {
|
||||||
if (looper == null) {
|
if (looper == null) {
|
||||||
throw new IllegalArgumentException("looper must not be null");
|
throw new IllegalArgumentException("looper must not be null");
|
||||||
}
|
}
|
||||||
|
|
||||||
mMessageQueue = looper.getQueue();
|
mMessageQueue = looper.getQueue();
|
||||||
mReceiverPtr = nativeInit(new WeakReference<DisplayEventReceiver>(this), mMessageQueue,
|
mReceiverPtr = nativeInit(new WeakReference<DisplayEventReceiver>(this), mMessageQueue,
|
||||||
vsyncSource);
|
vsyncSource, configChanged);
|
||||||
|
|
||||||
mCloseGuard.open("dispose");
|
mCloseGuard.open("dispose");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -48,7 +48,8 @@ static struct {
|
|||||||
class NativeDisplayEventReceiver : public DisplayEventDispatcher {
|
class NativeDisplayEventReceiver : public DisplayEventDispatcher {
|
||||||
public:
|
public:
|
||||||
NativeDisplayEventReceiver(JNIEnv* env,
|
NativeDisplayEventReceiver(JNIEnv* env,
|
||||||
jobject receiverWeak, const sp<MessageQueue>& messageQueue, jint vsyncSource);
|
jobject receiverWeak, const sp<MessageQueue>& messageQueue, jint vsyncSource,
|
||||||
|
jint configChanged);
|
||||||
|
|
||||||
void dispose();
|
void dispose();
|
||||||
|
|
||||||
@@ -68,9 +69,11 @@ private:
|
|||||||
|
|
||||||
|
|
||||||
NativeDisplayEventReceiver::NativeDisplayEventReceiver(JNIEnv* env,
|
NativeDisplayEventReceiver::NativeDisplayEventReceiver(JNIEnv* env,
|
||||||
jobject receiverWeak, const sp<MessageQueue>& messageQueue, jint vsyncSource) :
|
jobject receiverWeak, const sp<MessageQueue>& messageQueue, jint vsyncSource,
|
||||||
|
jint configChanged) :
|
||||||
DisplayEventDispatcher(messageQueue->getLooper(),
|
DisplayEventDispatcher(messageQueue->getLooper(),
|
||||||
static_cast<ISurfaceComposer::VsyncSource>(vsyncSource)),
|
static_cast<ISurfaceComposer::VsyncSource>(vsyncSource),
|
||||||
|
static_cast<ISurfaceComposer::ConfigChanged>(configChanged)),
|
||||||
mReceiverWeakGlobal(env->NewGlobalRef(receiverWeak)),
|
mReceiverWeakGlobal(env->NewGlobalRef(receiverWeak)),
|
||||||
mMessageQueue(messageQueue) {
|
mMessageQueue(messageQueue) {
|
||||||
ALOGV("receiver %p ~ Initializing display event receiver.", this);
|
ALOGV("receiver %p ~ Initializing display event receiver.", this);
|
||||||
@@ -136,7 +139,7 @@ void NativeDisplayEventReceiver::dispatchConfigChanged(nsecs_t timestamp,
|
|||||||
|
|
||||||
|
|
||||||
static jlong nativeInit(JNIEnv* env, jclass clazz, jobject receiverWeak,
|
static jlong nativeInit(JNIEnv* env, jclass clazz, jobject receiverWeak,
|
||||||
jobject messageQueueObj, jint vsyncSource) {
|
jobject messageQueueObj, jint vsyncSource, jint configChanged) {
|
||||||
sp<MessageQueue> messageQueue = android_os_MessageQueue_getMessageQueue(env, messageQueueObj);
|
sp<MessageQueue> messageQueue = android_os_MessageQueue_getMessageQueue(env, messageQueueObj);
|
||||||
if (messageQueue == NULL) {
|
if (messageQueue == NULL) {
|
||||||
jniThrowRuntimeException(env, "MessageQueue is not initialized.");
|
jniThrowRuntimeException(env, "MessageQueue is not initialized.");
|
||||||
@@ -144,7 +147,7 @@ static jlong nativeInit(JNIEnv* env, jclass clazz, jobject receiverWeak,
|
|||||||
}
|
}
|
||||||
|
|
||||||
sp<NativeDisplayEventReceiver> receiver = new NativeDisplayEventReceiver(env,
|
sp<NativeDisplayEventReceiver> receiver = new NativeDisplayEventReceiver(env,
|
||||||
receiverWeak, messageQueue, vsyncSource);
|
receiverWeak, messageQueue, vsyncSource, configChanged);
|
||||||
status_t status = receiver->initialize();
|
status_t status = receiver->initialize();
|
||||||
if (status) {
|
if (status) {
|
||||||
String8 message;
|
String8 message;
|
||||||
@@ -179,7 +182,7 @@ static void nativeScheduleVsync(JNIEnv* env, jclass clazz, jlong receiverPtr) {
|
|||||||
static const JNINativeMethod gMethods[] = {
|
static const JNINativeMethod gMethods[] = {
|
||||||
/* name, signature, funcPtr */
|
/* name, signature, funcPtr */
|
||||||
{ "nativeInit",
|
{ "nativeInit",
|
||||||
"(Ljava/lang/ref/WeakReference;Landroid/os/MessageQueue;I)J",
|
"(Ljava/lang/ref/WeakReference;Landroid/os/MessageQueue;II)J",
|
||||||
(void*)nativeInit },
|
(void*)nativeInit },
|
||||||
{ "nativeDispose",
|
{ "nativeDispose",
|
||||||
"(J)V",
|
"(J)V",
|
||||||
|
|||||||
@@ -34,8 +34,9 @@ namespace android {
|
|||||||
static const size_t EVENT_BUFFER_SIZE = 100;
|
static const size_t EVENT_BUFFER_SIZE = 100;
|
||||||
|
|
||||||
DisplayEventDispatcher::DisplayEventDispatcher(const sp<Looper>& looper,
|
DisplayEventDispatcher::DisplayEventDispatcher(const sp<Looper>& looper,
|
||||||
ISurfaceComposer::VsyncSource vsyncSource) :
|
ISurfaceComposer::VsyncSource vsyncSource,
|
||||||
mLooper(looper), mReceiver(vsyncSource), mWaitingForVsync(false) {
|
ISurfaceComposer::ConfigChanged configChanged) :
|
||||||
|
mLooper(looper), mReceiver(vsyncSource, configChanged), mWaitingForVsync(false) {
|
||||||
ALOGV("dispatcher %p ~ Initializing display event dispatcher.", this);
|
ALOGV("dispatcher %p ~ Initializing display event dispatcher.", this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -23,7 +23,8 @@ namespace android {
|
|||||||
class DisplayEventDispatcher : public LooperCallback {
|
class DisplayEventDispatcher : public LooperCallback {
|
||||||
public:
|
public:
|
||||||
explicit DisplayEventDispatcher(const sp<Looper>& looper,
|
explicit DisplayEventDispatcher(const sp<Looper>& looper,
|
||||||
ISurfaceComposer::VsyncSource vsyncSource = ISurfaceComposer::eVsyncSourceApp);
|
ISurfaceComposer::VsyncSource vsyncSource = ISurfaceComposer::eVsyncSourceApp,
|
||||||
|
ISurfaceComposer::ConfigChanged configChanged = ISurfaceComposer::eConfigChangedSuppress);
|
||||||
|
|
||||||
status_t initialize();
|
status_t initialize();
|
||||||
void dispose();
|
void dispose();
|
||||||
|
|||||||
@@ -156,7 +156,9 @@ void RenderThread::initializeDisplayEventReceiver() {
|
|||||||
LOG_ALWAYS_FATAL_IF(mVsyncSource, "Initializing a second DisplayEventReceiver?");
|
LOG_ALWAYS_FATAL_IF(mVsyncSource, "Initializing a second DisplayEventReceiver?");
|
||||||
|
|
||||||
if (!Properties::isolatedProcess) {
|
if (!Properties::isolatedProcess) {
|
||||||
auto receiver = std::make_unique<DisplayEventReceiver>();
|
auto receiver = std::make_unique<DisplayEventReceiver>(
|
||||||
|
ISurfaceComposer::eVsyncSourceApp,
|
||||||
|
ISurfaceComposer::eConfigChangedDispatch);
|
||||||
status_t status = receiver->initCheck();
|
status_t status = receiver->initCheck();
|
||||||
LOG_ALWAYS_FATAL_IF(status != NO_ERROR,
|
LOG_ALWAYS_FATAL_IF(status != NO_ERROR,
|
||||||
"Initialization of DisplayEventReceiver "
|
"Initialization of DisplayEventReceiver "
|
||||||
|
|||||||
@@ -856,7 +856,7 @@ final class LocalDisplayAdapter extends DisplayAdapter {
|
|||||||
|
|
||||||
private final class PhysicalDisplayEventReceiver extends DisplayEventReceiver {
|
private final class PhysicalDisplayEventReceiver extends DisplayEventReceiver {
|
||||||
PhysicalDisplayEventReceiver(Looper looper) {
|
PhysicalDisplayEventReceiver(Looper looper) {
|
||||||
super(looper, VSYNC_SOURCE_APP);
|
super(looper, VSYNC_SOURCE_APP, CONFIG_CHANGED_EVENT_DISPATCH);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
Reference in New Issue
Block a user