Skip to content
Permalink
Browse files
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):


Canonical link: https://commits.webkit.org/132385@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@147742 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
cdumez committed Apr 5, 2013
1 parent bb26e25 commit b172de573970dbbc3646cbcd2fc9290b56923108
Showing 2 changed files with 40 additions and 30 deletions.
@@ -1,3 +1,22 @@
2013-04-05 Christophe Dumez <ch.dumez@sisa.samsung.com>

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):

2013-04-05 Aivo Paas <aivopaas@gmail.com>

Updating mouse cursor on style changes without emitting fake mousemove event
@@ -88,13 +88,11 @@ struct TextureMapperGLData {

PassRefPtr<TextureMapperShaderProgram> getShaderProgram(TextureMapperShaderProgram::Options options)
{
HashMap<TextureMapperShaderProgram::Options, RefPtr<TextureMapperShaderProgram> >::iterator it = m_programs.find(options);
if (it != m_programs.end())
return it->value;
HashMap<TextureMapperShaderProgram::Options, RefPtr<TextureMapperShaderProgram> >::AddResult result = m_programs.add(options, 0);
if (result.isNewEntry)
result.iterator->value = TextureMapperShaderProgram::create(m_context, options);

RefPtr<TextureMapperShaderProgram> program = TextureMapperShaderProgram::create(m_context, options);
m_programs.add(options, program);
return program;
return result.iterator->value;
}

HashMap<TextureMapperShaderProgram::Options, RefPtr<TextureMapperShaderProgram> > m_programs;
@@ -158,15 +156,15 @@ struct TextureMapperGLData {

Platform3DObject TextureMapperGLData::getStaticVBO(GC3Denum target, GC3Dsizeiptr size, const void* data)
{
HashMap<const void*, Platform3DObject>::iterator it = vbos.find(data);
if (it != vbos.end())
return it->value;

Platform3DObject vbo = context->createBuffer();
context->bindBuffer(target, vbo);
context->bufferData(target, size, data, GraphicsContext3D::STATIC_DRAW);
vbos.add(data, vbo);
return vbo;
HashMap<const void*, Platform3DObject>::AddResult result = vbos.add(data, 0);
if (result.isNewEntry) {
Platform3DObject vbo = context->createBuffer();
context->bindBuffer(target, vbo);
context->bufferData(target, size, data, GraphicsContext3D::STATIC_DRAW);
result.iterator->value = vbo;
}

return result.iterator->value;
}

TextureMapperGLData::~TextureMapperGLData()
@@ -904,14 +902,10 @@ bool TextureMapperGL::drawUsingCustomFilter(BitmapTexture& target, const BitmapT
RefPtr<CustomFilterProgram> program = customFilter->program();
renderer = CustomFilterRenderer::create(m_context3D, program->programType(), customFilter->parameters(),
customFilter->meshRows(), customFilter->meshColumns(), customFilter->meshType());
RefPtr<CustomFilterCompiledProgram> compiledProgram;
CustomFilterProgramMap::iterator iter = m_customFilterPrograms.find(program->programInfo());
if (iter == m_customFilterPrograms.end()) {
compiledProgram = CustomFilterCompiledProgram::create(m_context3D, program->vertexShaderString(), program->fragmentShaderString(), program->programType());
m_customFilterPrograms.set(program->programInfo(), compiledProgram);
} else
compiledProgram = iter->value;
renderer->setCompiledProgram(compiledProgram.release());
CustomFilterProgramMap::AddResult result = m_customFilterPrograms.add(program->programInfo(), 0);
if (result.isNewEntry)
result.iterator->value = CustomFilterCompiledProgram::create(m_context3D, program->vertexShaderString(), program->fragmentShaderString(), program->programType());
renderer->setCompiledProgram(result.iterator->value);
break;
}
case FilterOperation::VALIDATED_CUSTOM: {
@@ -921,13 +915,10 @@ bool TextureMapperGL::drawUsingCustomFilter(BitmapTexture& target, const BitmapT
renderer = CustomFilterRenderer::create(m_context3D, program->programInfo().programType(), customFilter->parameters(),
customFilter->meshRows(), customFilter->meshColumns(), customFilter->meshType());
RefPtr<CustomFilterCompiledProgram> compiledProgram;
CustomFilterProgramMap::iterator iter = m_customFilterPrograms.find(program->programInfo());
if (iter == m_customFilterPrograms.end()) {
compiledProgram = CustomFilterCompiledProgram::create(m_context3D, program->validatedVertexShader(), program->validatedFragmentShader(), program->programInfo().programType());
m_customFilterPrograms.set(program->programInfo(), compiledProgram);
} else
compiledProgram = iter->value;
renderer->setCompiledProgram(compiledProgram.release());
CustomFilterProgramMap::AddResult result = m_customFilterPrograms.add(program->programInfo(), 0);
if (result.isNewEntry)
result.iterator->value = CustomFilterCompiledProgram::create(m_context3D, program->validatedVertexShader(), program->validatedFragmentShader(), program->programInfo().programType());
renderer->setCompiledProgram(result.iterator->value);
break;
}
default:

0 comments on commit b172de5

Please sign in to comment.