Commit 9c1a68ab authored by ch.dumez@sisa.samsung.com's avatar ch.dumez@sisa.samsung.com
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):


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@147742 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent daa44c12
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 @@ public:
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 @@ public:
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:
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment