diff options
Diffstat (limited to 'content/common')
10 files changed, 131 insertions, 175 deletions
diff --git a/content/common/gpu/media/dxva_video_decode_accelerator.cc b/content/common/gpu/media/dxva_video_decode_accelerator.cc index ec46901..d354f24 100644 --- a/content/common/gpu/media/dxva_video_decode_accelerator.cc +++ b/content/common/gpu/media/dxva_video_decode_accelerator.cc @@ -26,8 +26,6 @@ #include "base/shared_memory.h" #include "base/threading/worker_pool.h" #include "media/video/video_decode_accelerator.h" -#include "third_party/angle/include/EGL/egl.h" -#include "third_party/angle/include/EGL/eglext.h" #include "ui/gl/gl_bindings.h" #include "ui/gl/gl_surface.h" #include "ui/gl/gl_switches.h" diff --git a/content/common/gpu/media/exynos_video_decode_accelerator.cc b/content/common/gpu/media/exynos_video_decode_accelerator.cc index ae464aa..8c6762e 100644 --- a/content/common/gpu/media/exynos_video_decode_accelerator.cc +++ b/content/common/gpu/media/exynos_video_decode_accelerator.cc @@ -20,7 +20,6 @@ #include "content/common/gpu/gl_scoped_binders.h" #include "content/common/gpu/media/exynos_video_decode_accelerator.h" #include "content/common/gpu/media/h264_parser.h" -#include "third_party/angle/include/GLES2/gl2.h" namespace content { @@ -49,44 +48,18 @@ namespace content { } \ } while (0) -#define POSTSANDBOX_DLSYM(lib, func, type, name) \ - func = reinterpret_cast<type>(dlsym(lib, name)); \ - if (func == NULL) { \ - DPLOG(ERROR) << "PostSandboxInitialization(): failed to dlsym() " \ - << name << ": " << dlerror(); \ - return false; \ - } - namespace { const char kExynosMfcDevice[] = "/dev/mfc-dec"; const char kExynosGscDevice[] = "/dev/gsc1"; const char kMaliDriver[] = "libmali.so"; -// TODO(sheu): fix OpenGL ES header includes, remove unnecessary redefinitions. -// http://crbug.com/169433 -typedef void* GLeglImageOES; typedef EGLBoolean (*MaliEglImageGetBufferExtPhandleFunc)(EGLImageKHR, EGLint*, void*); -typedef EGLImageKHR (*EglCreateImageKhrFunc)(EGLDisplay, EGLContext, EGLenum, - EGLClientBuffer, const EGLint*); -typedef EGLBoolean (*EglDestroyImageKhrFunc)(EGLDisplay, EGLImageKHR); -typedef EGLSyncKHR (*EglCreateSyncKhrFunc)(EGLDisplay, EGLenum, const EGLint*); -typedef EGLBoolean (*EglDestroySyncKhrFunc)(EGLDisplay, EGLSyncKHR); -typedef EGLint (*EglClientWaitSyncKhrFunc)(EGLDisplay, EGLSyncKHR, EGLint, - EGLTimeKHR); -typedef void (*GlEglImageTargetTexture2dOesFunc)(GLenum, GLeglImageOES); void* libmali_handle = NULL; MaliEglImageGetBufferExtPhandleFunc mali_egl_image_get_buffer_ext_phandle = NULL; -EglCreateImageKhrFunc egl_create_image_khr = NULL; -EglDestroyImageKhrFunc egl_destroy_image_khr = NULL; -EglCreateSyncKhrFunc egl_create_sync_khr = NULL; -EglDestroySyncKhrFunc egl_destroy_sync_khr = NULL; -EglClientWaitSyncKhrFunc egl_client_wait_sync_khr = NULL; -GlEglImageTargetTexture2dOesFunc gl_egl_image_target_texture_2d_oes = NULL; - } // anonymous namespace struct ExynosVideoDecodeAccelerator::BitstreamBufferRef { @@ -161,7 +134,7 @@ ExynosVideoDecodeAccelerator::PictureBufferArrayRef::~PictureBufferArrayRef() { for (size_t i = 0; i < picture_buffers.size(); ++i) { PictureBufferRef& buffer = picture_buffers[i]; if (buffer.egl_image != EGL_NO_IMAGE_KHR) - egl_destroy_image_khr(egl_display, buffer.egl_image); + eglDestroyImageKHR(egl_display, buffer.egl_image); if (buffer.egl_image_fd != -1) HANDLE_EINTR(close(buffer.egl_image_fd)); } @@ -175,7 +148,7 @@ ExynosVideoDecodeAccelerator::EGLSyncKHRRef::EGLSyncKHRRef( ExynosVideoDecodeAccelerator::EGLSyncKHRRef::~EGLSyncKHRRef() { if (egl_sync != EGL_NO_SYNC_KHR) - egl_destroy_sync_khr(egl_display, egl_sync); + eglDestroySyncKHR(egl_display, egl_sync); } ExynosVideoDecodeAccelerator::MfcInputRecord::MfcInputRecord() @@ -336,6 +309,19 @@ bool ExynosVideoDecodeAccelerator::Initialize( return false; } + // We need the context to be initialized to query extensions. + if (!make_context_current_.Run()) { + DLOG(ERROR) << "Initialize(): could not make context current"; + NOTIFY_ERROR(PLATFORM_FAILURE); + return false; + } + + if (!gfx::g_driver_egl.ext.b_EGL_KHR_fence_sync) { + DLOG(ERROR) << "Initialize(): context does not have EGL_KHR_fence_sync"; + NOTIFY_ERROR(PLATFORM_FAILURE); + return false; + } + // Open the video devices. DVLOG(2) << "Initialize(): opening MFC device: " << kExynosMfcDevice; mfc_fd_ = HANDLE_EINTR(open(kExynosMfcDevice, @@ -393,12 +379,6 @@ bool ExynosVideoDecodeAccelerator::Initialize( control.value = 8; // Magic number from Samsung folks. IOCTL_OR_ERROR_RETURN_FALSE(mfc_fd_, VIDIOC_S_CTRL, &control); - if (!make_context_current_.Run()) { - DLOG(ERROR) << "Initialize(): could not make context current"; - NOTIFY_ERROR(PLATFORM_FAILURE); - return false; - } - if (!CreateMfcInputBuffers()) return false; @@ -490,7 +470,7 @@ void ExynosVideoDecodeAccelerator::AssignPictureBuffers( return; } glBindTexture(GL_TEXTURE_2D, buffers[i].texture_id()); - EGLImageKHR egl_image = egl_create_image_khr( + EGLImageKHR egl_image = eglCreateImageKHR( egl_display_, EGL_NO_CONTEXT, EGL_NATIVE_PIXMAP_KHR, (EGLClientBuffer)pixmap, kImageAttrs); // We can free the X pixmap immediately -- according to the @@ -511,7 +491,7 @@ void ExynosVideoDecodeAccelerator::AssignPictureBuffers( return; } buffer.egl_image_fd = fd; - gl_egl_image_target_texture_2d_oes(GL_TEXTURE_2D, egl_image); + glEGLImageTargetTexture2DOES(GL_TEXTURE_2D, egl_image); buffer.client_id = buffers[i].id(); } decoder_thread_.message_loop()->PostTask(FROM_HERE, base::Bind( @@ -531,7 +511,7 @@ void ExynosVideoDecodeAccelerator::ReusePictureBuffer(int32 picture_buffer_id) { } EGLSyncKHR egl_sync = - egl_create_sync_khr(egl_display_, EGL_SYNC_FENCE_KHR, NULL); + eglCreateSyncKHR(egl_display_, EGL_SYNC_FENCE_KHR, NULL); if (egl_sync == EGL_NO_SYNC_KHR) { DLOG(ERROR) << "ReusePictureBuffer(): eglCreateSyncKHR() failed"; NOTIFY_ERROR(PLATFORM_FAILURE); @@ -604,41 +584,14 @@ bool ExynosVideoDecodeAccelerator::PostSandboxInitialization() { } dlerror(); - - POSTSANDBOX_DLSYM(libmali_handle, - mali_egl_image_get_buffer_ext_phandle, - MaliEglImageGetBufferExtPhandleFunc, - "mali_egl_image_get_buffer_ext_phandle"); - - POSTSANDBOX_DLSYM(libmali_handle, - egl_create_image_khr, - EglCreateImageKhrFunc, - "eglCreateImageKHR"); - - POSTSANDBOX_DLSYM(libmali_handle, - egl_destroy_image_khr, - EglDestroyImageKhrFunc, - "eglDestroyImageKHR"); - - POSTSANDBOX_DLSYM(libmali_handle, - egl_create_sync_khr, - EglCreateSyncKhrFunc, - "eglCreateSyncKHR"); - - POSTSANDBOX_DLSYM(libmali_handle, - egl_destroy_sync_khr, - EglDestroySyncKhrFunc, - "eglDestroySyncKHR"); - - POSTSANDBOX_DLSYM(libmali_handle, - egl_client_wait_sync_khr, - EglClientWaitSyncKhrFunc, - "eglClientWaitSyncKHR"); - - POSTSANDBOX_DLSYM(libmali_handle, - gl_egl_image_target_texture_2d_oes, - GlEglImageTargetTexture2dOesFunc, - "glEGLImageTargetTexture2DOES"); + mali_egl_image_get_buffer_ext_phandle = + reinterpret_cast<MaliEglImageGetBufferExtPhandleFunc>( + dlsym(libmali_handle, "mali_egl_image_get_buffer_ext_phandle")); + if (mali_egl_image_get_buffer_ext_phandle == NULL) { + DPLOG(ERROR) << "PostSandboxInitialization(): failed to dlsym() " + << "mali_egl_image_get_buffer_ext_phandle: " << dlerror(); + return false; + } return true; } @@ -1513,9 +1466,9 @@ bool ExynosVideoDecodeAccelerator::EnqueueGscOutputRecord() { // If we have to wait for completion, wait. Note that // gsc_free_output_buffers_ is a FIFO queue, so we always wait on the // buffer that has been in the queue the longest. - egl_client_wait_sync_khr(egl_display_, output_record.egl_sync, 0, + eglClientWaitSyncKHR(egl_display_, output_record.egl_sync, 0, EGL_FOREVER_KHR); - egl_destroy_sync_khr(egl_display_, output_record.egl_sync); + eglDestroySyncKHR(egl_display_, output_record.egl_sync); output_record.egl_sync = EGL_NO_SYNC_KHR; } struct v4l2_buffer qbuf; @@ -2229,9 +2182,9 @@ void ExynosVideoDecodeAccelerator::DestroyGscOutputBuffers() { if (output_record.fd != -1) HANDLE_EINTR(close(output_record.fd)); if (output_record.egl_image != EGL_NO_IMAGE_KHR) - egl_destroy_image_khr(egl_display_, output_record.egl_image); + eglDestroyImageKHR(egl_display_, output_record.egl_image); if (output_record.egl_sync != EGL_NO_SYNC_KHR) - egl_destroy_sync_khr(egl_display_, output_record.egl_sync); + eglDestroySyncKHR(egl_display_, output_record.egl_sync); if (client_) client_->DismissPictureBuffer(output_record.picture_id); ++i; diff --git a/content/common/gpu/media/exynos_video_decode_accelerator.h b/content/common/gpu/media/exynos_video_decode_accelerator.h index 3459293..2c0c249 100644 --- a/content/common/gpu/media/exynos_video_decode_accelerator.h +++ b/content/common/gpu/media/exynos_video_decode_accelerator.h @@ -18,9 +18,8 @@ #include "content/common/content_export.h" #include "media/base/video_decoder_config.h" #include "media/video/video_decode_accelerator.h" -#include "third_party/angle/include/EGL/egl.h" -#include "third_party/angle/include/EGL/eglext.h" #include "ui/gfx/size.h" +#include "ui/gl/gl_bindings.h" namespace base { class MessageLoopProxy; diff --git a/content/common/gpu/media/gles2_texture_to_egl_image_translator.cc b/content/common/gpu/media/gles2_texture_to_egl_image_translator.cc index 4cd06b2..24a8554 100644 --- a/content/common/gpu/media/gles2_texture_to_egl_image_translator.cc +++ b/content/common/gpu/media/gles2_texture_to_egl_image_translator.cc @@ -13,30 +13,9 @@ namespace content { -// Get EGL extension functions. -static PFNEGLCREATEIMAGEKHRPROC egl_create_image_khr = - reinterpret_cast<PFNEGLCREATEIMAGEKHRPROC>( - eglGetProcAddress("eglCreateImageKHR")); -static PFNEGLDESTROYIMAGEKHRPROC egl_destroy_image_khr = - reinterpret_cast<PFNEGLDESTROYIMAGEKHRPROC>( - eglGetProcAddress("eglDestroyImageKHR")); -static PFNGLEGLIMAGETARGETTEXTURE2DOESPROC glegl_image_targettexture_2does = - reinterpret_cast<PFNGLEGLIMAGETARGETTEXTURE2DOESPROC>( - eglGetProcAddress("glEGLImageTargetTexture2DOES")); - -static bool AreEGLExtensionsInitialized() { - return (egl_create_image_khr && egl_destroy_image_khr && - glegl_image_targettexture_2does); -} - Gles2TextureToEglImageTranslator::Gles2TextureToEglImageTranslator( bool use_backing_pixmaps) : use_backing_pixmaps_(use_backing_pixmaps) { - if (!AreEGLExtensionsInitialized()) { - LOG(DFATAL) << "Failed to get EGL extensions"; - return; - } - CHECK_EQ(eglGetError(), EGL_SUCCESS); } @@ -47,13 +26,8 @@ EGLImageKHR Gles2TextureToEglImageTranslator::TranslateToEglImage( EGLDisplay egl_display, EGLContext egl_context, uint32 texture, const gfx::Size& dimensions) { - if (!egl_create_image_khr) - return EGL_NO_IMAGE_KHR; EGLImageKHR hEglImage; if (use_backing_pixmaps_) { - if (!glegl_image_targettexture_2does) - return EGL_NO_IMAGE_KHR; - EGLint image_attrs[] = { EGL_IMAGE_PRESERVED_KHR, 1 , EGL_NONE }; glActiveTexture(GL_TEXTURE0); @@ -64,24 +38,24 @@ EGLImageKHR Gles2TextureToEglImageTranslator::TranslateToEglImage( dimensions.width(), dimensions.height(), 32); - hEglImage = egl_create_image_khr(egl_display, - EGL_NO_CONTEXT, - EGL_NATIVE_PIXMAP_KHR, - (EGLClientBuffer)pixmap, - image_attrs); + hEglImage = eglCreateImageKHR(egl_display, + EGL_NO_CONTEXT, + EGL_NATIVE_PIXMAP_KHR, + (EGLClientBuffer)pixmap, + image_attrs); - glegl_image_targettexture_2does(GL_TEXTURE_2D, hEglImage); + glEGLImageTargetTexture2DOES(GL_TEXTURE_2D, hEglImage); bool inserted = eglimage_pixmap_.insert(std::make_pair( hEglImage, pixmap)).second; DCHECK(inserted); } else { EGLint attrib = EGL_NONE; // Create an EGLImage - hEglImage = egl_create_image_khr(egl_display, - egl_context, - EGL_GL_TEXTURE_2D_KHR, - reinterpret_cast<EGLClientBuffer>(texture), - &attrib); + hEglImage = eglCreateImageKHR(egl_display, + egl_context, + EGL_GL_TEXTURE_2D_KHR, + reinterpret_cast<EGLClientBuffer>(texture), + &attrib); } CHECK(hEglImage) << "Failed to eglCreateImageKHR for " << texture << ", error: 0x" << std::hex << eglGetError(); @@ -101,11 +75,7 @@ void Gles2TextureToEglImageTranslator::DestroyEglImage( EGLDisplay egl_display, EGLImageKHR egl_image) { // Clients of this class will call this method for each EGLImage handle. // Actual destroying of the handles is done here. - if (!egl_destroy_image_khr) { - DLOG(ERROR) << "egl_destroy_image_khr failed"; - return; - } - egl_destroy_image_khr(egl_display, egl_image); + eglDestroyImageKHR(egl_display, egl_image); if (use_backing_pixmaps_) { ImagePixmap::iterator it = eglimage_pixmap_.find(egl_image); diff --git a/content/common/gpu/media/gles2_texture_to_egl_image_translator.h b/content/common/gpu/media/gles2_texture_to_egl_image_translator.h index d01407b..bb1eacc 100644 --- a/content/common/gpu/media/gles2_texture_to_egl_image_translator.h +++ b/content/common/gpu/media/gles2_texture_to_egl_image_translator.h @@ -9,10 +9,7 @@ #include "base/basictypes.h" #include "media/video/picture.h" -#include "third_party/angle/include/EGL/egl.h" -#include "third_party/angle/include/EGL/eglext.h" -#include "third_party/angle/include/GLES2/gl2.h" -#include "third_party/angle/include/GLES2/gl2ext.h" +#include "ui/gl/gl_bindings.h" namespace content { diff --git a/content/common/gpu/media/omx_video_decode_accelerator.cc b/content/common/gpu/media/omx_video_decode_accelerator.cc index c44ce80..06897a8 100644 --- a/content/common/gpu/media/omx_video_decode_accelerator.cc +++ b/content/common/gpu/media/omx_video_decode_accelerator.cc @@ -43,10 +43,6 @@ OMXGetComponentsOfRole omx_get_components_of_role = NULL; OMXFreeHandle omx_free_handle = NULL; OMXDeinit omx_deinit = NULL; -static PFNEGLCREATESYNCKHRPROC egl_create_sync_khr = NULL; -static PFNEGLGETSYNCATTRIBKHRPROC egl_get_sync_attrib_khr = NULL; -static PFNEGLDESTROYSYNCKHRPROC egl_destroy_sync_khr = NULL; - // Maps h264-related Profile enum values to OMX_VIDEO_AVCPROFILETYPE values. static OMX_U32 MapH264ProfileToOMXAVCProfile(uint32 profile) { switch (profile) { @@ -118,17 +114,17 @@ OmxVideoDecodeAccelerator::PictureSyncObject::PictureSyncObject( : egl_display_(egl_display) { DCHECK(egl_display_ != EGL_NO_DISPLAY); - egl_sync_obj_ = egl_create_sync_khr(egl_display_, EGL_SYNC_FENCE_KHR, NULL); + egl_sync_obj_ = eglCreateSyncKHR(egl_display_, EGL_SYNC_FENCE_KHR, NULL); DCHECK_NE(egl_sync_obj_, EGL_NO_SYNC_KHR); } OmxVideoDecodeAccelerator::PictureSyncObject::~PictureSyncObject() { - egl_destroy_sync_khr(egl_display_, egl_sync_obj_); + eglDestroySyncKHR(egl_display_, egl_sync_obj_); } bool OmxVideoDecodeAccelerator::PictureSyncObject::IsSynced() { EGLint value = EGL_UNSIGNALED_KHR; - EGLBoolean ret = egl_get_sync_attrib_khr( + EGLBoolean ret = eglGetSyncAttribKHR( egl_display_, egl_sync_obj_, EGL_SYNC_STATUS_KHR, &value); DCHECK(ret) << "Failed getting sync object state."; @@ -196,6 +192,16 @@ bool OmxVideoDecodeAccelerator::Initialize(media::VideoCodecProfile profile) { INVALID_ARGUMENT, false); } + // We need the context to be initialized to query extensions. + RETURN_ON_FAILURE(make_context_current_.Run(), + "Failed make context current", + PLATFORM_FAILURE, + false); + RETURN_ON_FAILURE(gfx::g_driver_egl.ext.b_EGL_KHR_fence_sync, + "Platform does not support EGL_KHR_fence_sync", + PLATFORM_FAILURE, + false); + if (!CreateComponent()) // Does its own RETURN_ON_FAILURE dances. return false; @@ -1171,16 +1177,8 @@ bool OmxVideoDecodeAccelerator::PostSandboxInitialization() { omx_deinit = reinterpret_cast<OMXDeinit>(dlsym(omx_handle, "OMX_Deinit")); - egl_create_sync_khr = reinterpret_cast<PFNEGLCREATESYNCKHRPROC>( - eglGetProcAddress("eglCreateSyncKHR")); - egl_get_sync_attrib_khr = reinterpret_cast<PFNEGLGETSYNCATTRIBKHRPROC>( - eglGetProcAddress("eglGetSyncAttribKHR")); - egl_destroy_sync_khr = reinterpret_cast<PFNEGLDESTROYSYNCKHRPROC>( - eglGetProcAddress("eglDestroySyncKHR")); - return (omx_init && omx_gethandle && omx_get_components_of_role && - omx_free_handle && omx_deinit && egl_create_sync_khr && - egl_get_sync_attrib_khr && egl_destroy_sync_khr); + omx_free_handle && omx_deinit); } // static diff --git a/content/common/gpu/media/omx_video_decode_accelerator.h b/content/common/gpu/media/omx_video_decode_accelerator.h index 2cb15b6..8855809 100644 --- a/content/common/gpu/media/omx_video_decode_accelerator.h +++ b/content/common/gpu/media/omx_video_decode_accelerator.h @@ -19,11 +19,10 @@ #include "base/shared_memory.h" #include "content/common/content_export.h" #include "media/video/video_decode_accelerator.h" -#include "third_party/angle/include/EGL/egl.h" -#include "third_party/angle/include/EGL/eglext.h" #include "third_party/openmax/il/OMX_Component.h" #include "third_party/openmax/il/OMX_Core.h" #include "third_party/openmax/il/OMX_Video.h" +#include "ui/gl/gl_bindings.h" namespace content { class Gles2TextureToEglImageTranslator; diff --git a/content/common/gpu/media/rendering_helper_gl.cc b/content/common/gpu/media/rendering_helper_gl.cc index f87745a..b4cf57d 100644 --- a/content/common/gpu/media/rendering_helper_gl.cc +++ b/content/common/gpu/media/rendering_helper_gl.cc @@ -6,23 +6,16 @@ #include <map> -#if defined(OS_WIN) || defined(ARCH_CPU_ARMEL) -#include "third_party/angle/include/EGL/egl.h" // Must precede ui/gl headers! -#endif - #include "base/bind.h" #include "base/mac/scoped_nsautorelease_pool.h" #include "base/message_loop.h" #include "base/stringize_macros.h" #include "base/synchronization/waitable_event.h" -#if !defined(ARCH_CPU_ARMEL) #include "ui/gl/gl_bindings.h" #include "ui/gl/gl_context.h" +#include "ui/gl/gl_context_stub.h" #include "ui/gl/gl_implementation.h" #include "ui/gl/gl_surface.h" -#else -#include "third_party/angle/include/GLES2/gl2.h" -#endif #if !defined(OS_WIN) && defined(ARCH_CPU_X86_FAMILY) #define GL_VARIANT_GLX 1 @@ -58,6 +51,42 @@ static void CreateShader(GLuint program, CHECK_EQ(static_cast<int>(glGetError()), GL_NO_ERROR); } +namespace { + +// Lightweight GLContext stub implementation that returns a constructed +// extensions string. We use this to create a context that we can use to +// initialize GL extensions with, without actually creating a platform context. +class GLContextStubWithExtensions : public gfx::GLContextStub { + public: + GLContextStubWithExtensions() {} + virtual std::string GetExtensions() OVERRIDE; + + void AddExtensionsString(const char* extensions); + + protected: + virtual ~GLContextStubWithExtensions() {} + + private: + std::string extensions_; + + DISALLOW_COPY_AND_ASSIGN(GLContextStubWithExtensions); +}; + +void GLContextStubWithExtensions::AddExtensionsString(const char* extensions) { + if (extensions == NULL) + return; + + if (extensions_.size() != 0) + extensions_ += ' '; + extensions_ += extensions; +} + +std::string GLContextStubWithExtensions::GetExtensions() { + return extensions_; +} + +} // anonymous + namespace content { class RenderingHelperGL : public RenderingHelper { @@ -81,6 +110,8 @@ class RenderingHelperGL : public RenderingHelper { virtual void* GetGLContext() OVERRIDE; virtual void* GetGLDisplay() OVERRIDE; + static const gfx::GLImplementation kGLImplementation; + private: void Clear(); @@ -88,6 +119,7 @@ class RenderingHelperGL : public RenderingHelper { // if |window_id < 0|. void MakeCurrent(int window_id); + MessageLoop* message_loop_; int width_; int height_; @@ -112,25 +144,24 @@ class RenderingHelperGL : public RenderingHelper { }; // static +const gfx::GLImplementation RenderingHelperGL::kGLImplementation = +#if defined(GL_VARIANT_GLX) + gfx::kGLImplementationDesktopGL; +#elif defined(GL_VARIANT_EGL) + gfx::kGLImplementationEGLGLES2; +#else + -1; +#error "Unknown GL implementation." +#endif + +// static RenderingHelper* RenderingHelper::Create() { return new RenderingHelperGL; } // static void RenderingHelper::InitializePlatform() { -#if defined(OS_WIN) - gfx::InitializeGLBindings(gfx::kGLImplementationEGLGLES2); - gfx::GLSurface::InitializeOneOff(); - { - // Hack to ensure that EGL extension function pointers are initialized. - scoped_refptr<gfx::GLSurface> surface( - gfx::GLSurface::CreateOffscreenGLSurface(false, gfx::Size(1, 1))); - scoped_refptr<gfx::GLContext> context( - gfx::GLContext::CreateGLContext(NULL, surface.get(), - gfx::PreferIntegratedGpu)); - context->MakeCurrent(surface.get()); - } -#endif // OS_WIN + gfx::InitializeGLBindings(RenderingHelperGL::kGLImplementation); } RenderingHelperGL::RenderingHelperGL() { @@ -175,6 +206,8 @@ void RenderingHelperGL::Initialize(bool suppress_swap_to_display, done.Wait(); } + scoped_refptr<GLContextStubWithExtensions> stub_context( + new GLContextStubWithExtensions()); suppress_swap_to_display_ = suppress_swap_to_display; CHECK_GT(width, 0); CHECK_GT(height, 0); @@ -186,7 +219,6 @@ void RenderingHelperGL::Initialize(bool suppress_swap_to_display, #if GL_VARIANT_GLX x_display_ = base::MessagePumpForUI::GetDefaultXDisplay(); CHECK(x_display_); - gfx::InitializeGLBindings(gfx::kGLImplementationDesktopGL); CHECK(glXQueryVersion(x_display_, NULL, NULL)); const int fbconfig_attr[] = { GLX_DRAWABLE_TYPE, GLX_WINDOW_BIT, @@ -206,19 +238,24 @@ void RenderingHelperGL::Initialize(bool suppress_swap_to_display, CHECK(x_visual_); gl_context_ = glXCreateContext(x_display_, x_visual_, 0, true); CHECK(gl_context_); + stub_context->AddExtensionsString( + reinterpret_cast<const char*>(glGetString(GL_EXTENSIONS))); #else // EGL + EGLNativeDisplayType native_display; + #if defined(OS_WIN) - gl_display_ = eglGetDisplay(EGL_DEFAULT_DISPLAY); - CHECK(gl_display_); - CHECK(eglInitialize(gl_display_, NULL, NULL)) << glGetError(); + native_display = EGL_DEFAULT_DISPLAY; #else x_display_ = base::MessagePumpForUI::GetDefaultXDisplay(); CHECK(x_display_); - gl_display_ = eglGetDisplay(x_display_); + native_display = x_display_; +#endif + + gl_display_ = eglGetDisplay(native_display); CHECK(gl_display_); CHECK(eglInitialize(gl_display_, NULL, NULL)) << glGetError(); -#endif + static EGLint rgba8888[] = { EGL_RED_SIZE, 8, EGL_GREEN_SIZE, 8, @@ -236,6 +273,10 @@ void RenderingHelperGL::Initialize(bool suppress_swap_to_display, gl_context_ = eglCreateContext( gl_display_, egl_config, EGL_NO_CONTEXT, context_attribs); CHECK_NE(gl_context_, EGL_NO_CONTEXT) << eglGetError(); + stub_context->AddExtensionsString( + reinterpret_cast<const char*>(glGetString(GL_EXTENSIONS))); + stub_context->AddExtensionsString( + eglQueryString(gl_display_, EGL_EXTENSIONS)); #endif // Per-window/surface X11 & EGL initialization. @@ -285,6 +326,9 @@ void RenderingHelperGL::Initialize(bool suppress_swap_to_display, MakeCurrent(i); } + // Must be done after a context is made current. + gfx::InitializeGLExtensionBindings(kGLImplementation, stub_context.get()); + static const float kVertices[] = { -1.f, 1.f, -1.f, -1.f, 1.f, 1.f, 1.f, -1.f, }; static const float kTextureCoords[] = { 0, 1, 0, 0, 1, 1, 1, 0, }; diff --git a/content/common/gpu/media/rendering_helper_mac.mm b/content/common/gpu/media/rendering_helper_mac.mm index bcecd0b..1a58646 100644 --- a/content/common/gpu/media/rendering_helper_mac.mm +++ b/content/common/gpu/media/rendering_helper_mac.mm @@ -5,7 +5,6 @@ #include "content/common/gpu/media/rendering_helper.h" #import <Cocoa/Cocoa.h> -#import <OpenGL/gl.h> #import <OpenGL/CGLMacro.h> #include "base/mac/scoped_nsautorelease_pool.h" diff --git a/content/common/gpu/media/vaapi_video_decode_accelerator.h b/content/common/gpu/media/vaapi_video_decode_accelerator.h index 140eb12..f1cd07a 100644 --- a/content/common/gpu/media/vaapi_video_decode_accelerator.h +++ b/content/common/gpu/media/vaapi_video_decode_accelerator.h @@ -8,8 +8,6 @@ #ifndef CONTENT_COMMON_GPU_MEDIA_VAAPI_VIDEO_DECODE_ACCELERATOR_H_ #define CONTENT_COMMON_GPU_MEDIA_VAAPI_VIDEO_DECODE_ACCELERATOR_H_ -#include <GL/glx.h> - #include <queue> #include <utility> #include <vector> @@ -28,6 +26,7 @@ #include "media/base/bitstream_buffer.h" #include "media/video/picture.h" #include "media/video/video_decode_accelerator.h" +#include "ui/gl/gl_bindings.h" namespace content { |