Search in sources :

Example 16 with AttachInfo

use of android.view.View.AttachInfo in project cornerstone by Onskreen.

the class ViewRootImpl method draw.

private void draw(boolean fullRedrawNeeded) {
    Surface surface = mSurface;
    if (surface == null || !surface.isValid()) {
        return;
    }
    if (DEBUG_FPS) {
        trackFPS();
    }
    if (!sFirstDrawComplete) {
        synchronized (sFirstDrawHandlers) {
            sFirstDrawComplete = true;
            final int count = sFirstDrawHandlers.size();
            for (int i = 0; i < count; i++) {
                mHandler.post(sFirstDrawHandlers.get(i));
            }
        }
    }
    scrollToRectOrFocus(null, false);
    final AttachInfo attachInfo = mAttachInfo;
    if (attachInfo.mViewScrollChanged) {
        attachInfo.mViewScrollChanged = false;
        attachInfo.mTreeObserver.dispatchOnScrollChanged();
    }
    int yoff;
    boolean animating = mScroller != null && mScroller.computeScrollOffset();
    if (animating) {
        yoff = mScroller.getCurrY();
    } else {
        yoff = mScrollY;
    }
    if (mCurScrollY != yoff) {
        mCurScrollY = yoff;
        fullRedrawNeeded = true;
    }
    final float appScale = attachInfo.mApplicationScale;
    final boolean scalingRequired = attachInfo.mScalingRequired;
    int resizeAlpha = 0;
    if (mResizeBuffer != null) {
        long deltaTime = SystemClock.uptimeMillis() - mResizeBufferStartTime;
        if (deltaTime < mResizeBufferDuration) {
            float amt = deltaTime / (float) mResizeBufferDuration;
            amt = mResizeInterpolator.getInterpolation(amt);
            animating = true;
            resizeAlpha = 255 - (int) (amt * 255);
        } else {
            disposeResizeBuffer();
        }
    }
    final Rect dirty = mDirty;
    if (mSurfaceHolder != null) {
        // The app owns the surface, we won't draw.
        dirty.setEmpty();
        if (animating) {
            if (mScroller != null) {
                mScroller.abortAnimation();
            }
            disposeResizeBuffer();
        }
        return;
    }
    if (fullRedrawNeeded) {
        attachInfo.mIgnoreDirtyState = true;
        dirty.set(0, 0, (int) (mWidth * appScale + 0.5f), (int) (mHeight * appScale + 0.5f));
    }
    if (DEBUG_ORIENTATION || DEBUG_DRAW) {
        Log.v(TAG, "Draw " + mView + "/" + mWindowAttributes.getTitle() + ": dirty={" + dirty.left + "," + dirty.top + "," + dirty.right + "," + dirty.bottom + "} surface=" + surface + " surface.isValid()=" + surface.isValid() + ", appScale:" + appScale + ", width=" + mWidth + ", height=" + mHeight);
    }
    attachInfo.mTreeObserver.dispatchOnDraw();
    if (!dirty.isEmpty() || mIsAnimating) {
        if (attachInfo.mHardwareRenderer != null && attachInfo.mHardwareRenderer.isEnabled()) {
            // Draw with hardware renderer.
            mIsAnimating = false;
            mHardwareYOffset = yoff;
            mResizeAlpha = resizeAlpha;
            mCurrentDirty.set(dirty);
            mCurrentDirty.union(mPreviousDirty);
            mPreviousDirty.set(dirty);
            dirty.setEmpty();
            if (attachInfo.mHardwareRenderer.draw(mView, attachInfo, this, animating ? null : mCurrentDirty)) {
                mPreviousDirty.set(0, 0, mWidth, mHeight);
            }
        } else if (!drawSoftware(surface, attachInfo, yoff, scalingRequired, dirty)) {
            return;
        }
    }
    if (animating) {
        mFullRedrawNeeded = true;
        scheduleTraversals();
    }
}
Also used : Rect(android.graphics.Rect) AttachInfo(android.view.View.AttachInfo) Paint(android.graphics.Paint) Point(android.graphics.Point)

Example 17 with AttachInfo

use of android.view.View.AttachInfo in project platform_frameworks_base by android.

the class AccessibilityInteractionController method applyAppScaleAndMagnificationSpecIfNeeded.

private void applyAppScaleAndMagnificationSpecIfNeeded(AccessibilityNodeInfo info, MagnificationSpec spec) {
    if (info == null) {
        return;
    }
    final float applicationScale = mViewRootImpl.mAttachInfo.mApplicationScale;
    if (!shouldApplyAppScaleAndMagnificationSpec(applicationScale, spec)) {
        return;
    }
    Rect boundsInParent = mTempRect;
    Rect boundsInScreen = mTempRect1;
    info.getBoundsInParent(boundsInParent);
    info.getBoundsInScreen(boundsInScreen);
    if (applicationScale != 1.0f) {
        boundsInParent.scale(applicationScale);
        boundsInScreen.scale(applicationScale);
    }
    if (spec != null) {
        boundsInParent.scale(spec.scale);
        // boundsInParent must not be offset.
        boundsInScreen.scale(spec.scale);
        boundsInScreen.offset((int) spec.offsetX, (int) spec.offsetY);
    }
    info.setBoundsInParent(boundsInParent);
    info.setBoundsInScreen(boundsInScreen);
    if (spec != null) {
        AttachInfo attachInfo = mViewRootImpl.mAttachInfo;
        if (attachInfo.mDisplay == null) {
            return;
        }
        final float scale = attachInfo.mApplicationScale * spec.scale;
        Rect visibleWinFrame = mTempRect1;
        visibleWinFrame.left = (int) (attachInfo.mWindowLeft * scale + spec.offsetX);
        visibleWinFrame.top = (int) (attachInfo.mWindowTop * scale + spec.offsetY);
        visibleWinFrame.right = (int) (visibleWinFrame.left + mViewRootImpl.mWidth * scale);
        visibleWinFrame.bottom = (int) (visibleWinFrame.top + mViewRootImpl.mHeight * scale);
        attachInfo.mDisplay.getRealSize(mTempPoint);
        final int displayWidth = mTempPoint.x;
        final int displayHeight = mTempPoint.y;
        Rect visibleDisplayFrame = mTempRect2;
        visibleDisplayFrame.set(0, 0, displayWidth, displayHeight);
        if (!visibleWinFrame.intersect(visibleDisplayFrame)) {
            // If there's no intersection with display, set visibleWinFrame empty.
            visibleDisplayFrame.setEmpty();
        }
        if (!visibleWinFrame.intersects(boundsInScreen.left, boundsInScreen.top, boundsInScreen.right, boundsInScreen.bottom)) {
            info.setVisibleToUser(false);
        }
    }
}
Also used : Rect(android.graphics.Rect) AttachInfo(android.view.View.AttachInfo) Point(android.graphics.Point)

Example 18 with AttachInfo

use of android.view.View.AttachInfo in project android_frameworks_base by ParanoidAndroid.

the class AttachInfo_Accessor method setAttachInfo.

public static void setAttachInfo(View view) {
    Context context = view.getContext();
    WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
    Display display = wm.getDefaultDisplay();
    ViewRootImpl root = new ViewRootImpl(context, display);
    AttachInfo info = new AttachInfo(new BridgeWindowSession(), new BridgeWindow(), display, root, new Handler(), null);
    info.mHasWindowFocus = true;
    info.mWindowVisibility = View.VISIBLE;
    // this is so that we can display selections.
    info.mInTouchMode = false;
    info.mHardwareAccelerated = false;
    view.dispatchAttachedToWindow(info, 0);
}
Also used : Context(android.content.Context) BridgeWindowSession(com.android.layoutlib.bridge.android.BridgeWindowSession) BridgeWindow(com.android.layoutlib.bridge.android.BridgeWindow) Handler(android.os.Handler) AttachInfo(android.view.View.AttachInfo)

Example 19 with AttachInfo

use of android.view.View.AttachInfo in project android_frameworks_base by ParanoidAndroid.

the class ViewRootImpl method collectViewAttributes.

private boolean collectViewAttributes() {
    final View.AttachInfo attachInfo = mAttachInfo;
    if (attachInfo.mRecomputeGlobalAttributes) {
        //Log.i(TAG, "Computing view hierarchy attributes!");
        attachInfo.mRecomputeGlobalAttributes = false;
        boolean oldScreenOn = attachInfo.mKeepScreenOn;
        attachInfo.mKeepScreenOn = false;
        attachInfo.mSystemUiVisibility = 0;
        attachInfo.mHasSystemUiListeners = false;
        mView.dispatchCollectViewAttributes(attachInfo, 0);
        attachInfo.mSystemUiVisibility &= ~attachInfo.mDisabledSystemUiVisibility;
        WindowManager.LayoutParams params = mWindowAttributes;
        if (attachInfo.mKeepScreenOn != oldScreenOn || attachInfo.mSystemUiVisibility != params.subtreeSystemUiVisibility || attachInfo.mHasSystemUiListeners != params.hasSystemUiListeners) {
            applyKeepScreenOnFlag(params);
            params.subtreeSystemUiVisibility = attachInfo.mSystemUiVisibility;
            params.hasSystemUiListeners = attachInfo.mHasSystemUiListeners;
            mView.dispatchWindowSystemUiVisiblityChanged(attachInfo.mSystemUiVisibility);
            return true;
        }
    }
    return false;
}
Also used : AttachInfo(android.view.View.AttachInfo)

Example 20 with AttachInfo

use of android.view.View.AttachInfo in project android_frameworks_base by AOSPA.

the class AccessibilityInteractionController method applyAppScaleAndMagnificationSpecIfNeeded.

private void applyAppScaleAndMagnificationSpecIfNeeded(AccessibilityNodeInfo info, MagnificationSpec spec) {
    if (info == null) {
        return;
    }
    final float applicationScale = mViewRootImpl.mAttachInfo.mApplicationScale;
    if (!shouldApplyAppScaleAndMagnificationSpec(applicationScale, spec)) {
        return;
    }
    Rect boundsInParent = mTempRect;
    Rect boundsInScreen = mTempRect1;
    info.getBoundsInParent(boundsInParent);
    info.getBoundsInScreen(boundsInScreen);
    if (applicationScale != 1.0f) {
        boundsInParent.scale(applicationScale);
        boundsInScreen.scale(applicationScale);
    }
    if (spec != null) {
        boundsInParent.scale(spec.scale);
        // boundsInParent must not be offset.
        boundsInScreen.scale(spec.scale);
        boundsInScreen.offset((int) spec.offsetX, (int) spec.offsetY);
    }
    info.setBoundsInParent(boundsInParent);
    info.setBoundsInScreen(boundsInScreen);
    if (spec != null) {
        AttachInfo attachInfo = mViewRootImpl.mAttachInfo;
        if (attachInfo.mDisplay == null) {
            return;
        }
        final float scale = attachInfo.mApplicationScale * spec.scale;
        Rect visibleWinFrame = mTempRect1;
        visibleWinFrame.left = (int) (attachInfo.mWindowLeft * scale + spec.offsetX);
        visibleWinFrame.top = (int) (attachInfo.mWindowTop * scale + spec.offsetY);
        visibleWinFrame.right = (int) (visibleWinFrame.left + mViewRootImpl.mWidth * scale);
        visibleWinFrame.bottom = (int) (visibleWinFrame.top + mViewRootImpl.mHeight * scale);
        attachInfo.mDisplay.getRealSize(mTempPoint);
        final int displayWidth = mTempPoint.x;
        final int displayHeight = mTempPoint.y;
        Rect visibleDisplayFrame = mTempRect2;
        visibleDisplayFrame.set(0, 0, displayWidth, displayHeight);
        if (!visibleWinFrame.intersect(visibleDisplayFrame)) {
            // If there's no intersection with display, set visibleWinFrame empty.
            visibleDisplayFrame.setEmpty();
        }
        if (!visibleWinFrame.intersects(boundsInScreen.left, boundsInScreen.top, boundsInScreen.right, boundsInScreen.bottom)) {
            info.setVisibleToUser(false);
        }
    }
}
Also used : Rect(android.graphics.Rect) AttachInfo(android.view.View.AttachInfo) Point(android.graphics.Point)

Aggregations

AttachInfo (android.view.View.AttachInfo)27 Point (android.graphics.Point)13 Rect (android.graphics.Rect)12 Paint (android.graphics.Paint)7 Context (android.content.Context)6 Handler (android.os.Handler)6 BridgeWindow (com.android.layoutlib.bridge.android.BridgeWindow)6 BridgeWindowSession (com.android.layoutlib.bridge.android.BridgeWindowSession)6 AccessibilityManager (android.view.accessibility.AccessibilityManager)5 AccessibilityNodeProvider (android.view.accessibility.AccessibilityNodeProvider)5 CompatibilityInfo (android.content.res.CompatibilityInfo)2 Resources (android.content.res.Resources)2 Region (android.graphics.Region)2 RemoteException (android.os.RemoteException)2 DisplayMetrics (android.util.DisplayMetrics)2 IAccessibilityInteractionConnectionCallback (android.view.accessibility.IAccessibilityInteractionConnectionCallback)2 InputMethodManager (android.view.inputmethod.InputMethodManager)2 Scroller (android.widget.Scroller)2 BaseSurfaceHolder (com.android.internal.view.BaseSurfaceHolder)2 IInputMethodCallback (com.android.internal.view.IInputMethodCallback)1