Commit e79d5d85 authored by achaulk's avatar achaulk Committed by Commit bot

Surfaceless GLSurfaceOzone implementation.

BUG=380861
NOTRY=true

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

Cr-Commit-Position: refs/heads/master@{#292048}
parent cf244d18
...@@ -30,6 +30,9 @@ class GL_EXPORT GLSurfaceOzoneEGL : public NativeViewGLSurfaceEGL { ...@@ -30,6 +30,9 @@ class GL_EXPORT GLSurfaceOzoneEGL : public NativeViewGLSurfaceEGL {
ozone_surface_(ozone_surface.Pass()), ozone_surface_(ozone_surface.Pass()),
widget_(widget) {} widget_(widget) {}
virtual bool Initialize() OVERRIDE {
return Initialize(ozone_surface_->CreateVSyncProvider());
}
virtual bool Resize(const gfx::Size& size) OVERRIDE { virtual bool Resize(const gfx::Size& size) OVERRIDE {
if (!ozone_surface_->ResizeNativeWindow(size)) { if (!ozone_surface_->ResizeNativeWindow(size)) {
if (!ReinitializeNativeSurface() || if (!ReinitializeNativeSurface() ||
...@@ -55,6 +58,8 @@ class GL_EXPORT GLSurfaceOzoneEGL : public NativeViewGLSurfaceEGL { ...@@ -55,6 +58,8 @@ class GL_EXPORT GLSurfaceOzoneEGL : public NativeViewGLSurfaceEGL {
} }
private: private:
using NativeViewGLSurfaceEGL::Initialize;
virtual ~GLSurfaceOzoneEGL() { virtual ~GLSurfaceOzoneEGL() {
Destroy(); // EGL surface must be destroyed before SurfaceOzone Destroy(); // EGL surface must be destroyed before SurfaceOzone
} }
...@@ -79,9 +84,7 @@ class GL_EXPORT GLSurfaceOzoneEGL : public NativeViewGLSurfaceEGL { ...@@ -79,9 +84,7 @@ class GL_EXPORT GLSurfaceOzoneEGL : public NativeViewGLSurfaceEGL {
} }
window_ = ozone_surface_->GetNativeWindow(); window_ = ozone_surface_->GetNativeWindow();
scoped_ptr<VSyncProvider> vsync_provider = if (!Initialize()) {
ozone_surface_->CreateVSyncProvider();
if (!Initialize(vsync_provider.Pass())) {
LOG(ERROR) << "Failed to initialize."; LOG(ERROR) << "Failed to initialize.";
return false; return false;
} }
...@@ -89,7 +92,6 @@ class GL_EXPORT GLSurfaceOzoneEGL : public NativeViewGLSurfaceEGL { ...@@ -89,7 +92,6 @@ class GL_EXPORT GLSurfaceOzoneEGL : public NativeViewGLSurfaceEGL {
return true; return true;
} }
// The native surface. Deleting this is allowed to free the EGLNativeWindow. // The native surface. Deleting this is allowed to free the EGLNativeWindow.
scoped_ptr<ui::SurfaceOzoneEGL> ozone_surface_; scoped_ptr<ui::SurfaceOzoneEGL> ozone_surface_;
AcceleratedWidget widget_; AcceleratedWidget widget_;
...@@ -97,6 +99,57 @@ class GL_EXPORT GLSurfaceOzoneEGL : public NativeViewGLSurfaceEGL { ...@@ -97,6 +99,57 @@ class GL_EXPORT GLSurfaceOzoneEGL : public NativeViewGLSurfaceEGL {
DISALLOW_COPY_AND_ASSIGN(GLSurfaceOzoneEGL); DISALLOW_COPY_AND_ASSIGN(GLSurfaceOzoneEGL);
}; };
class GL_EXPORT GLSurfaceOzoneSurfaceless : public SurfacelessEGL {
public:
GLSurfaceOzoneSurfaceless(scoped_ptr<ui::SurfaceOzoneEGL> ozone_surface,
AcceleratedWidget widget)
: SurfacelessEGL(gfx::Size()),
ozone_surface_(ozone_surface.Pass()),
widget_(widget) {}
virtual bool Initialize() OVERRIDE {
if (!SurfacelessEGL::Initialize())
return false;
vsync_provider_ = ozone_surface_->CreateVSyncProvider();
if (!vsync_provider_)
return false;
return true;
}
virtual bool Resize(const gfx::Size& size) OVERRIDE {
if (!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);
}
virtual bool IsOffscreen() OVERRIDE { return false; }
virtual VSyncProvider* GetVSyncProvider() OVERRIDE {
return vsync_provider_.get();
}
private:
virtual ~GLSurfaceOzoneSurfaceless() {
Destroy(); // EGL surface must be destroyed before SurfaceOzone
}
// The native surface. Deleting this is allowed to free the EGLNativeWindow.
scoped_ptr<ui::SurfaceOzoneEGL> ozone_surface_;
AcceleratedWidget widget_;
scoped_ptr<VSyncProvider> vsync_provider_;
DISALLOW_COPY_AND_ASSIGN(GLSurfaceOzoneSurfaceless);
};
} // namespace } // namespace
// static // static
...@@ -128,17 +181,26 @@ scoped_refptr<GLSurface> GLSurface::CreateViewGLSurface( ...@@ -128,17 +181,26 @@ scoped_refptr<GLSurface> GLSurface::CreateViewGLSurface(
} }
DCHECK(GetGLImplementation() == kGLImplementationEGLGLES2); DCHECK(GetGLImplementation() == kGLImplementationEGLGLES2);
if (window != kNullAcceleratedWidget) { if (window != kNullAcceleratedWidget) {
scoped_ptr<ui::SurfaceOzoneEGL> surface_ozone = scoped_refptr<GLSurface> surface;
ui::SurfaceFactoryOzone::GetInstance()->CreateEGLSurfaceForWidget( if (GLSurfaceEGL::IsEGLSurfacelessContextSupported() &&
window); ui::SurfaceFactoryOzone::GetInstance()
if (!surface_ozone) ->CanShowPrimaryPlaneAsOverlay()) {
return NULL; scoped_ptr<ui::SurfaceOzoneEGL> surface_ozone =
ui::SurfaceFactoryOzone::GetInstance()
->CreateSurfacelessEGLSurfaceForWidget(window);
if (!surface_ozone)
return NULL;
surface = new GLSurfaceOzoneSurfaceless(surface_ozone.Pass(), window);
} else {
scoped_ptr<ui::SurfaceOzoneEGL> surface_ozone =
ui::SurfaceFactoryOzone::GetInstance()->CreateEGLSurfaceForWidget(
window);
if (!surface_ozone)
return NULL;
scoped_ptr<VSyncProvider> vsync_provider = surface = new GLSurfaceOzoneEGL(surface_ozone.Pass(), window);
surface_ozone->CreateVSyncProvider(); }
scoped_refptr<GLSurfaceOzoneEGL> surface = if (!surface->Initialize())
new GLSurfaceOzoneEGL(surface_ozone.Pass(), window);
if (!surface->Initialize(vsync_provider.Pass()))
return NULL; return NULL;
return surface; return surface;
} else { } else {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment