本文整理汇总了C++中UpdatableTile::copyAndClearDirty方法的典型用法代码示例。如果您正苦于以下问题:C++ UpdatableTile::copyAndClearDirty方法的具体用法?C++ UpdatableTile::copyAndClearDirty怎么用?C++ UpdatableTile::copyAndClearDirty使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UpdatableTile
的用法示例。
在下文中一共展示了UpdatableTile::copyAndClearDirty方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: prepareToUpdateTiles
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);
}
//.........这里部分代码省略.........