コード例 #1
0
ファイル: TextureMapper.cpp プロジェクト: ZeusbaseWeb/webkit
PassRefPtr<BitmapTexture> BitmapTexturePool::acquireTexture(const IntSize& size, TextureMapper* textureMapper)
{
    BitmapTexturePoolEntry* selectedEntry = 0;
    for (size_t i = 0; i < m_textures.size(); ++i) {
        BitmapTexturePoolEntry* entry = &m_textures[i];

        // If the surface has only one reference (the one in m_textures), we can safely reuse it.
        if (entry->m_texture->refCount() > 1)
            continue;

        if (entry->m_texture->canReuseWith(size)) {
            selectedEntry = entry;
            break;
        }
    }

    if (!selectedEntry) {
        m_textures.append(BitmapTexturePoolEntry(textureMapper->createTexture()));
        selectedEntry = &m_textures.last();
    }

    scheduleReleaseUnusedTextures();
    selectedEntry->markUsed();
    return selectedEntry->m_texture;
}
コード例 #2
0
PassRefPtr<BitmapTexture> BitmapTexturePool::acquireTexture(const IntSize& size)
{
    BitmapTexturePoolEntry* selectedEntry = 0;
    for (auto& entry : m_textures) {
        // If the surface has only one reference (the one in m_textures), we can safely reuse it.
        if (entry.m_texture->refCount() > 1)
            continue;

        if (entry.m_texture->size() == size) {
            selectedEntry = &entry;
            break;
        }
    }

    if (!selectedEntry) {
        m_textures.append(BitmapTexturePoolEntry(createTexture()));
        selectedEntry = &m_textures.last();
    }

    scheduleReleaseUnusedTextures();
    selectedEntry->markUsed();
    return selectedEntry->m_texture;
}