Chromium Code Reviews| Index: chrome/browser/android/vr_shell/vr_shell_renderer.cc |
| diff --git a/chrome/browser/android/vr_shell/vr_shell_renderer.cc b/chrome/browser/android/vr_shell/vr_shell_renderer.cc |
| index 098e8608e5fd3364988a4c8137f444cf82f700dc..3632b710ed0f742faa1536d63b6d03f53fdb8191 100644 |
| --- a/chrome/browser/android/vr_shell/vr_shell_renderer.cc |
| +++ b/chrome/browser/android/vr_shell/vr_shell_renderer.cc |
| @@ -138,7 +138,8 @@ const char* GetShaderSource(vr_shell::ShaderID shader) { |
| vec2(u_CopyRect[0] + v_TexCoordinate.x * u_CopyRect[2], |
| u_CopyRect[1] + v_TexCoordinate.y * u_CopyRect[3]); |
| lowp vec4 color = texture2D(u_Texture, scaledTex); |
| - gl_FragColor = vec4(color.xyz, color.w * opacity); |
| + // premultiply opacity |
|
tiborg
2017/05/25 00:47:18
Nit: capital P and period in the end.
|
| + gl_FragColor = color * opacity; |
| } |
| /* clang-format on */); |
| case vr_shell::ShaderID::WEBVR_VERTEX_SHADER: |
| @@ -251,7 +252,8 @@ const char* GetShaderSource(vr_shell::ShaderID shader) { |
| void main() { |
| lowp vec4 texture_color = texture2D(u_texture, v_TexCoordinate); |
| - gl_FragColor = vec4(texture_color.xyz, texture_color.w * u_Opacity); |
| + // premultiply alpha |
|
tiborg
2017/05/25 00:47:18
Here too.
|
| + gl_FragColor = texture_color * u_Opacity; |
| } |
| /* clang-format on */); |
| default: |
| @@ -415,7 +417,8 @@ void TexturedQuadRenderer::Flush() { |
| glEnableVertexAttribArray(tex_coord_handle_); |
| glEnable(GL_BLEND); |
| - glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); |
| + // Our textures have premultiplied alpha |
|
tiborg
2017/05/25 00:47:18
Nit: period in the end.
|
| + glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA); |
| // Link texture data with texture unit. |
| glActiveTexture(GL_TEXTURE0); |
| @@ -667,7 +670,8 @@ void ControllerRenderer::Draw(VrControllerModel::State state, |
| glEnableVertexAttribArray(tex_coord_handle_); |
| glEnable(GL_BLEND); |
| - glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); |
| + // Our textures have premultiplied alpha. |
| + glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA); |
| glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, indices_buffer_); |