Loading core/java/android/view/Surface.java +9 −28 Original line number Diff line number Diff line Loading @@ -262,12 +262,8 @@ public class Surface implements Parcelable { IBinder displayToken, SurfaceTexture surfaceTexture); private static native void nativeSetDisplayLayerStack( IBinder displayToken, int layerStack); private static native void nativeSetDisplayOrientation( IBinder displayToken, int orientation); private static native void nativeSetDisplayViewport( IBinder displayToken, Rect viewport); private static native void nativeSetDisplayFrame( IBinder displayToken, Rect frame); private static native void nativeSetDisplayProjection( IBinder displayToken, int orientation, Rect layerStackRect, Rect displayRect); private static native boolean nativeGetDisplayInfo( IBinder displayToken, PhysicalDisplayInfo outInfo); Loading Loading @@ -617,33 +613,18 @@ public class Surface implements Parcelable { } /** @hide */ public static void setDisplayOrientation(IBinder displayToken, int orientation) { public static void setDisplayProjection(IBinder displayToken, int orientation, Rect layerStackRect, Rect displayRect) { if (displayToken == null) { throw new IllegalArgumentException("displayToken must not be null"); } nativeSetDisplayOrientation(displayToken, orientation); if (layerStackRect == null) { throw new IllegalArgumentException("layerStackRect must not be null"); } /** @hide */ public static void setDisplayViewport(IBinder displayToken, Rect viewport) { if (displayToken == null) { throw new IllegalArgumentException("displayToken must not be null"); } if (viewport == null) { throw new IllegalArgumentException("viewport must not be null"); } nativeSetDisplayViewport(displayToken, viewport); } /** @hide */ public static void setDisplayFrame(IBinder displayToken, Rect frame) { if (displayToken == null) { throw new IllegalArgumentException("displayToken must not be null"); } if (frame == null) { throw new IllegalArgumentException("frame must not be null"); if (displayRect == null) { throw new IllegalArgumentException("displayRect must not be null"); } nativeSetDisplayFrame(displayToken, frame); nativeSetDisplayProjection(displayToken, orientation, layerStackRect, displayRect); } /** @hide */ Loading core/jni/android_view_Surface.cpp +15 −33 Original line number Diff line number Diff line Loading @@ -647,38 +647,24 @@ static void nativeSetDisplayLayerStack(JNIEnv* env, jclass clazz, SurfaceComposerClient::setDisplayLayerStack(token, layerStack); } static void nativeSetDisplayOrientation(JNIEnv* env, jclass clazz, jobject tokenObj, jint orientation) { static void nativeSetDisplayProjection(JNIEnv* env, jclass clazz, jobject tokenObj, jint orientation, jobject rect1Obj, jobject rect2Obj) { sp<IBinder> token(ibinderForJavaObject(env, tokenObj)); if (token == NULL) return; SurfaceComposerClient::setDisplayOrientation(token, orientation); } static void nativeSetDisplayViewport(JNIEnv* env, jclass clazz, jobject tokenObj, jobject rectObj) { sp<IBinder> token(ibinderForJavaObject(env, tokenObj)); if (token == NULL) return; Rect rect1; rect1.left = env->GetIntField(rect1Obj, gRectClassInfo.left); rect1.top = env->GetIntField(rect1Obj, gRectClassInfo.top); rect1.right = env->GetIntField(rect1Obj, gRectClassInfo.right); rect1.bottom = env->GetIntField(rect1Obj, gRectClassInfo.bottom); Rect rect; rect.left = env->GetIntField(rectObj, gRectClassInfo.left); rect.top = env->GetIntField(rectObj, gRectClassInfo.top); rect.right = env->GetIntField(rectObj, gRectClassInfo.right); rect.bottom = env->GetIntField(rectObj, gRectClassInfo.bottom); SurfaceComposerClient::setDisplayViewport(token, rect); } static void nativeSetDisplayFrame(JNIEnv* env, jclass clazz, jobject tokenObj, jobject rectObj) { sp<IBinder> token(ibinderForJavaObject(env, tokenObj)); if (token == NULL) return; Rect rect2; rect2.left = env->GetIntField(rect2Obj, gRectClassInfo.left); rect2.top = env->GetIntField(rect2Obj, gRectClassInfo.top); rect2.right = env->GetIntField(rect2Obj, gRectClassInfo.right); rect2.bottom = env->GetIntField(rect2Obj, gRectClassInfo.bottom); Rect rect; rect.left = env->GetIntField(rectObj, gRectClassInfo.left); rect.top = env->GetIntField(rectObj, gRectClassInfo.top); rect.right = env->GetIntField(rectObj, gRectClassInfo.right); rect.bottom = env->GetIntField(rectObj, gRectClassInfo.bottom); SurfaceComposerClient::setDisplayFrame(token, rect); SurfaceComposerClient::setDisplayProjection(token, orientation, rect1, rect2); } static jboolean nativeGetDisplayInfo(JNIEnv* env, jclass clazz, Loading Loading @@ -818,12 +804,8 @@ static JNINativeMethod gSurfaceMethods[] = { (void*)nativeSetDisplaySurface }, {"nativeSetDisplayLayerStack", "(Landroid/os/IBinder;I)V", (void*)nativeSetDisplayLayerStack }, {"nativeSetDisplayOrientation", "(Landroid/os/IBinder;I)V", (void*)nativeSetDisplayOrientation }, {"nativeSetDisplayViewport", "(Landroid/os/IBinder;Landroid/graphics/Rect;)V", (void*)nativeSetDisplayViewport }, {"nativeSetDisplayFrame", "(Landroid/os/IBinder;Landroid/graphics/Rect;)V", (void*)nativeSetDisplayFrame }, {"nativeSetDisplayProjection", "(Landroid/os/IBinder;ILandroid/graphics/Rect;Landroid/graphics/Rect;)V", (void*)nativeSetDisplayProjection }, {"nativeGetDisplayInfo", "(Landroid/os/IBinder;Landroid/view/Surface$PhysicalDisplayInfo;)Z", (void*)nativeGetDisplayInfo }, {"nativeCopyFrom", "(Landroid/view/Surface;)V", Loading services/java/com/android/server/display/DisplayDevice.java +20 −38 Original line number Diff line number Diff line Loading @@ -38,8 +38,8 @@ abstract class DisplayDevice { // the display manager service. The display device shouldn't really be looking at these. private int mCurrentLayerStack = -1; private int mCurrentOrientation = -1; private Rect mCurrentViewport; private Rect mCurrentFrame; private Rect mCurrentLayerStackRect; private Rect mCurrentDisplayRect; // The display device does own its surface texture, but it should only set it // within a transaction from performTraversalInTransactionLocked. Loading Loading @@ -117,44 +117,26 @@ abstract class DisplayDevice { } /** * Sets the display orientation while in a transaction. * Sets the display projection while in a transaction. * * @param orientation defines the display's orientation * @param layerStackRect defines which area of the window manager coordinate * space will be used * @param displayRect defines where on the display will layerStackRect be * mapped to. displayRect is specified post-orientation, that is * it uses the orientation seen by the end-user */ public final void setOrientationInTransactionLocked(int orientation) { if (mCurrentOrientation == orientation) { return; } public final void setProjectionInTransactionLocked(int orientation, Rect layerStackRect, Rect displayRect) { mCurrentOrientation = orientation; Surface.setDisplayOrientation(mDisplayToken, orientation); } /** * Sets the display viewport while in a transaction. */ public final void setViewportInTransactionLocked(Rect viewport) { if (mCurrentViewport != null) { if (mCurrentViewport.equals(viewport)) { return; } } else { mCurrentViewport = new Rect(); } mCurrentViewport.set(viewport); Surface.setDisplayViewport(mDisplayToken, viewport); } /** * Sets the display frame while in a transaction. */ public final void setFrameInTransactionLocked(Rect frame) { if (mCurrentFrame != null) { if (mCurrentFrame.equals(frame)) { return; if (mCurrentLayerStackRect == null) { mCurrentLayerStackRect = new Rect(); } } else { mCurrentFrame = new Rect(); mCurrentLayerStackRect.set(layerStackRect); if (mCurrentDisplayRect == null) { mCurrentDisplayRect = new Rect(); } mCurrentFrame.set(frame); Surface.setDisplayFrame(mDisplayToken, frame); mCurrentDisplayRect.set(displayRect); Surface.setDisplayProjection(mDisplayToken, orientation, layerStackRect, displayRect); } /** Loading @@ -176,8 +158,8 @@ abstract class DisplayDevice { pw.println("mAdapter=" + mDisplayAdapter.getName()); pw.println("mCurrentLayerStack=" + mCurrentLayerStack); pw.println("mCurrentOrientation=" + mCurrentOrientation); pw.println("mCurrentViewport=" + mCurrentViewport); pw.println("mCurrentFrame=" + mCurrentFrame); pw.println("mCurrentViewport=" + mCurrentLayerStackRect); pw.println("mCurrentFrame=" + mCurrentDisplayRect); pw.println("mCurrentSurfaceTexture=" + mCurrentSurfaceTexture); } } services/java/com/android/server/display/LogicalDisplay.java +14 −13 Original line number Diff line number Diff line Loading @@ -64,7 +64,8 @@ final class LogicalDisplay { private DisplayDeviceInfo mPrimaryDisplayDeviceInfo; // Temporary rectangle used when needed. private final Rect mTempRect = new Rect(); private final Rect mTempLayerStackRect = new Rect(); private final Rect mTempDisplayRect = new Rect(); public LogicalDisplay(int layerStack, DisplayDevice primaryDisplayDevice) { mLayerStack = layerStack; Loading Loading @@ -208,8 +209,7 @@ final class LogicalDisplay { // Set the viewport. // This is the area of the logical display that we intend to show on the // display device. For now, it is always the full size of the logical display. mTempRect.set(0, 0, displayInfo.logicalWidth, displayInfo.logicalHeight); device.setViewportInTransactionLocked(mTempRect); mTempLayerStackRect.set(0, 0, displayInfo.logicalWidth, displayInfo.logicalHeight); // Set the orientation. // The orientation specifies how the physical coordinate system of the display Loading @@ -219,7 +219,6 @@ final class LogicalDisplay { && (displayDeviceInfo.flags & DisplayDeviceInfo.FLAG_SUPPORTS_ROTATION) != 0) { orientation = displayInfo.rotation; } device.setOrientationInTransactionLocked(orientation); // Set the frame. // The frame specifies the rotated physical coordinates into which the viewport Loading @@ -238,21 +237,23 @@ final class LogicalDisplay { // We avoid a division (and possible floating point imprecision) here by // multiplying the fractions by the product of their denominators before // comparing them. int frameWidth, frameHeight; int displayRectWidth, displayRectHeight; if (physWidth * displayInfo.logicalHeight < physHeight * displayInfo.logicalWidth) { // Letter box. frameWidth = physWidth; frameHeight = displayInfo.logicalHeight * physWidth / displayInfo.logicalWidth; displayRectWidth = physWidth; displayRectHeight = displayInfo.logicalHeight * physWidth / displayInfo.logicalWidth; } else { // Pillar box. frameWidth = displayInfo.logicalWidth * physHeight / displayInfo.logicalHeight; frameHeight = physHeight; displayRectWidth = displayInfo.logicalWidth * physHeight / displayInfo.logicalHeight; displayRectHeight = physHeight; } int frameTop = (physHeight - frameHeight) / 2; int frameLeft = (physWidth - frameWidth) / 2; mTempRect.set(frameLeft, frameTop, frameLeft + frameWidth, frameTop + frameHeight); device.setFrameInTransactionLocked(mTempRect); int displayRectTop = (physHeight - displayRectHeight) / 2; int displayRectLeft = (physWidth - displayRectWidth) / 2; mTempDisplayRect.set(displayRectLeft, displayRectTop, displayRectLeft + displayRectWidth, displayRectTop + displayRectHeight); device.setProjectionInTransactionLocked(orientation, mTempLayerStackRect, mTempDisplayRect); } public void dumpLocked(PrintWriter pw) { Loading Loading
core/java/android/view/Surface.java +9 −28 Original line number Diff line number Diff line Loading @@ -262,12 +262,8 @@ public class Surface implements Parcelable { IBinder displayToken, SurfaceTexture surfaceTexture); private static native void nativeSetDisplayLayerStack( IBinder displayToken, int layerStack); private static native void nativeSetDisplayOrientation( IBinder displayToken, int orientation); private static native void nativeSetDisplayViewport( IBinder displayToken, Rect viewport); private static native void nativeSetDisplayFrame( IBinder displayToken, Rect frame); private static native void nativeSetDisplayProjection( IBinder displayToken, int orientation, Rect layerStackRect, Rect displayRect); private static native boolean nativeGetDisplayInfo( IBinder displayToken, PhysicalDisplayInfo outInfo); Loading Loading @@ -617,33 +613,18 @@ public class Surface implements Parcelable { } /** @hide */ public static void setDisplayOrientation(IBinder displayToken, int orientation) { public static void setDisplayProjection(IBinder displayToken, int orientation, Rect layerStackRect, Rect displayRect) { if (displayToken == null) { throw new IllegalArgumentException("displayToken must not be null"); } nativeSetDisplayOrientation(displayToken, orientation); if (layerStackRect == null) { throw new IllegalArgumentException("layerStackRect must not be null"); } /** @hide */ public static void setDisplayViewport(IBinder displayToken, Rect viewport) { if (displayToken == null) { throw new IllegalArgumentException("displayToken must not be null"); } if (viewport == null) { throw new IllegalArgumentException("viewport must not be null"); } nativeSetDisplayViewport(displayToken, viewport); } /** @hide */ public static void setDisplayFrame(IBinder displayToken, Rect frame) { if (displayToken == null) { throw new IllegalArgumentException("displayToken must not be null"); } if (frame == null) { throw new IllegalArgumentException("frame must not be null"); if (displayRect == null) { throw new IllegalArgumentException("displayRect must not be null"); } nativeSetDisplayFrame(displayToken, frame); nativeSetDisplayProjection(displayToken, orientation, layerStackRect, displayRect); } /** @hide */ Loading
core/jni/android_view_Surface.cpp +15 −33 Original line number Diff line number Diff line Loading @@ -647,38 +647,24 @@ static void nativeSetDisplayLayerStack(JNIEnv* env, jclass clazz, SurfaceComposerClient::setDisplayLayerStack(token, layerStack); } static void nativeSetDisplayOrientation(JNIEnv* env, jclass clazz, jobject tokenObj, jint orientation) { static void nativeSetDisplayProjection(JNIEnv* env, jclass clazz, jobject tokenObj, jint orientation, jobject rect1Obj, jobject rect2Obj) { sp<IBinder> token(ibinderForJavaObject(env, tokenObj)); if (token == NULL) return; SurfaceComposerClient::setDisplayOrientation(token, orientation); } static void nativeSetDisplayViewport(JNIEnv* env, jclass clazz, jobject tokenObj, jobject rectObj) { sp<IBinder> token(ibinderForJavaObject(env, tokenObj)); if (token == NULL) return; Rect rect1; rect1.left = env->GetIntField(rect1Obj, gRectClassInfo.left); rect1.top = env->GetIntField(rect1Obj, gRectClassInfo.top); rect1.right = env->GetIntField(rect1Obj, gRectClassInfo.right); rect1.bottom = env->GetIntField(rect1Obj, gRectClassInfo.bottom); Rect rect; rect.left = env->GetIntField(rectObj, gRectClassInfo.left); rect.top = env->GetIntField(rectObj, gRectClassInfo.top); rect.right = env->GetIntField(rectObj, gRectClassInfo.right); rect.bottom = env->GetIntField(rectObj, gRectClassInfo.bottom); SurfaceComposerClient::setDisplayViewport(token, rect); } static void nativeSetDisplayFrame(JNIEnv* env, jclass clazz, jobject tokenObj, jobject rectObj) { sp<IBinder> token(ibinderForJavaObject(env, tokenObj)); if (token == NULL) return; Rect rect2; rect2.left = env->GetIntField(rect2Obj, gRectClassInfo.left); rect2.top = env->GetIntField(rect2Obj, gRectClassInfo.top); rect2.right = env->GetIntField(rect2Obj, gRectClassInfo.right); rect2.bottom = env->GetIntField(rect2Obj, gRectClassInfo.bottom); Rect rect; rect.left = env->GetIntField(rectObj, gRectClassInfo.left); rect.top = env->GetIntField(rectObj, gRectClassInfo.top); rect.right = env->GetIntField(rectObj, gRectClassInfo.right); rect.bottom = env->GetIntField(rectObj, gRectClassInfo.bottom); SurfaceComposerClient::setDisplayFrame(token, rect); SurfaceComposerClient::setDisplayProjection(token, orientation, rect1, rect2); } static jboolean nativeGetDisplayInfo(JNIEnv* env, jclass clazz, Loading Loading @@ -818,12 +804,8 @@ static JNINativeMethod gSurfaceMethods[] = { (void*)nativeSetDisplaySurface }, {"nativeSetDisplayLayerStack", "(Landroid/os/IBinder;I)V", (void*)nativeSetDisplayLayerStack }, {"nativeSetDisplayOrientation", "(Landroid/os/IBinder;I)V", (void*)nativeSetDisplayOrientation }, {"nativeSetDisplayViewport", "(Landroid/os/IBinder;Landroid/graphics/Rect;)V", (void*)nativeSetDisplayViewport }, {"nativeSetDisplayFrame", "(Landroid/os/IBinder;Landroid/graphics/Rect;)V", (void*)nativeSetDisplayFrame }, {"nativeSetDisplayProjection", "(Landroid/os/IBinder;ILandroid/graphics/Rect;Landroid/graphics/Rect;)V", (void*)nativeSetDisplayProjection }, {"nativeGetDisplayInfo", "(Landroid/os/IBinder;Landroid/view/Surface$PhysicalDisplayInfo;)Z", (void*)nativeGetDisplayInfo }, {"nativeCopyFrom", "(Landroid/view/Surface;)V", Loading
services/java/com/android/server/display/DisplayDevice.java +20 −38 Original line number Diff line number Diff line Loading @@ -38,8 +38,8 @@ abstract class DisplayDevice { // the display manager service. The display device shouldn't really be looking at these. private int mCurrentLayerStack = -1; private int mCurrentOrientation = -1; private Rect mCurrentViewport; private Rect mCurrentFrame; private Rect mCurrentLayerStackRect; private Rect mCurrentDisplayRect; // The display device does own its surface texture, but it should only set it // within a transaction from performTraversalInTransactionLocked. Loading Loading @@ -117,44 +117,26 @@ abstract class DisplayDevice { } /** * Sets the display orientation while in a transaction. * Sets the display projection while in a transaction. * * @param orientation defines the display's orientation * @param layerStackRect defines which area of the window manager coordinate * space will be used * @param displayRect defines where on the display will layerStackRect be * mapped to. displayRect is specified post-orientation, that is * it uses the orientation seen by the end-user */ public final void setOrientationInTransactionLocked(int orientation) { if (mCurrentOrientation == orientation) { return; } public final void setProjectionInTransactionLocked(int orientation, Rect layerStackRect, Rect displayRect) { mCurrentOrientation = orientation; Surface.setDisplayOrientation(mDisplayToken, orientation); } /** * Sets the display viewport while in a transaction. */ public final void setViewportInTransactionLocked(Rect viewport) { if (mCurrentViewport != null) { if (mCurrentViewport.equals(viewport)) { return; } } else { mCurrentViewport = new Rect(); } mCurrentViewport.set(viewport); Surface.setDisplayViewport(mDisplayToken, viewport); } /** * Sets the display frame while in a transaction. */ public final void setFrameInTransactionLocked(Rect frame) { if (mCurrentFrame != null) { if (mCurrentFrame.equals(frame)) { return; if (mCurrentLayerStackRect == null) { mCurrentLayerStackRect = new Rect(); } } else { mCurrentFrame = new Rect(); mCurrentLayerStackRect.set(layerStackRect); if (mCurrentDisplayRect == null) { mCurrentDisplayRect = new Rect(); } mCurrentFrame.set(frame); Surface.setDisplayFrame(mDisplayToken, frame); mCurrentDisplayRect.set(displayRect); Surface.setDisplayProjection(mDisplayToken, orientation, layerStackRect, displayRect); } /** Loading @@ -176,8 +158,8 @@ abstract class DisplayDevice { pw.println("mAdapter=" + mDisplayAdapter.getName()); pw.println("mCurrentLayerStack=" + mCurrentLayerStack); pw.println("mCurrentOrientation=" + mCurrentOrientation); pw.println("mCurrentViewport=" + mCurrentViewport); pw.println("mCurrentFrame=" + mCurrentFrame); pw.println("mCurrentViewport=" + mCurrentLayerStackRect); pw.println("mCurrentFrame=" + mCurrentDisplayRect); pw.println("mCurrentSurfaceTexture=" + mCurrentSurfaceTexture); } }
services/java/com/android/server/display/LogicalDisplay.java +14 −13 Original line number Diff line number Diff line Loading @@ -64,7 +64,8 @@ final class LogicalDisplay { private DisplayDeviceInfo mPrimaryDisplayDeviceInfo; // Temporary rectangle used when needed. private final Rect mTempRect = new Rect(); private final Rect mTempLayerStackRect = new Rect(); private final Rect mTempDisplayRect = new Rect(); public LogicalDisplay(int layerStack, DisplayDevice primaryDisplayDevice) { mLayerStack = layerStack; Loading Loading @@ -208,8 +209,7 @@ final class LogicalDisplay { // Set the viewport. // This is the area of the logical display that we intend to show on the // display device. For now, it is always the full size of the logical display. mTempRect.set(0, 0, displayInfo.logicalWidth, displayInfo.logicalHeight); device.setViewportInTransactionLocked(mTempRect); mTempLayerStackRect.set(0, 0, displayInfo.logicalWidth, displayInfo.logicalHeight); // Set the orientation. // The orientation specifies how the physical coordinate system of the display Loading @@ -219,7 +219,6 @@ final class LogicalDisplay { && (displayDeviceInfo.flags & DisplayDeviceInfo.FLAG_SUPPORTS_ROTATION) != 0) { orientation = displayInfo.rotation; } device.setOrientationInTransactionLocked(orientation); // Set the frame. // The frame specifies the rotated physical coordinates into which the viewport Loading @@ -238,21 +237,23 @@ final class LogicalDisplay { // We avoid a division (and possible floating point imprecision) here by // multiplying the fractions by the product of their denominators before // comparing them. int frameWidth, frameHeight; int displayRectWidth, displayRectHeight; if (physWidth * displayInfo.logicalHeight < physHeight * displayInfo.logicalWidth) { // Letter box. frameWidth = physWidth; frameHeight = displayInfo.logicalHeight * physWidth / displayInfo.logicalWidth; displayRectWidth = physWidth; displayRectHeight = displayInfo.logicalHeight * physWidth / displayInfo.logicalWidth; } else { // Pillar box. frameWidth = displayInfo.logicalWidth * physHeight / displayInfo.logicalHeight; frameHeight = physHeight; displayRectWidth = displayInfo.logicalWidth * physHeight / displayInfo.logicalHeight; displayRectHeight = physHeight; } int frameTop = (physHeight - frameHeight) / 2; int frameLeft = (physWidth - frameWidth) / 2; mTempRect.set(frameLeft, frameTop, frameLeft + frameWidth, frameTop + frameHeight); device.setFrameInTransactionLocked(mTempRect); int displayRectTop = (physHeight - displayRectHeight) / 2; int displayRectLeft = (physWidth - displayRectWidth) / 2; mTempDisplayRect.set(displayRectLeft, displayRectTop, displayRectLeft + displayRectWidth, displayRectTop + displayRectHeight); device.setProjectionInTransactionLocked(orientation, mTempLayerStackRect, mTempDisplayRect); } public void dumpLocked(PrintWriter pw) { Loading