summaryrefslogtreecommitdiffstats
path: root/media
diff options
context:
space:
mode:
authorwjia@google.com <wjia@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2010-06-09 21:14:38 +0000
committerwjia@google.com <wjia@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2010-06-09 21:14:38 +0000
commite2a011098d8eb2c682ee6673e543a5060f9bf6ff (patch)
treee94a56b8f492bea669a2d71489f15d5123b28a43 /media
parentcac84da0caa10e9d170632984f4fca5e6193884d (diff)
downloadchromium_src-e2a011098d8eb2c682ee6673e543a5060f9bf6ff.zip
chromium_src-e2a011098d8eb2c682ee6673e543a5060f9bf6ff.tar.gz
chromium_src-e2a011098d8eb2c682ee6673e543a5060f9bf6ff.tar.bz2
revert cl 49121 since the way of using glEglImageTargetTexture2DOES is undefined and
it crashes randomly. BUG=none TEST=dev platform Review URL: http://codereview.chromium.org/2765005 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@49318 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'media')
-rw-r--r--media/tools/player_x11/gles_video_renderer.cc45
-rw-r--r--media/tools/player_x11/gles_video_renderer.h2
2 files changed, 24 insertions, 23 deletions
diff --git a/media/tools/player_x11/gles_video_renderer.cc b/media/tools/player_x11/gles_video_renderer.cc
index fab345a..ef02d75 100644
--- a/media/tools/player_x11/gles_video_renderer.cc
+++ b/media/tools/player_x11/gles_video_renderer.cc
@@ -44,6 +44,8 @@ bool GlesVideoRenderer::IsMediaFormatSupported(
void GlesVideoRenderer::OnStop() {
// TODO(hclam): Context switching seems to be broek so the following
// calls may fail. Need to fix them.
+ eglMakeCurrent(egl_display_, EGL_NO_SURFACE,
+ EGL_NO_SURFACE, EGL_NO_CONTEXT);
for (size_t i = 0; i < egl_frames_.size(); ++i) {
scoped_refptr<media::VideoFrame> frame = egl_frames_[i].first;
if (frame->private_buffer())
@@ -52,8 +54,6 @@ void GlesVideoRenderer::OnStop() {
glDeleteTextures(1, &egl_frames_[i].second);
}
egl_frames_.clear();
- eglMakeCurrent(egl_display_, EGL_NO_SURFACE,
- EGL_NO_SURFACE, EGL_NO_CONTEXT);
eglDestroyContext(egl_display_, egl_context_);
eglDestroySurface(egl_display_, egl_surface_);
}
@@ -175,12 +175,14 @@ void GlesVideoRenderer::Paint() {
if (uses_egl_image_) {
if (media::VideoFrame::TYPE_EGL_IMAGE == video_frame->type()) {
- glActiveTexture(GL_TEXTURE0);
- EGLImageKHR egl_image =
- reinterpret_cast<EGLImageKHR>(video_frame->private_buffer());
- gl_eglimage_target_texture2d_oes_(GL_TEXTURE_2D, egl_image);
- glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
- eglSwapBuffers(egl_display_, egl_surface_);
+
+ GLuint texture = FindTexture(video_frame);
+ if (texture) {
+ glActiveTexture(GL_TEXTURE0);
+ glBindTexture(GL_TEXTURE_2D, texture);
+ glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
+ eglSwapBuffers(egl_display_, egl_surface_);
+ }
}
return;
}
@@ -233,6 +235,17 @@ void GlesVideoRenderer::Paint() {
eglSwapBuffers(egl_display_, egl_surface_);
}
+// find if texture exists corresponding to video_frame
+GLuint GlesVideoRenderer::FindTexture(
+ scoped_refptr<media::VideoFrame> video_frame) {
+ for (size_t i = 0; i < egl_frames_.size(); ++i) {
+ scoped_refptr<media::VideoFrame> frame = egl_frames_[i].first;
+ if (video_frame->private_buffer() == frame->private_buffer())
+ return egl_frames_[i].second;
+ }
+ return NULL;
+}
+
bool GlesVideoRenderer::InitializeGles() {
// Resize the window to fit that of the video.
XResizeWindow(display_, window_, width_, height_);
@@ -373,24 +386,12 @@ void GlesVideoRenderer::LinkProgram(GLuint program) {
}
void GlesVideoRenderer::CreateTextureAndProgramEgl() {
- if (!egl_create_image_khr_) {
+ if (!egl_create_image_khr_)
egl_create_image_khr_ = reinterpret_cast<PFNEGLCREATEIMAGEKHRPROC>
(eglGetProcAddress("eglCreateImageKHR"));
- CHECK(egl_create_image_khr_);
- }
- if (!egl_destroy_image_khr_) {
+ if (!egl_destroy_image_khr_)
egl_destroy_image_khr_ = reinterpret_cast<PFNEGLDESTROYIMAGEKHRPROC>
(eglGetProcAddress("eglDestroyImageKHR"));
- CHECK(egl_destroy_image_khr_);
- }
-
- if (!gl_eglimage_target_texture2d_oes_) {
- gl_eglimage_target_texture2d_oes_ =
- reinterpret_cast<PFNGLEGLIMAGETARGETTEXTURE2DOESPROC>
- (eglGetProcAddress("glEGLImageTargetTexture2DOES"));
- CHECK(gl_eglimage_target_texture2d_oes_);
- }
-
// TODO(wjia): get count from decoder.
for (int i = 0; i < 4; i++) {
GLuint texture;
diff --git a/media/tools/player_x11/gles_video_renderer.h b/media/tools/player_x11/gles_video_renderer.h
index 2aaa19c..8256c890 100644
--- a/media/tools/player_x11/gles_video_renderer.h
+++ b/media/tools/player_x11/gles_video_renderer.h
@@ -54,6 +54,7 @@ class GlesVideoRenderer : public media::VideoRendererBase {
friend class scoped_refptr<GlesVideoRenderer>;
virtual ~GlesVideoRenderer();
+ GLuint FindTexture(scoped_refptr<media::VideoFrame> video_frame);
bool InitializeGles();
void CreateShader(GLuint program, GLenum type,
const char* vs_source, int vs_size);
@@ -63,7 +64,6 @@ class GlesVideoRenderer : public media::VideoRendererBase {
PFNEGLCREATEIMAGEKHRPROC egl_create_image_khr_;
PFNEGLDESTROYIMAGEKHRPROC egl_destroy_image_khr_;
- PFNGLEGLIMAGETARGETTEXTURE2DOESPROC gl_eglimage_target_texture2d_oes_;
int width_;
int height_;