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();
}
}
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();
}
}
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;
}
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();
}
}
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;
}
Aggregations