SurfaceView: Correct coordinate space in windowPositionLostRT.

am: 3387913237

Change-Id: I7f28aab013bd6fe213a90e293664cc59ee6d23cf
This commit is contained in:
Robert Carr
2016-09-07 19:25:20 +00:00
committed by android-build-merger
2 changed files with 24 additions and 19 deletions

View File

@@ -115,6 +115,7 @@ public class SurfaceView extends View {
final Rect mStableInsets = new Rect();
final Rect mOutsets = new Rect();
final Rect mBackdropFrame = new Rect();
final Rect mTmpRect = new Rect();
final Configuration mConfiguration = new Configuration();
static final int KEEP_SCREEN_ON_MSG = 1;
@@ -661,21 +662,21 @@ public class SurfaceView extends View {
transformFromViewToWindowSpace(mLocation);
mWinFrame.set(mWindowSpaceLeft, mWindowSpaceTop,
mTmpRect.set(mWindowSpaceLeft, mWindowSpaceTop,
mLocation[0], mLocation[1]);
if (mTranslator != null) {
mTranslator.translateRectInAppWindowToScreen(mWinFrame);
mTranslator.translateRectInAppWindowToScreen(mTmpRect);
}
if (!isHardwareAccelerated() || !mRtHandlingPositionUpdates) {
try {
if (DEBUG) Log.d(TAG, String.format("%d updateWindowPosition UI, " +
"postion = [%d, %d, %d, %d]", System.identityHashCode(this),
mWinFrame.left, mWinFrame.top,
mWinFrame.right, mWinFrame.bottom));
mSession.repositionChild(mWindow, mWinFrame.left, mWinFrame.top,
mWinFrame.right, mWinFrame.bottom, -1, mWinFrame);
mTmpRect.left, mTmpRect.top,
mTmpRect.right, mTmpRect.bottom));
mSession.repositionChild(mWindow, mTmpRect.left, mTmpRect.top,
mTmpRect.right, mTmpRect.bottom, -1, mTmpRect);
} catch (RemoteException ex) {
Log.e(TAG, "Exception from relayout", ex);
}
@@ -687,10 +688,10 @@ public class SurfaceView extends View {
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
*/
public final void updateWindowPositionRT(long frameNumber,
public final void updateWindowPosition_renderWorker(long frameNumber,
int left, int top, int right, int bottom) {
IWindowSession session = mSession;
MyWindow window = mWindow;
@@ -715,7 +716,7 @@ public class SurfaceView extends View {
}
try {
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),
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
* draw tree
* draw tree. UI thread is blocked at this point.
* @hide
*/
public final void windowPositionLostRT(long frameNumber) {
public final void windowPositionLost_uiRtSync(long frameNumber) {
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));
}
IWindowSession session = mSession;
@@ -752,14 +753,18 @@ public class SurfaceView extends View {
// safely access other member variables at this time.
// So do what the UI thread would have done if RT wasn't handling position
// 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 {
if (DEBUG) Log.d(TAG, String.format("%d updateWindowPosition, " +
"postion = [%d, %d, %d, %d]", System.identityHashCode(this),
mWinFrame.left, mWinFrame.top,
mWinFrame.right, mWinFrame.bottom));
session.repositionChild(window, mWinFrame.left, mWinFrame.top,
mWinFrame.right, mWinFrame.bottom, frameNumber, mWinFrame);
mTmpRect.left, mTmpRect.top,
mTmpRect.right, mTmpRect.bottom));
session.repositionChild(window, mTmpRect.left, mTmpRect.top,
mTmpRect.right, mTmpRect.bottom, frameNumber, mWinFrame);
} catch (RemoteException ex) {
Log.e(TAG, "Exception from relayout", ex);
}

View File

@@ -721,9 +721,9 @@ static const JNINativeMethod gMethods[] = {
int register_android_view_RenderNode(JNIEnv* env) {
jclass clazz = FindClassOrDie(env, "android/view/SurfaceView");
gSurfaceViewPositionUpdateMethod = GetMethodIDOrDie(env, clazz,
"updateWindowPositionRT", "(JIIII)V");
"updateWindowPosition_renderWorker", "(JIIII)V");
gSurfaceViewPositionLostMethod = GetMethodIDOrDie(env, clazz,
"windowPositionLostRT", "(J)V");
"windowPositionLost_uiRtSync", "(J)V");
clazz = FindClassOrDie(env, "android/view/RenderNode");
gOnRenderNodeDetached = GetMethodIDOrDie(env, clazz,
"onRenderNodeDetached", "()V");