Example #1
0
// When bliting, if the item from the transfer queue is mismatching b/t the
// BaseTile and the content, then the item is considered as obsolete, and
// the content is discarded.
bool TransferQueue::checkObsolete(int index)
{
    BaseTile* baseTilePtr = m_transferQueue[index].savedBaseTilePtr;
    if (!baseTilePtr) {
        XLOG("Invalid savedBaseTilePtr , such that the tile is obsolete");
        return true;
    }

    BaseTileTexture* baseTileTexture = baseTilePtr->backTexture();
    if (!baseTileTexture) {
        XLOG("Invalid baseTileTexture , such that the tile is obsolete");
        return true;
    }

    const TextureTileInfo* tileInfo = &m_transferQueue[index].tileInfo;

    if (tileInfo->m_x != baseTilePtr->x()
        || tileInfo->m_y != baseTilePtr->y()
        || tileInfo->m_scale != baseTilePtr->scale()
        || tileInfo->m_painter != baseTilePtr->painter()) {
        XLOG("Mismatching x, y, scale or painter , such that the tile is obsolete");
        return true;
    }

    return false;
}
void TiledPage::prepareRow(bool goingLeft, int tilesInRow, int firstTileX, int y, const SkIRect& tileBounds)
{
    for (int i = 0; i < tilesInRow; i++) {
        int x = firstTileX;

        // If we are goingLeft, we want to schedule the tiles starting from the
        // right (and to the left if not). This is because tiles are appended to
        // the list and the texture uploader goes through the set front to back.
        if (goingLeft)
            x += (tilesInRow - 1) - i;
        else
            x += i;

        BaseTile* currentTile = 0;
        BaseTile* availableTile = 0;
        for (int j = 0; j < m_baseTileSize; j++) {
            BaseTile& tile = m_baseTiles[j];
            if (tile.x() == x && tile.y() == y) {
                currentTile = &tile;
                break;
            }

            if (!availableTile || (tile.drawCount() < availableTile->drawCount()))
                availableTile = &tile;
        }

        if (!currentTile && availableTile) {
            XLOG("STEALING tile %d, %d (draw count %llu) for tile %d, %d",
                 availableTile->x(), availableTile->y(), availableTile->drawCount(), x, y);
            availableTile->discardTextures(); // don't wait for textures to be stolen
            currentTile = availableTile;
        }

        if (!currentTile) {
            XLOG("ERROR: No tile available for tile %d %d", x, y);
        }

        if (currentTile) {
            currentTile->setGLWebViewState(m_glWebViewState);
            currentTile->setPage(this);

            currentTile->setContents(this, x, y, m_scale);

            // TODO: move below (which is largely the same for layers / tiled
            // page) into prepare() function

            // ensure there is a texture associated with the tile and then check to
            // see if the texture is dirty and in need of repainting
            if (currentTile->isDirty() || !currentTile->frontTexture())
                currentTile->reserveTexture();
            if (currentTile->backTexture()
                    && currentTile->isDirty()
                    && !currentTile->isRepaintPending()) {
                PaintTileOperation *operation = new PaintTileOperation(currentTile);
                TilesManager::instance()->scheduleOperation(operation);
            }
        }
    }
}