Changeset 147742 in webkit
- Timestamp:
- Apr 5, 2013 6:26:01 AM (11 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r147739 r147742 1 2013-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 1 20 2013-04-05 Aivo Paas <aivopaas@gmail.com> 2 21 -
trunk/Source/WebCore/platform/graphics/texmap/TextureMapperGL.cpp
r147643 r147742 89 89 PassRefPtr<TextureMapperShaderProgram> getShaderProgram(TextureMapperShaderProgram::Options options) 90 90 { 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; 98 96 } 99 97 … … 159 157 Platform3DObject TextureMapperGLData::getStaticVBO(GC3Denum target, GC3Dsizeiptr size, const void* data) 160 158 { 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; 170 168 } 171 169 … … 905 903 renderer = CustomFilterRenderer::create(m_context3D, program->programType(), customFilter->parameters(), 906 904 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); 915 909 break; 916 910 } … … 922 916 customFilter->meshRows(), customFilter->meshColumns(), customFilter->meshType()); 923 917 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); 931 922 break; 932 923 }
Note: See TracChangeset
for help on using the changeset viewer.