Search in sources :

Example 11 with SurfaceControl

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

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 12 with SurfaceControl

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

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 13 with SurfaceControl

use of android.view.SurfaceControl in project platform_frameworks_base by android.

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 14 with SurfaceControl

use of android.view.SurfaceControl in project platform_frameworks_base by android.

the class WindowManagerService method prepareDragSurface.

// -------------------------------------------------------------
// Drag and drop
// -------------------------------------------------------------
IBinder prepareDragSurface(IWindow window, SurfaceSession session, int flags, int width, int height, Surface outSurface) {
    if (DEBUG_DRAG) {
        Slog.d(TAG_WM, "prepare drag surface: w=" + width + " h=" + height + " flags=" + Integer.toHexString(flags) + " win=" + window + " asbinder=" + window.asBinder());
    }
    final int callerPid = Binder.getCallingPid();
    final int callerUid = Binder.getCallingUid();
    final long origId = Binder.clearCallingIdentity();
    IBinder token = null;
    try {
        synchronized (mWindowMap) {
            try {
                if (mDragState == null) {
                    // TODO(multi-display): support other displays
                    final DisplayContent displayContent = getDefaultDisplayContentLocked();
                    final Display display = displayContent.getDisplay();
                    SurfaceControl surface = new SurfaceControl(session, "drag surface", width, height, PixelFormat.TRANSLUCENT, SurfaceControl.HIDDEN);
                    surface.setLayerStack(display.getLayerStack());
                    float alpha = 1;
                    if ((flags & View.DRAG_FLAG_OPAQUE) == 0) {
                        alpha = DRAG_SHADOW_ALPHA_TRANSPARENT;
                    }
                    surface.setAlpha(alpha);
                    if (SHOW_TRANSACTIONS)
                        Slog.i(TAG_WM, "  DRAG " + surface + ": CREATE");
                    outSurface.copyFrom(surface);
                    final IBinder winBinder = window.asBinder();
                    token = new Binder();
                    mDragState = new DragState(this, token, surface, flags, winBinder);
                    mDragState.mPid = callerPid;
                    mDragState.mUid = callerUid;
                    mDragState.mOriginalAlpha = alpha;
                    token = mDragState.mToken = new Binder();
                    // 5 second timeout for this window to actually begin the drag
                    mH.removeMessages(H.DRAG_START_TIMEOUT, winBinder);
                    Message msg = mH.obtainMessage(H.DRAG_START_TIMEOUT, winBinder);
                    mH.sendMessageDelayed(msg, 5000);
                } else {
                    Slog.w(TAG_WM, "Drag already in progress");
                }
            } catch (OutOfResourcesException e) {
                Slog.e(TAG_WM, "Can't allocate drag surface w=" + width + " h=" + height, e);
                if (mDragState != null) {
                    mDragState.reset();
                    mDragState = null;
                }
            }
        }
    } finally {
        Binder.restoreCallingIdentity(origId);
    }
    return token;
}
Also used : Binder(android.os.Binder) IBinder(android.os.IBinder) IBinder(android.os.IBinder) Message(android.os.Message) OutOfResourcesException(android.view.Surface.OutOfResourcesException) SurfaceControl(android.view.SurfaceControl) Point(android.graphics.Point) Display(android.view.Display)

Example 15 with SurfaceControl

use of android.view.SurfaceControl in project platform_frameworks_base by android.

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)

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