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

Side by Side Diff: ui/gl/init/gl_factory_x11.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_win.cc ('k') | no next file » | 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/trace_event/trace_event.h" 7 #include "base/trace_event/trace_event.h"
8 #include "ui/gl/gl_context.h" 8 #include "ui/gl/gl_context.h"
9 #include "ui/gl/gl_context_egl.h" 9 #include "ui/gl/gl_context_egl.h"
10 #include "ui/gl/gl_context_glx.h" 10 #include "ui/gl/gl_context_glx.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_egl_x11.h"
18 #include "ui/gl/gl_surface_glx.h"
19 #include "ui/gl/gl_surface_osmesa.h"
20 #include "ui/gl/gl_surface_osmesa_x11.h"
21 #include "ui/gl/gl_surface_stub.h"
16 22
17 namespace gl { 23 namespace gl {
18 namespace init { 24 namespace init {
19 25
20 scoped_refptr<GLContext> CreateGLContext(GLShareGroup* share_group, 26 scoped_refptr<GLContext> CreateGLContext(GLShareGroup* share_group,
21 GLSurface* compatible_surface, 27 GLSurface* compatible_surface,
22 GpuPreference gpu_preference) { 28 GpuPreference gpu_preference) {
23 TRACE_EVENT0("gpu", "gl::init::CreateGLContext"); 29 TRACE_EVENT0("gpu", "gl::init::CreateGLContext");
24 switch (GetGLImplementation()) { 30 switch (GetGLImplementation()) {
25 case kGLImplementationOSMesaGL: 31 case kGLImplementationOSMesaGL:
26 return InitializeGLContext(new GLContextOSMesa(share_group), 32 return InitializeGLContext(new GLContextOSMesa(share_group),
27 compatible_surface, gpu_preference); 33 compatible_surface, gpu_preference);
28 case kGLImplementationDesktopGL: 34 case kGLImplementationDesktopGL:
29 return InitializeGLContext(new GLContextGLX(share_group), 35 return InitializeGLContext(new GLContextGLX(share_group),
30 compatible_surface, gpu_preference); 36 compatible_surface, gpu_preference);
31 case kGLImplementationEGLGLES2: 37 case kGLImplementationEGLGLES2:
32 return InitializeGLContext(new GLContextEGL(share_group), 38 return InitializeGLContext(new GLContextEGL(share_group),
33 compatible_surface, gpu_preference); 39 compatible_surface, gpu_preference);
34 case kGLImplementationMockGL: 40 case kGLImplementationMockGL:
35 return new GLContextStub(share_group); 41 return new GLContextStub(share_group);
36 default: 42 default:
37 NOTREACHED(); 43 NOTREACHED();
38 return nullptr; 44 return nullptr;
39 } 45 }
40 } 46 }
41 47
48 scoped_refptr<GLSurface> CreateViewGLSurface(gfx::AcceleratedWidget window) {
49 TRACE_EVENT0("gpu", "gl::init::CreateViewGLSurface");
50 switch (GetGLImplementation()) {
51 case kGLImplementationOSMesaGL:
52 return InitializeGLSurface(new GLSurfaceOSMesaX11(window));
53 case kGLImplementationDesktopGL:
54 return InitializeGLSurface(new NativeViewGLSurfaceGLX(window));
55 case kGLImplementationEGLGLES2:
56 DCHECK(window != gfx::kNullAcceleratedWidget);
57 return InitializeGLSurface(new NativeViewGLSurfaceEGLX11(window));
58 case kGLImplementationMockGL:
59 return new GLSurfaceStub;
60 default:
61 NOTREACHED();
62 return nullptr;
63 }
64 }
65
66 scoped_refptr<GLSurface> CreateOffscreenGLSurface(const gfx::Size& size) {
67 TRACE_EVENT0("gpu", "gl::init::CreateOffscreenGLSurface");
68 switch (GetGLImplementation()) {
69 case kGLImplementationOSMesaGL:
70 return InitializeGLSurface(
71 new GLSurfaceOSMesa(GLSurface::SURFACE_OSMESA_RGBA, size));
72 case kGLImplementationDesktopGL:
73 return InitializeGLSurface(new UnmappedNativeViewGLSurfaceGLX(size));
74 case kGLImplementationEGLGLES2:
75 return InitializeGLSurface(new PbufferGLSurfaceEGL(size));
76 case kGLImplementationMockGL:
77 return new GLSurfaceStub;
78 default:
79 NOTREACHED();
80 return nullptr;
81 }
82 }
83
42 } // namespace init 84 } // namespace init
43 } // namespace gl 85 } // namespace gl
OLDNEW
« no previous file with comments | « ui/gl/init/gl_factory_win.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698