本文整理汇总了C++中tile::Coordinate::x方法的典型用法代码示例。如果您正苦于以下问题:C++ Coordinate::x方法的具体用法?C++ Coordinate::x怎么用?C++ Coordinate::x使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tile::Coordinate
的用法示例。
在下文中一共展示了Coordinate::x方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: tileDistance
double TiledBackingStore::tileDistance(const IntRect& viewport, const Tile::Coordinate& tileCoordinate) const
{
if (viewport.intersects(tileRectForCoordinate(tileCoordinate)))
return 0;
IntPoint viewCenter = viewport.location() + IntSize(viewport.width() / 2, viewport.height() / 2);
Tile::Coordinate centerCoordinate = tileCoordinateForPoint(viewCenter);
return std::max(abs(centerCoordinate.y() - tileCoordinate.y()), abs(centerCoordinate.x() - tileCoordinate.x()));
}
示例2: createTiles
void TiledBackingStore::createTiles()
{
// Guard here as as these can change before the timer fires.
if (isBackingStoreUpdatesSuspended())
return;
// Update our backing store geometry.
const IntRect previousRect = m_rect;
m_rect = mapFromContents(m_client->tiledBackingStoreContentsRect());
const IntRect visibleRect = this->visibleRect();
m_visibleRect = visibleRect;
if (visibleRect.isEmpty())
return;
IntRect keepRect;
IntRect coverRect;
computeCoverAndKeepRect(visibleRect, coverRect, keepRect);
setKeepRect(keepRect);
// Resize tiles at the edge in case the contents size has changed, but only do so
// after having dropped tiles outside the keep rect.
bool didResizeTiles = false;
if (previousRect != m_rect)
didResizeTiles = resizeEdgeTiles();
// Search for the tile position closest to the viewport center that does not yet contain a tile.
// Which position is considered the closest depends on the tileDistance function.
double shortestDistance = std::numeric_limits<double>::infinity();
Vector<Tile::Coordinate> tilesToCreate;
unsigned requiredTileCount = 0;
// Cover areas (in tiles) with minimum distance from the visible rect. If the visible rect is
// not covered already it will be covered first in one go, due to the distance being 0 for tiles
// inside the visible rect.
Tile::Coordinate topLeft = tileCoordinateForPoint(coverRect.location());
Tile::Coordinate bottomRight = tileCoordinateForPoint(innerBottomRight(coverRect));
for (unsigned yCoordinate = topLeft.y(); yCoordinate <= bottomRight.y(); ++yCoordinate) {
for (unsigned xCoordinate = topLeft.x(); xCoordinate <= bottomRight.x(); ++xCoordinate) {
Tile::Coordinate currentCoordinate(xCoordinate, yCoordinate);
if (tileAt(currentCoordinate))
continue;
++requiredTileCount;
double distance = tileDistance(visibleRect, currentCoordinate);
if (distance > shortestDistance)
continue;
if (distance < shortestDistance) {
tilesToCreate.clear();
shortestDistance = distance;
}
tilesToCreate.append(currentCoordinate);
}
}
// Now construct the tile(s) within the shortest distance.
unsigned tilesToCreateCount = tilesToCreate.size();
for (unsigned n = 0; n < tilesToCreateCount; ++n) {
Tile::Coordinate coordinate = tilesToCreate[n];
setTile(coordinate, m_backend->createTile(this, coordinate));
}
requiredTileCount -= tilesToCreateCount;
// Paint the content of the newly created tiles or resized tiles.
if (tilesToCreateCount || didResizeTiles)
updateTileBuffers();
// Re-call createTiles on a timer to cover the visible area with the newest shortest distance.
if (requiredTileCount)
m_backingStoreUpdateTimer.startOneShot(m_tileCreationDelay);
}
示例3: createTiles
void TiledBackingStore::createTiles()
{
if (m_contentsFrozen)
return;
IntRect visibleRect = mapFromContents(m_client->tiledBackingStoreVisibleRect());
m_previousVisibleRect = visibleRect;
if (visibleRect.isEmpty())
return;
// Remove tiles that extend outside the current contents rect.
dropOverhangingTiles();
IntRect keepRect = visibleRect;
// Inflates to both sides, so divide inflate delta by 2
keepRect.inflateX(visibleRect.width() * (m_keepAreaMultiplier.width() - 1.f) / 2);
keepRect.inflateY(visibleRect.height() * (m_keepAreaMultiplier.height() - 1.f) / 2);
keepRect.intersect(contentsRect());
dropTilesOutsideRect(keepRect);
IntRect coverRect = visibleRect;
// Inflates to both sides, so divide inflate delta by 2
coverRect.inflateX(visibleRect.width() * (m_coverAreaMultiplier.width() - 1.f) / 2);
coverRect.inflateY(visibleRect.height() * (m_coverAreaMultiplier.height() - 1.f) / 2);
coverRect.intersect(contentsRect());
// Search for the tile position closest to the viewport center that does not yet contain a tile.
// Which position is considered the closest depends on the tileDistance function.
double shortestDistance = std::numeric_limits<double>::infinity();
Vector<Tile::Coordinate> tilesToCreate;
unsigned requiredTileCount = 0;
Tile::Coordinate topLeft = tileCoordinateForPoint(coverRect.location());
Tile::Coordinate bottomRight = tileCoordinateForPoint(IntPoint(coverRect.maxX(), coverRect.maxY()));
for (unsigned yCoordinate = topLeft.y(); yCoordinate <= bottomRight.y(); ++yCoordinate) {
for (unsigned xCoordinate = topLeft.x(); xCoordinate <= bottomRight.x(); ++xCoordinate) {
Tile::Coordinate currentCoordinate(xCoordinate, yCoordinate);
if (tileAt(currentCoordinate))
continue;
++requiredTileCount;
// Distance is 0 for all currently visible tiles.
double distance = tileDistance(visibleRect, currentCoordinate);
if (distance > shortestDistance)
continue;
if (distance < shortestDistance) {
tilesToCreate.clear();
shortestDistance = distance;
}
tilesToCreate.append(currentCoordinate);
}
}
// Now construct the tile(s)
unsigned tilesToCreateCount = tilesToCreate.size();
for (unsigned n = 0; n < tilesToCreateCount; ++n) {
Tile::Coordinate coordinate = tilesToCreate[n];
setTile(coordinate, Tile::create(this, coordinate));
}
requiredTileCount -= tilesToCreateCount;
// Paint the content of the newly created tiles
if (tilesToCreateCount)
updateTileBuffers();
// Keep creating tiles until the whole coverRect is covered.
if (requiredTileCount)
m_tileCreationTimer->startOneShot(m_tileCreationDelay);
}