diff options
author | Teng-Hui Zhu <ztenghui@google.com> | 2012-01-23 13:54:27 -0800 |
---|---|---|
committer | Teng-Hui Zhu <ztenghui@google.com> | 2012-01-23 14:00:27 -0800 |
commit | a88a02318873ea1ed00398091f92d6ebe1dc1139 (patch) | |
tree | e304b77b09c721e5658530f43ece369b81838335 | |
parent | 2641f0118c78c83b37b7dd9ee6f6cb793cdb8cfb (diff) | |
download | external_webkit-a88a02318873ea1ed00398091f92d6ebe1dc1139.zip external_webkit-a88a02318873ea1ed00398091f92d6ebe1dc1139.tar.gz external_webkit-a88a02318873ea1ed00398091f92d6ebe1dc1139.tar.bz2 |
Delay the shader init till the draw time.
GLWebViewState::setupDrawing is checking whether or not the shader has been
initialized and initialize it if necessary now, with that, we don't need to
initialized the GL resource in the constuctor of ShaderProgram any more.
TODO: create/destroy all GL resources as request.
bug:5093097
Change-Id: I8b280a9060a8f8fc2f03b8427feb597928ea6d9f
-rw-r--r-- | Source/WebCore/platform/graphics/android/ShaderProgram.cpp | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/Source/WebCore/platform/graphics/android/ShaderProgram.cpp b/Source/WebCore/platform/graphics/android/ShaderProgram.cpp index a706276..a4af713 100644 --- a/Source/WebCore/platform/graphics/android/ShaderProgram.cpp +++ b/Source/WebCore/platform/graphics/android/ShaderProgram.cpp @@ -219,11 +219,15 @@ ShaderProgram::ShaderProgram() , m_currentScale(1.0f) , m_needsInit(true) { - init(); } void ShaderProgram::init() { + // To detect whether or not resources for ShaderProgram allocated + // successfully, we clean up pre-existing errors here and will check for + // new errors at the end of this function. + GLUtils::checkGlError("before init"); + GLint tex2DProgram = createProgram(gVertexShader, gFragmentShader); GLint pureColorProgram = createProgram(gPureColorVertexShader, gPureColorFragmentShader); GLint tex2DInvProgram = createProgram(gVertexShader, gFragmentShaderInverted); @@ -242,7 +246,6 @@ void ShaderProgram::init() m_needsInit = true; return; } - m_needsInit = false; GLint pureColorPosition = glGetAttribLocation(pureColorProgram, "vPosition"); GLint pureColorProjMtx = glGetUniformLocation(pureColorProgram, "projectionMatrix"); @@ -309,7 +312,12 @@ void ShaderProgram::init() matrix.translate3d(-0.5, -0.5, 0); GLUtils::toGLMatrix(m_transferProjMtx, matrix); - GLUtils::checkGlError("init"); + if (GLUtils::checkGlError("init")) + m_needsInit = true; + else + m_needsInit = false; + + return; } void ShaderProgram::resetBlending() |