Changeset 147742 in webkit


Ignore:
Timestamp:
Apr 5, 2013 6:26:01 AM (11 years ago)
Author:
Christophe Dumez
Message:

Avoid double hash table lookups in TextureMapperGL
https://bugs.webkit.org/show_bug.cgi?id=114030

Reviewed by Noam Rosenthal.

Use Vector::add() and leverage its returned AddResult value instead of
calling Vector::find() then Vector::set() if the key does not already
exist in the map. This results in a single hash lookup instead of two
in this case.

No new tests, no behavior change.

  • platform/graphics/texmap/TextureMapperGL.cpp:

(WebCore::TextureMapperGLData::SharedGLData::getShaderProgram):
(WebCore::TextureMapperGLData::getStaticVBO):
(WebCore::TextureMapperGL::drawUsingCustomFilter):

Location:
trunk/Source/WebCore
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r147739 r147742  
     12013-04-05  Christophe Dumez  <ch.dumez@sisa.samsung.com>
     2
     3        Avoid double hash table lookups in TextureMapperGL
     4        https://bugs.webkit.org/show_bug.cgi?id=114030
     5
     6        Reviewed by Noam Rosenthal.
     7
     8        Use Vector::add() and leverage its returned AddResult value instead of
     9        calling Vector::find() then Vector::set() if the key does not already
     10        exist in the map. This results in a single hash lookup instead of two
     11        in this case.
     12
     13        No new tests, no behavior change.
     14
     15        * platform/graphics/texmap/TextureMapperGL.cpp:
     16        (WebCore::TextureMapperGLData::SharedGLData::getShaderProgram):
     17        (WebCore::TextureMapperGLData::getStaticVBO):
     18        (WebCore::TextureMapperGL::drawUsingCustomFilter):
     19
    1202013-04-05  Aivo Paas  <aivopaas@gmail.com>
    221
  • trunk/Source/WebCore/platform/graphics/texmap/TextureMapperGL.cpp

    r147643 r147742  
    8989        PassRefPtr<TextureMapperShaderProgram> getShaderProgram(TextureMapperShaderProgram::Options options)
    9090        {
    91             HashMap<TextureMapperShaderProgram::Options, RefPtr<TextureMapperShaderProgram> >::iterator it = m_programs.find(options);
    92             if (it != m_programs.end())
    93                 return it->value;
    94 
    95             RefPtr<TextureMapperShaderProgram> program = TextureMapperShaderProgram::create(m_context, options);
    96             m_programs.add(options, program);
    97             return program;
     91            HashMap<TextureMapperShaderProgram::Options, RefPtr<TextureMapperShaderProgram> >::AddResult result = m_programs.add(options, 0);
     92            if (result.isNewEntry)
     93                result.iterator->value = TextureMapperShaderProgram::create(m_context, options);
     94
     95            return result.iterator->value;
    9896        }
    9997
     
    159157Platform3DObject TextureMapperGLData::getStaticVBO(GC3Denum target, GC3Dsizeiptr size, const void* data)
    160158{
    161     HashMap<const void*, Platform3DObject>::iterator it = vbos.find(data);
    162     if (it != vbos.end())
    163         return it->value;
    164 
    165     Platform3DObject vbo = context->createBuffer();
    166     context->bindBuffer(target, vbo);
    167     context->bufferData(target, size, data, GraphicsContext3D::STATIC_DRAW);
    168     vbos.add(data, vbo);
    169     return vbo;
     159    HashMap<const void*, Platform3DObject>::AddResult result = vbos.add(data, 0);
     160    if (result.isNewEntry) {
     161        Platform3DObject vbo = context->createBuffer();
     162        context->bindBuffer(target, vbo);
     163        context->bufferData(target, size, data, GraphicsContext3D::STATIC_DRAW);
     164        result.iterator->value = vbo;
     165    }
     166
     167    return result.iterator->value;
    170168}
    171169
     
    905903        renderer = CustomFilterRenderer::create(m_context3D, program->programType(), customFilter->parameters(),
    906904            customFilter->meshRows(), customFilter->meshColumns(), customFilter->meshType());
    907         RefPtr<CustomFilterCompiledProgram> compiledProgram;
    908         CustomFilterProgramMap::iterator iter = m_customFilterPrograms.find(program->programInfo());
    909         if (iter == m_customFilterPrograms.end()) {
    910             compiledProgram = CustomFilterCompiledProgram::create(m_context3D, program->vertexShaderString(), program->fragmentShaderString(), program->programType());
    911             m_customFilterPrograms.set(program->programInfo(), compiledProgram);
    912         } else
    913             compiledProgram = iter->value;
    914         renderer->setCompiledProgram(compiledProgram.release());
     905        CustomFilterProgramMap::AddResult result = m_customFilterPrograms.add(program->programInfo(), 0);
     906        if (result.isNewEntry)
     907            result.iterator->value = CustomFilterCompiledProgram::create(m_context3D, program->vertexShaderString(), program->fragmentShaderString(), program->programType());
     908        renderer->setCompiledProgram(result.iterator->value);
    915909        break;
    916910    }
     
    922916            customFilter->meshRows(), customFilter->meshColumns(), customFilter->meshType());
    923917        RefPtr<CustomFilterCompiledProgram> compiledProgram;
    924         CustomFilterProgramMap::iterator iter = m_customFilterPrograms.find(program->programInfo());
    925         if (iter == m_customFilterPrograms.end()) {
    926             compiledProgram = CustomFilterCompiledProgram::create(m_context3D, program->validatedVertexShader(), program->validatedFragmentShader(), program->programInfo().programType());
    927             m_customFilterPrograms.set(program->programInfo(), compiledProgram);
    928         } else
    929             compiledProgram = iter->value;
    930         renderer->setCompiledProgram(compiledProgram.release());
     918        CustomFilterProgramMap::AddResult result = m_customFilterPrograms.add(program->programInfo(), 0);
     919        if (result.isNewEntry)
     920            result.iterator->value = CustomFilterCompiledProgram::create(m_context3D, program->validatedVertexShader(), program->validatedFragmentShader(), program->programInfo().programType());
     921        renderer->setCompiledProgram(result.iterator->value);
    931922        break;
    932923    }
Note: See TracChangeset for help on using the changeset viewer.