FileDocCategorySizeDatePackage
FocusedStackFrame.javaAPI DocAndroid 5.1 API5167Thu Mar 12 22:22:42 GMT 2015com.android.server.wm

FocusedStackFrame

public class FocusedStackFrame extends Object

Fields Summary
private static final String
TAG
private static final int
THICKNESS
private static final float
ALPHA
private final android.view.SurfaceControl
mSurfaceControl
private final android.view.Surface
mSurface
private final android.graphics.Rect
mLastBounds
final android.graphics.Rect
mBounds
private final android.graphics.Rect
mTmpDrawRect
Constructors Summary
public FocusedStackFrame(android.view.Display display, android.view.SurfaceSession session)


         
        SurfaceControl ctrl = null;
        try {
            if (DEBUG_SURFACE_TRACE) {
                ctrl = new SurfaceTrace(session, "FocusedStackFrame",
                    1, 1, PixelFormat.TRANSLUCENT, SurfaceControl.HIDDEN);
            } else {
                ctrl = new SurfaceControl(session, "FocusedStackFrame",
                    1, 1, PixelFormat.TRANSLUCENT, SurfaceControl.HIDDEN);
            }
            ctrl.setLayerStack(display.getLayerStack());
            ctrl.setAlpha(ALPHA);
            mSurface.copyFrom(ctrl);
        } catch (OutOfResourcesException e) {
        }
        mSurfaceControl = ctrl;
    
Methods Summary
private voiddraw(android.graphics.Rect bounds, int color)

        if (false && DEBUG_STACK) Slog.i(TAG, "draw: bounds=" + bounds.toShortString() +
                " color=" + Integer.toHexString(color));
        mTmpDrawRect.set(bounds);
        Canvas c = null;
        try {
            c = mSurface.lockCanvas(mTmpDrawRect);
        } catch (IllegalArgumentException e) {
        } catch (Surface.OutOfResourcesException e) {
        }
        if (c == null) {
            return;
        }

        final int w = bounds.width();
        final int h = bounds.height();

        // Top
        mTmpDrawRect.set(0, 0, w, THICKNESS);
        c.clipRect(mTmpDrawRect, Region.Op.REPLACE);
        c.drawColor(color);
        // Left (not including Top or Bottom stripe).
        mTmpDrawRect.set(0, THICKNESS, THICKNESS, h - THICKNESS);
        c.clipRect(mTmpDrawRect, Region.Op.REPLACE);
        c.drawColor(color);
        // Right (not including Top or Bottom stripe).
        mTmpDrawRect.set(w - THICKNESS, THICKNESS, w, h - THICKNESS);
        c.clipRect(mTmpDrawRect, Region.Op.REPLACE);
        c.drawColor(color);
        // Bottom
        mTmpDrawRect.set(0, h - THICKNESS, w, h);
        c.clipRect(mTmpDrawRect, Region.Op.REPLACE);
        c.drawColor(color);

        mSurface.unlockCanvasAndPost(c);
    
private voidpositionSurface(android.graphics.Rect bounds)

        if (false && DEBUG_STACK) Slog.i(TAG, "positionSurface: bounds=" + bounds.toShortString());
        mSurfaceControl.setSize(bounds.width(), bounds.height());
        mSurfaceControl.setPosition(bounds.left, bounds.top);
    
public voidsetBounds(TaskStack stack)

        stack.getBounds(mBounds);
        if (false && DEBUG_STACK) Slog.i(TAG, "setBounds: bounds=" + mBounds);
    
public voidsetLayer(int layer)

        mSurfaceControl.setLayer(layer);
    
public voidsetVisibility(boolean on)

        if (false && DEBUG_STACK) Slog.i(TAG, "setVisibility: on=" + on +
                " mLastBounds=" + mLastBounds.toShortString() +
                " mBounds=" + mBounds.toShortString());
        if (mSurfaceControl == null) {
            return;
        }
        if (on) {
            if (!mLastBounds.equals(mBounds)) {
                // Erase the previous rectangle.
                positionSurface(mLastBounds);
                draw(mLastBounds, Color.TRANSPARENT);
                // Draw the latest rectangle.
                positionSurface(mBounds);
                draw(mBounds, Color.WHITE);
                // Update the history.
                mLastBounds.set(mBounds);
            }
            mSurfaceControl.show();
        } else {
            mSurfaceControl.hide();
        }