Search in sources :

Example 76 with DisplayInfo

use of android.view.DisplayInfo in project android_frameworks_base by crdroidandroid.

the class DisplayContent method initializeDisplayBaseInfo.

void initializeDisplayBaseInfo() {
    // Bootstrap the default logical display from the display manager.
    final DisplayInfo newDisplayInfo = mService.mDisplayManagerInternal.getDisplayInfo(mDisplayId);
    if (newDisplayInfo != null) {
        mDisplayInfo.copyFrom(newDisplayInfo);
    }
    mBaseDisplayWidth = mInitialDisplayWidth = mDisplayInfo.logicalWidth;
    mBaseDisplayHeight = mInitialDisplayHeight = mDisplayInfo.logicalHeight;
    mBaseDisplayDensity = mInitialDisplayDensity = mDisplayInfo.logicalDensityDpi;
    mBaseDisplayRect.set(0, 0, mBaseDisplayWidth, mBaseDisplayHeight);
}
Also used : DisplayInfo(android.view.DisplayInfo)

Example 77 with DisplayInfo

use of android.view.DisplayInfo in project android_frameworks_base by crdroidandroid.

the class DividerSnapAlgorithm method create.

public static DividerSnapAlgorithm create(Context ctx, Rect insets) {
    DisplayInfo displayInfo = new DisplayInfo();
    ctx.getSystemService(DisplayManager.class).getDisplay(Display.DEFAULT_DISPLAY).getDisplayInfo(displayInfo);
    int dividerWindowWidth = ctx.getResources().getDimensionPixelSize(com.android.internal.R.dimen.docked_stack_divider_thickness);
    int dividerInsets = ctx.getResources().getDimensionPixelSize(com.android.internal.R.dimen.docked_stack_divider_insets);
    return new DividerSnapAlgorithm(ctx.getResources(), displayInfo.logicalWidth, displayInfo.logicalHeight, dividerWindowWidth - 2 * dividerInsets, ctx.getApplicationContext().getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT, insets);
}
Also used : DisplayInfo(android.view.DisplayInfo)

Example 78 with DisplayInfo

use of android.view.DisplayInfo in project android_frameworks_base by crdroidandroid.

the class DisplayManagerService method getDisplayIdsInternal.

private int[] getDisplayIdsInternal(int callingUid) {
    synchronized (mSyncRoot) {
        final int count = mLogicalDisplays.size();
        int[] displayIds = new int[count];
        int n = 0;
        for (int i = 0; i < count; i++) {
            LogicalDisplay display = mLogicalDisplays.valueAt(i);
            DisplayInfo info = display.getDisplayInfoLocked();
            if (info.hasAccess(callingUid)) {
                displayIds[n++] = mLogicalDisplays.keyAt(i);
            }
        }
        if (n != count) {
            displayIds = Arrays.copyOfRange(displayIds, 0, n);
        }
        return displayIds;
    }
}
Also used : DisplayInfo(android.view.DisplayInfo)

Example 79 with DisplayInfo

use of android.view.DisplayInfo in project android_frameworks_base by crdroidandroid.

the class LogicalDisplay method setDisplayInfoOverrideFromWindowManagerLocked.

/**
     * Sets overridden logical display information from the window manager.
     * This method can be used to adjust application insets, rotation, and other
     * properties that the window manager takes care of.
     *
     * @param info The logical display information, may be null.
     */
public boolean setDisplayInfoOverrideFromWindowManagerLocked(DisplayInfo info) {
    if (info != null) {
        if (mOverrideDisplayInfo == null) {
            mOverrideDisplayInfo = new DisplayInfo(info);
            mInfo = null;
            return true;
        }
        if (!mOverrideDisplayInfo.equals(info)) {
            mOverrideDisplayInfo.copyFrom(info);
            mInfo = null;
            return true;
        }
    } else if (mOverrideDisplayInfo != null) {
        mOverrideDisplayInfo = null;
        mInfo = null;
        return true;
    }
    return false;
}
Also used : DisplayInfo(android.view.DisplayInfo)

Example 80 with DisplayInfo

use of android.view.DisplayInfo in project android_frameworks_base by crdroidandroid.

the class LogicalDisplay method configureDisplayInTransactionLocked.

/**
     * Applies the layer stack and transformation to the given display device
     * so that it shows the contents of this logical display.
     *
     * We know that the given display device is only ever showing the contents of
     * a single logical display, so this method is expected to blow away all of its
     * transformation properties to make it happen regardless of what the
     * display device was previously showing.
     *
     * The caller must have an open Surface transaction.
     *
     * The display device may not be the primary display device, in the case
     * where the display is being mirrored.
     *
     * @param device The display device to modify.
     * @param isBlanked True if the device is being blanked.
     */
public void configureDisplayInTransactionLocked(DisplayDevice device, boolean isBlanked) {
    // Set the layer stack.
    device.setLayerStackInTransactionLocked(isBlanked ? BLANK_LAYER_STACK : mLayerStack);
    // Set the color mode and mode.
    if (device == mPrimaryDisplayDevice) {
        device.requestDisplayModesInTransactionLocked(mRequestedColorMode, mRequestedModeId);
    } else {
        // Revert to default.
        device.requestDisplayModesInTransactionLocked(0, 0);
    }
    // Only grab the display info now as it may have been changed based on the requests above.
    final DisplayInfo displayInfo = getDisplayInfoLocked();
    final DisplayDeviceInfo displayDeviceInfo = device.getDisplayDeviceInfoLocked();
    // 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.
    mTempLayerStackRect.set(0, 0, displayInfo.logicalWidth, displayInfo.logicalHeight);
    // Set the orientation.
    // The orientation specifies how the physical coordinate system of the display
    // is rotated when the contents of the logical display are rendered.
    int orientation = Surface.ROTATION_0;
    if ((displayDeviceInfo.flags & DisplayDeviceInfo.FLAG_ROTATES_WITH_CONTENT) != 0) {
        orientation = displayInfo.rotation;
    }
    // Apply the physical rotation of the display device itself.
    orientation = (orientation + displayDeviceInfo.rotation) % 4;
    // Set the frame.
    // The frame specifies the rotated physical coordinates into which the viewport
    // is mapped.  We need to take care to preserve the aspect ratio of the viewport.
    // Currently we maximize the area to fill the display, but we could try to be
    // more clever and match resolutions.
    boolean rotated = (orientation == Surface.ROTATION_90 || orientation == Surface.ROTATION_270);
    int physWidth = rotated ? displayDeviceInfo.height : displayDeviceInfo.width;
    int physHeight = rotated ? displayDeviceInfo.width : displayDeviceInfo.height;
    // Determine whether the width or height is more constrained to be scaled.
    //    physWidth / displayInfo.logicalWidth    => letter box
    // or physHeight / displayInfo.logicalHeight  => pillar box
    //
    // We avoid a division (and possible floating point imprecision) here by
    // multiplying the fractions by the product of their denominators before
    // comparing them.
    int displayRectWidth, displayRectHeight;
    if ((displayInfo.flags & Display.FLAG_SCALING_DISABLED) != 0) {
        displayRectWidth = displayInfo.logicalWidth;
        displayRectHeight = displayInfo.logicalHeight;
    } else if (physWidth * displayInfo.logicalHeight < physHeight * displayInfo.logicalWidth) {
        // Letter box.
        displayRectWidth = physWidth;
        displayRectHeight = displayInfo.logicalHeight * physWidth / displayInfo.logicalWidth;
    } else {
        // Pillar box.
        displayRectWidth = displayInfo.logicalWidth * physHeight / displayInfo.logicalHeight;
        displayRectHeight = physHeight;
    }
    int displayRectTop = (physHeight - displayRectHeight) / 2;
    int displayRectLeft = (physWidth - displayRectWidth) / 2;
    mTempDisplayRect.set(displayRectLeft, displayRectTop, displayRectLeft + displayRectWidth, displayRectTop + displayRectHeight);
    mTempDisplayRect.left += mDisplayOffsetX;
    mTempDisplayRect.right += mDisplayOffsetX;
    mTempDisplayRect.top += mDisplayOffsetY;
    mTempDisplayRect.bottom += mDisplayOffsetY;
    device.setProjectionInTransactionLocked(orientation, mTempLayerStackRect, mTempDisplayRect);
}
Also used : DisplayInfo(android.view.DisplayInfo)

Aggregations

DisplayInfo (android.view.DisplayInfo)186 Point (android.graphics.Point)53 Rect (android.graphics.Rect)29 RemoteException (android.os.RemoteException)19 Display (android.view.Display)11 Animation (android.view.animation.Animation)10 Bitmap (android.graphics.Bitmap)9 WindowManager (android.view.WindowManager)8 DividerSnapAlgorithm (com.android.internal.policy.DividerSnapAlgorithm)8 Canvas (android.graphics.Canvas)6 SurfaceControl (android.view.SurfaceControl)6 LayoutParams (android.view.WindowManager.LayoutParams)6 DisplayManager (android.hardware.display.DisplayManager)5 DisplayMetrics (android.util.DisplayMetrics)5 Surface (android.view.Surface)5 InputDevice (android.view.InputDevice)4 SnapTarget (com.android.internal.policy.DividerSnapAlgorithm.SnapTarget)4 FileNotFoundException (java.io.FileNotFoundException)4 IOException (java.io.IOException)4 OutOfResourcesException (android.view.Surface.OutOfResourcesException)3