void GLWebViewState::swapPages()
{
    android::Mutex::Autolock lock(m_tiledPageLock);
    m_usePageA ^= true;
    TiledPage* oldPage = m_usePageA ? m_tiledPageB : m_tiledPageA;
    zoomManager()->swapPages();
    oldPage->discardTextures();
}
Ejemplo n.º 2
0
void GLWebViewState::swapPages()
{
    android::Mutex::Autolock lock(m_tiledPageLock);
    m_usePageA ^= true;
    TiledPage* oldPage = m_usePageA ? m_tiledPageB : m_tiledPageA;
    zoomManager()->swapPages();
    oldPage->discardTextures();
    //SAMSUNG CHNAGES >>	
    if(mSharpenStartTime != -1){
         mSharpenEndTime = WTF::currentTimeMS();	
         double sharpenTime = (mSharpenEndTime - mSharpenStartTime);
         XLOGC("Disappearing white area time and Sharpening time after zooming: %.3f milliSecs", sharpenTime );		 
	  		//XLOGC("White Area time during zooming: %.3f milliSecs", mWhiteAreaTime );		 
	  		mSharpenStartTime = mSharpenEndTime = -1;	 
    }
    //SAMSUNG CHNAGES <<	
}
int PaintTileOperation::priority()
{
    if (!m_tile)
        return -1;

    int priority = 200000;

    // if scrolling, prioritize the prefetch page, otherwise deprioritize
    TiledPage* page = m_tile->page();
    if (page && page->isPrefetchPage()) {
        if (page->glWebViewState()->isScrolling())
            priority = 0;
        else
            priority = 400000;
    }

    // prioritize higher draw count
    unsigned long long currentDraw = TilesManager::instance()->getDrawGLCount();
    unsigned long long drawDelta = currentDraw - m_tile->drawCount();
    priority += 100000 * (int)std::min(drawDelta, (unsigned long long)1000);

    // prioritize unpainted tiles, within the same drawCount
    if (m_tile->frontTexture())
        priority += 50000;

    // for base tiles, prioritize based on position
    if (!m_tile->isLayerTile()) {
        bool goingDown = m_tile->page()->scrollingDown();
        priority += m_tile->x();

        if (goingDown)
            priority += 100000 - (1 + m_tile->y()) * 1000;
        else
            priority += m_tile->y() * 1000;
    }

    return priority;
}
bool BaseLayerAndroid::prepareBasePictureInGL(SkRect& viewport, float scale,
                                              double currentTime)
{
    ZoomManager* zoomManager = m_state->zoomManager();

    bool goingDown = m_state->goingDown();
    bool goingLeft = m_state->goingLeft();

    const SkIRect& viewportTileBounds = m_state->viewportTileBounds();
    XLOG("drawBasePicture, TX: %d, TY: %d scale %.2f", viewportTileBounds.fLeft,
            viewportTileBounds.fTop, scale);

    // Query the resulting state from the zoom manager
    bool prepareNextTiledPage = zoomManager->needPrepareNextTiledPage();

    // Display the current page
    TiledPage* tiledPage = m_state->frontPage();
    TiledPage* nextTiledPage = m_state->backPage();
    tiledPage->setScale(zoomManager->currentScale());

    // Let's prepare the page if needed so that it will start painting
    if (prepareNextTiledPage) {
        nextTiledPage->setScale(scale);
        m_state->setFutureViewport(viewportTileBounds);

        // ignore dirtiness return value since while zooming we repaint regardless
        nextTiledPage->updateTileDirtiness(viewportTileBounds);

        nextTiledPage->prepare(goingDown, goingLeft, viewportTileBounds,
                               TiledPage::VisibleBounds);
        // Cancel pending paints for the foreground page
        TilesManager::instance()->removePaintOperationsForPage(tiledPage, false);
    }

    // If we fired a request, let's check if it's ready to use
    if (zoomManager->didFireRequest()) {
        if (nextTiledPage->swapBuffersIfReady(viewportTileBounds,
                                              zoomManager->futureScale()))
            zoomManager->setReceivedRequest(); // transition to received request state
    }

    float transparency = 1;
    bool doZoomPageSwap = false;

    // If the page is ready, display it. We do a short transition between
    // the two pages (current one and future one with the new scale factor)
    if (zoomManager->didReceivedRequest()) {
        float nextTiledPageTransparency = 1;
        m_state->resetFrameworkInval();
        zoomManager->processTransition(currentTime, scale, &doZoomPageSwap,
                                       &nextTiledPageTransparency, &transparency);
        nextTiledPage->prepareForDrawGL(nextTiledPageTransparency, viewportTileBounds);
    }

    const SkIRect& preZoomBounds = m_state->preZoomBounds();

    bool zooming = ZoomManager::kNoScaleRequest != zoomManager->scaleRequestState();

    if (doZoomPageSwap) {
        zoomManager->setCurrentScale(scale);
        m_state->swapPages();
    }

    bool needsRedraw = zooming;

    // if applied invals mark tiles dirty, need to redraw
    needsRedraw |= tiledPage->updateTileDirtiness(preZoomBounds);

    // paint what's needed unless we're zooming, since the new tiles won't
    // be relevant soon anyway
    if (!zooming)
        tiledPage->prepare(goingDown, goingLeft, preZoomBounds,
                           TiledPage::ExpandedBounds);

    XLOG("scrolling %d, zooming %d, needsRedraw %d",
         scrolling, zooming, needsRedraw);

    // prefetch in the nextTiledPage if unused by zooming (even if not scrolling
    // since we want the tiles to be ready before they're needed)
    bool usePrefetchPage = !zooming;
    nextTiledPage->setIsPrefetchPage(usePrefetchPage);
    if (usePrefetchPage) {
        // if the non-prefetch page isn't missing tiles, don't bother drawing
        // prefetch page
        bool drawPrefetchPage = tiledPage->hasMissingContent(preZoomBounds);
        prefetchBasePicture(viewport, scale, nextTiledPage, drawPrefetchPage);
    }

    tiledPage->prepareForDrawGL(transparency, preZoomBounds);

    return needsRedraw;
}