0

Add callbacks to register EGL bindings from Ozone

Ozone needs to provide a custom way to load EGL and GLES2 bindings. Since Ozone
lives in ui/gfx/ozone it cannot have dependencies to ui/gl to register the
libraries.

This patch adds to callbacks to Ozone's LoadEGLGLES2Bindings function such that
when performing GL bindings initialization ui/gl will provide the callbacks to
register the bindings.

BUG=

Review URL: https://codereview.chromium.org/47213009

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@231893 0039d316-1c4b-4281-b951-d872f2087c98
This commit is contained in:
dnicoara@chromium.org
2013-10-30 19:23:27 +00:00
parent 914bcd8860
commit 4f8a62e9ba
7 changed files with 33 additions and 8 deletions

@ -55,7 +55,9 @@ AcceleratedWidget FileSurfaceFactoryOzone::RealizeAcceleratedWidget(
return 1;
}
bool FileSurfaceFactoryOzone::LoadEGLGLES2Bindings() {
bool FileSurfaceFactoryOzone::LoadEGLGLES2Bindings(
AddGLLibraryCallback add_gl_library,
SetGLGetProcAddressProcCallback set_gl_get_proc_address) {
return false;
}

@ -28,7 +28,9 @@ class FileSurfaceFactoryOzone : public SurfaceFactoryOzone {
virtual AcceleratedWidget GetAcceleratedWidget() OVERRIDE;
virtual AcceleratedWidget RealizeAcceleratedWidget(
AcceleratedWidget widget) OVERRIDE;
virtual bool LoadEGLGLES2Bindings() OVERRIDE;
virtual bool LoadEGLGLES2Bindings(
AddGLLibraryCallback add_gl_library,
SetGLGetProcAddressProcCallback set_gl_get_proc_address) OVERRIDE;
virtual bool AttemptToResizeAcceleratedWidget(AcceleratedWidget widget,
const Rect& bounds) OVERRIDE;
virtual bool SchedulePageFlip(AcceleratedWidget widget) OVERRIDE;

@ -186,7 +186,9 @@ gfx::AcceleratedWidget SoftwareSurfaceFactoryOzone::RealizeAcceleratedWidget(
return reinterpret_cast<gfx::AcceleratedWidget>(controller_->get_surface());
}
bool SoftwareSurfaceFactoryOzone::LoadEGLGLES2Bindings() {
bool SoftwareSurfaceFactoryOzone::LoadEGLGLES2Bindings(
AddGLLibraryCallback add_gl_library,
SetGLGetProcAddressProcCallback set_gl_get_proc_address) {
return false;
}

@ -29,7 +29,9 @@ class SoftwareSurfaceFactoryOzone : public SurfaceFactoryOzone {
virtual gfx::AcceleratedWidget RealizeAcceleratedWidget(
gfx::AcceleratedWidget w) OVERRIDE;
virtual bool LoadEGLGLES2Bindings() OVERRIDE;
virtual bool LoadEGLGLES2Bindings(
AddGLLibraryCallback add_gl_library,
SetGLGetProcAddressProcCallback set_gl_get_proc_address) OVERRIDE;
virtual bool AttemptToResizeAcceleratedWidget(
gfx::AcceleratedWidget w,

@ -27,7 +27,11 @@ class SurfaceFactoryOzoneStub : public SurfaceFactoryOzone {
gfx::AcceleratedWidget w) OVERRIDE {
return 0;
}
virtual bool LoadEGLGLES2Bindings() OVERRIDE { return true; }
virtual bool LoadEGLGLES2Bindings(
AddGLLibraryCallback add_gl_library,
SetGLGetProcAddressProcCallback set_gl_get_proc_address) OVERRIDE {
return true;
}
virtual bool AttemptToResizeAcceleratedWidget(
gfx::AcceleratedWidget w,
const gfx::Rect& bounds) OVERRIDE {

@ -5,6 +5,8 @@
#ifndef UI_GFX_OZONE_SURFACE_LNUX_FACTORY_OZONE_H_
#define UI_GFX_OZONE_SURFACE_LNUX_FACTORY_OZONE_H_
#include "base/callback.h"
#include "base/native_library.h"
#include "ui/gfx/gfx_export.h"
#include "ui/gfx/native_widget_types.h"
#include "ui/gfx/rect.h"
@ -51,6 +53,11 @@ class GFX_EXPORT SurfaceFactoryOzone {
FAILED,
};
typedef void*(*GLGetProcAddressProc)(const char* name);
typedef base::Callback<void(base::NativeLibrary)> AddGLLibraryCallback;
typedef base::Callback<void(GLGetProcAddressProc)>
SetGLGetProcAddressProcCallback;
SurfaceFactoryOzone();
virtual ~SurfaceFactoryOzone();
@ -91,8 +98,11 @@ class GFX_EXPORT SurfaceFactoryOzone {
virtual gfx::AcceleratedWidget RealizeAcceleratedWidget(
gfx::AcceleratedWidget w) = 0;
// Sets up GL bindings for the native surface.
virtual bool LoadEGLGLES2Bindings() = 0;
// Sets up GL bindings for the native surface. Takes two callback parameters
// that allow Ozone to register the GL bindings.
virtual bool LoadEGLGLES2Bindings(
AddGLLibraryCallback add_gl_library,
SetGLGetProcAddressProcCallback set_gl_get_proc_address) = 0;
// If possible attempts to resize the given AcceleratedWidget instance and if
// a resize action was performed returns true, otherwise false (native

@ -2,6 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "base/bind.h"
#include "ui/gfx/ozone/surface_factory_ozone.h"
#include "ui/gl/gl_bindings.h"
#include "ui/gl/gl_egl_api_implementation.h"
@ -41,7 +42,9 @@ bool InitializeGLBindings(GLImplementation implementation) {
case kGLImplementationOSMesaGL:
return InitializeGLBindingsOSMesaGL();
case kGLImplementationEGLGLES2:
if (!gfx::SurfaceFactoryOzone::GetInstance()->LoadEGLGLES2Bindings())
if (!gfx::SurfaceFactoryOzone::GetInstance()->LoadEGLGLES2Bindings(
base::Bind(&AddGLNativeLibrary),
base::Bind(&SetGLGetProcAddressProc)))
return false;
SetGLImplementation(kGLImplementationEGLGLES2);
InitializeGLBindingsGL();