Search in sources :

Example 26 with SurfaceControl

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

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

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

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)

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