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

EmulatorDisplayOverlay

public class EmulatorDisplayOverlay extends Object

Fields Summary
private static final String
TAG
private android.graphics.Point
mScreenSize
private final android.view.SurfaceControl
mSurfaceControl
private final android.view.Surface
mSurface
private int
mLastDW
private int
mLastDH
private boolean
mDrawNeeded
private android.graphics.drawable.Drawable
mOverlay
private int
mRotation
private boolean
mVisible
Constructors Summary
public EmulatorDisplayOverlay(android.content.Context context, android.view.Display display, android.view.SurfaceSession session, int zOrder)


          
              
        mScreenSize = new Point();
        display.getSize(mScreenSize);

        SurfaceControl ctrl = null;
        try {
            if (WindowManagerService.DEBUG_SURFACE_TRACE) {
                ctrl = new WindowStateAnimator.SurfaceTrace(session, "EmulatorDisplayOverlay",
                        mScreenSize.x, mScreenSize.y, PixelFormat.TRANSLUCENT,
                        SurfaceControl.HIDDEN);
            } else {
                ctrl = new SurfaceControl(session, "EmulatorDisplayOverlay", mScreenSize.x,
                        mScreenSize.y, PixelFormat.TRANSLUCENT, SurfaceControl.HIDDEN);
            }
            ctrl.setLayerStack(display.getLayerStack());
            ctrl.setLayer(zOrder);
            ctrl.setPosition(0, 0);
            ctrl.show();
            mSurface.copyFrom(ctrl);
        } catch (OutOfResourcesException e) {
        }
        mSurfaceControl = ctrl;
        mDrawNeeded = true;
        mOverlay = context.getDrawable(
                com.android.internal.R.drawable.emulator_circular_window_overlay);
    
Methods Summary
private voiddrawIfNeeded()

        if (!mDrawNeeded || !mVisible) {
            return;
        }
        mDrawNeeded = false;

        Rect dirty = new Rect(0, 0, mScreenSize.x, mScreenSize.y);
        Canvas c = null;
        try {
            c = mSurface.lockCanvas(dirty);
        } catch (IllegalArgumentException e) {
        } catch (OutOfResourcesException e) {
        }
        if (c == null) {
            return;
        }
        c.drawColor(Color.TRANSPARENT, PorterDuff.Mode.SRC);
        mSurfaceControl.setPosition(0, 0);
        mOverlay.setBounds(0, 0, mScreenSize.x, mScreenSize.y);
        mOverlay.draw(c);
        mSurface.unlockCanvasAndPost(c);
    
voidpositionSurface(int dw, int dh, int rotation)

        if (mLastDW == dw && mLastDH == dh && mRotation == rotation) {
            return;
        }
        mLastDW = dw;
        mLastDH = dh;
        mDrawNeeded = true;
        mRotation = rotation;
        drawIfNeeded();
    
public voidsetVisibility(boolean on)

        if (mSurfaceControl == null) {
            return;
        }
        mVisible = on;
        drawIfNeeded();
        if (on) {
            mSurfaceControl.show();
        } else {
            mSurfaceControl.hide();
        }