Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef MEDIA_TOOLS_PLAYER_X11_GL_VIDEO_RENDERER_H_ | 5 #ifndef MEDIA_TOOLS_PLAYER_X11_GL_VIDEO_RENDERER_H_ |
| 6 #define MEDIA_TOOLS_PLAYER_X11_GL_VIDEO_RENDERER_H_ | 6 #define MEDIA_TOOLS_PLAYER_X11_GL_VIDEO_RENDERER_H_ |
| 7 | 7 |
| 8 #include <EGL/egl.h> | 8 #include <EGL/egl.h> |
| 9 #include <EGL/eglext.h> | 9 #include <EGL/eglext.h> |
| 10 #include <GLES2/gl2.h> | 10 #include <GLES2/gl2.h> |
| (...skipping 17 matching lines...) Expand all Loading... | |
| 28 | 28 |
| 29 // This method is called to paint the current video frame to the assigned | 29 // This method is called to paint the current video frame to the assigned |
| 30 // window. | 30 // window. |
| 31 void Paint(); | 31 void Paint(); |
| 32 | 32 |
| 33 // media::FilterFactoryImpl2 Implementation. | 33 // media::FilterFactoryImpl2 Implementation. |
| 34 static bool IsMediaFormatSupported(const media::MediaFormat& media_format); | 34 static bool IsMediaFormatSupported(const media::MediaFormat& media_format); |
| 35 | 35 |
| 36 static GlesVideoRenderer* instance() { return instance_; } | 36 static GlesVideoRenderer* instance() { return instance_; } |
| 37 | 37 |
| 38 void set_glx_thread_message_loop(MessageLoop* message_loop) { | |
| 39 glx_thread_message_loop_ = message_loop; | |
| 40 } | |
|
wjia(left Chromium)
2010/06/09 01:08:06
Is it possible to use the message_loop in MediaFil
| |
| 41 | |
| 42 MessageLoop* glx_thread_message_loop() { | |
|
jiesun
2010/06/09 01:18:36
MediaFilter::message_loop_ mostly mean its own mes
| |
| 43 return glx_thread_message_loop_; | |
| 44 } | |
| 45 | |
| 38 protected: | 46 protected: |
| 39 // VideoRendererBase implementation. | 47 // VideoRendererBase implementation. |
| 40 virtual bool OnInitialize(media::VideoDecoder* decoder); | 48 virtual bool OnInitialize(media::VideoDecoder* decoder); |
| 41 virtual void OnStop(); | 49 virtual void OnStop(); |
| 42 virtual void OnFrameAvailable(); | 50 virtual void OnFrameAvailable(); |
| 43 | 51 |
| 44 private: | 52 private: |
| 45 // Only allow to be deleted by reference counting. | 53 // Only allow to be deleted by reference counting. |
| 46 friend class scoped_refptr<GlesVideoRenderer>; | 54 friend class scoped_refptr<GlesVideoRenderer>; |
| 47 virtual ~GlesVideoRenderer(); | 55 virtual ~GlesVideoRenderer(); |
| 48 | 56 |
| 49 bool InitializeGles(); | 57 bool InitializeGles(); |
| 50 void CreateShader(GLuint program, GLenum type, | 58 void CreateShader(GLuint program, GLenum type, |
| 51 const char* vs_source, int vs_size); | 59 const char* vs_source, int vs_size); |
| 52 void LinkProgram(GLuint program); | 60 void LinkProgram(GLuint program); |
| 53 void CreateTextureAndProgramEgl(); | 61 void CreateTextureAndProgramEgl(); |
| 54 void CreateTextureAndProgramYuv2Rgb(); | 62 void CreateTextureAndProgramYuv2Rgb(); |
| 55 | 63 |
| 56 PFNEGLCREATEIMAGEKHRPROC egl_create_image_khr_; | 64 PFNEGLCREATEIMAGEKHRPROC egl_create_image_khr_; |
| 57 PFNEGLDESTROYIMAGEKHRPROC egl_destroy_image_khr_; | 65 PFNEGLDESTROYIMAGEKHRPROC egl_destroy_image_khr_; |
| 58 PFNGLEGLIMAGETARGETTEXTURE2DOESPROC gl_eglimage_target_texture2d_oes_; | 66 PFNGLEGLIMAGETARGETTEXTURE2DOESPROC gl_eglimage_target_texture2d_oes_; |
| 59 | 67 |
| 60 int width_; | 68 int width_; |
| 61 int height_; | 69 int height_; |
| 62 bool uses_egl_image_; | 70 bool uses_egl_image_; |
| 63 | 71 |
| 64 Display* display_; | 72 Display* display_; |
| 65 Window window_; | 73 Window window_; |
| 66 | 74 |
| 67 // Protects |new_frame_|. | |
| 68 Lock lock_; | |
| 69 bool new_frame_; | |
| 70 | |
| 71 // EGL context. | 75 // EGL context. |
| 72 EGLDisplay egl_display_; | 76 EGLDisplay egl_display_; |
| 73 EGLSurface egl_surface_; | 77 EGLSurface egl_surface_; |
| 74 EGLContext egl_context_; | 78 EGLContext egl_context_; |
| 75 | 79 |
| 76 // textures for EGL image | 80 // textures for EGL image |
| 77 typedef std::pair<scoped_refptr<media::VideoFrame>, GLuint> EglFrame; | 81 typedef std::pair<scoped_refptr<media::VideoFrame>, GLuint> EglFrame; |
| 78 std::vector<EglFrame> egl_frames_; | 82 std::vector<EglFrame> egl_frames_; |
| 79 | 83 |
| 80 // 3 textures, one for each plane. | 84 // 3 textures, one for each plane. |
| 81 GLuint textures_[3]; | 85 GLuint textures_[3]; |
| 82 | 86 |
| 87 MessageLoop* glx_thread_message_loop_; | |
| 83 static GlesVideoRenderer* instance_; | 88 static GlesVideoRenderer* instance_; |
| 84 | 89 |
| 85 DISALLOW_COPY_AND_ASSIGN(GlesVideoRenderer); | 90 DISALLOW_COPY_AND_ASSIGN(GlesVideoRenderer); |
| 86 }; | 91 }; |
| 87 | 92 |
| 88 #endif // MEDIA_TOOLS_PLAYER_X11_GLES_VIDEO_RENDERER_H_ | 93 #endif // MEDIA_TOOLS_PLAYER_X11_GLES_VIDEO_RENDERER_H_ |
| OLD | NEW |