Search in sources :

Example 16 with DisplayInfo

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

the class WindowManagerService method updateWallpaperVisibilityLocked.

void updateWallpaperVisibilityLocked() {
    final boolean visible = isWallpaperVisible(mWallpaperTarget);
    final DisplayContent displayContent = mWallpaperTarget.mDisplayContent;
    final DisplayInfo displayInfo = displayContent.getDisplayInfo();
    final int dw = displayInfo.appWidth;
    final int dh = displayInfo.appHeight;
    int curTokenIndex = mWallpaperTokens.size();
    while (curTokenIndex > 0) {
        curTokenIndex--;
        WindowToken token = mWallpaperTokens.get(curTokenIndex);
        if (token.hidden == visible) {
            token.hidden = !visible;
            // Need to do a layout to ensure the wallpaper now has the
            // correct size.
            getDefaultDisplayContentLocked().layoutNeeded = true;
        }
        int curWallpaperIndex = token.windows.size();
        while (curWallpaperIndex > 0) {
            curWallpaperIndex--;
            WindowState wallpaper = token.windows.get(curWallpaperIndex);
            if (visible) {
                updateWallpaperOffsetLocked(wallpaper, dw, dh, false);
            }
            dispatchWallpaperVisibility(wallpaper, visible);
        }
    }
}
Also used : DisplayInfo(android.view.DisplayInfo) Point(android.graphics.Point)

Example 17 with DisplayInfo

use of android.view.DisplayInfo in project platform_frameworks_base by android.

the class DividerView method updateDisplayInfo.

private void updateDisplayInfo() {
    final DisplayManager displayManager = (DisplayManager) mContext.getSystemService(Context.DISPLAY_SERVICE);
    Display display = displayManager.getDisplay(Display.DEFAULT_DISPLAY);
    final DisplayInfo info = new DisplayInfo();
    display.getDisplayInfo(info);
    mDisplayWidth = info.logicalWidth;
    mDisplayHeight = info.logicalHeight;
    mSnapAlgorithm = null;
    initializeSnapAlgorithm();
}
Also used : DisplayInfo(android.view.DisplayInfo) DisplayManager(android.hardware.display.DisplayManager) Display(android.view.Display)

Example 18 with DisplayInfo

use of android.view.DisplayInfo in project platform_frameworks_base by android.

the class LogicalDisplay method getDisplayInfoLocked.

/**
     * Gets information about the logical display.
     *
     * @return The device info, which should be treated as immutable by the caller.
     * The logical display should allocate a new display info object whenever
     * the data changes.
     */
public DisplayInfo getDisplayInfoLocked() {
    if (mInfo == null) {
        mInfo = new DisplayInfo();
        mInfo.copyFrom(mBaseDisplayInfo);
        if (mOverrideDisplayInfo != null) {
            mInfo.appWidth = mOverrideDisplayInfo.appWidth;
            mInfo.appHeight = mOverrideDisplayInfo.appHeight;
            mInfo.smallestNominalAppWidth = mOverrideDisplayInfo.smallestNominalAppWidth;
            mInfo.smallestNominalAppHeight = mOverrideDisplayInfo.smallestNominalAppHeight;
            mInfo.largestNominalAppWidth = mOverrideDisplayInfo.largestNominalAppWidth;
            mInfo.largestNominalAppHeight = mOverrideDisplayInfo.largestNominalAppHeight;
            mInfo.logicalWidth = mOverrideDisplayInfo.logicalWidth;
            mInfo.logicalHeight = mOverrideDisplayInfo.logicalHeight;
            mInfo.overscanLeft = mOverrideDisplayInfo.overscanLeft;
            mInfo.overscanTop = mOverrideDisplayInfo.overscanTop;
            mInfo.overscanRight = mOverrideDisplayInfo.overscanRight;
            mInfo.overscanBottom = mOverrideDisplayInfo.overscanBottom;
            mInfo.rotation = mOverrideDisplayInfo.rotation;
            mInfo.logicalDensityDpi = mOverrideDisplayInfo.logicalDensityDpi;
            mInfo.physicalXDpi = mOverrideDisplayInfo.physicalXDpi;
            mInfo.physicalYDpi = mOverrideDisplayInfo.physicalYDpi;
        }
    }
    return mInfo;
}
Also used : DisplayInfo(android.view.DisplayInfo)

Example 19 with DisplayInfo

use of android.view.DisplayInfo in project platform_frameworks_base by android.

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)

Example 20 with DisplayInfo

use of android.view.DisplayInfo in project platform_frameworks_base by android.

the class ColorFade method prepare.

/**
     * Warms up the color fade in preparation for turning on or off.
     * This method prepares a GL context, and captures a screen shot.
     *
     * @param mode The desired mode for the upcoming animation.
     * @return True if the color fade is ready, false if it is uncontrollable.
     */
public boolean prepare(Context context, int mode) {
    if (DEBUG) {
        Slog.d(TAG, "prepare: mode=" + mode);
    }
    mMode = mode;
    // Get the display size and layer stack.
    // This is not expected to change while the color fade surface is showing.
    DisplayInfo displayInfo = mDisplayManagerInternal.getDisplayInfo(mDisplayId);
    mDisplayLayerStack = displayInfo.layerStack;
    mDisplayWidth = displayInfo.getNaturalWidth();
    mDisplayHeight = displayInfo.getNaturalHeight();
    // Prepare the surface for drawing.
    if (!(createSurface() && createEglContext() && createEglSurface() && captureScreenshotTextureAndSetViewport())) {
        dismiss();
        return false;
    }
    // Init GL
    if (!attachEglContext()) {
        return false;
    }
    try {
        if (!initGLShaders(context) || !initGLBuffers() || checkGlErrors("prepare")) {
            detachEglContext();
            dismiss();
            return false;
        }
    } finally {
        detachEglContext();
    }
    // Done.
    mCreatedResources = true;
    mPrepared = true;
    // painting the screenshot as-is.
    if (mode == MODE_COOL_DOWN) {
        for (int i = 0; i < DEJANK_FRAMES; i++) {
            draw(1.0f);
        }
    }
    return true;
}
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