FocusedStackFramepublic 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 void | draw(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 void | positionSurface(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 void | setBounds(TaskStack stack)
stack.getBounds(mBounds);
if (false && DEBUG_STACK) Slog.i(TAG, "setBounds: bounds=" + mBounds);
| public void | setLayer(int layer)
mSurfaceControl.setLayer(layer);
| public void | setVisibility(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();
}
|
|