Chromium Code Reviews| Index: ui/gl/gl_surface_ozone.cc |
| diff --git a/ui/gl/gl_surface_ozone.cc b/ui/gl/gl_surface_ozone.cc |
| index 3e11e926387ba8350515b31e08b6ac2100913a36..c6af58f58b7fe9f74b614558a567dc36946b303f 100644 |
| --- a/ui/gl/gl_surface_ozone.cc |
| +++ b/ui/gl/gl_surface_ozone.cc |
| @@ -8,6 +8,7 @@ |
| #include "base/memory/ref_counted.h" |
| #include "ui/gfx/native_widget_types.h" |
| #include "ui/gfx/ozone/surface_factory_ozone.h" |
| +#include "ui/gfx/ozone/surface_ozone.h" |
| #include "ui/gl/gl_implementation.h" |
| #include "ui/gl/gl_surface_egl.h" |
| #include "ui/gl/gl_surface_osmesa.h" |
| @@ -15,6 +16,28 @@ |
| namespace gfx { |
| +namespace { |
| + |
| +// A thin wrapper around GLSurfaceEGL that owns the EGLNativeWindow |
| +class GL_EXPORT GLSurfaceOzoneEGL : public NativeViewGLSurfaceEGL { |
|
rjkroege
2014/03/26 19:59:02
it bothers me that there is a whole class here who
spang
2014/03/26 22:21:28
The point of SurfaceOzone is that platforms implem
|
| + public: |
| + GLSurfaceOzoneEGL(scoped_ptr<SurfaceOzone> ozone_surface) |
| + : NativeViewGLSurfaceEGL(ozone_surface->GetEGLNativeWindow()), |
| + ozone_surface_(ozone_surface.Pass()) {} |
| + |
| + virtual ~GLSurfaceOzoneEGL() { |
| + Destroy(); // EGL surface must be destroyed before SurfaceOzone |
| + } |
| + |
| + private: |
| + // The native surface. Deleting this is allowed to free the EGLNativeWindow. |
| + scoped_ptr<SurfaceOzone> ozone_surface_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(GLSurfaceOzoneEGL); |
| +}; |
| + |
| +} // namespace |
| + |
| // static |
| bool GLSurface::InitializeOneOffInternal() { |
| switch (GetGLImplementation()) { |
| @@ -40,16 +63,15 @@ scoped_refptr<GLSurface> GLSurface::CreateViewGLSurface( |
| } |
| DCHECK(GetGLImplementation() == kGLImplementationEGLGLES2); |
| if (window != kNullAcceleratedWidget) { |
| - EGLNativeWindowType egl_window = |
| - gfx::SurfaceFactoryOzone::GetInstance()->RealizeAcceleratedWidget( |
| - window); |
| - scoped_ptr<VSyncProvider> sync_provider = |
| - gfx::SurfaceFactoryOzone::GetInstance()->CreateVSyncProvider( |
| - egl_window); |
| - scoped_refptr<NativeViewGLSurfaceEGL> surface = |
| - new NativeViewGLSurfaceEGL(egl_window); |
| - if (surface->Initialize(sync_provider.Pass())) |
| - return surface; |
| + scoped_ptr<SurfaceOzone> surface_ozone = |
| + SurfaceFactoryOzone::GetInstance()->CreateSurfaceForWidget(window); |
| + if (!surface_ozone->InitializeEGL()) |
| + return NULL; |
| + scoped_refptr<GLSurfaceOzoneEGL> surface = |
| + new GLSurfaceOzoneEGL(surface_ozone.Pass()); |
| + if (!surface->Initialize(surface_ozone->CreateVSyncProvider())) |
| + return NULL; |
| + return surface; |
| } else { |
| scoped_refptr<GLSurface> surface = new GLSurfaceStub(); |
| if (surface->Initialize()) |