Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(217)

Unified Diff: chrome/browser/android/vr_shell/vr_shell_renderer.cc

Issue 2624243002: VrShell: Allow native control of UI element opacity. (Closed)
Patch Set: for (auto nit : nits) nit.fix(); Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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 9e5159c14eb51656cafd6412dd20da4b00f91ab7..10c1498bcea5f941664bb4001212e10532c2ee76 100644
--- a/chrome/browser/android/vr_shell/vr_shell_renderer.cc
+++ b/chrome/browser/android/vr_shell/vr_shell_renderer.cc
@@ -90,11 +90,15 @@ const char* GetShaderSource(vr_shell::ShaderID shader) {
uniform samplerExternalOES u_Texture;
uniform vec4 u_CopyRect; // rectangle
varying vec2 v_TexCoordinate;
+ uniform lowp vec4 color;
+ uniform mediump float opacity;
+
void main() {
vec2 scaledTex =
vec2(u_CopyRect[0] + v_TexCoordinate.x * u_CopyRect[2],
u_CopyRect[1] + v_TexCoordinate.y * u_CopyRect[3]);
- gl_FragColor = texture2D(u_Texture, scaledTex);
+ lowp vec4 color = texture2D(u_Texture, scaledTex);
+ gl_FragColor = vec4(color.xyz, color.w * opacity);
});
case vr_shell::ShaderID::WEBVR_VERTEX_SHADER:
return SHADER(
@@ -230,11 +234,13 @@ TexturedQuadRenderer::TexturedQuadRenderer()
tex_uniform_handle_ = glGetUniformLocation(program_handle_, "u_Texture");
copy_rect_uniform_handle_ =
glGetUniformLocation(program_handle_, "u_CopyRect");
+ opacity_handle_ = glGetUniformLocation(program_handle_, "opacity");
}
void TexturedQuadRenderer::Draw(int texture_data_handle,
const gvr::Mat4f& combined_matrix,
- const Rectf& copy_rect) {
+ const Rectf& copy_rect,
+ float opacity) {
PrepareToDraw(combined_matrix_handle_, combined_matrix);
// Link texture data with texture unit.
@@ -247,6 +253,7 @@ void TexturedQuadRenderer::Draw(int texture_data_handle,
glUniform1i(tex_uniform_handle_, 0);
glUniform4fv(copy_rect_uniform_handle_, 1, (float*)(&copy_rect));
+ glUniform1f(opacity_handle_, opacity);
glDrawArrays(GL_TRIANGLES, 0, kVerticesNumber);
« no previous file with comments | « chrome/browser/android/vr_shell/vr_shell_renderer.h ('k') | chrome/browser/resources/vr_shell/vr_shell_ui.css » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698