Merge "SurfaceView: Correct coordinate space in windowPositionLostRT." into nyc-mr1-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
b5820b3dc9
@@ -115,6 +115,7 @@ public class SurfaceView extends View {
|
|||||||
final Rect mStableInsets = new Rect();
|
final Rect mStableInsets = new Rect();
|
||||||
final Rect mOutsets = new Rect();
|
final Rect mOutsets = new Rect();
|
||||||
final Rect mBackdropFrame = new Rect();
|
final Rect mBackdropFrame = new Rect();
|
||||||
|
final Rect mTmpRect = new Rect();
|
||||||
final Configuration mConfiguration = new Configuration();
|
final Configuration mConfiguration = new Configuration();
|
||||||
|
|
||||||
static final int KEEP_SCREEN_ON_MSG = 1;
|
static final int KEEP_SCREEN_ON_MSG = 1;
|
||||||
@@ -661,21 +662,21 @@ public class SurfaceView extends View {
|
|||||||
|
|
||||||
transformFromViewToWindowSpace(mLocation);
|
transformFromViewToWindowSpace(mLocation);
|
||||||
|
|
||||||
mWinFrame.set(mWindowSpaceLeft, mWindowSpaceTop,
|
mTmpRect.set(mWindowSpaceLeft, mWindowSpaceTop,
|
||||||
mLocation[0], mLocation[1]);
|
mLocation[0], mLocation[1]);
|
||||||
|
|
||||||
if (mTranslator != null) {
|
if (mTranslator != null) {
|
||||||
mTranslator.translateRectInAppWindowToScreen(mWinFrame);
|
mTranslator.translateRectInAppWindowToScreen(mTmpRect);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!isHardwareAccelerated() || !mRtHandlingPositionUpdates) {
|
if (!isHardwareAccelerated() || !mRtHandlingPositionUpdates) {
|
||||||
try {
|
try {
|
||||||
if (DEBUG) Log.d(TAG, String.format("%d updateWindowPosition UI, " +
|
if (DEBUG) Log.d(TAG, String.format("%d updateWindowPosition UI, " +
|
||||||
"postion = [%d, %d, %d, %d]", System.identityHashCode(this),
|
"postion = [%d, %d, %d, %d]", System.identityHashCode(this),
|
||||||
mWinFrame.left, mWinFrame.top,
|
mTmpRect.left, mTmpRect.top,
|
||||||
mWinFrame.right, mWinFrame.bottom));
|
mTmpRect.right, mTmpRect.bottom));
|
||||||
mSession.repositionChild(mWindow, mWinFrame.left, mWinFrame.top,
|
mSession.repositionChild(mWindow, mTmpRect.left, mTmpRect.top,
|
||||||
mWinFrame.right, mWinFrame.bottom, -1, mWinFrame);
|
mTmpRect.right, mTmpRect.bottom, -1, mTmpRect);
|
||||||
} catch (RemoteException ex) {
|
} catch (RemoteException ex) {
|
||||||
Log.e(TAG, "Exception from relayout", ex);
|
Log.e(TAG, "Exception from relayout", ex);
|
||||||
}
|
}
|
||||||
@@ -687,10 +688,10 @@ public class SurfaceView extends View {
|
|||||||
private Rect mRTLastReportedPosition = new Rect();
|
private Rect mRTLastReportedPosition = new Rect();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called by native on RenderThread to update the window position
|
* Called by native by a Rendering Worker thread to update the window position
|
||||||
* @hide
|
* @hide
|
||||||
*/
|
*/
|
||||||
public final void updateWindowPositionRT(long frameNumber,
|
public final void updateWindowPosition_renderWorker(long frameNumber,
|
||||||
int left, int top, int right, int bottom) {
|
int left, int top, int right, int bottom) {
|
||||||
IWindowSession session = mSession;
|
IWindowSession session = mSession;
|
||||||
MyWindow window = mWindow;
|
MyWindow window = mWindow;
|
||||||
@@ -715,7 +716,7 @@ public class SurfaceView extends View {
|
|||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
if (DEBUG) {
|
if (DEBUG) {
|
||||||
Log.d(TAG, String.format("%d updateWindowPosition RT, frameNr = %d, " +
|
Log.d(TAG, String.format("%d updateWindowPosition RenderWorker, frameNr = %d, " +
|
||||||
"postion = [%d, %d, %d, %d]", System.identityHashCode(this),
|
"postion = [%d, %d, %d, %d]", System.identityHashCode(this),
|
||||||
frameNumber, left, top, right, bottom));
|
frameNumber, left, top, right, bottom));
|
||||||
}
|
}
|
||||||
@@ -732,12 +733,12 @@ public class SurfaceView extends View {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Called by native on RenderThread to notify that the window is no longer in the
|
* Called by native on RenderThread to notify that the window is no longer in the
|
||||||
* draw tree
|
* draw tree. UI thread is blocked at this point.
|
||||||
* @hide
|
* @hide
|
||||||
*/
|
*/
|
||||||
public final void windowPositionLostRT(long frameNumber) {
|
public final void windowPositionLost_uiRtSync(long frameNumber) {
|
||||||
if (DEBUG) {
|
if (DEBUG) {
|
||||||
Log.d(TAG, String.format("%d windowPositionLostRT RT, frameNr = %d",
|
Log.d(TAG, String.format("%d windowPositionLost, frameNr = %d",
|
||||||
System.identityHashCode(this), frameNumber));
|
System.identityHashCode(this), frameNumber));
|
||||||
}
|
}
|
||||||
IWindowSession session = mSession;
|
IWindowSession session = mSession;
|
||||||
@@ -752,14 +753,18 @@ public class SurfaceView extends View {
|
|||||||
// safely access other member variables at this time.
|
// safely access other member variables at this time.
|
||||||
// So do what the UI thread would have done if RT wasn't handling position
|
// So do what the UI thread would have done if RT wasn't handling position
|
||||||
// updates.
|
// updates.
|
||||||
if (!mWinFrame.isEmpty() && !mWinFrame.equals(mRTLastReportedPosition)) {
|
mTmpRect.set(mLayout.x, mLayout.y,
|
||||||
|
mLayout.x + mLayout.width,
|
||||||
|
mLayout.y + mLayout.height);
|
||||||
|
|
||||||
|
if (!mTmpRect.isEmpty() && !mTmpRect.equals(mRTLastReportedPosition)) {
|
||||||
try {
|
try {
|
||||||
if (DEBUG) Log.d(TAG, String.format("%d updateWindowPosition, " +
|
if (DEBUG) Log.d(TAG, String.format("%d updateWindowPosition, " +
|
||||||
"postion = [%d, %d, %d, %d]", System.identityHashCode(this),
|
"postion = [%d, %d, %d, %d]", System.identityHashCode(this),
|
||||||
mWinFrame.left, mWinFrame.top,
|
mTmpRect.left, mTmpRect.top,
|
||||||
mWinFrame.right, mWinFrame.bottom));
|
mTmpRect.right, mTmpRect.bottom));
|
||||||
session.repositionChild(window, mWinFrame.left, mWinFrame.top,
|
session.repositionChild(window, mTmpRect.left, mTmpRect.top,
|
||||||
mWinFrame.right, mWinFrame.bottom, frameNumber, mWinFrame);
|
mTmpRect.right, mTmpRect.bottom, frameNumber, mWinFrame);
|
||||||
} catch (RemoteException ex) {
|
} catch (RemoteException ex) {
|
||||||
Log.e(TAG, "Exception from relayout", ex);
|
Log.e(TAG, "Exception from relayout", ex);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -721,9 +721,9 @@ static const JNINativeMethod gMethods[] = {
|
|||||||
int register_android_view_RenderNode(JNIEnv* env) {
|
int register_android_view_RenderNode(JNIEnv* env) {
|
||||||
jclass clazz = FindClassOrDie(env, "android/view/SurfaceView");
|
jclass clazz = FindClassOrDie(env, "android/view/SurfaceView");
|
||||||
gSurfaceViewPositionUpdateMethod = GetMethodIDOrDie(env, clazz,
|
gSurfaceViewPositionUpdateMethod = GetMethodIDOrDie(env, clazz,
|
||||||
"updateWindowPositionRT", "(JIIII)V");
|
"updateWindowPosition_renderWorker", "(JIIII)V");
|
||||||
gSurfaceViewPositionLostMethod = GetMethodIDOrDie(env, clazz,
|
gSurfaceViewPositionLostMethod = GetMethodIDOrDie(env, clazz,
|
||||||
"windowPositionLostRT", "(J)V");
|
"windowPositionLost_uiRtSync", "(J)V");
|
||||||
clazz = FindClassOrDie(env, "android/view/RenderNode");
|
clazz = FindClassOrDie(env, "android/view/RenderNode");
|
||||||
gOnRenderNodeDetached = GetMethodIDOrDie(env, clazz,
|
gOnRenderNodeDetached = GetMethodIDOrDie(env, clazz,
|
||||||
"onRenderNodeDetached", "()V");
|
"onRenderNodeDetached", "()V");
|
||||||
|
|||||||
Reference in New Issue
Block a user