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 d71867cf53e48091efd5d18fa6d5ae694840a0a9..dfa73b1cd89b95d3f6c372326a922cf1b60f92ed 100644 |
| --- a/ui/gl/gl_surface_ozone.cc |
| +++ b/ui/gl/gl_surface_ozone.cc |
| @@ -89,7 +89,6 @@ class GL_EXPORT GLSurfaceOzoneEGL : public NativeViewGLSurfaceEGL { |
| return true; |
| } |
| - |
| // The native surface. Deleting this is allowed to free the EGLNativeWindow. |
| scoped_ptr<ui::SurfaceOzoneEGL> ozone_surface_; |
| AcceleratedWidget widget_; |
| @@ -97,6 +96,70 @@ class GL_EXPORT GLSurfaceOzoneEGL : public NativeViewGLSurfaceEGL { |
| DISALLOW_COPY_AND_ASSIGN(GLSurfaceOzoneEGL); |
| }; |
| +class GL_EXPORT GLSurfaceOzoneSurfaceless : public SurfacelessEGL { |
|
dnicoara
2014/08/26 00:13:21
I'm wondering if you should also override IsOffscr
achaulk
2014/08/26 00:35:58
Hmm, might be a good idea yeah
|
| + public: |
| + GLSurfaceOzoneSurfaceless(scoped_ptr<ui::SurfaceOzoneEGL> ozone_surface, |
| + AcceleratedWidget widget, |
| + const gfx::Size& size) |
| + : SurfacelessEGL(size), |
| + ozone_surface_(ozone_surface.Pass()), |
| + widget_(widget) {} |
| + |
| + virtual bool Resize(const gfx::Size& size) OVERRIDE { |
| + if (!ozone_surface_->ResizeNativeWindow(size)) { |
| + if (!ReinitializeNativeSurface() || |
|
dnicoara
2014/08/26 00:13:21
This is mostly a hack for the surface case. On sur
achaulk
2014/08/26 00:35:58
Sounds good. It was working without all of this, I
|
| + !ozone_surface_->ResizeNativeWindow(size)) |
| + return false; |
| + } |
| + |
| + return SurfacelessEGL::Resize(size); |
| + } |
| + virtual bool SwapBuffers() OVERRIDE { |
| + return ozone_surface_->OnSwapBuffers(); |
| + } |
| + virtual bool ScheduleOverlayPlane(int z_order, |
| + OverlayTransform transform, |
| + GLImage* image, |
| + const Rect& bounds_rect, |
| + const RectF& crop_rect) OVERRIDE { |
| + return image->ScheduleOverlayPlane( |
| + widget_, z_order, transform, bounds_rect, crop_rect); |
| + } |
| + |
| + private: |
| + bool ReinitializeNativeSurface() { |
| + scoped_ptr<ui::ScopedMakeCurrent> scoped_make_current; |
| + GLContext* current_context = GLContext::GetCurrent(); |
| + bool was_current = current_context && current_context->IsCurrent(this); |
| + if (was_current) { |
| + scoped_make_current.reset( |
| + new ui::ScopedMakeCurrent(current_context, this)); |
| + } |
| + |
| + Destroy(); |
| + ozone_surface_ = ui::SurfaceFactoryOzone::GetInstance() |
| + ->CreateSurfacelessEGLSurfaceForWidget(widget_) |
| + .Pass(); |
| + if (!ozone_surface_) { |
| + LOG(ERROR) << "Failed to create native surface."; |
| + return false; |
| + } |
| + |
| + if (!Initialize()) { |
| + LOG(ERROR) << "Failed to initialize."; |
| + return false; |
| + } |
| + |
| + return true; |
| + } |
| + |
| + // The native surface. Deleting this is allowed to free the EGLNativeWindow. |
| + scoped_ptr<ui::SurfaceOzoneEGL> ozone_surface_; |
| + AcceleratedWidget widget_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(GLSurfaceOzoneSurfaceless); |
| +}; |
| + |
| } // namespace |
| // static |
| @@ -128,6 +191,21 @@ scoped_refptr<GLSurface> GLSurface::CreateViewGLSurface( |
| } |
| DCHECK(GetGLImplementation() == kGLImplementationEGLGLES2); |
| if (window != kNullAcceleratedWidget) { |
| + if (GLSurfaceEGL::IsEGLSurfacelessContextSupported() && |
| + ui::SurfaceFactoryOzone::GetInstance() |
| + ->CanShowPrimaryPlaneAsOverlay()) { |
| + scoped_ptr<ui::SurfaceOzoneEGL> surface_ozone = |
| + ui::SurfaceFactoryOzone::GetInstance() |
| + ->CreateSurfacelessEGLSurfaceForWidget(window); |
| + if (!surface_ozone) |
| + return NULL; |
| + scoped_refptr<GLSurfaceOzoneSurfaceless> surface = |
| + new GLSurfaceOzoneSurfaceless( |
| + surface_ozone.Pass(), window, gfx::Size()); |
| + if (!surface->Initialize()) |
| + return NULL; |
| + return surface; |
| + } |
| scoped_ptr<ui::SurfaceOzoneEGL> surface_ozone = |
| ui::SurfaceFactoryOzone::GetInstance()->CreateEGLSurfaceForWidget( |
| window); |