void Player::use() { Tile* curr = nullptr; switch (dir) { case kLeft: curr = tileAt(worldPos.x, worldPos.y, tileLeft().x, tileLeft().y); break; case kRight: curr = tileAt(worldPos.x, worldPos.y, tileRight().x, tileRight().y); break; case kDown: curr = tileAt(worldPos.x, worldPos.y, tileDown().x, tileDown().y); break; case kUp: curr = tileAt(worldPos.x, worldPos.y, tileUp().x, tileUp().y); break; default: break; } if (curr != nullptr) { if (curr->canUse()) { if (curr->use()) { requestUpdate(delegate); } } } }
bool Player::checkCollision(int rx, int ry, int tx, int ty) { if (cartographer == nullptr) { WARN("no cartog ref in player.. no collision detection"); return false; } return tileAt(rx, ry, tx, ty)->isSolid() || tileAt(rx, ry, tx, ty)->hasMob(); }
void TiledLayerChromium::addSelfToOccludedScreenSpace(Region& occludedScreenSpace) { if (m_skipsDraw || drawOpacity() != 1 || !isPaintedAxisAlignedInScreen()) return; if (opaque()) { LayerChromium::addSelfToOccludedScreenSpace(occludedScreenSpace); return; } IntRect visibleRect = visibleLayerRect(); TransformationMatrix contentTransform = contentToScreenSpaceTransform(); // FIXME: Create/Use a FloatRegion for the occludedScreenSpace, instead of a Region based on ints, to avoid this step and get better accuracy between layers in target space. Region tileRegion; int left, top, right, bottom; m_tiler->layerRectToTileIndices(visibleLayerRect(), left, top, right, bottom); for (int j = top; j <= bottom; ++j) { for (int i = left; i <= right; ++i) { UpdatableTile* tile = tileAt(i, j); if (tile) { IntRect visibleTileOpaqueRect = intersection(visibleRect, tile->m_opaqueRect); FloatRect screenRect = contentTransform.mapRect(FloatRect(visibleTileOpaqueRect)); IntRect screenIntRect = enclosedIntRect(screenRect); if (!screenIntRect.isEmpty()) occludedScreenSpace.unite(screenIntRect); } } } }
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(); }
void GraphicalBoardFrame::resizeWidgets(int sideLength) { PixmapCacher::self()->invalidate(); bool firstTile = true; 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)) { TileWidget *tile = tileAt(currentTile); if (!tile) continue; tile->setSideLength(sideLength); if (firstTile) { emit tileFontChanged(tile->actualLetterFont()); firstTile = false; } } } for (int row = 0; row <= m_boardSize.height(); ++row) { TileWidget *mark = markAt(QSize(0, row)); mark->setSideLength(sideLength); } for (int col = 1; col <= m_boardSize.width(); ++col) { TileWidget *mark = markAt(QSize(col, 0)); mark->setSideLength(sideLength); } }
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)); } }
void TiledDrawingAreaProxy::paint(const IntRect& rect, PlatformDrawingContext context) { if (m_isWaitingForDidSetFrameNotification) { WebPageProxy* page = this->page(); if (!page->isValid()) return; if (page->process()->isLaunching()) return; } adjustVisibleRect(); GraphicsContext gc(context); gc.save(); // Assumes the backing store is painted with the scale transform applied. // Since tile content is already scaled, first revert the scaling from the painter. gc.scale(FloatSize(1 / m_contentsScale, 1 / m_contentsScale)); IntRect dirtyRect = mapFromContents(rect); TiledDrawingAreaTile::Coordinate topLeft = tileCoordinateForPoint(dirtyRect.topLeft()); TiledDrawingAreaTile::Coordinate bottomRight = tileCoordinateForPoint(dirtyRect.bottomRight()); for (unsigned yCoordinate = topLeft.y(); yCoordinate <= bottomRight.y(); ++yCoordinate) { for (unsigned xCoordinate = topLeft.x(); xCoordinate <= bottomRight.x(); ++xCoordinate) { TiledDrawingAreaTile::Coordinate currentCoordinate(xCoordinate, yCoordinate); RefPtr<TiledDrawingAreaTile> currentTile = tileAt(currentCoordinate); if (currentTile && currentTile->isReadyToPaint()) currentTile->paint(&gc, dirtyRect); } } gc.restore(); }
void TiledLayerChromium::reserveTextures() { updateBounds(); const IntRect& layerRect = visibleLayerRect(); if (layerRect.isEmpty() || !m_tiler->numTiles()) return; int left, top, right, bottom; m_tiler->layerRectToTileIndices(layerRect, left, top, right, bottom); createTextureUpdaterIfNeeded(); for (int j = top; j <= bottom; ++j) { for (int i = left; i <= right; ++i) { UpdatableTile* tile = tileAt(i, j); if (!tile) tile = createTile(i, j); if (!tile->managedTexture()->isValid(m_tiler->tileSize(), m_textureFormat)) tile->m_dirtyRect = m_tiler->tileRect(tile); if (!tile->managedTexture()->reserve(m_tiler->tileSize(), m_textureFormat)) return; } } }
void TiledBackingStore::paint(GraphicsContext* context, const IntRect& rect) { context->save(); // Assumes the backing store is painted with the scale transform applied. // Since tile content is already scaled, first revert the scaling from the painter. context->scale(FloatSize(1.f / m_contentsScale, 1.f / m_contentsScale)); IntRect dirtyRect = mapFromContents(rect); Tile::Coordinate topLeft = tileCoordinateForPoint(dirtyRect.location()); Tile::Coordinate bottomRight = tileCoordinateForPoint(innerBottomRight(dirtyRect)); for (unsigned yCoordinate = topLeft.y(); yCoordinate <= bottomRight.y(); ++yCoordinate) { for (unsigned xCoordinate = topLeft.x(); xCoordinate <= bottomRight.x(); ++xCoordinate) { Tile::Coordinate currentCoordinate(xCoordinate, yCoordinate); RefPtr<Tile> currentTile = tileAt(currentCoordinate); if (currentTile && currentTile->isReadyToPaint()) currentTile->paint(context, dirtyRect); else { IntRect tileRect = tileRectForCoordinate(currentCoordinate); IntRect target = intersection(tileRect, dirtyRect); if (target.isEmpty()) continue; m_backend->paintCheckerPattern(context, FloatRect(target)); } } } context->restore(); }
void GraphicalBoardFrame::generateBoardPixmap(QPixmap *pixmap) { if (m_sizeForBoard.isEmpty()) { *pixmap = QPixmap(0, 0); return; } *pixmap = QPixmap(m_sizeForBoard); QPainter painter(pixmap); 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)) { TileWidget *tile = tileAt(currentTile); if (!tile) continue; painter.drawPixmap(coordinatesOfTile(currentTile), tile->tilePixmap()); } } for (int row = 0; row <= m_boardSize.height(); ++row) { const QSize location(0, row); painter.drawPixmap(coordinatesOfMark(location), markAt(location)->tilePixmap()); } for (int col = 1; col <= m_boardSize.width(); ++col) { const QSize location(col, 0); painter.drawPixmap(coordinatesOfMark(location), markAt(location)->tilePixmap()); } }
void TiledBackingStore::invalidate(const IntRect& contentsDirtyRect) { IntRect dirtyRect(mapFromContents(contentsDirtyRect)); IntRect keepRectFitToTileSize = tileRectForCoordinate(tileCoordinateForPoint(m_keepRect.location())); keepRectFitToTileSize.unite(tileRectForCoordinate(tileCoordinateForPoint(innerBottomRight(m_keepRect)))); // Only iterate on the part of the rect that we know we might have tiles. IntRect coveredDirtyRect = intersection(dirtyRect, keepRectFitToTileSize); Tile::Coordinate topLeft = tileCoordinateForPoint(coveredDirtyRect.location()); Tile::Coordinate bottomRight = tileCoordinateForPoint(innerBottomRight(coveredDirtyRect)); for (int yCoordinate = topLeft.y(); yCoordinate <= bottomRight.y(); ++yCoordinate) { for (int xCoordinate = topLeft.x(); xCoordinate <= bottomRight.x(); ++xCoordinate) { RefPtr<Tile> currentTile = tileAt(Tile::Coordinate(xCoordinate, yCoordinate)); if (!currentTile) continue; // Pass the full rect to each tile as coveredDirtyRect might not // contain them completely and we don't want partial tile redraws. #if PLATFORM(JS) fprintf(stderr, "WebKit: TiledBackingStore: invalidate: invalidating currentTile (x,y,w,h): %i %i %i %i\n",dirtyRect.x(),dirtyRect.y(),dirtyRect.width(),dirtyRect.height()); #endif currentTile->invalidate(dirtyRect); } } startTileBufferUpdateTimer(); }
void TilesetEditor::currentChanged(const QModelIndex &index) { if (!index.isValid()) return; auto model = static_cast<const TilesetModel*>(index.model()); setCurrentTile(model->tileAt(index)); }
void CCTiledLayerImpl::pushInvalidTile(int i, int j) { DrawableTile* tile = tileAt(i, j); if (!tile) tile = createTile(i, j); tile->setResourceId(0); tile->setOpaqueRect(IntRect()); }
void CCTiledLayerImpl::pushTileProperties(int i, int j, CCResourceProvider::ResourceId resourceId, const IntRect& opaqueRect) { DrawableTile* tile = tileAt(i, j); if (!tile) tile = createTile(i, j); tile->setResourceId(resourceId); tile->setOpaqueRect(opaqueRect); }
TileKernel World::getTileKernel(const Int2 position) const { const Int2 positionL = position + Int2(-1, 0); const Int2 positionR = position + Int2( 1, 0); const Int2 positionD = position + Int2( 0, -1); const Int2 positionU = position + Int2( 0, 1); Tile center = isTilePositionOK(position) ? tileAt(position) : Tile(); return TileKernel( center, isTilePositionOK(positionL) ? tileAt(positionL) : center, isTilePositionOK(positionR) ? tileAt(positionR) : center, isTilePositionOK(positionD) ? tileAt(positionD) : center, isTilePositionOK(positionU) ? tileAt(positionU) : center, position ); }
void TiledLayerChromium::updateCompositorResources(GraphicsContext3D*, CCTextureUpdater& updater) { // Painting could cause compositing to get turned off, which may cause the tiler to become invalidated mid-update. if (m_skipsDraw || m_requestedUpdateTilesRect.isEmpty() || m_tiler->isEmpty()) return; int left = m_requestedUpdateTilesRect.x(); int top = m_requestedUpdateTilesRect.y(); int right = m_requestedUpdateTilesRect.maxX() - 1; int bottom = m_requestedUpdateTilesRect.maxY() - 1; for (int j = top; j <= bottom; ++j) { for (int i = left; i <= right; ++i) { UpdatableTile* tile = tileAt(i, j); // Required tiles are created in prepareToUpdate(). A tile should // never be removed between the call to prepareToUpdate() and the // call to updateCompositorResources(). if (!tile) CRASH(); IntRect sourceRect = tile->m_updateRect; if (tile->m_updateRect.isEmpty()) continue; ASSERT(tile->managedTexture()->isReserved()); const IntPoint anchor = m_tiler->tileRect(tile).location(); // Calculate tile-space rectangle to upload into. IntRect destRect(IntPoint(sourceRect.x() - anchor.x(), sourceRect.y() - anchor.y()), sourceRect.size()); if (destRect.x() < 0) CRASH(); if (destRect.y() < 0) CRASH(); // Offset from paint rectangle to this tile's dirty rectangle. IntPoint paintOffset(sourceRect.x() - m_paintRect.x(), sourceRect.y() - m_paintRect.y()); if (paintOffset.x() < 0) CRASH(); if (paintOffset.y() < 0) CRASH(); if (paintOffset.x() + destRect.width() > m_paintRect.width()) CRASH(); if (paintOffset.y() + destRect.height() > m_paintRect.height()) CRASH(); if (tile->m_partialUpdate) updater.appendPartial(tile->texture(), sourceRect, destRect); else updater.append(tile->texture(), sourceRect, destRect); } } // The updateRect should be in layer space. So we have to convert the paintRect from content space to layer space. m_updateRect = FloatRect(m_paintRect); float widthScale = bounds().width() / static_cast<float>(contentBounds().width()); float heightScale = bounds().height() / static_cast<float>(contentBounds().height()); m_updateRect.scale(widthScale, heightScale); }
void TiledLayerChromium::updateCompositorResources(GraphicsContext3D* context) { // Painting could cause compositing to get turned off, which may cause the tiler to become invalidated mid-update. if (m_skipsDraw || m_updateRect.isEmpty() || !m_tiler->numTiles()) return; int left, top, right, bottom; m_tiler->contentRectToTileIndices(m_updateRect, left, top, right, bottom); for (int j = top; j <= bottom; ++j) { for (int i = left; i <= right; ++i) { UpdatableTile* tile = tileAt(i, j); if (!tile) tile = createTile(i, j); else if (!tile->dirty()) continue; // Calculate page-space rectangle to copy from. IntRect sourceRect = m_tiler->tileContentRect(tile); const IntPoint anchor = sourceRect.location(); sourceRect.intersect(m_tiler->layerRectToContentRect(tile->m_dirtyLayerRect)); // Paint rect not guaranteed to line up on tile boundaries, so // make sure that sourceRect doesn't extend outside of it. sourceRect.intersect(m_paintRect); if (sourceRect.isEmpty()) continue; ASSERT(tile->texture()->isReserved()); // Calculate tile-space rectangle to upload into. IntRect destRect(IntPoint(sourceRect.x() - anchor.x(), sourceRect.y() - anchor.y()), sourceRect.size()); if (destRect.x() < 0) CRASH(); if (destRect.y() < 0) CRASH(); // Offset from paint rectangle to this tile's dirty rectangle. IntPoint paintOffset(sourceRect.x() - m_paintRect.x(), sourceRect.y() - m_paintRect.y()); if (paintOffset.x() < 0) CRASH(); if (paintOffset.y() < 0) CRASH(); if (paintOffset.x() + destRect.width() > m_paintRect.width()) CRASH(); if (paintOffset.y() + destRect.height() > m_paintRect.height()) CRASH(); tile->texture()->bindTexture(context); const GC3Dint filter = m_tiler->hasBorderTexels() ? GraphicsContext3D::LINEAR : GraphicsContext3D::NEAREST; GLC(context, context->texParameteri(GraphicsContext3D::TEXTURE_2D, GraphicsContext3D::TEXTURE_MIN_FILTER, filter)); GLC(context, context->texParameteri(GraphicsContext3D::TEXTURE_2D, GraphicsContext3D::TEXTURE_MAG_FILTER, filter)); GLC(context, context->bindTexture(GraphicsContext3D::TEXTURE_2D, 0)); textureUpdater()->updateTextureRect(context, tile->texture(), sourceRect, destRect); tile->clearDirty(); } } }
void GraphicalBoardFrame::drawArrow(const QSize &location, int arrowDirection) { TileWidget *tile = tileAt(location); if (!tile) return; tile->setArrowDirection(arrowDirection); tile->prepare(); }
void TiledLayerChromium::prepareToUpdate(const IntRect& contentRect) { ASSERT(m_tiler); m_skipsDraw = false; if (contentRect.isEmpty()) { m_updateRect = IntRect(); return; } // Invalidate old tiles that were previously used but aren't in use this // frame so that they can get reused for new tiles. invalidateTiles(contentRect); m_tiler->growLayerToContain(contentRect); if (!m_tiler->numTiles()) { m_updateRect = IntRect(); return; } // Create tiles as needed, expanding a dirty rect to contain all // the dirty regions currently being drawn. IntRect dirtyLayerRect; int left, top, right, bottom; m_tiler->contentRectToTileIndices(contentRect, left, top, right, bottom); for (int j = top; j <= bottom; ++j) { for (int i = left; i <= right; ++i) { UpdatableTile* tile = tileAt(i, j); if (!tile) tile = createTile(i, j); if (!tile->texture()->isValid(m_tiler->tileSize(), m_textureFormat)) tile->m_dirtyLayerRect = m_tiler->tileLayerRect(tile); if (!tile->texture()->reserve(m_tiler->tileSize(), m_textureFormat)) { m_skipsDraw = true; cleanupResources(); return; } dirtyLayerRect.unite(tile->m_dirtyLayerRect); } } // Due to borders, when the paint rect is extended to tile boundaries, it // may end up overlapping more tiles than the original content rect. Record // that original rect so we don't upload more tiles than necessary. m_updateRect = contentRect; m_paintRect = m_tiler->layerRectToContentRect(dirtyLayerRect); if (dirtyLayerRect.isEmpty()) return; textureUpdater()->prepareToUpdate(m_paintRect, m_tiler->tileSize(), m_tiler->hasBorderTexels()); }
CCResourceProvider::ResourceId CCTiledLayerImpl::contentsResourceId() const { // This function is only valid for single texture layers, e.g. masks. ASSERT(m_tiler); ASSERT(m_tiler->numTilesX() == 1); ASSERT(m_tiler->numTilesY() == 1); DrawableTile* tile = tileAt(0, 0); CCResourceProvider::ResourceId resourceId = tile ? tile->resourceId() : 0; return resourceId; }
Region CCLayerTilingData::opaqueRegionInLayerRect(const IntRect& layerRect) const { Region opaqueRegion; int left, top, right, bottom; layerRectToTileIndices(layerRect, left, top, right, bottom); for (int j = top; j <= bottom; ++j) { for (int i = left; i <= right; ++i) { Tile* tile = tileAt(i, j); if (!tile) continue; IntRect tileOpaqueRect = intersection(layerRect, tile->opaqueRect()); opaqueRegion.unite(tileOpaqueRect); } } return opaqueRegion; }
void World::draw(Window* window , float delta,int startRow,int endRow,int startCol,int endCol) { for(int r = startRow ; r < (_tiles.size()<endRow?_tiles.size():endRow) ; r++) { for(int c = startCol ; c < (_tiles[r].size()<endCol?_tiles[r].size():endCol) ; c++) { _tiles[r][c]->draw(window,delta); } } for(int i = 0 ; i < _enemyBots.size() ; i++) { if(tileAt(_enemyBots[i]->getLocation())->visible) { _enemyBots[i]->draw(window,delta); } } _player->draw(window,delta); }
void TiledBackingStore::invalidate(const IntRect& contentsDirtyRect) { IntRect dirtyRect(mapFromContents(contentsDirtyRect)); Tile::Coordinate topLeft = tileCoordinateForPoint(dirtyRect.location()); Tile::Coordinate bottomRight = tileCoordinateForPoint(innerBottomRight(dirtyRect)); for (unsigned yCoordinate = topLeft.y(); yCoordinate <= bottomRight.y(); ++yCoordinate) { for (unsigned xCoordinate = topLeft.x(); xCoordinate <= bottomRight.x(); ++xCoordinate) { RefPtr<Tile> currentTile = tileAt(Tile::Coordinate(xCoordinate, yCoordinate)); if (!currentTile) continue; currentTile->invalidate(dirtyRect); } } startTileBufferUpdateTimer(); }
void TiledLayerChromium::protectTileTextures(const IntRect& layerRect) { if (m_tiler->isEmpty() || layerRect.isEmpty()) return; int left, top, right, bottom; m_tiler->layerRectToTileIndices(layerRect, left, top, right, bottom); for (int j = top; j <= bottom; ++j) { for (int i = left; i <= right; ++i) { UpdatableTile* tile = tileAt(i, j); if (!tile || !tile->managedTexture()->isValid(m_tiler->tileSize(), m_textureFormat)) continue; tile->managedTexture()->reserve(m_tiler->tileSize(), m_textureFormat); } } }
void TiledLayerChromium::invalidateRect(const IntRect& layerRect) { if (m_tiler->isEmpty() || layerRect.isEmpty() || m_skipsDraw) return; int left, top, right, bottom; m_tiler->layerRectToTileIndices(layerRect, left, top, right, bottom); for (int j = top; j <= bottom; ++j) { for (int i = left; i <= right; ++i) { UpdatableTile* tile = tileAt(i, j); if (!tile) continue; IntRect bound = m_tiler->tileRect(tile); bound.intersect(layerRect); tile->m_dirtyRect.unite(bound); } } }
bool TiledLayerChromium::needsIdlePaint(const IntRect& layerRect) { if (m_skipsIdlePaint) return false; IntRect idlePaintLayerRect = idlePaintRect(layerRect); int left, top, right, bottom; m_tiler->layerRectToTileIndices(idlePaintLayerRect, left, top, right, bottom); for (int j = top; j <= bottom; ++j) { for (int i = left; i <= right; ++i) { if (m_requestedUpdateTilesRect.contains(IntPoint(i, j))) continue; UpdatableTile* tile = tileAt(i, j); if (!tile || !tile->managedTexture()->isValid(m_tiler->tileSize(), m_textureFormat) || tile->isDirty()) return true; } } return false; }
// Returns a ratio between 0.0f and 1.0f of the surface of contentsRect covered by rendered tiles. float TiledBackingStore::coverageRatio(const WebCore::IntRect& contentsRect) const { IntRect dirtyRect = mapFromContents(contentsRect); float rectArea = dirtyRect.width() * dirtyRect.height(); float coverArea = 0.0f; Tile::Coordinate topLeft = tileCoordinateForPoint(dirtyRect.location()); Tile::Coordinate bottomRight = tileCoordinateForPoint(innerBottomRight(dirtyRect)); for (unsigned yCoordinate = topLeft.y(); yCoordinate <= bottomRight.y(); ++yCoordinate) { for (unsigned xCoordinate = topLeft.x(); xCoordinate <= bottomRight.x(); ++xCoordinate) { Tile::Coordinate currentCoordinate(xCoordinate, yCoordinate); RefPtr<Tile> currentTile = tileAt(Tile::Coordinate(xCoordinate, yCoordinate)); if (currentTile && currentTile->isReadyToPaint()) { IntRect coverRect = intersection(dirtyRect, currentTile->rect()); coverArea += coverRect.width() * coverRect.height(); } } } return coverArea / rectArea; }
void GraphicalBoardFrame::drawMove(const Quackle::Move &move) { if (move.action == Quackle::Move::Place) { if (move.tiles().empty()) return; const QSize startTile(move.startcol, move.startrow); const Quackle::LetterString::const_iterator end(move.tiles().end()); int i = 0; for (Quackle::LetterString::const_iterator it = move.tiles().begin(); it != end; ++it, ++i) { // if this is a cemented letter that we shouldn't overwrite if (move.isAlreadyOnBoard(*it)) continue; QSize currentTile(startTile); if (move.horizontal) currentTile.setWidth(currentTile.width() + i); else currentTile.setHeight(currentTile.height() + i); TileWidget *tileWidget = tileAt(currentTile); if (!tileWidget) continue; Quackle::Board::TileInformation info; info.tileType = Quackle::Board::LetterTile; info.isBlank = QUACKLE_ALPHABET_PARAMETERS->isBlankLetter(*it); info.letter = QUACKLE_ALPHABET_PARAMETERS->clearBlankness(*it); tileWidget->setInformation(info); tileWidget->setCemented(false); tileWidget->prepare(); } } }
void GraphicalBoardFrame::drawBoard(const Quackle::Board &board) { QSize newBoardSize(board.width(), board.height()); if (m_boardSize != newBoardSize) { // if it was empty, we need to recalculate // tile widths bool wasEmpty = m_boardSize.isEmpty(); deleteWidgets(); m_boardSize = newBoardSize; recreateWidgets(); if (wasEmpty) expandToSize(m_maxSize); } 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)) { Quackle::Board::TileInformation info(board.tileInformation(currentTile.height(), currentTile.width())); TileWidget *tile = tileAt(currentTile); if (!tile) continue; tile->setInformation(info); tile->setArrowDirection(NoArrow); tile->setCemented(info.tileType == Quackle::Board::LetterTile); tile->prepare(); } } }
void TiledLayerChromium::invalidateRect(const IntRect& contentRect) { if (!m_tiler || contentRect.isEmpty() || m_skipsDraw) return; m_tiler->growLayerToContain(contentRect); // Dirty rects are always in layer space, as the layer could be repositioned // after invalidation. const IntRect layerRect = m_tiler->contentRectToLayerRect(contentRect); int left, top, right, bottom; m_tiler->contentRectToTileIndices(contentRect, left, top, right, bottom); for (int j = top; j <= bottom; ++j) { for (int i = left; i <= right; ++i) { UpdatableTile* tile = tileAt(i, j); if (!tile) continue; IntRect bound = m_tiler->tileLayerRect(tile); bound.intersect(layerRect); tile->m_dirtyLayerRect.unite(bound); } } }