diff options
author | scherkus@chromium.org <scherkus@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-03-03 21:39:42 +0000 |
---|---|---|
committer | scherkus@chromium.org <scherkus@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-03-03 21:39:42 +0000 |
commit | d2970673eb08326b1f8f639a2a7ab3e873e3b6c3 (patch) | |
tree | 2bf0e5f43589b2f841d0a081aa4e2b59a60e00fa /media | |
parent | cfbe8e44e66cdac1d9fd259b66bb0e70dcca84d9 (diff) | |
download | chromium_src-d2970673eb08326b1f8f639a2a7ab3e873e3b6c3.zip chromium_src-d2970673eb08326b1f8f639a2a7ab3e873e3b6c3.tar.gz chromium_src-d2970673eb08326b1f8f639a2a7ab3e873e3b6c3.tar.bz2 |
Fixing some subtle issues with player_x11 and GL/GLES video renderers.
BUG=n/a
TEST=n/a
Review URL: http://codereview.chromium.org/665008
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@40539 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'media')
-rw-r--r-- | media/tools/player_x11/gl_video_renderer.cc | 49 | ||||
-rw-r--r-- | media/tools/player_x11/gl_video_renderer.h | 5 | ||||
-rw-r--r-- | media/tools/player_x11/gles_video_renderer.cc | 49 | ||||
-rw-r--r-- | media/tools/player_x11/gles_video_renderer.h | 5 | ||||
-rw-r--r-- | media/tools/player_x11/player_x11.cc | 6 |
5 files changed, 56 insertions, 58 deletions
diff --git a/media/tools/player_x11/gl_video_renderer.cc b/media/tools/player_x11/gl_video_renderer.cc index f2f623d..ebcb9b5 100644 --- a/media/tools/player_x11/gl_video_renderer.cc +++ b/media/tools/player_x11/gl_video_renderer.cc @@ -183,65 +183,68 @@ bool GlVideoRenderer::OnInitialize(media::VideoDecoder* decoder) { glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); glEnable(GL_TEXTURE_2D); - GLuint program_ = glCreateProgram(); + GLuint program = glCreateProgram(); // Create our YUV->RGB shader. - GLuint vertex_shader_ = glCreateShader(GL_VERTEX_SHADER); + GLuint vertex_shader = glCreateShader(GL_VERTEX_SHADER); const char* vs_source = kVertexShader; int vs_size = sizeof(kVertexShader); - glShaderSource(vertex_shader_, 1, &vs_source, &vs_size); - glCompileShader(vertex_shader_); + glShaderSource(vertex_shader, 1, &vs_source, &vs_size); + glCompileShader(vertex_shader); int result = GL_FALSE; - glGetShaderiv(vertex_shader_, GL_COMPILE_STATUS, &result); + glGetShaderiv(vertex_shader, GL_COMPILE_STATUS, &result); if (!result) { char log[kErrorSize]; int len; - glGetShaderInfoLog(vertex_shader_, kErrorSize - 1, &len, log); + glGetShaderInfoLog(vertex_shader, kErrorSize - 1, &len, log); log[kErrorSize - 1] = 0; LOG(FATAL) << log; } - glAttachShader(program_, vertex_shader_); + glAttachShader(program, vertex_shader); + glDeleteShader(vertex_shader); - GLuint fragment_shader_ = glCreateShader(GL_FRAGMENT_SHADER); + GLuint fragment_shader = glCreateShader(GL_FRAGMENT_SHADER); const char* ps_source = kFragmentShader; int ps_size = sizeof(kFragmentShader); - glShaderSource(fragment_shader_, 1, &ps_source, &ps_size); - glCompileShader(fragment_shader_); + glShaderSource(fragment_shader, 1, &ps_source, &ps_size); + glCompileShader(fragment_shader); result = GL_FALSE; - glGetShaderiv(fragment_shader_, GL_COMPILE_STATUS, &result); + glGetShaderiv(fragment_shader, GL_COMPILE_STATUS, &result); if (!result) { char log[kErrorSize]; int len; - glGetShaderInfoLog(fragment_shader_, kErrorSize - 1, &len, log); + glGetShaderInfoLog(fragment_shader, kErrorSize - 1, &len, log); log[kErrorSize - 1] = 0; LOG(FATAL) << log; } - glAttachShader(program_, fragment_shader_); + glAttachShader(program, fragment_shader); + glDeleteShader(fragment_shader); - glLinkProgram(program_); + glLinkProgram(program); result = GL_FALSE; - glGetProgramiv(program_, GL_LINK_STATUS, &result); + glGetProgramiv(program, GL_LINK_STATUS, &result); if (!result) { char log[kErrorSize]; int len; - glGetProgramInfoLog(program_, kErrorSize - 1, &len, log); + glGetProgramInfoLog(program, kErrorSize - 1, &len, log); log[kErrorSize - 1] = 0; LOG(FATAL) << log; } - glUseProgram(program_); + glUseProgram(program); + glDeleteProgram(program); // Bind parameters. - glUniform1i(glGetUniformLocation(program_, "y_tex"), 0); - glUniform1i(glGetUniformLocation(program_, "u_tex"), 1); - glUniform1i(glGetUniformLocation(program_, "v_tex"), 2); - int yuv2rgb_location = glGetUniformLocation(program_, "yuv2rgb"); + glUniform1i(glGetUniformLocation(program, "y_tex"), 0); + glUniform1i(glGetUniformLocation(program, "u_tex"), 1); + glUniform1i(glGetUniformLocation(program, "v_tex"), 2); + int yuv2rgb_location = glGetUniformLocation(program, "yuv2rgb"); glUniformMatrix3fv(yuv2rgb_location, 1, GL_TRUE, kYUV2RGB); - int pos_location = glGetAttribLocation(program_, "in_pos"); + int pos_location = glGetAttribLocation(program, "in_pos"); glEnableVertexAttribArray(pos_location); glVertexAttribPointer(pos_location, 2, GL_FLOAT, GL_FALSE, 0, kVertices); - int tc_location = glGetAttribLocation(program_, "in_tc"); + int tc_location = glGetAttribLocation(program, "in_tc"); glEnableVertexAttribArray(tc_location); glVertexAttribPointer(tc_location, 2, GL_FLOAT, GL_FALSE, 0, kTextureCoords); diff --git a/media/tools/player_x11/gl_video_renderer.h b/media/tools/player_x11/gl_video_renderer.h index 21d6aaf..e4a75e0 100644 --- a/media/tools/player_x11/gl_video_renderer.h +++ b/media/tools/player_x11/gl_video_renderer.h @@ -59,11 +59,6 @@ class GlVideoRenderer : public media::VideoRendererBase { // 3 textures, one for each plane. GLuint textures_[3]; - // Shaders and program for YUV->RGB conversion. - GLuint vertex_shader_; - GLuint fragment_shader_; - GLuint program_; - static GlVideoRenderer* instance_; DISALLOW_COPY_AND_ASSIGN(GlVideoRenderer); diff --git a/media/tools/player_x11/gles_video_renderer.cc b/media/tools/player_x11/gles_video_renderer.cc index 084b119..ebdd5e0 100644 --- a/media/tools/player_x11/gles_video_renderer.cc +++ b/media/tools/player_x11/gles_video_renderer.cc @@ -309,65 +309,68 @@ bool GlesVideoRenderer::InitializeGles() { glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); glEnable(GL_TEXTURE_2D); - GLuint program_ = glCreateProgram(); + GLuint program = glCreateProgram(); // Create our YUV->RGB shader. - GLuint vertex_shader_ = glCreateShader(GL_VERTEX_SHADER); + GLuint vertex_shader = glCreateShader(GL_VERTEX_SHADER); const char* vs_source = kVertexShader; int vs_size = sizeof(kVertexShader); - glShaderSource(vertex_shader_, 1, &vs_source, &vs_size); - glCompileShader(vertex_shader_); + glShaderSource(vertex_shader, 1, &vs_source, &vs_size); + glCompileShader(vertex_shader); int result = GL_FALSE; - glGetShaderiv(vertex_shader_, GL_COMPILE_STATUS, &result); + glGetShaderiv(vertex_shader, GL_COMPILE_STATUS, &result); if (!result) { char log[kErrorSize]; int len; - glGetShaderInfoLog(vertex_shader_, kErrorSize - 1, &len, log); + glGetShaderInfoLog(vertex_shader, kErrorSize - 1, &len, log); log[kErrorSize - 1] = 0; LOG(FATAL) << log; } - glAttachShader(program_, vertex_shader_); + glAttachShader(program, vertex_shader); + glDeleteShader(vertex_shader); - GLuint fragment_shader_ = glCreateShader(GL_FRAGMENT_SHADER); + GLuint fragment_shader = glCreateShader(GL_FRAGMENT_SHADER); const char* ps_source = kFragmentShader; int ps_size = sizeof(kFragmentShader); - glShaderSource(fragment_shader_, 1, &ps_source, &ps_size); - glCompileShader(fragment_shader_); + glShaderSource(fragment_shader, 1, &ps_source, &ps_size); + glCompileShader(fragment_shader); result = GL_FALSE; - glGetShaderiv(fragment_shader_, GL_COMPILE_STATUS, &result); + glGetShaderiv(fragment_shader, GL_COMPILE_STATUS, &result); if (!result) { char log[kErrorSize]; int len; - glGetShaderInfoLog(fragment_shader_, kErrorSize - 1, &len, log); + glGetShaderInfoLog(fragment_shader, kErrorSize - 1, &len, log); log[kErrorSize - 1] = 0; LOG(FATAL) << log; } - glAttachShader(program_, fragment_shader_); + glAttachShader(program, fragment_shader); + glDeleteShader(fragment_shader); - glLinkProgram(program_); + glLinkProgram(program); result = GL_FALSE; - glGetProgramiv(program_, GL_LINK_STATUS, &result); + glGetProgramiv(program, GL_LINK_STATUS, &result); if (!result) { char log[kErrorSize]; int len; - glGetProgramInfoLog(program_, kErrorSize - 1, &len, log); + glGetProgramInfoLog(program, kErrorSize - 1, &len, log); log[kErrorSize - 1] = 0; LOG(FATAL) << log; } - glUseProgram(program_); + glUseProgram(program); + glDeleteProgram(program); // Bind parameters. - glUniform1i(glGetUniformLocation(program_, "y_tex"), 0); - glUniform1i(glGetUniformLocation(program_, "u_tex"), 1); - glUniform1i(glGetUniformLocation(program_, "v_tex"), 2); - int yuv2rgb_location = glGetUniformLocation(program_, "yuv2rgb"); + glUniform1i(glGetUniformLocation(program, "y_tex"), 0); + glUniform1i(glGetUniformLocation(program, "u_tex"), 1); + glUniform1i(glGetUniformLocation(program, "v_tex"), 2); + int yuv2rgb_location = glGetUniformLocation(program, "yuv2rgb"); glUniformMatrix3fv(yuv2rgb_location, 1, GL_FALSE, kYUV2RGB); - int pos_location = glGetAttribLocation(program_, "in_pos"); + int pos_location = glGetAttribLocation(program, "in_pos"); glEnableVertexAttribArray(pos_location); glVertexAttribPointer(pos_location, 2, GL_FLOAT, GL_FALSE, 0, kVertices); - int tc_location = glGetAttribLocation(program_, "in_tc"); + int tc_location = glGetAttribLocation(program, "in_tc"); glEnableVertexAttribArray(tc_location); glVertexAttribPointer(tc_location, 2, GL_FLOAT, GL_FALSE, 0, kTextureCoords); diff --git a/media/tools/player_x11/gles_video_renderer.h b/media/tools/player_x11/gles_video_renderer.h index 87c4703..d8c22c8 100644 --- a/media/tools/player_x11/gles_video_renderer.h +++ b/media/tools/player_x11/gles_video_renderer.h @@ -64,11 +64,6 @@ class GlesVideoRenderer : public media::VideoRendererBase { // 3 textures, one for each plane. GLuint textures_[3]; - // Shaders and program for YUV->RGB conversion. - GLuint vertex_shader_; - GLuint fragment_shader_; - GLuint program_; - static GlesVideoRenderer* instance_; DISALLOW_COPY_AND_ASSIGN(GlesVideoRenderer); diff --git a/media/tools/player_x11/player_x11.cc b/media/tools/player_x11/player_x11.cc index 24ba556..69d7fc5 100644 --- a/media/tools/player_x11/player_x11.cc +++ b/media/tools/player_x11/player_x11.cc @@ -25,12 +25,14 @@ #if defined(RENDERER_GL) #include "media/tools/player_x11/gl_video_renderer.h" typedef GlVideoRenderer Renderer; -#elif RENDERER_GLES +#elif defined(RENDERER_GLES) #include "media/tools/player_x11/gles_video_renderer.h" typedef GlesVideoRenderer Renderer; -#elif RENDERER_X11 +#elif defined(RENDERER_X11) #include "media/tools/player_x11/x11_video_renderer.h" typedef X11VideoRenderer Renderer; +#else +#error No video renderer defined. #endif Display* g_display = NULL; |