void TiledDrawingAreaProxy::invalidate(const IntRect& contentsDirtyRect) { IntRect dirtyRect(mapFromContents(contentsDirtyRect)); TiledDrawingAreaTile::Coordinate topLeft = tileCoordinateForPoint(dirtyRect.topLeft()); TiledDrawingAreaTile::Coordinate bottomRight = tileCoordinateForPoint(dirtyRect.bottomRight()); IntRect coverRect = calculateCoverRect(m_previousVisibleRect); Vector<TiledDrawingAreaTile::Coordinate> tilesToRemove; for (unsigned yCoordinate = topLeft.y(); yCoordinate <= bottomRight.y(); ++yCoordinate) { for (unsigned xCoordinate = topLeft.x(); xCoordinate <= bottomRight.x(); ++xCoordinate) { RefPtr<TiledDrawingAreaTile> currentTile = tileAt(TiledDrawingAreaTile::Coordinate(xCoordinate, yCoordinate)); if (!currentTile) continue; if (!currentTile->rect().intersects(dirtyRect)) continue; // If a tile outside out current cover rect gets invalidated, just drop it instead of updating. if (!currentTile->rect().intersects(coverRect)) { tilesToRemove.append(currentTile->coordinate()); continue; } currentTile->invalidate(dirtyRect); } } unsigned removeCount = tilesToRemove.size(); for (unsigned n = 0; n < removeCount; ++n) removeTile(tilesToRemove[n]); startTileBufferUpdateTimer(); }
/** * Insert a new widget * @param widget :: An MdiSubWindow to add. * @param row :: A row index at which to place the new tile. * @param col :: A column index at which to place the new tile. */ void TiledWindow::insertWidget(MdiSubWindow *widget, int row, int col) { int index = calcFlatIndex( row, col ); int lastRow = rowCount() - 1; int lastCol = columnCount() - 1; // if the last tile has a widget append a row if ( getWidget( lastRow, lastCol ) != NULL ) { ++lastRow; Tile *tile = getOrAddTile( lastRow, lastCol ); (void) tile; } // shift widgets towards the bottom int lastIndex = calcFlatIndex( lastRow, lastCol ); int rowTo(0), colTo(0), rowFrom(0), colFrom(0); for(int i = lastIndex; i > index; --i) { calcTilePosition( i, rowTo, colTo ); calcTilePosition( i - 1, rowFrom, colFrom ); if ( hasWidget( rowFrom, colFrom ) ) { MdiSubWindow *w = removeTile( rowFrom, colFrom ); addWidget( w, rowTo, colTo ); } } addWidget( widget, row, col ); }
void GraphicalBoardFrame::deleteWidgets() { if (m_boardSize.isEmpty()) return; for (QSize currentTile(0, 0); currentTile.height() < m_boardSize.height(); currentTile.setHeight(currentTile.height() + 1)) { for (currentTile.setWidth(0); currentTile.width() < m_boardSize.width(); currentTile.setWidth(currentTile.width() + 1)) { delete tileAt(currentTile); removeTile(currentTile); } } for (int row = 0; row <= m_boardSize.height(); ++row) { delete markAt(QSize(0, row)); removeMark(QSize(0, row)); } for (int col = 1; col <= m_boardSize.width(); ++col) { delete markAt(QSize(col, 0)); removeMark(QSize(col, 0)); } }
bool OgreDetourTileCache::buildTile(const int tx, const int ty, InputGeom *inputGeom) { if (tx < 0 || tx >= m_tw) return false; if (ty < 0 || ty >= m_th) return false; //TODO maybe I want to keep these values up to date /* m_cacheLayerCount = 0; m_cacheCompressedSize = 0; m_cacheRawSize = 0; */ TileCacheData tiles[MAX_LAYERS]; memset(tiles, 0, sizeof(tiles)); int ntiles = rasterizeTileLayers(inputGeom, tx, ty, m_cfg, tiles, MAX_LAYERS); // This is where the tile is built dtStatus status; // I don't know exactly why this can still be multiple tiles (??) for (int i = 0; i < ntiles; ++i) { TileCacheData* tile = &tiles[i]; dtTileCacheLayerHeader* header = (dtTileCacheLayerHeader*)tile->data; // Important: if a tile already exists at this position, first remove the old one or it will not be updated! removeTile( m_tileCache->getTileRef(m_tileCache->getTileAt(header->tx, header->ty,header->tlayer)) ); status = m_tileCache->addTile(tile->data, tile->dataSize, DT_COMPRESSEDTILE_FREE_DATA, 0); // Add compressed tiles to tileCache if (dtStatusFailed(status)) { dtFree(tile->data); tile->data = 0; continue; // TODO maybe return false here? } // TODO this has to be recalculated differently when rebuilding a tile /* m_cacheLayerCount++; m_cacheCompressedSize += tile->dataSize; m_cacheRawSize += calcLayerBufferSize(m_tcparams.width, m_tcparams.height); */ } //TODO add a deferred command for this? // Build navmesh tile from cached tile m_tileCache->buildNavMeshTilesAt(tx,ty, m_recast->m_navMesh); // This immediately builds the tile, without the need of a dtTileCache::update() //TODO update this value? //m_cacheBuildMemUsage = m_talloc->high; // TODO extract debug drawing to a separate class drawDetail(tx, ty); return true; }
void TiledDrawingAreaProxy::removeAllTiles() { Vector<RefPtr<TiledDrawingAreaTile> > tilesToRemove; copyValuesToVector(m_tiles, tilesToRemove); unsigned removeCount = tilesToRemove.size(); for (unsigned n = 0; n < removeCount; ++n) removeTile(tilesToRemove[n]->coordinate()); }
void MapView::removeTiles(int z) { QList<OSMTile *> tilesAtZ = tiles[z]; for (int i = tilesAtZ.count()-1; i>=0; --i) { removeTile(tilesAtZ.at(i)); } }
/** * Remove (but don't delete) a tile. * @param row :: The row of a tile to remove. * @param col :: The column of a tile to remove. * @return :: A pointer to the removed subwindow. */ MdiSubWindow *TiledWindow::removeTile(int row, int col) { Tile *tile = getTile(row, col); MdiSubWindow *widget = removeTile(tile); if (widget == NULL) { QString msg = QString("Cell (%1,%2) is empty.").arg(row).arg(col); throw std::runtime_error(msg.toStdString()); } return widget; }
void TileList::remove(int x, int y){ //get the tile int index = indexOfTopTile(x,y); //there was no tile if (index == -1) return; removeTile(index); }
/** * Remove (but don't delete) a widget. * @param w :: A widget to remove. */ void TiledWindow::removeWidget(MdiSubWindow *w) { for (int row = 0; row < rowCount(); ++row) { for (int col = 0; col < columnCount(); ++col) { if (getWidget(row, col) == w) { removeTile(row, col); return; } } } }
/** * Take a widget at position (row,col), remove it and make docked. * @param row :: The tile's row index. * @param col :: The tile's column index. */ void TiledWindow::removeWidgetTo(int row, int col, TiledWindow::RemoveDestination to) { try { deselectWidget(row, col); MdiSubWindow *widget = removeTile(row, col); sendWidgetTo(widget, to); } catch (std::runtime_error &ex) { QMessageBox::critical(this, "MantidPlot- Error", "Cannot remove a widget from a TiledWindow:\n\n" + QString::fromStdString(ex.what())); } }
void grab_pointer_position(int *src_x, int *src_y, int *width, int *height) { int dest_x, dest_y; createWindow(); removeTile(); show_forever(); show_toplevel(); changeCursor(dpy, win); showWindow(); window_main_loop(src_x, src_y, &dest_x, &dest_y); *width = IMAX(*src_x, dest_x) - IMIN(*src_x, dest_x); *height = IMAX(*src_y, dest_y) - IMIN(*src_y, dest_y); }
ossimRefPtr<ossimImageData> ossimFixedTileCache::removeTile() { OpenThreads::ScopedLock<OpenThreads::Mutex> lock(theMutex); if(theUseLruFlag) { if(theLruQueue.begin() != theLruQueue.end()) { return removeTile(*(theLruQueue.begin())); } } return NULL; }
void TileList::raise(int x, int y){ //get the tile int index = indexOfTopTile(x,y); //there was no tile if (index == -1) return; Tile tile = tileArray[index]; //remove the tile from its current place and add it to the end of the list removeTile(index); addTile(tile); }
void MapView::removeDistantTiles(qreal factor) { //Removes items that are not partially in the extended viewRect QRectF viewRect = mapToScene(0,0,width(),height()).boundingRect(); QRectF extendedViewRect = viewRect; extendedViewRect.setSize(extendedViewRect.size()*factor); extendedViewRect.moveCenter(viewRect.center()); QList<QGraphicsItem *> allItems = scene()->items(); QList<QGraphicsItem *> visibleItems = scene()->items(extendedViewRect,Qt::IntersectsItemBoundingRect); for (int i = allItems.count()-1; i>=0; --i) { //removes tiles not in viewrect if (!visibleItems.contains(allItems.at(i)) && allItems.at(i)->zValue()<18) removeTile(dynamic_cast<OSMTile*>(allItems.at(i))); } }
void OgreDetourTileCache::unloadTiles(const Ogre::AxisAlignedBox &areaToUpdate) { // Determine which navmesh tiles have to be removed float bmin[3], bmax[3]; OgreRecast::OgreVect3ToFloatA(areaToUpdate.getMinimum(), bmin); OgreRecast::OgreVect3ToFloatA(areaToUpdate.getMaximum(), bmax); dtCompressedTileRef touched[DT_MAX_TOUCHED_TILES]; int ntouched = 0; m_tileCache->queryTiles(bmin, bmax, touched, &ntouched, DT_MAX_TOUCHED_TILES); // Remove tiles for (int i = 0; i < ntouched; ++i) { removeTile(touched[i]); } }
void TiledBackingStore::dropTilesOutsideRect(const IntRect& keepRect) { FloatRect keepRectF = keepRect; Vector<Tile::Coordinate> toRemove; TileMap::iterator end = m_tiles.end(); for (TileMap::iterator it = m_tiles.begin(); it != end; ++it) { Tile::Coordinate coordinate = it->second->coordinate(); FloatRect tileRect = it->second->rect(); if (!tileRect.intersects(keepRectF)) toRemove.append(coordinate); } unsigned removeCount = toRemove.size(); for (unsigned n = 0; n < removeCount; ++n) removeTile(toRemove[n]); }
void TiledBackingStore::dropOverhangingTiles() { IntRect contentsRect = this->contentsRect(); Vector<Tile::Coordinate> tilesToRemove; TileMap::iterator end = m_tiles.end(); for (TileMap::iterator it = m_tiles.begin(); it != end; ++it) { Tile::Coordinate tileCoordinate = it->second->coordinate(); IntRect tileRect = it->second->rect(); IntRect expectedTileRect = tileRectForCoordinate(tileCoordinate); if (expectedTileRect != tileRect || !contentsRect.contains(tileRect)) tilesToRemove.append(tileCoordinate); } unsigned removeCount = tilesToRemove.size(); for (unsigned n = 0; n < removeCount; ++n) removeTile(tilesToRemove[n]); }
boolean findMoves(MatchingContext_t context, int currentTileIndex) { if(currentTileIndex >= NUM_TILES) { int moveScore = calculateScore(context); int scoreDiff = context->midPoint - moveScore; if(scoreDiff < 0) { scoreDiff *= -1; } boolean inRange = moveScore >= context->lowerBound && moveScore <= context->upperBound; if(inRange || scoreDiff < context->bestScoreDiff) { context->bestScoreDiff = scoreDiff; int i; int len = NUM_TILES * 2; for(i = 0; i < len; i++) { context->bestMove[i] = context->currentMove[i]; } context->bestScore = moveScore; } return inRange; } int row, col, dir; char *currentTile = context->tiles[currentTileIndex]; for(row = 0; row < BOARD_SIZE; row++) { for(col = 0; col < BOARD_SIZE; col++) { for(dir = 0; dir < 4; dir++) { if(checkAndPlaceTile(context, currentTile, row, col, dir)) { int index = 2 * currentTileIndex; context->currentMove[index] = row * BOARD_SIZE + col; context->currentMove[index + 1] = dir; if(findMoves(context, currentTileIndex + 1) == TRUE) { return TRUE; } removeTile(context, currentTile, row, col, dir); context->currentMove[index] = -1; context->currentMove[index + 1] = -1; } } } } return FALSE; }
boost::optional<RemovedRecastMeshObject> TileCachedRecastMeshManager::removeObject(const ObjectId id) { const auto object = mObjectsTilesPositions.find(id); if (object == mObjectsTilesPositions.end()) return boost::none; boost::optional<RemovedRecastMeshObject> result; { auto tiles = mTiles.lock(); for (const auto& tilePosition : object->second) { const auto removed = removeTile(id, tilePosition, tiles.get()); if (removed && !result) result = removed; } } if (result) ++mRevision; return result; }
bool TiledBackingStore::resizeEdgeTiles() { bool wasResized = false; Vector<Tile::Coordinate> tilesToRemove; TileMap::iterator end = m_tiles.end(); for (TileMap::iterator it = m_tiles.begin(); it != end; ++it) { Tile::Coordinate tileCoordinate = it->second->coordinate(); IntRect tileRect = it->second->rect(); IntRect expectedTileRect = tileRectForCoordinate(tileCoordinate); if (expectedTileRect.isEmpty()) tilesToRemove.append(tileCoordinate); else if (expectedTileRect != tileRect) { it->second->resize(expectedTileRect.size()); wasResized = true; } } unsigned removeCount = tilesToRemove.size(); for (unsigned n = 0; n < removeCount; ++n) removeTile(tilesToRemove[n]); return wasResized; }
void TileList::lower(int x, int y){ //get the tile int index = indexOfTopTile(x,y); //there was no tile if (index == -1) return; Tile tile = tileArray[index]; //remove the tile but increment currentSize since we want to keep the size of the array removeTile(index); currentSize++; //shift the array and put tile in the first spot for (int i = currentSize - 2; i >= 0; --i){ tileArray[i + 1] = tileArray[i]; } //add the tile to the start of the array tileArray[0] = tile; }
std::vector<TilePosition> TileCachedRecastMeshManager::updateObject(const ObjectId id, const btCollisionShape& shape, const btTransform& transform, const AreaType areaType) { const auto object = mObjectsTilesPositions.find(id); if (object == mObjectsTilesPositions.end()) return std::vector<TilePosition>(); auto& currentTiles = object->second; const auto border = getBorderSize(mSettings); std::vector<TilePosition> changedTiles; std::set<TilePosition> newTiles; { auto tiles = mTiles.lock(); const auto onTilePosition = [&] (const TilePosition& tilePosition) { if (currentTiles.count(tilePosition)) { newTiles.insert(tilePosition); if (updateTile(id, transform, areaType, tilePosition, tiles.get())) changedTiles.push_back(tilePosition); } else if (addTile(id, shape, transform, areaType, tilePosition, border, tiles.get())) { newTiles.insert(tilePosition); changedTiles.push_back(tilePosition); } }; getTilesPositions(shape, transform, mSettings, onTilePosition); for (const auto& tile : currentTiles) if (!newTiles.count(tile) && removeTile(id, tile, tiles.get())) changedTiles.push_back(tile); } std::swap(currentTiles, newTiles); if (!changedTiles.empty()) ++mRevision; return changedTiles; }
void CB_Room::removeTile(uint32_t x, uint32_t y) { uint32_t i = x + y * width; if(i >= width * height) { return; } SDL_mutexP(roomMutex); CB_Tile * tile = tileMap[i]; tileMap[i] = CB_Tile::BLANK_TILE; SDL_mutexV(roomMutex); if(tile == 0) { return; } else if(tile == CB_Tile::BLANK_TILE) { uint32_t cX = x; while(true) { uint32_t cY = y; while(true) { uint32_t cI = cX + cY * width; SDL_mutexP(roomMutex); CB_Tile * tile = tileMap[cI]; SDL_mutexV(roomMutex); if(tile == 0) { break; } if(tile != CB_Tile::BLANK_TILE) { if(cX + tile->getWidth(tileSize) > x && cY + tile->getHeight(tileSize) > y) { removeTile(cX, cY); return; } break; } if(cY == 0) { break; } cY--; } if(cX == 0) { break; } cX--; } } SDL_mutexP(roomMutex); uint32_t tileW = min(width - x, (uint32_t)tile->getWidth(tileSize)); uint32_t tileH = min(height - y, (uint32_t)tile->getHeight(tileSize)); SDL_mutexV(roomMutex); for(uint32_t tY = 0; tY < tileH; tY++) { for(uint32_t tX = 0; tX < tileW; tX++) { SDL_mutexP(roomMutex); uint32_t tI = x + tX + (y + tY) * width; if(tileMap[tI] == CB_Tile::BLANK_TILE) { tileMap[tI] = 0; } SDL_mutexV(roomMutex); } } }
void LayerTreeHostProxy::syncRemoteContent() { // We enqueue messages and execute them during paint, as they require an active GL context. ensureRootLayer(); while (OwnPtr<LayerTreeMessageToRenderer> nextMessage = m_messagesToRenderer.tryGetMessage()) { switch (nextMessage->type()) { case LayerTreeMessageToRenderer::SetRootLayer: { const SetRootLayerMessageData& data = static_cast<SetRootLayerMessage*>(nextMessage.get())->data(); setRootLayerID(data.layerID); break; } case LayerTreeMessageToRenderer::DeleteLayer: { const DeleteLayerMessageData& data = static_cast<DeleteLayerMessage*>(nextMessage.get())->data(); deleteLayer(data.layerID); break; } case LayerTreeMessageToRenderer::SyncLayerParameters: { const SyncLayerParametersMessageData& data = static_cast<SyncLayerParametersMessage*>(nextMessage.get())->data(); syncLayerParameters(data.layerInfo); break; } case LayerTreeMessageToRenderer::CreateTile: { const CreateTileMessageData& data = static_cast<CreateTileMessage*>(nextMessage.get())->data(); createTile(data.layerID, data.remoteTileID, data.scale); break; } case LayerTreeMessageToRenderer::RemoveTile: { const RemoveTileMessageData& data = static_cast<RemoveTileMessage*>(nextMessage.get())->data(); removeTile(data.layerID, data.remoteTileID); break; } case LayerTreeMessageToRenderer::UpdateTile: { const UpdateTileMessageData& data = static_cast<UpdateTileMessage*>(nextMessage.get())->data(); updateTile(data.layerID, data.remoteTileID, data.sourceRect, data.targetRect, data.image); break; } case LayerTreeMessageToRenderer::CreateImage: { const CreateImageMessageData& data = static_cast<CreateImageMessage*>(nextMessage.get())->data(); createImage(data.imageID, data.image); break; } case LayerTreeMessageToRenderer::DestroyImage: { const CreateImageMessageData& data = static_cast<CreateImageMessage*>(nextMessage.get())->data(); destroyImage(data.imageID); break; } case LayerTreeMessageToRenderer::FlushLayerChanges: flushLayerChanges(); break; } } }
void TileManager::updateTileSet() { m_tileSetChanged = false; // Check if any native worker needs to be dispatched i.e. queuedTiles is not empty { auto workersIter = m_workers.begin(); auto queuedTilesIter = m_queuedTiles.begin(); while (workersIter != m_workers.end() && queuedTilesIter != m_queuedTiles.end()) { auto& worker = *workersIter; if (worker->isFree()) { worker->processTileData(std::move(*queuedTilesIter), m_scene->getStyles(), *m_view); queuedTilesIter = m_queuedTiles.erase(queuedTilesIter); } ++workersIter; } } // Check if any incoming tiles are finished for (auto& worker : m_workers) { if (!worker->isFree() && worker->isFinished()) { // Get result from worker and move it into tile set auto tile = worker->getTileResult(); const TileID& id = tile->getID(); logMsg("Tile [%d, %d, %d] finished loading\n", id.z, id.x, id.y); std::swap(m_tileSet[id], tile); cleanProxyTiles(id); m_tileSetChanged = true; } } if (! (m_view->changedOnLastUpdate() || m_tileSetChanged) ) { // No new tiles have come into view and no tiles have finished loading, // so the tileset is unchanged return; } const std::set<TileID>& visibleTiles = m_view->getVisibleTiles(); // Loop over visibleTiles and add any needed tiles to tileSet { auto setTilesIter = m_tileSet.begin(); auto visTilesIter = visibleTiles.begin(); while (visTilesIter != visibleTiles.end()) { if (setTilesIter == m_tileSet.end() || *visTilesIter < setTilesIter->first) { // tileSet is missing an element present in visibleTiles addTile(*visTilesIter); m_tileSetChanged = true; ++visTilesIter; } else if (setTilesIter->first < *visTilesIter) { // visibleTiles is missing an element present in tileSet (handled below) ++setTilesIter; } else { // tiles in both sets match, move on ++setTilesIter; ++visTilesIter; } } } // Loop over tileSet and remove any tiles that are neither visible nor proxies { auto setTilesIter = m_tileSet.begin(); auto visTilesIter = visibleTiles.begin(); while (setTilesIter != m_tileSet.end()) { if (visTilesIter == visibleTiles.end() || setTilesIter->first < *visTilesIter) { // visibleTiles is missing an element present in tileSet if (setTilesIter->second->getProxyCounter() <= 0) { removeTile(setTilesIter); m_tileSetChanged = true; } else { ++setTilesIter; } } else if (*visTilesIter < setTilesIter->first) { // tileSet is missing an element present in visibleTiles (shouldn't occur) ++visTilesIter; } else { // tiles in both sets match, move on ++setTilesIter; ++visTilesIter; } } } }