本文整理汇总了C++中UpdatableTile类的典型用法代码示例。如果您正苦于以下问题:C++ UpdatableTile类的具体用法?C++ UpdatableTile怎么用?C++ UpdatableTile使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了UpdatableTile类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: pushPropertiesTo
void TiledLayerChromium::pushPropertiesTo(CCLayerImpl* layer)
{
LayerChromium::pushPropertiesTo(layer);
CCTiledLayerImpl* tiledLayer = static_cast<CCTiledLayerImpl*>(layer);
if (!m_tiler) {
tiledLayer->setSkipsDraw(true);
return;
}
tiledLayer->setTilingTransform(tilingTransform());
tiledLayer->setSkipsDraw(m_skipsDraw);
tiledLayer->setTextureOrientation(m_textureOrientation);
tiledLayer->setSampledTexelFormat(m_sampledTexelFormat);
tiledLayer->setTilingData(*m_tiler);
for (CCLayerTilingData::TileMap::const_iterator iter = m_tiler->tiles().begin(); iter != m_tiler->tiles().end(); ++iter) {
int i = iter->first.first;
int j = iter->first.second;
UpdatableTile* tile = static_cast<UpdatableTile*>(iter->second.get());
if (!tile->texture()->isValid(m_tiler->tileSize(), m_textureFormat))
continue;
tiledLayer->syncTextureId(i, j, tile->texture()->textureId());
}
}
开发者ID:Xertz,项目名称:EAWebKit,代码行数:26,代码来源:TiledLayerChromium.cpp
示例2: updateBounds
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;
}
}
}
开发者ID:,项目名称:,代码行数:26,代码来源:
示例3: pushPropertiesTo
void TiledLayerChromium::pushPropertiesTo(CCLayerImpl* layer)
{
LayerChromium::pushPropertiesTo(layer);
CCTiledLayerImpl* tiledLayer = static_cast<CCTiledLayerImpl*>(layer);
tiledLayer->setSkipsDraw(m_skipsDraw);
tiledLayer->setContentsSwizzled(m_sampledTexelFormat != LayerTextureUpdater::SampledTexelFormatRGBA);
tiledLayer->setTilingData(*m_tiler);
Vector<UpdatableTile*> invalidTiles;
for (CCLayerTilingData::TileMap::const_iterator iter = m_tiler->tiles().begin(); iter != m_tiler->tiles().end(); ++iter) {
int i = iter->first.first;
int j = iter->first.second;
UpdatableTile* tile = static_cast<UpdatableTile*>(iter->second.get());
if (!tile->managedTexture()->isValid(m_tiler->tileSize(), m_textureFormat)) {
invalidTiles.append(tile);
continue;
}
if (tile->isDirtyForCurrentFrame())
continue;
tiledLayer->pushTileProperties(i, j, tile->managedTexture()->textureId(), tile->opaqueRect());
}
for (Vector<UpdatableTile*>::const_iterator iter = invalidTiles.begin(); iter != invalidTiles.end(); ++iter)
m_tiler->takeTile((*iter)->i(), (*iter)->j());
}
开发者ID:,项目名称:,代码行数:27,代码来源:
示例4: tileAt
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);
}
开发者ID:,项目名称:,代码行数:58,代码来源:
示例5: ASSERT
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());
}
开发者ID:Xertz,项目名称:EAWebKit,代码行数:56,代码来源:TiledLayerChromium.cpp
示例6: setLayerTreeHost
void TiledLayerChromium::setLayerTreeHost(CCLayerTreeHost* host)
{
if (host && host != layerTreeHost()) {
for (CCLayerTilingData::TileMap::const_iterator iter = m_tiler->tiles().begin(); iter != m_tiler->tiles().end(); ++iter) {
UpdatableTile* tile = static_cast<UpdatableTile*>(iter->second.get());
tile->managedTexture()->setTextureManager(host->contentsTextureManager());
}
}
LayerChromium::setLayerTreeHost(host);
}
开发者ID:,项目名称:,代码行数:10,代码来源:
示例7: idlePaintRect
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;
}
开发者ID:,项目名称:,代码行数:20,代码来源:
示例8: tileAt
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();
}
}
}
开发者ID:Xertz,项目名称:EAWebKit,代码行数:57,代码来源:TiledLayerChromium.cpp
示例9: createTextureUpdaterIfNeeded
void TiledLayerChromium::prepareToUpdateTiles(bool idle, int left, int top, int right, int bottom, const CCOcclusionTracker* occlusion)
{
createTextureUpdaterIfNeeded();
// Create tiles as needed, expanding a dirty rect to contain all
// the dirty regions currently being drawn. All dirty tiles that are to be painted
// get their m_updateRect set to m_dirtyRect and m_dirtyRect cleared. This way if
// invalidateRect is invoked during prepareToUpdate we don't lose the request.
IntRect dirtyLayerRect;
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);
// When not idle painting, if the visible region of the tile is occluded, don't reserve a texture or mark it for update.
// If any part of the tile is visible, then we need to paint it so the tile is pushed to the impl thread.
// This will also avoid painting the tile in the next loop, below.
if (!idle && occlusion) {
IntRect visibleTileRect = intersection(m_tiler->tileBounds(i, j), visibleLayerRect());
if (occlusion->occluded(this, visibleTileRect))
continue;
}
// FIXME: Decide if partial update should be allowed based on cost
// of update. https://bugs.webkit.org/show_bug.cgi?id=77376
if (tileOnlyNeedsPartialUpdate(tile) && layerTreeHost() && layerTreeHost()->requestPartialTextureUpdate())
tile->m_partialUpdate = true;
else if (tileNeedsBufferedUpdate(tile) && layerTreeHost())
layerTreeHost()->deleteTextureAfterCommit(tile->managedTexture()->steal());
if (!tile->managedTexture()->isValid(m_tiler->tileSize(), m_textureFormat)) {
// Sets the dirty rect to a full-sized tile with border texels.
tile->m_dirtyRect = m_tiler->tileRect(tile);
}
if (!tile->managedTexture()->reserve(m_tiler->tileSize(), m_textureFormat)) {
m_skipsIdlePaint = true;
if (!idle) {
// If the background covers the viewport, always draw this
// layer so that checkerboarded tiles will still draw.
if (!backgroundCoversViewport())
m_skipsDraw = true;
m_tiler->reset();
m_paintRect = IntRect();
m_requestedUpdateTilesRect = IntRect();
}
return;
}
dirtyLayerRect.unite(tile->m_dirtyRect);
tile->copyAndClearDirty();
}
}
m_paintRect = dirtyLayerRect;
if (dirtyLayerRect.isEmpty())
return;
// 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
// the original tiles so we don't upload more tiles than necessary.
if (!m_paintRect.isEmpty())
m_requestedUpdateTilesRect = IntRect(left, top, right - left + 1, bottom - top + 1);
// Calling prepareToUpdate() calls into WebKit to paint, which may have the side
// effect of disabling compositing, which causes our reference to the texture updater to be deleted.
// However, we can't free the memory backing the GraphicsContext until the paint finishes,
// so we grab a local reference here to hold the updater alive until the paint completes.
RefPtr<LayerTextureUpdater> protector(textureUpdater());
IntRect paintedOpaqueRect;
textureUpdater()->prepareToUpdate(m_paintRect, m_tiler->tileSize(), m_tiler->hasBorderTexels(), contentsScale(), &paintedOpaqueRect);
for (int j = top; j <= bottom; ++j) {
for (int i = left; i <= right; ++i) {
UpdatableTile* tile = tileAt(i, j);
// Tiles are created before prepareToUpdate() is called.
if (!tile)
CRASH();
IntRect tileRect = m_tiler->tileBounds(i, j);
// Use m_updateRect as copyAndClearDirty above moved the existing dirty rect to m_updateRect if the tile isn't culled.
const IntRect& dirtyRect = tile->m_updateRect;
if (dirtyRect.isEmpty())
continue;
// Save what was painted opaque in the tile. Keep the old area if the paint didn't touch it, and didn't paint some
// other part of the tile opaque.
IntRect tilePaintedRect = intersection(tileRect, m_paintRect);
IntRect tilePaintedOpaqueRect = intersection(tileRect, paintedOpaqueRect);
if (!tilePaintedRect.isEmpty()) {
IntRect paintInsideTileOpaqueRect = intersection(tile->opaqueRect(), tilePaintedRect);
bool paintInsideTileOpaqueRectIsNonOpaque = !tilePaintedOpaqueRect.contains(paintInsideTileOpaqueRect);
bool opaquePaintNotInsideTileOpaqueRect = !tilePaintedOpaqueRect.isEmpty() && !tile->opaqueRect().contains(tilePaintedOpaqueRect);
if (paintInsideTileOpaqueRectIsNonOpaque || opaquePaintNotInsideTileOpaqueRect)
tile->setOpaqueRect(tilePaintedOpaqueRect);
}
//.........这里部分代码省略.........
开发者ID:,项目名称:,代码行数:101,代码来源:
示例10: IntRect
void TiledLayerChromium::prepareToUpdateTiles(bool idle, int left, int top, int right, int bottom)
{
// Reset m_updateRect for all tiles.
for (CCLayerTilingData::TileMap::const_iterator iter = m_tiler->tiles().begin(); iter != m_tiler->tiles().end(); ++iter) {
UpdatableTile* tile = static_cast<UpdatableTile*>(iter->second.get());
tile->m_updateRect = IntRect();
}
// Create tiles as needed, expanding a dirty rect to contain all
// the dirty regions currently being drawn. All dirty tiles that are to be painted
// get their m_updateRect set to m_dirtyRect and m_dirtyRect cleared. This way if
// invalidateRect is invoked during prepareToUpdate we don't lose the request.
IntRect dirtyLayerRect;
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);
// Do post commit deletion of current texture when partial texture
// updates are not used.
if (tile->isDirty() && layerTreeHost() && !layerTreeHost()->settings().partialTextureUpdates)
layerTreeHost()->deleteTextureAfterCommit(tile->managedTexture()->steal());
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)) {
m_skipsIdlePaint = true;
if (!idle) {
m_skipsDraw = true;
cleanupResources();
}
return;
}
dirtyLayerRect.unite(tile->m_dirtyRect);
tile->copyAndClearDirty();
}
}
m_paintRect = dirtyLayerRect;
if (dirtyLayerRect.isEmpty())
return;
// 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
// the original tiles so we don't upload more tiles than necessary.
if (!m_paintRect.isEmpty())
m_requestedUpdateTilesRect = IntRect(left, top, right - left + 1, bottom - top + 1);
// Calling prepareToUpdate() calls into WebKit to paint, which may have the side
// effect of disabling compositing, which causes our reference to the texture updater to be deleted.
// However, we can't free the memory backing the GraphicsContext until the paint finishes,
// so we grab a local reference here to hold the updater alive until the paint completes.
RefPtr<LayerTextureUpdater> protector(textureUpdater());
IntRect opaqueRect; // FIXME: unused. remove this and store in the layer to pass to impl for draw culling
textureUpdater()->prepareToUpdate(m_paintRect, m_tiler->tileSize(), m_tiler->hasBorderTexels(), contentsScale(), &opaqueRect);
for (int j = top; j <= bottom; ++j) {
for (int i = left; i <= right; ++i) {
UpdatableTile* tile = tileAt(i, j);
// Tiles are created before prepareToUpdate() is called.
if (!tile)
CRASH();
// Use m_updateRect as copyAndClearDirty above moved the existing dirty rect to m_updateRect.
const IntRect& dirtyRect = tile->m_updateRect;
if (dirtyRect.isEmpty())
continue;
IntRect sourceRect = m_tiler->tileRect(tile);
sourceRect.intersect(dirtyRect);
// 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);
tile->m_updateRect = sourceRect;
if (sourceRect.isEmpty())
continue;
tile->texture()->prepareRect(sourceRect);
}
}
}
开发者ID:,项目名称:,代码行数:85,代码来源:
注:本文中的UpdatableTile类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论