Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(627)

Unified Diff: ui/gl/init/gl_factory_ozone.cc

Issue 2156503003: Have Ozone X11 directly create GLSurfaces. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@new_ozone_gl
Patch Set: Rebase. Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ui/gl/init/OWNERS ('k') | ui/ozone/platform/x11/BUILD.gn » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/gl/init/gl_factory_ozone.cc
diff --git a/ui/gl/init/gl_factory_ozone.cc b/ui/gl/init/gl_factory_ozone.cc
index 097f249a6b8b8b9d18adb8a6b1fb2f428348ed63..9df9e01482231b4412da94ea47e720220663cb7b 100644
--- a/ui/gl/init/gl_factory_ozone.cc
+++ b/ui/gl/init/gl_factory_ozone.cc
@@ -24,48 +24,114 @@
namespace gl {
namespace init {
-scoped_refptr<GLContext> CreateGLContext(GLShareGroup* share_group,
- GLSurface* compatible_surface,
- GpuPreference gpu_preference) {
- TRACE_EVENT0("gpu", "gl::init::CreateGLContext");
+namespace {
+
+ui::SurfaceFactoryOzone* GetSurfaceFactory() {
+ return ui::OzonePlatform::GetInstance()->GetSurfaceFactoryOzone();
+}
+
+bool HasDefaultImplementation(GLImplementation impl) {
+ return impl == kGLImplementationOSMesaGL || impl == kGLImplementationMockGL;
+}
+
+scoped_refptr<GLSurface> CreateDefaultViewGLSurface(
+ gfx::AcceleratedWidget window) {
switch (GetGLImplementation()) {
- case kGLImplementationMockGL:
- return scoped_refptr<GLContext>(new GLContextStub(share_group));
case kGLImplementationOSMesaGL:
- return InitializeGLContext(new GLContextOSMesa(share_group),
- compatible_surface, gpu_preference);
- case kGLImplementationEGLGLES2:
- return InitializeGLContext(new GLContextEGL(share_group),
- compatible_surface, gpu_preference);
-
+ return InitializeGLSurface(new GLSurfaceOSMesaHeadless());
+ case kGLImplementationMockGL:
+ return InitializeGLSurface(new GLSurfaceStub());
default:
NOTREACHED();
- return nullptr;
}
+ return nullptr;
}
-scoped_refptr<GLSurface> CreateViewGLSurface(gfx::AcceleratedWidget window) {
- TRACE_EVENT0("gpu", "gl::init::CreateViewGLSurface");
+scoped_refptr<GLSurface> CreateDefaultOffscreenGLSurface(
+ const gfx::Size& size) {
switch (GetGLImplementation()) {
case kGLImplementationOSMesaGL:
- return InitializeGLSurface(new GLSurfaceOSMesaHeadless());
+ return InitializeGLSurface(
+ new GLSurfaceOSMesa(GLSurface::SURFACE_OSMESA_BGRA, size));
+ case kGLImplementationMockGL:
+ return InitializeGLSurface(new GLSurfaceStub);
+ default:
+ NOTREACHED();
+ }
+ return nullptr;
+}
+
+// TODO(kylechar): Remove when all implementations are switched over.
+scoped_refptr<GLSurface> CreateViewGLSurfaceOld(gfx::AcceleratedWidget window) {
+ switch (GetGLImplementation()) {
case kGLImplementationEGLGLES2: {
DCHECK_NE(window, gfx::kNullAcceleratedWidget);
scoped_refptr<GLSurface> surface;
- if (GLSurfaceEGL::IsEGLSurfacelessContextSupported())
+ if (!surface && GLSurfaceEGL::IsEGLSurfacelessContextSupported())
surface = CreateViewGLSurfaceOzoneSurfacelessSurfaceImpl(window);
if (!surface)
surface = CreateViewGLSurfaceOzone(window);
return surface;
}
+ default:
+ NOTREACHED();
+ return nullptr;
+ }
+}
+
+// TODO(kylechar): Remove when all implementations are switched over.
+scoped_refptr<GLSurface> CreateOffscreenGLSurfaceOld(const gfx::Size& size) {
+ switch (GetGLImplementation()) {
+ case kGLImplementationEGLGLES2:
+ if (GLSurfaceEGL::IsEGLSurfacelessContextSupported() &&
+ (size.width() == 0 && size.height() == 0)) {
+ return InitializeGLSurface(new SurfacelessEGL(size));
+ } else {
+ return InitializeGLSurface(new PbufferGLSurfaceEGL(size));
+ }
+ default:
+ NOTREACHED();
+ }
+ return nullptr;
+}
+
+} // namespace
+
+scoped_refptr<GLContext> CreateGLContext(GLShareGroup* share_group,
+ GLSurface* compatible_surface,
+ GpuPreference gpu_preference) {
+ TRACE_EVENT0("gpu", "gl::init::CreateGLContext");
+ switch (GetGLImplementation()) {
case kGLImplementationMockGL:
- return InitializeGLSurface(new GLSurfaceStub());
+ return scoped_refptr<GLContext>(new GLContextStub(share_group));
+ case kGLImplementationOSMesaGL:
+ return InitializeGLContext(new GLContextOSMesa(share_group),
+ compatible_surface, gpu_preference);
+ case kGLImplementationEGLGLES2:
+ return InitializeGLContext(new GLContextEGL(share_group),
+ compatible_surface, gpu_preference);
+
default:
NOTREACHED();
return nullptr;
}
}
+scoped_refptr<GLSurface> CreateViewGLSurface(gfx::AcceleratedWidget window) {
+ TRACE_EVENT0("gpu", "gl::init::CreateViewGLSurface");
+
+ if (HasDefaultImplementation(GetGLImplementation()))
+ return CreateDefaultViewGLSurface(window);
+
+ // TODO(kylechar): This is deprecated, remove when possible.
+ if (!GetSurfaceFactory()->UseNewSurfaceAPI())
+ return CreateViewGLSurfaceOld(window);
+
+ return GetSurfaceFactory()->CreateViewGLSurface(GetGLImplementation(),
+ window);
+}
+
+// TODO(kylechar): Update to use new API.
scoped_refptr<GLSurface> CreateSurfacelessViewGLSurface(
gfx::AcceleratedWidget window) {
TRACE_EVENT0("gpu", "gl::init::CreateSurfacelessViewGLSurface");
@@ -79,23 +145,16 @@ scoped_refptr<GLSurface> CreateSurfacelessViewGLSurface(
scoped_refptr<GLSurface> CreateOffscreenGLSurface(const gfx::Size& size) {
TRACE_EVENT0("gpu", "gl::init::CreateOffscreenGLSurface");
- switch (GetGLImplementation()) {
- case kGLImplementationOSMesaGL:
- return InitializeGLSurface(
- new GLSurfaceOSMesa(GLSurface::SURFACE_OSMESA_BGRA, size));
- case kGLImplementationEGLGLES2:
- if (GLSurfaceEGL::IsEGLSurfacelessContextSupported() &&
- (size.width() == 0 && size.height() == 0)) {
- return InitializeGLSurface(new SurfacelessEGL(size));
- } else {
- return InitializeGLSurface(new PbufferGLSurfaceEGL(size));
- }
- case kGLImplementationMockGL:
- return new GLSurfaceStub;
- default:
- NOTREACHED();
- return nullptr;
- }
+
+ if (HasDefaultImplementation(GetGLImplementation()))
+ return CreateDefaultOffscreenGLSurface(size);
+
+ // TODO(kylechar): This is deprecated, remove when possible.
+ if (!GetSurfaceFactory()->UseNewSurfaceAPI())
+ return CreateOffscreenGLSurfaceOld(size);
+
+ return GetSurfaceFactory()->CreateOffscreenGLSurface(GetGLImplementation(),
+ size);
}
} // namespace init
« no previous file with comments | « ui/gl/init/OWNERS ('k') | ui/ozone/platform/x11/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698