Search in sources :

Example 21 with SurfaceControl

use of android.view.SurfaceControl in project android_frameworks_base by DirtyUnicorns.

the class DimLayer method constructSurface.

private void constructSurface(WindowManagerService service) {
    SurfaceControl.openTransaction();
    try {
        if (DEBUG_SURFACE_TRACE) {
            mDimSurface = new WindowSurfaceController.SurfaceTrace(service.mFxSession, "DimSurface", 16, 16, PixelFormat.OPAQUE, SurfaceControl.FX_SURFACE_DIM | SurfaceControl.HIDDEN);
        } else {
            mDimSurface = new SurfaceControl(service.mFxSession, mName, 16, 16, PixelFormat.OPAQUE, SurfaceControl.FX_SURFACE_DIM | SurfaceControl.HIDDEN);
        }
        if (SHOW_TRANSACTIONS || SHOW_SURFACE_ALLOC)
            Slog.i(TAG, "  DIM " + mDimSurface + ": CREATE");
        mDimSurface.setLayerStack(mDisplayId);
        adjustBounds();
        adjustAlpha(mAlpha);
        adjustLayer(mLayer);
    } catch (Exception e) {
        Slog.e(TAG_WM, "Exception creating Dim surface", e);
    } finally {
        SurfaceControl.closeTransaction();
    }
}
Also used : SurfaceControl(android.view.SurfaceControl)

Example 22 with SurfaceControl

use of android.view.SurfaceControl in project android_frameworks_base by DirtyUnicorns.

the class WindowSurfacePlacer method createThumbnailAppAnimator.

private void createThumbnailAppAnimator(int transit, AppWindowToken appToken, int openingLayer, int closingLayer) {
    AppWindowAnimator openingAppAnimator = (appToken == null) ? null : appToken.mAppAnimator;
    if (openingAppAnimator == null || openingAppAnimator.animation == null) {
        return;
    }
    final int taskId = appToken.mTask.mTaskId;
    Bitmap thumbnailHeader = mService.mAppTransition.getAppTransitionThumbnailHeader(taskId);
    if (thumbnailHeader == null || thumbnailHeader.getConfig() == Bitmap.Config.ALPHA_8) {
        if (DEBUG_APP_TRANSITIONS)
            Slog.d(TAG, "No thumbnail header bitmap for: " + taskId);
        return;
    }
    // This thumbnail animation is very special, we need to have
    // an extra surface with the thumbnail included with the animation.
    Rect dirty = new Rect(0, 0, thumbnailHeader.getWidth(), thumbnailHeader.getHeight());
    try {
        // TODO(multi-display): support other displays
        final DisplayContent displayContent = mService.getDefaultDisplayContentLocked();
        final Display display = displayContent.getDisplay();
        final DisplayInfo displayInfo = displayContent.getDisplayInfo();
        // Create a new surface for the thumbnail
        SurfaceControl surfaceControl = new SurfaceControl(mService.mFxSession, "thumbnail anim", dirty.width(), dirty.height(), PixelFormat.TRANSLUCENT, SurfaceControl.HIDDEN);
        surfaceControl.setLayerStack(display.getLayerStack());
        if (SHOW_TRANSACTIONS) {
            Slog.i(TAG, "  THUMBNAIL " + surfaceControl + ": CREATE");
        }
        // Draw the thumbnail onto the surface
        Surface drawSurface = new Surface();
        drawSurface.copyFrom(surfaceControl);
        Canvas c = drawSurface.lockCanvas(dirty);
        c.drawBitmap(thumbnailHeader, 0, 0, null);
        drawSurface.unlockCanvasAndPost(c);
        drawSurface.release();
        // Get the thumbnail animation
        Animation anim;
        if (mService.mAppTransition.isNextThumbnailTransitionAspectScaled()) {
            // If this is a multi-window scenario, we use the windows frame as
            // destination of the thumbnail header animation. If this is a full screen
            // window scenario, we use the whole display as the target.
            WindowState win = appToken.findMainWindow();
            Rect appRect = win != null ? win.getContentFrameLw() : new Rect(0, 0, displayInfo.appWidth, displayInfo.appHeight);
            Rect insets = win != null ? win.mContentInsets : null;
            // For the new aspect-scaled transition, we want it to always show
            // above the animating opening/closing window, and we want to
            // synchronize its thumbnail surface with the surface for the
            // open/close animation (only on the way down)
            anim = mService.mAppTransition.createThumbnailAspectScaleAnimationLocked(appRect, insets, thumbnailHeader, taskId, mService.mCurConfiguration.uiMode, mService.mCurConfiguration.orientation);
            openingAppAnimator.thumbnailForceAboveLayer = Math.max(openingLayer, closingLayer);
            openingAppAnimator.deferThumbnailDestruction = !mService.mAppTransition.isNextThumbnailTransitionScaleUp();
        } else {
            anim = mService.mAppTransition.createThumbnailScaleAnimationLocked(displayInfo.appWidth, displayInfo.appHeight, transit, thumbnailHeader);
        }
        anim.restrictDuration(MAX_ANIMATION_DURATION);
        anim.scaleCurrentDuration(mService.getTransitionAnimationScaleLocked());
        openingAppAnimator.thumbnail = surfaceControl;
        openingAppAnimator.thumbnailLayer = openingLayer;
        openingAppAnimator.thumbnailAnimation = anim;
        mService.mAppTransition.getNextAppTransitionStartRect(taskId, mTmpStartRect);
    } catch (Surface.OutOfResourcesException e) {
        Slog.e(TAG, "Can't allocate thumbnail/Canvas surface w=" + dirty.width() + " h=" + dirty.height(), e);
        openingAppAnimator.clearThumbnail();
    }
}
Also used : Rect(android.graphics.Rect) DisplayInfo(android.view.DisplayInfo) SurfaceControl(android.view.SurfaceControl) Canvas(android.graphics.Canvas) Surface(android.view.Surface) Bitmap(android.graphics.Bitmap) Animation(android.view.animation.Animation) Display(android.view.Display)

Example 23 with SurfaceControl

use of android.view.SurfaceControl in project android_frameworks_base by ResurrectionRemix.

the class ColorFade method createSurface.

private boolean createSurface() {
    if (mSurfaceSession == null) {
        mSurfaceSession = new SurfaceSession();
    }
    SurfaceControl.openTransaction();
    try {
        if (mSurfaceControl == null) {
            try {
                int flags;
                if (mMode == MODE_FADE) {
                    flags = SurfaceControl.FX_SURFACE_DIM | SurfaceControl.HIDDEN;
                } else {
                    flags = SurfaceControl.OPAQUE | SurfaceControl.HIDDEN;
                }
                mSurfaceControl = new SurfaceControl(mSurfaceSession, "ColorFade", mDisplayWidth, mDisplayHeight, PixelFormat.OPAQUE, flags);
            } catch (OutOfResourcesException ex) {
                Slog.e(TAG, "Unable to create surface.", ex);
                return false;
            }
            mSurfaceControl.setLayerStack(mDisplayLayerStack);
            mSurfaceControl.setSize(mDisplayWidth, mDisplayHeight);
            mSurface = new Surface();
            mSurface.copyFrom(mSurfaceControl);
            mSurfaceLayout = new NaturalSurfaceLayout(mDisplayManagerInternal, mDisplayId, mSurfaceControl);
            mSurfaceLayout.onDisplayTransaction();
        }
    } finally {
        SurfaceControl.closeTransaction();
    }
    return true;
}
Also used : OutOfResourcesException(android.view.Surface.OutOfResourcesException) SurfaceSession(android.view.SurfaceSession) SurfaceControl(android.view.SurfaceControl) EGLSurface(android.opengl.EGLSurface) Surface(android.view.Surface)

Example 24 with SurfaceControl

use of android.view.SurfaceControl in project android_frameworks_base by ResurrectionRemix.

the class DimLayer method constructSurface.

private void constructSurface(WindowManagerService service) {
    SurfaceControl.openTransaction();
    try {
        if (DEBUG_SURFACE_TRACE) {
            mDimSurface = new WindowSurfaceController.SurfaceTrace(service.mFxSession, "DimSurface", 16, 16, PixelFormat.OPAQUE, SurfaceControl.FX_SURFACE_DIM | SurfaceControl.HIDDEN);
        } else {
            mDimSurface = new SurfaceControl(service.mFxSession, mName, 16, 16, PixelFormat.OPAQUE, SurfaceControl.FX_SURFACE_DIM | SurfaceControl.HIDDEN);
        }
        if (SHOW_TRANSACTIONS || SHOW_SURFACE_ALLOC)
            Slog.i(TAG, "  DIM " + mDimSurface + ": CREATE");
        mDimSurface.setLayerStack(mDisplayId);
        adjustBounds();
        adjustAlpha(mAlpha);
        adjustLayer(mLayer);
    } catch (Exception e) {
        Slog.e(TAG_WM, "Exception creating Dim surface", e);
    } finally {
        SurfaceControl.closeTransaction();
    }
}
Also used : SurfaceControl(android.view.SurfaceControl)

Example 25 with SurfaceControl

use of android.view.SurfaceControl in project android_frameworks_base by crdroidandroid.

the class Session method performDrag.

public boolean performDrag(IWindow window, IBinder dragToken, int touchSource, float touchX, float touchY, float thumbCenterX, float thumbCenterY, ClipData data) {
    if (DEBUG_DRAG) {
        Slog.d(TAG_WM, "perform drag: win=" + window + " data=" + data);
    }
    synchronized (mService.mWindowMap) {
        if (mService.mDragState == null) {
            Slog.w(TAG_WM, "No drag prepared");
            throw new IllegalStateException("performDrag() without prepareDrag()");
        }
        if (dragToken != mService.mDragState.mToken) {
            Slog.w(TAG_WM, "Performing mismatched drag");
            throw new IllegalStateException("performDrag() does not match prepareDrag()");
        }
        WindowState callingWin = mService.windowForClientLocked(null, window, false);
        if (callingWin == null) {
            Slog.w(TAG_WM, "Bad requesting window " + window);
            // !!! TODO: throw here?
            return false;
        }
        // !!! TODO: if input is not still focused on the initiating window, fail
        // the drag initiation (e.g. an alarm window popped up just as the application
        // called performDrag()
        mService.mH.removeMessages(H.DRAG_START_TIMEOUT, window.asBinder());
        // !!! TODO: extract the current touch (x, y) in screen coordinates.  That
        // will let us eliminate the (touchX,touchY) parameters from the API.
        // !!! FIXME: put all this heavy stuff onto the mH looper, as well as
        // the actual drag event dispatch stuff in the dragstate
        final DisplayContent displayContent = callingWin.getDisplayContent();
        if (displayContent == null) {
            return false;
        }
        Display display = displayContent.getDisplay();
        mService.mDragState.register(display);
        mService.mInputMonitor.updateInputWindowsLw(true);
        if (!mService.mInputManager.transferTouchFocus(callingWin.mInputChannel, mService.mDragState.mServerChannel)) {
            Slog.e(TAG_WM, "Unable to transfer touch focus");
            mService.mDragState.unregister();
            mService.mDragState = null;
            mService.mInputMonitor.updateInputWindowsLw(true);
            return false;
        }
        mService.mDragState.mData = data;
        mService.mDragState.broadcastDragStartedLw(touchX, touchY);
        mService.mDragState.overridePointerIconLw(touchSource);
        // remember the thumb offsets for later
        mService.mDragState.mThumbOffsetX = thumbCenterX;
        mService.mDragState.mThumbOffsetY = thumbCenterY;
        // Make the surface visible at the proper location
        final SurfaceControl surfaceControl = mService.mDragState.mSurfaceControl;
        if (SHOW_LIGHT_TRANSACTIONS)
            Slog.i(TAG_WM, ">>> OPEN TRANSACTION performDrag");
        SurfaceControl.openTransaction();
        try {
            surfaceControl.setPosition(touchX - thumbCenterX, touchY - thumbCenterY);
            surfaceControl.setLayer(mService.mDragState.getDragLayerLw());
            surfaceControl.setLayerStack(display.getLayerStack());
            surfaceControl.show();
        } finally {
            SurfaceControl.closeTransaction();
            if (SHOW_LIGHT_TRANSACTIONS)
                Slog.i(TAG_WM, "<<< CLOSE TRANSACTION performDrag");
        }
        mService.mDragState.notifyLocationLw(touchX, touchY);
    }
    // success!
    return true;
}
Also used : SurfaceControl(android.view.SurfaceControl) Display(android.view.Display)

Aggregations

SurfaceControl (android.view.SurfaceControl)27 Display (android.view.Display)14 Surface (android.view.Surface)11 Point (android.graphics.Point)8 OutOfResourcesException (android.view.Surface.OutOfResourcesException)8 EGLSurface (android.opengl.EGLSurface)6 DisplayInfo (android.view.DisplayInfo)6 SurfaceSession (android.view.SurfaceSession)6 Bitmap (android.graphics.Bitmap)5 Canvas (android.graphics.Canvas)5 Rect (android.graphics.Rect)5 Animation (android.view.animation.Animation)5 Binder (android.os.Binder)4 IBinder (android.os.IBinder)4 Message (android.os.Message)4 LayoutParams (android.view.WindowManager.LayoutParams)3 RemoteException (android.os.RemoteException)2 WindowManager (android.view.WindowManager)2 SparseIntArray (android.util.SparseIntArray)1 IWindowManager (android.view.IWindowManager)1