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

Side by Side Diff: ui/gl/init/gl_factory_ozone.cc

Issue 2047283003: Move GLSurface creation from //ui/gl to //ui/gl/init. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@gl_context
Patch Set: Fix Ozone CreateViewGLSurface logic. Created 4 years, 6 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 unified diff | Download patch
« no previous file with comments | « ui/gl/init/gl_factory_mac.cc ('k') | ui/gl/init/gl_factory_win.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ui/gl/init/gl_factory.h" 5 #include "ui/gl/init/gl_factory.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/trace_event/trace_event.h" 8 #include "base/trace_event/trace_event.h"
9 #include "ui/gl/gl_context.h" 9 #include "ui/gl/gl_context.h"
10 #include "ui/gl/gl_context_egl.h" 10 #include "ui/gl/gl_context_egl.h"
11 #include "ui/gl/gl_context_osmesa.h" 11 #include "ui/gl/gl_context_osmesa.h"
12 #include "ui/gl/gl_context_stub.h" 12 #include "ui/gl/gl_context_stub.h"
13 #include "ui/gl/gl_implementation.h" 13 #include "ui/gl/gl_implementation.h"
14 #include "ui/gl/gl_share_group.h" 14 #include "ui/gl/gl_share_group.h"
15 #include "ui/gl/gl_surface.h" 15 #include "ui/gl/gl_surface.h"
16 #include "ui/gl/gl_surface_egl.h"
17 #include "ui/gl/gl_surface_osmesa.h"
18 #include "ui/gl/gl_surface_ozone.h"
19 #include "ui/gl/gl_surface_stub.h"
20 #include "ui/ozone/public/ozone_platform.h"
21 #include "ui/ozone/public/surface_factory_ozone.h"
22 #include "ui/ozone/public/surface_ozone_egl.h"
16 23
17 namespace gl { 24 namespace gl {
18 namespace init { 25 namespace init {
19 26
20 scoped_refptr<GLContext> CreateGLContext(GLShareGroup* share_group, 27 scoped_refptr<GLContext> CreateGLContext(GLShareGroup* share_group,
21 GLSurface* compatible_surface, 28 GLSurface* compatible_surface,
22 GpuPreference gpu_preference) { 29 GpuPreference gpu_preference) {
23 TRACE_EVENT0("gpu", "gl::init::CreateGLContext"); 30 TRACE_EVENT0("gpu", "gl::init::CreateGLContext");
24 switch (GetGLImplementation()) { 31 switch (GetGLImplementation()) {
25 case kGLImplementationMockGL: 32 case kGLImplementationMockGL:
26 return scoped_refptr<GLContext>(new GLContextStub(share_group)); 33 return scoped_refptr<GLContext>(new GLContextStub(share_group));
27 case kGLImplementationOSMesaGL: 34 case kGLImplementationOSMesaGL:
28 return InitializeGLContext(new GLContextOSMesa(share_group), 35 return InitializeGLContext(new GLContextOSMesa(share_group),
29 compatible_surface, gpu_preference); 36 compatible_surface, gpu_preference);
30 case kGLImplementationEGLGLES2: 37 case kGLImplementationEGLGLES2:
31 return InitializeGLContext(new GLContextEGL(share_group), 38 return InitializeGLContext(new GLContextEGL(share_group),
32 compatible_surface, gpu_preference); 39 compatible_surface, gpu_preference);
33 40
34 default: 41 default:
35 NOTREACHED(); 42 NOTREACHED();
36 return nullptr; 43 return nullptr;
37 } 44 }
38 } 45 }
39 46
47 scoped_refptr<GLSurface> CreateViewGLSurface(gfx::AcceleratedWidget window) {
48 TRACE_EVENT0("gpu", "gl::init::CreateViewGLSurface");
49 switch (GetGLImplementation()) {
50 case kGLImplementationOSMesaGL:
51 return InitializeGLSurface(new GLSurfaceOSMesaHeadless());
52 case kGLImplementationEGLGLES2: {
53 DCHECK_NE(window, gfx::kNullAcceleratedWidget);
54 scoped_refptr<GLSurface> surface;
55 if (GLSurfaceEGL::IsEGLSurfacelessContextSupported())
56 surface = CreateViewGLSurfaceOzoneSurfacelessSurfaceImpl(window);
57 if (!surface)
58 surface = CreateViewGLSurfaceOzone(window);
59 return surface;
60 }
61 case kGLImplementationMockGL:
62 return InitializeGLSurface(new GLSurfaceStub());
63 default:
64 NOTREACHED();
65 return nullptr;
66 }
67 }
68
69 scoped_refptr<GLSurface> CreateSurfacelessViewGLSurface(
70 gfx::AcceleratedWidget window) {
71 TRACE_EVENT0("gpu", "gl::init::CreateSurfacelessViewGLSurface");
72 if (GetGLImplementation() == kGLImplementationEGLGLES2 &&
73 window != gfx::kNullAcceleratedWidget &&
74 GLSurfaceEGL::IsEGLSurfacelessContextSupported()) {
75 return CreateViewGLSurfaceOzoneSurfaceless(window);
76 }
77 return nullptr;
78 }
79
80 scoped_refptr<GLSurface> CreateOffscreenGLSurface(const gfx::Size& size) {
81 TRACE_EVENT0("gpu", "gl::init::CreateOffscreenGLSurface");
82 switch (GetGLImplementation()) {
83 case kGLImplementationOSMesaGL:
84 return InitializeGLSurface(
85 new GLSurfaceOSMesa(GLSurface::SURFACE_OSMESA_BGRA, size));
86 case kGLImplementationEGLGLES2:
87 if (GLSurfaceEGL::IsEGLSurfacelessContextSupported() &&
88 (size.width() == 0 && size.height() == 0)) {
89 return InitializeGLSurface(new SurfacelessEGL(size));
90 } else {
91 return InitializeGLSurface(new PbufferGLSurfaceEGL(size));
92 }
93 case kGLImplementationMockGL:
94 return new GLSurfaceStub;
95 default:
96 NOTREACHED();
97 return nullptr;
98 }
99 }
100
40 } // namespace init 101 } // namespace init
41 } // namespace gl 102 } // namespace gl
OLDNEW
« no previous file with comments | « ui/gl/init/gl_factory_mac.cc ('k') | ui/gl/init/gl_factory_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698