summaryrefslogtreecommitdiffstats
path: root/media
diff options
context:
space:
mode:
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, 23 insertions, 24 deletions
diff --git a/media/tools/player_x11/gles_video_renderer.cc b/media/tools/player_x11/gles_video_renderer.cc
index a275366..f6cea9c 100644
--- a/media/tools/player_x11/gles_video_renderer.cc
+++ b/media/tools/player_x11/gles_video_renderer.cc
@@ -44,8 +44,6 @@ 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())
@@ -54,6 +52,8 @@ 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_);
}
@@ -184,14 +184,12 @@ void GlesVideoRenderer::Paint() {
if (uses_egl_image_) {
if (media::VideoFrame::TYPE_EGL_IMAGE == video_frame->type()) {
-
- 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_);
- }
+ 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_);
}
return;
}
@@ -244,17 +242,6 @@ 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_);
@@ -395,12 +382,24 @@ 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"));
- if (!egl_destroy_image_khr_)
+ CHECK(egl_create_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 075bdbc..d93fa2e 100644
--- a/media/tools/player_x11/gles_video_renderer.h
+++ b/media/tools/player_x11/gles_video_renderer.h
@@ -46,7 +46,6 @@ 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);
@@ -56,6 +55,7 @@ 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_;