@Override public void onDisplayTransaction() { synchronized (this) { if (mSurfaceControl == null) { return; } DisplayInfo displayInfo = mDisplayManager.getDisplayInfo(Display.DEFAULT_DISPLAY); switch ((displayInfo.rotation + mHWRotation) % 4) { case Surface.ROTATION_0: mSurfaceControl.setPosition(0, 0); mSurfaceControl.setMatrix(1, 0, 0, 1); break; case Surface.ROTATION_90: mSurfaceControl.setPosition(0, displayInfo.logicalHeight); mSurfaceControl.setMatrix(0, -1, 1, 0); break; case Surface.ROTATION_180: mSurfaceControl.setPosition(displayInfo.logicalWidth, displayInfo.logicalHeight); mSurfaceControl.setMatrix(-1, 0, 0, -1); break; case Surface.ROTATION_270: mSurfaceControl.setPosition(displayInfo.logicalWidth, 0); mSurfaceControl.setMatrix(0, 1, -1, 0); break; } } }
public ViewportWindow(Context context) { SurfaceControl surfaceControl = null; try { mWindowManager.getDefaultDisplay().getRealSize(mTempPoint); surfaceControl = new SurfaceControl( mWindowManagerService.mFxSession, SURFACE_TITLE, mTempPoint.x, mTempPoint.y, PixelFormat.TRANSLUCENT, SurfaceControl.HIDDEN); } catch (OutOfResourcesException oore) { /* ignore */ } mSurfaceControl = surfaceControl; mSurfaceControl.setLayerStack(mWindowManager.getDefaultDisplay().getLayerStack()); mSurfaceControl.setLayer( mWindowManagerService.mPolicy.windowTypeToLayerLw( WindowManager.LayoutParams.TYPE_MAGNIFICATION_OVERLAY) * WindowManagerService.TYPE_LAYER_MULTIPLIER); mSurfaceControl.setPosition(0, 0); mSurface.copyFrom(mSurfaceControl); TypedValue typedValue = new TypedValue(); context.getTheme().resolveAttribute(R.attr.colorActivatedHighlight, typedValue, true); final int borderColor = context.getResources().getColor(typedValue.resourceId); mPaint.setStyle(Paint.Style.STROKE); mPaint.setStrokeWidth(mBorderWidth); mPaint.setColor(borderColor); Interpolator interpolator = new DecelerateInterpolator(2.5f); final long longAnimationDuration = context.getResources().getInteger(com.android.internal.R.integer.config_longAnimTime); mShowHideFrameAnimator = ObjectAnimator.ofInt(this, PROPERTY_NAME_ALPHA, MIN_ALPHA, MAX_ALPHA); mShowHideFrameAnimator.setInterpolator(interpolator); mShowHideFrameAnimator.setDuration(longAnimationDuration); mInvalidated = true; }