bool TiledPage::swapBuffersIfReady(const SkIRect& tileBounds, float scale)
{
    if (!m_glWebViewState)
        return false;

    if (!m_invalRegion.isEmpty() && !m_prepare)
        return false;

    if (m_scale != scale)
        return false;

    int swaps = 0;
    bool fullSwap = true;
    for (int x = tileBounds.fLeft; x < tileBounds.fRight; x++) {
        for (int y = tileBounds.fTop; y < tileBounds.fBottom; y++) {
            BaseTile* t = getBaseTile(x, y);
            if (!t || !t->isTileReady())
                fullSwap = false;
        }
    }

    // swap every tile on page (even if off screen)
    for (int j = 0; j < m_baseTileSize; j++) {
        BaseTile& tile = m_baseTiles[j];
        if (tile.swapTexturesIfNeeded())
            swaps++;
    }

    XLOG("%p greedy swapped %d textures, returning true", this, swaps);
    return fullSwap;
}
コード例 #2
0
void TilesProfiler::nextTile(BaseTile& tile, float scale, bool inView)
{
    if (!m_enabled || (m_records.size() > MAX_PROF_FRAMES) || (m_records.size() == 0))
        return;

    bool isReady = tile.isTileReady();
    int left = tile.x() * TilesManager::tileWidth();
    int top = tile.y() * TilesManager::tileWidth();
    int right = left + TilesManager::tileWidth();
    int bottom = top + TilesManager::tileWidth();

    if (inView) {
        if (isReady)
            m_goodTiles++;
        else
            m_badTiles++;
    }
    m_records.last().append(TileProfileRecord(
                                left, top, right, bottom,
                                scale, isReady, (int)tile.drawCount()));
    XLOG("adding tile %d %d %d %d, scale %f", left, top, right, bottom, scale);
}