diff options
7 files changed, 137 insertions, 0 deletions
diff --git a/content/common/gpu/client/webgraphicscontext3d_command_buffer_impl.cc b/content/common/gpu/client/webgraphicscontext3d_command_buffer_impl.cc index a1718e2..6352a7a 100644 --- a/content/common/gpu/client/webgraphicscontext3d_command_buffer_impl.cc +++ b/content/common/gpu/client/webgraphicscontext3d_command_buffer_impl.cc @@ -1522,6 +1522,9 @@ DELEGATE_TO_GL_3(getQueryObjectuivEXT, GetQueryObjectuivEXT, DELEGATE_TO_GL_5(copyTextureCHROMIUM, CopyTextureCHROMIUM, WGC3Denum, WebGLId, WebGLId, WGC3Dint, WGC3Denum); +DELEGATE_TO_GL_3(bindUniformLocationCHROMIUM, BindUniformLocationCHROMIUM, + WebGLId, WGC3Dint, const WGC3Dchar*) + GrGLInterface* WebGraphicsContext3DCommandBufferImpl::onCreateGrGLInterface() { return webkit_glue::CreateCommandBufferSkiaGLBinding(); } diff --git a/content/common/gpu/client/webgraphicscontext3d_command_buffer_impl.h b/content/common/gpu/client/webgraphicscontext3d_command_buffer_impl.h index 6f4450b..f4d7285 100644 --- a/content/common/gpu/client/webgraphicscontext3d_command_buffer_impl.h +++ b/content/common/gpu/client/webgraphicscontext3d_command_buffer_impl.h @@ -570,6 +570,9 @@ class WebGraphicsContext3DCommandBufferImpl WebGLId dest_id, WGC3Dint level, WGC3Denum internal_format); + virtual void bindUniformLocationCHROMIUM(WebGLId program, WGC3Dint location, + const WGC3Dchar* uniform); + protected: virtual GrGLInterface* onCreateGrGLInterface(); diff --git a/gpu/command_buffer/tests/gl_bind_uniform_location_unittest.cc b/gpu/command_buffer/tests/gl_bind_uniform_location_unittest.cc index f942c15..23f09d1 100644 --- a/gpu/command_buffer/tests/gl_bind_uniform_location_unittest.cc +++ b/gpu/command_buffer/tests/gl_bind_uniform_location_unittest.cc @@ -84,6 +84,7 @@ TEST_F(BindUniformLocationTest, Basic) { 0.0f, 0.50f, 0.0f, 0.0f, 0.0f, 0.0f, 0.75f, 0.0f, }; + glUniform4f(color_a_location, 0.25f, 0.0f, 0.0f, 0.0f); glUniform4fv(color_b_location, 2, color_b); glUniform4f(color_c_location, 0.0f, 0.0f, 0.0f, 1.0f); @@ -97,6 +98,123 @@ TEST_F(BindUniformLocationTest, Basic) { GLTestHelper::CheckGLError("no errors", __LINE__); } +TEST_F(BindUniformLocationTest, Compositor) { + ASSERT_TRUE( + GLTestHelper::HasExtension("GL_CHROMIUM_bind_uniform_location")); + + static const char* v_shader_str = SHADER( + attribute vec4 a_position; + attribute vec2 a_texCoord; + uniform mat4 matrix; + uniform vec2 color_a[4]; + uniform vec4 color_b; + varying vec4 v_color; + void main() + { + v_color.xy = color_a[0] + color_a[1]; + v_color.zw = color_a[2] + color_a[3]; + v_color += color_b; + gl_Position = matrix * a_position; + } + ); + + static const char* f_shader_str = SHADER( + precision mediump float; + varying vec4 v_color; + uniform float alpha; + uniform vec4 multiplier; + uniform vec3 color_c[8]; + void main() + { + vec4 color_c_sum = vec4(0.0); + color_c_sum.xyz += color_c[0]; + color_c_sum.xyz += color_c[1]; + color_c_sum.xyz += color_c[2]; + color_c_sum.xyz += color_c[3]; + color_c_sum.xyz += color_c[4]; + color_c_sum.xyz += color_c[5]; + color_c_sum.xyz += color_c[6]; + color_c_sum.xyz += color_c[7]; + color_c_sum.w = alpha; + color_c_sum *= multiplier; + gl_FragColor = v_color + color_c_sum; + } + ); + + int counter = 0; + int matrix_location = counter++; + int color_a_location = counter++; + int color_b_location = counter++; + int alpha_location = counter++; + int multiplier_location = counter++; + int color_c_location = counter++; + + GLuint vertex_shader = GLTestHelper::LoadShader( + GL_VERTEX_SHADER, v_shader_str); + GLuint fragment_shader = GLTestHelper::LoadShader( + GL_FRAGMENT_SHADER, f_shader_str); + + GLuint program = glCreateProgram(); + + glBindUniformLocationCHROMIUM(program, matrix_location, "matrix"); + glBindUniformLocationCHROMIUM(program, color_a_location, "color_a"); + glBindUniformLocationCHROMIUM(program, color_b_location, "color_b"); + glBindUniformLocationCHROMIUM(program, alpha_location, "alpha"); + glBindUniformLocationCHROMIUM(program, multiplier_location, "multiplier"); + glBindUniformLocationCHROMIUM(program, color_c_location, "color_c"); + + glAttachShader(program, vertex_shader); + glAttachShader(program, fragment_shader); + // Link the program + glLinkProgram(program); + // Check the link status + GLint linked = 0; + glGetProgramiv(program, GL_LINK_STATUS, &linked); + EXPECT_EQ(1, linked); + + GLint position_loc = glGetAttribLocation(program, "a_position"); + + GLTestHelper::SetupUnitQuad(position_loc); + + glUseProgram(program); + + static const float color_a[] = { + 0.1f, 0.1f, 0.1f, 0.1f, + 0.1f, 0.1f, 0.1f, 0.1f, + }; + + static const float color_c[] = { + 0.1f, 0.1f, 0.1f, + 0.1f, 0.1f, 0.1f, + 0.1f, 0.1f, 0.1f, + 0.1f, 0.1f, 0.1f, + 0.1f, 0.1f, 0.1f, + 0.1f, 0.1f, 0.1f, + 0.1f, 0.1f, 0.1f, + 0.1f, 0.1f, 0.1f, + }; + + static const float identity[] = { + 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, + }; + + glUniformMatrix4fv(matrix_location, 1, false, identity); + glUniform2fv(color_a_location, 4, color_a); + glUniform4f(color_b_location, 0.2f, 0.2f, 0.2f, 0.2f); + glUniform1f(alpha_location, 0.8f); + glUniform4f(multiplier_location, 0.5f, 0.5f, 0.5f, 0.5f); + glUniform3fv(color_c_location, 8, color_c); + + glDrawArrays(GL_TRIANGLES, 0, 6); + + static const uint8 expected[] = { 204, 204, 204, 204 }; + EXPECT_TRUE( + GLTestHelper::CheckPixels(0, 0, kResolution, kResolution, 1, expected)); + + GLTestHelper::CheckGLError("no errors", __LINE__); + +} + } // namespace gpu diff --git a/webkit/gpu/webgraphicscontext3d_in_process_command_buffer_impl.cc b/webkit/gpu/webgraphicscontext3d_in_process_command_buffer_impl.cc index 91a37a5..b7e93df 100644 --- a/webkit/gpu/webgraphicscontext3d_in_process_command_buffer_impl.cc +++ b/webkit/gpu/webgraphicscontext3d_in_process_command_buffer_impl.cc @@ -1637,5 +1637,8 @@ void WebGraphicsContext3DInProcessCommandBufferImpl::OnContextLost() { } } +DELEGATE_TO_GL_3(bindUniformLocationCHROMIUM, BindUniformLocationCHROMIUM, + WebGLId, WGC3Dint, const WGC3Dchar*) + } // namespace gpu } // namespace webkit diff --git a/webkit/gpu/webgraphicscontext3d_in_process_command_buffer_impl.h b/webkit/gpu/webgraphicscontext3d_in_process_command_buffer_impl.h index 0fc140a..f436c9a6 100644 --- a/webkit/gpu/webgraphicscontext3d_in_process_command_buffer_impl.h +++ b/webkit/gpu/webgraphicscontext3d_in_process_command_buffer_impl.h @@ -479,6 +479,9 @@ class WebGraphicsContext3DInProcessCommandBufferImpl WGC3Duint dest_id, WGC3Dint level, WGC3Denum internal_format); + virtual void bindUniformLocationCHROMIUM(WebGLId program, WGC3Dint location, + const WGC3Dchar* uniform); + protected: virtual GrGLInterface* onCreateGrGLInterface(); diff --git a/webkit/gpu/webgraphicscontext3d_in_process_impl.cc b/webkit/gpu/webgraphicscontext3d_in_process_impl.cc index 6539487..14701c3 100644 --- a/webkit/gpu/webgraphicscontext3d_in_process_impl.cc +++ b/webkit/gpu/webgraphicscontext3d_in_process_impl.cc @@ -747,6 +747,11 @@ void WebGraphicsContext3DInProcessImpl::copyTextureToParentTextureCHROMIUM( NOTIMPLEMENTED(); } +void WebGraphicsContext3DInProcessImpl::bindUniformLocationCHROMIUM( + WebGLId program, WGC3Dint location, const WGC3Dchar* uniform) { + NOTIMPLEMENTED(); +} + WebString WebGraphicsContext3DInProcessImpl:: getRequestableExtensionsCHROMIUM() { return WebString(); diff --git a/webkit/gpu/webgraphicscontext3d_in_process_impl.h b/webkit/gpu/webgraphicscontext3d_in_process_impl.h index 3579d90..1be900e 100644 --- a/webkit/gpu/webgraphicscontext3d_in_process_impl.h +++ b/webkit/gpu/webgraphicscontext3d_in_process_impl.h @@ -475,6 +475,8 @@ class WebGraphicsContext3DInProcessImpl : public WebGraphicsContext3D { virtual void copyTextureCHROMIUM(WGC3Denum target, WGC3Duint source_id, WGC3Duint dest_id, WGC3Dint level, WGC3Denum internal_format); + virtual void bindUniformLocationCHROMIUM(WebGLId program, WGC3Dint location, + const WGC3Dchar* uniform); protected: virtual GrGLInterface* onCreateGrGLInterface(); |