Java Code Examples for android.view.SurfaceControl#Builder

The following examples show how to use android.view.SurfaceControl#Builder . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: WindowSurfaceController.java    From android_9.0.0_r45 with Apache License 2.0 6 votes vote down vote up
public WindowSurfaceController(SurfaceSession s, String name, int w, int h, int format,
        int flags, WindowStateAnimator animator, int windowType, int ownerUid) {
    mAnimator = animator;

    mSurfaceW = w;
    mSurfaceH = h;

    title = name;

    mService = animator.mService;
    final WindowState win = animator.mWin;
    mWindowType = windowType;
    mWindowSession = win.mSession;

    Trace.traceBegin(TRACE_TAG_WINDOW_MANAGER, "new SurfaceControl");
    final SurfaceControl.Builder b = win.makeSurface()
            .setParent(win.getSurfaceControl())
            .setName(name)
            .setSize(w, h)
            .setFormat(format)
            .setFlags(flags)
            .setMetadata(windowType, ownerUid);
    mSurfaceControl = b.build();
    Trace.traceEnd(TRACE_TAG_WINDOW_MANAGER);
}
 
Example 2
Source File: SurfaceAnimator.java    From android_9.0.0_r45 with Apache License 2.0 5 votes vote down vote up
private SurfaceControl createAnimationLeash(SurfaceControl surface, Transaction t, int width,
        int height, boolean hidden) {
    if (DEBUG_ANIM) Slog.i(TAG, "Reparenting to leash");
    final SurfaceControl.Builder builder = mAnimatable.makeAnimationLeash()
            .setParent(mAnimatable.getAnimationLeashParent())
            .setName(surface + " - animation-leash")
            .setSize(width, height);
    final SurfaceControl leash = builder.build();
    if (!hidden) {
        t.show(leash);
    }
    t.reparent(surface, leash.getHandle());
    return leash;
}
 
Example 3
Source File: DisplayContent.java    From android_9.0.0_r45 with Apache License 2.0 5 votes vote down vote up
@Override
SurfaceControl.Builder makeChildSurface(WindowContainer child) {
    final SurfaceControl.Builder builder = super.makeChildSurface(child);
    if (child instanceof WindowToken && ((WindowToken) child).mRoundedCornerOverlay) {
        // To draw above the ColorFade layer during the screen off transition, the
        // rounded corner overlays need to be at the root of the surface hierarchy.
        // TODO: move the ColorLayer into the display overlay layer such that this is not
        // necessary anymore.
        builder.setParent(null);
    }
    return builder;
}
 
Example 4
Source File: DisplayContent.java    From android_9.0.0_r45 with Apache License 2.0 5 votes vote down vote up
@Override
SurfaceControl.Builder makeChildSurface(WindowContainer child) {
    SurfaceSession s = child != null ? child.getSession() : getSession();
    final SurfaceControl.Builder b = mService.makeSurfaceBuilder(s);
    b.setSize(mSurfaceSize, mSurfaceSize);

    if (child == null) {
        return b;
    }

    return b.setName(child.getName())
            .setParent(mWindowingLayer);
}
 
Example 5
Source File: WindowContainer.java    From android_9.0.0_r45 with Apache License 2.0 5 votes vote down vote up
/**
 * @param child The WindowContainer this child surface is for, or null if the Surface
 *              is not assosciated with a WindowContainer (e.g. a surface used for Dimming).
 */
SurfaceControl.Builder makeChildSurface(WindowContainer child) {
    final WindowContainer p = getParent();
    // Give the parent a chance to set properties. In hierarchy v1 we rely
    // on this to set full-screen dimensions on all our Surface-less Layers.
    return p.makeChildSurface(child)
            .setParent(mSurfaceControl);
}
 
Example 6
Source File: DisplayContent.java    From android_9.0.0_r45 with Apache License 2.0 4 votes vote down vote up
/**
 * Create new {@link DisplayContent} instance, add itself to the root window container and
 * initialize direct children.
 * @param display May not be null.
 * @param service You know.
 * @param wallpaperController wallpaper windows controller used to adjust the positioning of the
 *                            wallpaper windows in the window list.
 */
DisplayContent(Display display, WindowManagerService service,
        WallpaperController wallpaperController, DisplayWindowController controller) {
    super(service);
    setController(controller);
    if (service.mRoot.getDisplayContent(display.getDisplayId()) != null) {
        throw new IllegalArgumentException("Display with ID=" + display.getDisplayId()
                + " already exists=" + service.mRoot.getDisplayContent(display.getDisplayId())
                + " new=" + display);
    }

    mDisplay = display;
    mDisplayId = display.getDisplayId();
    mWallpaperController = wallpaperController;
    display.getDisplayInfo(mDisplayInfo);
    display.getMetrics(mDisplayMetrics);
    isDefaultDisplay = mDisplayId == DEFAULT_DISPLAY;
    mDisplayFrames = new DisplayFrames(mDisplayId, mDisplayInfo,
            calculateDisplayCutoutForRotation(mDisplayInfo.rotation));
    initializeDisplayBaseInfo();
    mDividerControllerLocked = new DockedStackDividerController(service, this);
    mPinnedStackControllerLocked = new PinnedStackController(service, this);

    // We use this as our arbitrary surface size for buffer-less parents
    // that don't impose cropping on their children. It may need to be larger
    // than the display size because fullscreen windows can be shifted offscreen
    // due to surfaceInsets. 2 times the largest display dimension feels like an
    // appropriately arbitrary number. Eventually we would like to give SurfaceFlinger
    // layers the ability to match their parent sizes and be able to skip
    // such arbitrary size settings.
    mSurfaceSize = Math.max(mBaseDisplayHeight, mBaseDisplayWidth) * 2;

    final SurfaceControl.Builder b = mService.makeSurfaceBuilder(mSession)
            .setSize(mSurfaceSize, mSurfaceSize)
            .setOpaque(true);
    mWindowingLayer = b.setName("Display Root").build();
    mOverlayLayer = b.setName("Display Overlays").build();

    getPendingTransaction().setLayer(mWindowingLayer, 0)
            .setLayerStack(mWindowingLayer, mDisplayId)
            .show(mWindowingLayer)
            .setLayer(mOverlayLayer, 1)
            .setLayerStack(mOverlayLayer, mDisplayId)
            .show(mOverlayLayer);
    getPendingTransaction().apply();

    // These are the only direct children we should ever have and they are permanent.
    super.addChild(mBelowAppWindowsContainers, null);
    super.addChild(mTaskStackContainers, null);
    super.addChild(mAboveAppWindowsContainers, null);
    super.addChild(mImeWindowsContainers, null);

    // Add itself as a child to the root container.
    mService.mRoot.addChild(this, null);

    // TODO(b/62541591): evaluate whether this is the best spot to declare the
    // {@link DisplayContent} ready for use.
    mDisplayReady = true;
}
 
Example 7
Source File: DisplayContent.java    From android_9.0.0_r45 with Apache License 2.0 4 votes vote down vote up
SurfaceControl.Builder makeSurface(SurfaceSession s) {
    return mService.makeSurfaceBuilder(s)
            .setParent(mWindowingLayer);
}
 
Example 8
Source File: Dimmer.java    From android_9.0.0_r45 with Apache License 2.0 4 votes vote down vote up
@Override
public SurfaceControl.Builder makeAnimationLeash() {
    return mHost.makeAnimationLeash();
}
 
Example 9
Source File: WindowContainer.java    From android_9.0.0_r45 with Apache License 2.0 4 votes vote down vote up
SurfaceControl.Builder makeSurface() {
    final WindowContainer p = getParent();
    return p.makeChildSurface(this);
}
 
Example 10
Source File: SurfaceAnimator.java    From android_9.0.0_r45 with Apache License 2.0 2 votes vote down vote up
/**
 * @return A new surface to be used for the animation leash, inserted at the correct
 *         position in the hierarchy.
 */
SurfaceControl.Builder makeAnimationLeash();
 
Example 11
Source File: DisplayContent.java    From android_9.0.0_r45 with Apache License 2.0 2 votes vote down vote up
/**
 * The makeSurface variants are for use by the window-container
 * hierarchy. makeOverlay here is a function for various non windowing
 * overlays like the ScreenRotation screenshot, the Strict Mode Flash
 * and other potpourii.
 */
SurfaceControl.Builder makeOverlay() {
    return mService.makeSurfaceBuilder(mSession)
        .setParent(mOverlayLayer);
}
 
Example 12
Source File: Letterbox.java    From android_9.0.0_r45 with Apache License 2.0 2 votes vote down vote up
/**
 * Constructs a Letterbox.
 *
 * @param surfaceControlFactory a factory for creating the managed {@link SurfaceControl}s
 */
public Letterbox(Supplier<SurfaceControl.Builder> surfaceControlFactory) {
    mFactory = surfaceControlFactory;
}
 
Example 13
Source File: SurfaceBuilderFactory.java    From android_9.0.0_r45 with Apache License 2.0 votes vote down vote up
SurfaceControl.Builder make(SurfaceSession s);