Search in sources :

Example 1 with DrawFilter

use of android.graphics.DrawFilter in project android_frameworks_base by ParanoidAndroid.

the class WebViewClassic method drawContent.

private void drawContent(Canvas canvas) {
    if (mDrawHistory) {
        canvas.scale(mZoomManager.getScale(), mZoomManager.getScale());
        canvas.drawPicture(mHistoryPicture);
        return;
    }
    if (mNativeClass == 0)
        return;
    boolean animateZoom = mZoomManager.isFixedLengthAnimationInProgress();
    boolean animateScroll = ((!mScroller.isFinished() || mVelocityTracker != null) && (mTouchMode != TOUCH_DRAG_MODE || mHeldMotionless != MOTIONLESS_TRUE));
    if (mTouchMode == TOUCH_DRAG_MODE) {
        if (mHeldMotionless == MOTIONLESS_PENDING) {
            mPrivateHandler.removeMessages(DRAG_HELD_MOTIONLESS);
            mHeldMotionless = MOTIONLESS_FALSE;
        }
        if (mHeldMotionless == MOTIONLESS_FALSE) {
            mPrivateHandler.sendMessageDelayed(mPrivateHandler.obtainMessage(DRAG_HELD_MOTIONLESS), MOTIONLESS_TIME);
            mHeldMotionless = MOTIONLESS_PENDING;
        }
    }
    int saveCount = canvas.save();
    if (animateZoom) {
        mZoomManager.animateZoom(canvas);
    } else if (!canvas.isHardwareAccelerated()) {
        canvas.scale(mZoomManager.getScale(), mZoomManager.getScale());
    }
    boolean UIAnimationsRunning = false;
    // We may in the future decide to do that independently.
    if (mNativeClass != 0 && !canvas.isHardwareAccelerated() && nativeEvaluateLayersAnimations(mNativeClass)) {
        UIAnimationsRunning = true;
        // If we have unfinished (or unstarted) animations,
        // we ask for a repaint. We only need to do this in software
        // rendering (with hardware rendering we already have a different
        // method of requesting a repaint)
        mWebViewCore.sendMessage(EventHub.NOTIFY_ANIMATION_STARTED);
        invalidate();
    }
    // decide which adornments to draw
    int extras = DRAW_EXTRAS_NONE;
    if (!mFindIsUp && mShowTextSelectionExtra) {
        extras = DRAW_EXTRAS_SELECTION;
    }
    calcOurContentVisibleRectF(mVisibleContentRect);
    if (canvas.isHardwareAccelerated()) {
        Rect invScreenRect = mIsWebViewVisible ? mInvScreenRect : null;
        Rect screenRect = mIsWebViewVisible ? mScreenRect : null;
        int functor = nativeCreateDrawGLFunction(mNativeClass, invScreenRect, screenRect, mVisibleContentRect, getScale(), extras);
        ((HardwareCanvas) canvas).callDrawGLFunction(functor);
        if (mHardwareAccelSkia != getSettings().getHardwareAccelSkiaEnabled()) {
            mHardwareAccelSkia = getSettings().getHardwareAccelSkiaEnabled();
            nativeUseHardwareAccelSkia(mHardwareAccelSkia);
        }
    } else {
        DrawFilter df = null;
        if (mZoomManager.isZoomAnimating() || UIAnimationsRunning) {
            df = mZoomFilter;
        } else if (animateScroll) {
            df = mScrollFilter;
        }
        canvas.setDrawFilter(df);
        nativeDraw(canvas, mVisibleContentRect, mBackgroundColor, extras);
        canvas.setDrawFilter(null);
    }
    canvas.restoreToCount(saveCount);
    drawTextSelectionHandles(canvas);
    if (extras == DRAW_EXTRAS_CURSOR_RING) {
        if (mTouchMode == TOUCH_SHORTPRESS_START_MODE) {
            mTouchMode = TOUCH_SHORTPRESS_MODE;
        }
    }
}
Also used : Rect(android.graphics.Rect) HardwareCanvas(android.view.HardwareCanvas) DrawFilter(android.graphics.DrawFilter) PaintFlagsDrawFilter(android.graphics.PaintFlagsDrawFilter) Paint(android.graphics.Paint) Point(android.graphics.Point)

Example 2 with DrawFilter

use of android.graphics.DrawFilter in project XobotOS by xamarin.

the class WebView method drawCoreAndCursorRing.

private void drawCoreAndCursorRing(Canvas canvas, int color, boolean drawCursorRing) {
    if (mDrawHistory) {
        canvas.scale(mZoomManager.getScale(), mZoomManager.getScale());
        canvas.drawPicture(mHistoryPicture);
        return;
    }
    if (mNativeClass == 0)
        return;
    boolean animateZoom = mZoomManager.isFixedLengthAnimationInProgress();
    boolean animateScroll = ((!mScroller.isFinished() || mVelocityTracker != null) && (mTouchMode != TOUCH_DRAG_MODE || mHeldMotionless != MOTIONLESS_TRUE)) || mDeferTouchMode == TOUCH_DRAG_MODE;
    if (mTouchMode == TOUCH_DRAG_MODE) {
        if (mHeldMotionless == MOTIONLESS_PENDING) {
            mPrivateHandler.removeMessages(DRAG_HELD_MOTIONLESS);
            mPrivateHandler.removeMessages(AWAKEN_SCROLL_BARS);
            mHeldMotionless = MOTIONLESS_FALSE;
        }
        if (mHeldMotionless == MOTIONLESS_FALSE) {
            mPrivateHandler.sendMessageDelayed(mPrivateHandler.obtainMessage(DRAG_HELD_MOTIONLESS), MOTIONLESS_TIME);
            mHeldMotionless = MOTIONLESS_PENDING;
        }
    }
    int saveCount = canvas.save();
    if (animateZoom) {
        mZoomManager.animateZoom(canvas);
    } else if (!canvas.isHardwareAccelerated()) {
        canvas.scale(mZoomManager.getScale(), mZoomManager.getScale());
    }
    boolean UIAnimationsRunning = false;
    // We may in the future decide to do that independently.
    if (mNativeClass != 0 && nativeEvaluateLayersAnimations(mNativeClass)) {
        UIAnimationsRunning = true;
        // method of requesting a repaint)
        if (!canvas.isHardwareAccelerated())
            invalidate();
    }
    // decide which adornments to draw
    int extras = DRAW_EXTRAS_NONE;
    if (mFindIsUp) {
        extras = DRAW_EXTRAS_FIND;
    } else if (mSelectingText && !USE_JAVA_TEXT_SELECTION) {
        extras = DRAW_EXTRAS_SELECTION;
        nativeSetSelectionPointer(mNativeClass, mDrawSelectionPointer, mZoomManager.getInvScale(), mSelectX, mSelectY - getTitleHeight());
    } else if (drawCursorRing) {
        extras = DRAW_EXTRAS_CURSOR_RING;
    }
    if (DebugFlags.WEB_VIEW) {
        Log.v(LOGTAG, "mFindIsUp=" + mFindIsUp + " mSelectingText=" + mSelectingText + " nativePageShouldHandleShiftAndArrows()=" + nativePageShouldHandleShiftAndArrows() + " animateZoom=" + animateZoom + " extras=" + extras);
    }
    if (canvas.isHardwareAccelerated()) {
        int functor = nativeGetDrawGLFunction(mNativeClass, mGLViewportEmpty ? null : mGLRectViewport, mGLViewportEmpty ? null : mViewRectViewport, getScale(), extras);
        ((HardwareCanvas) canvas).callDrawGLFunction(functor);
        if (mHardwareAccelSkia != getSettings().getHardwareAccelSkiaEnabled()) {
            mHardwareAccelSkia = getSettings().getHardwareAccelSkiaEnabled();
            nativeUseHardwareAccelSkia(mHardwareAccelSkia);
        }
    } else {
        DrawFilter df = null;
        if (mZoomManager.isZoomAnimating() || UIAnimationsRunning) {
            df = mZoomFilter;
        } else if (animateScroll) {
            df = mScrollFilter;
        }
        canvas.setDrawFilter(df);
        // XXX: Revisit splitting content.  Right now it causes a
        // synchronization problem with layers.
        int content = nativeDraw(canvas, color, extras, false);
        canvas.setDrawFilter(null);
        if (!mBlockWebkitViewMessages && content != 0) {
            mWebViewCore.sendMessage(EventHub.SPLIT_PICTURE_SET, content, 0);
        }
    }
    canvas.restoreToCount(saveCount);
    if (mSelectingText && USE_JAVA_TEXT_SELECTION) {
        drawTextSelectionHandles(canvas);
    }
    if (extras == DRAW_EXTRAS_CURSOR_RING) {
        if (mTouchMode == TOUCH_SHORTPRESS_START_MODE) {
            mTouchMode = TOUCH_SHORTPRESS_MODE;
        }
    }
    if (mFocusSizeChanged) {
        mFocusSizeChanged = false;
        // updates the WebTextView position in sync with page swapping
        if (!canvas.isHardwareAccelerated() && !animateZoom && inEditingMode()) {
            didUpdateWebTextViewDimensions(ANYWHERE);
        }
    }
}
Also used : HardwareCanvas(android.view.HardwareCanvas) DrawFilter(android.graphics.DrawFilter) PaintFlagsDrawFilter(android.graphics.PaintFlagsDrawFilter) Paint(android.graphics.Paint) Point(android.graphics.Point)

Aggregations

DrawFilter (android.graphics.DrawFilter)2 Paint (android.graphics.Paint)2 PaintFlagsDrawFilter (android.graphics.PaintFlagsDrawFilter)2 Point (android.graphics.Point)2 HardwareCanvas (android.view.HardwareCanvas)2 Rect (android.graphics.Rect)1