NicosiaBackingStoreTextureMapperImpl.cpp [plain text]
#include "config.h"
#include "NicosiaBackingStoreTextureMapperImpl.h"
#if USE(TEXTURE_MAPPER)
namespace Nicosia {
auto BackingStoreTextureMapperImpl::createFactory() -> Factory
{
return Factory(
[](BackingStore&) {
return std::make_unique<BackingStoreTextureMapperImpl>();
});
}
BackingStoreTextureMapperImpl::BackingStoreTextureMapperImpl() = default;
BackingStoreTextureMapperImpl::~BackingStoreTextureMapperImpl() = default;
void BackingStoreTextureMapperImpl::tiledBackingStoreHasPendingTileCreation()
{
m_layerState.hasPendingTileCreation = true;
}
void BackingStoreTextureMapperImpl::createTile(uint32_t tileID, float scale)
{
ASSERT(m_layerState.isFlushing);
auto& update = m_layerState.update;
#if !ASSERT_DISABLED
auto matchesTile = [tileID](auto& tile) { return tile.tileID == tileID; };
#endif
ASSERT(std::none_of(update.tilesToCreate.begin(), update.tilesToCreate.end(), matchesTile));
ASSERT(std::none_of(update.tilesToUpdate.begin(), update.tilesToUpdate.end(), matchesTile));
ASSERT(std::none_of(update.tilesToRemove.begin(), update.tilesToRemove.end(), matchesTile));
update.tilesToCreate.append({ tileID, scale });
}
void BackingStoreTextureMapperImpl::updateTile(uint32_t tileID, const WebCore::SurfaceUpdateInfo& updateInfo, const WebCore::IntRect& tileRect)
{
ASSERT(m_layerState.isFlushing);
auto& update = m_layerState.update;
ASSERT(std::none_of(update.tilesToRemove.begin(), update.tilesToRemove.end(),
[tileID](auto& tile) { return tile.tileID == tileID; }));
update.tilesToUpdate.append({ tileID, tileRect, updateInfo });
}
void BackingStoreTextureMapperImpl::removeTile(uint32_t tileID)
{
ASSERT(m_layerState.isFlushing || m_layerState.isPurging);
auto& update = m_layerState.update;
auto matchesTile = [tileID](auto& tile) { return tile.tileID == tileID; };
update.tilesToCreate.removeAllMatching(matchesTile);
update.tilesToUpdate.removeAllMatching(matchesTile);
ASSERT(std::none_of(update.tilesToRemove.begin(), update.tilesToRemove.end(), matchesTile));
update.tilesToRemove.append(TileUpdate::RemovalData { tileID });
}
void BackingStoreTextureMapperImpl::flushUpdate()
{
ASSERT(!m_layerState.isFlushing);
m_layerState.hasPendingTileCreation = false;
{
LockHolder locker(m_update.lock);
m_update.pending.tilesToCreate.appendVector(m_layerState.update.tilesToCreate);
m_update.pending.tilesToUpdate.appendVector(m_layerState.update.tilesToUpdate);
m_update.pending.tilesToRemove.appendVector(m_layerState.update.tilesToRemove);
}
m_layerState.update = { };
}
auto BackingStoreTextureMapperImpl::takeUpdate() -> TileUpdate
{
LockHolder locker(m_update.lock);
return WTFMove(m_update.pending);
}
}
#endif // USE(TEXTURE_MAPPER)