static inline void _ewk_view_single_scroll_process_single(Ewk_View_Smart_Data* smartData, void* pixels, Evas_Coord width, Evas_Coord height, const WebCore::IntSize& scrollOffset, const WebCore::IntRect& rectToScroll)
{
    int scrollX = rectToScroll.x();
    int scrollY = rectToScroll.y();
    int scrollWidth = rectToScroll.width();
    int scrollHeight = rectToScroll.height();

    DBG("%d,%d + %d,%d %+03d,%+03d, store: %p %dx%d",
        scrollX, scrollY, scrollWidth, scrollHeight, scrollOffset.width(), scrollOffset.height(), pixels, width, height);

    if (abs(scrollOffset.width()) >= scrollWidth || abs(scrollOffset.height()) >= scrollHeight) {
        ewk_view_repaint_add(smartData->_priv, scrollX, scrollY, scrollWidth, scrollHeight);
        return;
    }

    if (scrollX < 0) {
        scrollWidth += scrollX;
        scrollX = 0;
    }
    if (scrollY < 0) {
        scrollHeight += scrollY;
        scrollY = 0;
    }

    if (scrollX + scrollWidth > width)
        scrollWidth = width - scrollX;
    if (scrollY + scrollHeight > height)
        scrollHeight = height - scrollY;

    if (scrollWidth <= 0 || scrollHeight <= 0)
        return;

    int sourceX = scrollOffset.width() < 0 ? abs(scrollOffset.width()) : 0;
    int sourceY = scrollOffset.height() < 0 ? abs(scrollOffset.height()) : 0;
    int destinationX = scrollOffset.width() < 0 ? 0 : scrollOffset.width();
    int destinationY = scrollOffset.height() < 0 ? 0 : scrollOffset.height();
    int copyWidth = scrollWidth - abs(scrollOffset.width());
    int copyHeight = scrollHeight - abs(scrollOffset.height());
    if (scrollOffset.width() || scrollOffset.height()) {
        _ewk_view_screen_move(static_cast<uint32_t*>(pixels), destinationX, destinationY, sourceX, sourceY, copyWidth, copyHeight, width);
        evas_object_image_data_update_add(smartData->backing_store, destinationX, destinationY, copyWidth, copyHeight);
    }

    Eina_Rectangle verticalUpdate;
    verticalUpdate.x = destinationX ? 0 : copyWidth - 1;
    verticalUpdate.y = 0;
    verticalUpdate.w = abs(scrollOffset.width());
    verticalUpdate.h = scrollHeight;
    if (verticalUpdate.w && verticalUpdate.h)
        ewk_view_repaint_add(smartData->_priv, verticalUpdate.x, verticalUpdate.y, verticalUpdate.w, verticalUpdate.h);

    Eina_Rectangle horizontalUpdate;
    horizontalUpdate.x = destinationX;
    horizontalUpdate.y = destinationY ? 0 : copyHeight - 1;
    horizontalUpdate.w = copyWidth;
    horizontalUpdate.h = abs(scrollOffset.height());
    if (horizontalUpdate.w && horizontalUpdate.h)
        ewk_view_repaint_add(smartData->_priv, horizontalUpdate.x, horizontalUpdate.y, horizontalUpdate.w, horizontalUpdate.h);
}
Exemple #2
0
static Eina_Bool _ewk_view_tiled_smart_scrolls_process(Ewk_View_Smart_Data* smartData)
{
    const Ewk_Scroll_Request* scrollRequest;
    const Ewk_Scroll_Request* endOfScrollRequest;
    size_t count;
    Evas_Coord contentsWidth, contentsHeight;

    ewk_frame_contents_size_get(smartData->main_frame, &contentsWidth, &contentsHeight);

    scrollRequest = ewk_view_scroll_requests_get(smartData->_priv, &count);
    endOfScrollRequest = scrollRequest + count;
    for (; scrollRequest < endOfScrollRequest; scrollRequest++) {
        if (scrollRequest->main_scroll)
            ewk_tiled_backing_store_scroll_full_offset_add
                (smartData->backing_store, scrollRequest->dx, scrollRequest->dy);
        else {
            Evas_Coord scrollX, scrollY, scrollWidth, scrollHeight;

            scrollX = scrollRequest->x;
            scrollY = scrollRequest->y;
            scrollWidth = scrollRequest->w;
            scrollHeight = scrollRequest->h;

            if (abs(scrollRequest->dx) >= scrollWidth || abs(scrollRequest->dy) >= scrollHeight) {
                /* doubt webkit would be so     stupid... */
                DBG("full page scroll %+03d,%+03d. convert to repaint %d,%d + %dx%d",
                    scrollRequest->dx, scrollRequest->dy, scrollX, scrollY, scrollWidth, scrollHeight);
                ewk_view_repaint_add(smartData->_priv, scrollX, scrollY, scrollWidth, scrollHeight);
                continue;
            }

            if (scrollX + scrollWidth > contentsWidth)
                scrollWidth = contentsWidth - scrollX;
            if (scrollY + scrollHeight > contentsHeight)
                scrollHeight = contentsHeight - scrollY;

            if (scrollWidth < 0)
                scrollWidth = 0;
            if (scrollHeight < 0)
                scrollHeight = 0;

            if (!scrollWidth || !scrollHeight)
                continue;

            scrollX -= abs(scrollRequest->dx);
            scrollY -= abs(scrollRequest->dy);
            scrollWidth += abs(scrollRequest->dx);
            scrollHeight += abs(scrollRequest->dy);
            ewk_view_repaint_add(smartData->_priv, scrollX, scrollY, scrollWidth, scrollHeight);
            INF("using repaint for inner frame scolling!");
        }
    }

    return true;
}
static Eina_Bool _ewk_view_tiled_smart_scrolls_process(Ewk_View_Smart_Data *sd)
{
    const Ewk_Scroll_Request *sr;
    const Ewk_Scroll_Request *sr_end;
    size_t count;
    Evas_Coord vw, vh;

    ewk_frame_contents_size_get(sd->main_frame, &vw, &vh);

    sr = ewk_view_scroll_requests_get(sd->_priv, &count);
    sr_end = sr + count;
    for (; sr < sr_end; sr++) {
        if (sr->main_scroll)
            ewk_tiled_backing_store_scroll_full_offset_add
                (sd->backing_store, sr->dx, sr->dy);
        else {
            Evas_Coord sx, sy, sw, sh;

            sx = sr->x;
            sy = sr->y;
            sw = sr->w;
            sh = sr->h;

            if (abs(sr->dx) >= sw || abs(sr->dy) >= sh) {
                /* doubt webkit would be so     stupid... */
                DBG("full page scroll %+03d,%+03d. convert to repaint %d,%d + %dx%d",
                    sr->dx, sr->dy, sx, sy, sw, sh);
                ewk_view_repaint_add(sd->_priv, sx, sy, sw, sh);
                continue;
            }

            if (sx + sw > vw)
                sw = vw - sx;
            if (sy + sh > vh)
                sh = vh - sy;

            if (sw < 0)
                sw = 0;
            if (sh < 0)
                sh = 0;

            if (!sw || !sh)
                continue;

            sx -= abs(sr->dx);
            sy -= abs(sr->dy);
            sw += abs(sr->dx);
            sh += abs(sr->dy);
            ewk_view_repaint_add(sd->_priv, sx, sy, sw, sh);
            INF("using repaint for inner frame scolling!");
        }
    }

    return EINA_TRUE;
}
static inline void _ewk_view_single_scroll_process_single(Ewk_View_Smart_Data* smartData, void* pixels, Evas_Coord width, Evas_Coord height, const Ewk_Scroll_Request* scrollRequest)
{
    Evas_Coord scrollX, scrollY, scrollWidth, scrollHeight;

    DBG("%d,%d + %d,%d %+03d,%+03d, store: %p %dx%d",
        scrollRequest->x, scrollRequest->y, scrollRequest->w, scrollRequest->h, scrollRequest->dx, scrollRequest->dy, pixels, width, height);

    scrollX = scrollRequest->x;
    scrollY = scrollRequest->y;
    scrollWidth = scrollRequest->w;
    scrollHeight = scrollRequest->h;

    if (abs(scrollRequest->dx) >= scrollWidth || abs(scrollRequest->dy) >= scrollHeight) {
        /* doubt webkit would be so stupid... */
        DBG("full page scroll %+03d,%+03d. convert to repaint %d,%d + %dx%d",
            scrollRequest->dx, scrollRequest->dy, scrollX, scrollY, scrollWidth, scrollHeight);
        ewk_view_repaint_add(smartData->_priv, scrollX, scrollY, scrollWidth, scrollHeight);
        return;
    }

    if (scrollX < 0) {
        scrollWidth += scrollX;
        scrollX = 0;
    }
    if (scrollY < 0) {
        scrollHeight += scrollY;
        scrollY = 0;
    }

    if (scrollX + scrollWidth > width)
        scrollWidth = width - scrollX;
    if (scrollY + scrollHeight > height)
        scrollHeight = height - scrollY;

    if (scrollWidth < 0)
        scrollWidth = 0;
    if (scrollHeight < 0)
        scrollHeight = 0;

    EINA_SAFETY_ON_TRUE_RETURN(!scrollWidth || !scrollHeight);

    int sourceX = scrollRequest->dx < 0 ? abs(scrollRequest->dx) : 0;
    int sourceY = scrollRequest->dy < 0 ? abs(scrollRequest->dy) : 0;
    int destinationX = scrollRequest->dx < 0 ? 0 : scrollRequest->dx;
    int destinationY = scrollRequest->dy < 0 ? 0 : scrollRequest->dy;
    int copyWidth = scrollWidth - abs(scrollRequest->dx);
    int copyHeight = scrollHeight - abs(scrollRequest->dy);
    if (scrollRequest->dx || scrollRequest->dy) {
        _ewk_view_screen_move(static_cast<uint32_t*>(pixels), destinationX, destinationY, sourceX, sourceY, copyWidth, copyHeight, width);
        evas_object_image_data_update_add(smartData->backing_store, destinationX, destinationY, copyWidth, copyHeight);
    }

    Eina_Rectangle verticalUpdate;
    verticalUpdate.x = destinationX ? 0 : copyWidth - 1;
    verticalUpdate.y = 0;
    verticalUpdate.w = abs(scrollRequest->dx);
    verticalUpdate.h = scrollHeight;
    if (verticalUpdate.w && verticalUpdate.h)
        ewk_view_repaint_add(smartData->_priv, verticalUpdate.x, verticalUpdate.y, verticalUpdate.w, verticalUpdate.h);

    Eina_Rectangle horizontalUpdate;
    horizontalUpdate.x = destinationX;
    horizontalUpdate.y = destinationY ? 0 : copyHeight - 1;
    horizontalUpdate.w = copyWidth;
    horizontalUpdate.h = abs(scrollRequest->dy);
    if (horizontalUpdate.w && horizontalUpdate.h)
        ewk_view_repaint_add(smartData->_priv, horizontalUpdate.x, horizontalUpdate.y, horizontalUpdate.w, horizontalUpdate.h);
}
static inline void _ewk_view_single_scroll_process_single(Ewk_View_Smart_Data *sd, void *pixels, Evas_Coord ow, Evas_Coord oh, const Ewk_Scroll_Request *sr)
{
    Evas_Coord sx, sy, sw, sh;

    DBG("%d,%d + %d,%d %+03d,%+03d, store: %p %dx%d",
        sr->x, sr->y, sr->w, sr->h, sr->dx, sr->dy, pixels, ow, oh);

    sx = sr->x;
    sy = sr->y;
    sw = sr->w;
    sh = sr->h;

    if (abs(sr->dx) >= sw || abs(sr->dy) >= sh) {
        /* doubt webkit would be so stupid... */
        DBG("full page scroll %+03d,%+03d. convert to repaint %d,%d + %dx%d",
            sr->dx, sr->dy, sx, sy, sw, sh);
        ewk_view_repaint_add(sd->_priv, sx, sy, sw, sh);
        return;
    }

    if (sx < 0) {
        sw += sx;
        sx = 0;
    }
    if (sy < 0) {
        sh += sy;
        sy = 0;
    }

    if (sx + sw > ow)
        sw = ow - sx;
    if (sy + sh > oh)
        sh = oh - sy;

    if (sw < 0)
        sw = 0;
    if (sh < 0)
        sh = 0;

    EINA_SAFETY_ON_TRUE_RETURN(!sw || !sh);
    if (!sr->dx) {
        if (sr->dy < 0) {
            DBG("scroll up: %+03d,%+03d update=%d,%d+%dx%d, "
                "repaint=%d,%d+%dx%d",
                sr->dx, sr->dy, sx, sy, sw, sh + sr->dy,
                sx, sy + sh + sr->dy, sw, -sr->dy);

            _ewk_view_4b_move_region_up
                ((uint32_t*)pixels, -sr->dy, sx, sy, sw, sh, ow);
            evas_object_image_data_update_add
                (sd->backing_store, sx, sy, sw, sh + sr->dy);

            ewk_view_repaint_add(sd->_priv, sx, sy + sh + sr->dy, sw, -sr->dy);
        } else if (sr->dy > 0) {
            DBG("scroll down: %+03d,%+03d update=%d,%d+%dx%d, "
                "repaint=%d,%d+%dx%d",
                sr->dx, sr->dy, sx, sy + sr->dy, sw, sh - sr->dy,
                sx, sy, sw, sr->dy);

            _ewk_view_4b_move_region_down
                ((uint32_t*)pixels, sr->dy, sx, sy, sw, sh, ow);
            evas_object_image_data_update_add
                (sd->backing_store, sx, sy + sr->dy, sw, sh - sr->dy);

            ewk_view_repaint_add(sd->_priv, sx, sy, sw, sr->dy);
        }
    } else if (!sr->dy) {
        if (sr->dx < 0) {
            DBG("scroll left: %+03d,%+03d update=%d,%d+%dx%d, "
                "repaint=%d,%d+%dx%d",
                sr->dx, sr->dy, sx, sy, sw + sr->dx, sh,
                sx + sw + sr->dx, sy, -sr->dx, sh);

            _ewk_view_4b_move_region_left
                ((uint32_t*)pixels, -sr->dx, sx, sy, sw, sh, ow);
            evas_object_image_data_update_add
                (sd->backing_store, sx, sy, sw + sr->dx, sh);

            ewk_view_repaint_add(sd->_priv, sx + sw + sr->dx, sy, -sr->dx, sh);
        } else if (sr->dx > 0) {
            DBG("scroll up: %+03d,%+03d update=%d,%d+%dx%d, "
                "repaint=%d,%d+%dx%d",
                sr->dx, sr->dy, sx + sr->dx, sy, sw - sr->dx, sh,
                sx, sy, sr->dx, sh);

            _ewk_view_4b_move_region_right
                ((uint32_t*)pixels, sr->dx, sx, sy, sw, sh, ow);
            evas_object_image_data_update_add
                (sd->backing_store, sx + sr->dx, sy, sw - sr->dx, sh);

            ewk_view_repaint_add(sd->_priv, sx, sy, sr->dx, sh);
        }
    } else {
        Evas_Coord mx, my, mw, mh, ax, ay, aw, ah, bx, by, bw, bh;

        if (sr->dx < 0) {
            mx = sx;
            mw = sw + sr->dx;
            ax = mx + mw;
            aw = -sr->dx;
        } else {
            ax = sx;
            aw = sr->dx;
            mx = ax + aw;
            mw = sw - sr->dx;
        }

        if (sr->dy < 0) {
            my = sy;
            mh = sh + sr->dy;
            by = my + mh;
            bh = -sr->dy;
        } else {
            by = sy;
            bh = sr->dy;
            my = by + bh;
            mh = sh - sr->dy;
        }

        ay = my;
        ah = mh;
        bx = sx;
        bw = sw;

        DBG("scroll diagonal: %+03d,%+03d update=%d,%d+%dx%d, "
            "repaints: h=%d,%d+%dx%d v=%d,%d+%dx%d",
            sr->dx, sr->dy, mx, my, mw, mh, ax, ay, aw, ah, bx, by, bw, bh);

        _ewk_view_4b_move_region
            ((uint32_t*)pixels, sr->dx, sr->dy, sx, sy, sw, sh, ow);

        evas_object_image_data_update_add(sd->backing_store, mx, my, mw, mh);
        ewk_view_repaint_add(sd->_priv, ax, ay, aw, ah);
        ewk_view_repaint_add(sd->_priv, bx, by, bw, bh);
    }
}