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

Side by Side Diff: ui/gl/init/gl_factory_win.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_ozone.cc ('k') | ui/gl/init/gl_factory_x11.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_context_wgl.h" 13 #include "ui/gl/gl_context_wgl.h"
14 #include "ui/gl/gl_implementation.h" 14 #include "ui/gl/gl_implementation.h"
15 #include "ui/gl/gl_share_group.h" 15 #include "ui/gl/gl_share_group.h"
16 #include "ui/gl/gl_surface.h" 16 #include "ui/gl/gl_surface.h"
17 #include "ui/gl/gl_surface_egl.h"
18 #include "ui/gl/gl_surface_osmesa.h"
19 #include "ui/gl/gl_surface_osmesa_win.h"
20 #include "ui/gl/gl_surface_stub.h"
21 #include "ui/gl/gl_surface_wgl.h"
22 #include "ui/gl/vsync_provider_win.h"
17 23
18 namespace gl { 24 namespace gl {
19 namespace init { 25 namespace init {
20 26
21 scoped_refptr<GLContext> CreateGLContext(GLShareGroup* share_group, 27 scoped_refptr<GLContext> CreateGLContext(GLShareGroup* share_group,
22 GLSurface* compatible_surface, 28 GLSurface* compatible_surface,
23 GpuPreference gpu_preference) { 29 GpuPreference gpu_preference) {
24 TRACE_EVENT0("gpu", "gl::init::CreateGLContext"); 30 TRACE_EVENT0("gpu", "gl::init::CreateGLContext");
25 switch (GetGLImplementation()) { 31 switch (GetGLImplementation()) {
26 case kGLImplementationOSMesaGL: 32 case kGLImplementationOSMesaGL:
27 return InitializeGLContext(new GLContextOSMesa(share_group), 33 return InitializeGLContext(new GLContextOSMesa(share_group),
28 compatible_surface, gpu_preference); 34 compatible_surface, gpu_preference);
29 case kGLImplementationEGLGLES2: 35 case kGLImplementationEGLGLES2:
30 return InitializeGLContext(new GLContextEGL(share_group), 36 return InitializeGLContext(new GLContextEGL(share_group),
31 compatible_surface, gpu_preference); 37 compatible_surface, gpu_preference);
32 case kGLImplementationDesktopGL: 38 case kGLImplementationDesktopGL:
33 return InitializeGLContext(new GLContextWGL(share_group), 39 return InitializeGLContext(new GLContextWGL(share_group),
34 compatible_surface, gpu_preference); 40 compatible_surface, gpu_preference);
35 case kGLImplementationMockGL: 41 case kGLImplementationMockGL:
36 return new GLContextStub(share_group); 42 return new GLContextStub(share_group);
37 default: 43 default:
38 NOTREACHED(); 44 NOTREACHED();
39 return nullptr; 45 return nullptr;
40 } 46 }
41 } 47 }
42 48
49 scoped_refptr<GLSurface> CreateViewGLSurface(gfx::AcceleratedWidget window) {
50 TRACE_EVENT0("gpu", "gl::init::CreateViewGLSurface");
51 switch (GetGLImplementation()) {
52 case kGLImplementationOSMesaGL:
53 return InitializeGLSurface(new GLSurfaceOSMesaWin(window));
54 case kGLImplementationEGLGLES2: {
55 DCHECK(window != gfx::kNullAcceleratedWidget);
56 scoped_refptr<NativeViewGLSurfaceEGL> surface(
57 new NativeViewGLSurfaceEGL(window));
58 std::unique_ptr<gfx::VSyncProvider> sync_provider;
59 sync_provider.reset(new VSyncProviderWin(window));
60 if (!surface->Initialize(std::move(sync_provider)))
61 return nullptr;
62
63 return surface;
64 }
65 case kGLImplementationDesktopGL:
66 return InitializeGLSurface(new NativeViewGLSurfaceWGL(window));
67 case kGLImplementationMockGL:
68 return new GLSurfaceStub;
69 default:
70 NOTREACHED();
71 return nullptr;
72 }
73 }
74
75 scoped_refptr<GLSurface> CreateOffscreenGLSurface(const gfx::Size& size) {
76 TRACE_EVENT0("gpu", "gl::init::CreateOffscreenGLSurface");
77 switch (GetGLImplementation()) {
78 case kGLImplementationOSMesaGL:
79 return InitializeGLSurface(
80 new GLSurfaceOSMesa(GLSurface::SURFACE_OSMESA_RGBA, size));
81 case kGLImplementationEGLGLES2:
82 return InitializeGLSurface(new PbufferGLSurfaceEGL(size));
83 case kGLImplementationDesktopGL:
84 return InitializeGLSurface(new PbufferGLSurfaceWGL(size));
85 case kGLImplementationMockGL:
86 return new GLSurfaceStub;
87 default:
88 NOTREACHED();
89 return nullptr;
90 }
91 }
92
43 } // namespace init 93 } // namespace init
44 } // namespace gl 94 } // namespace gl
OLDNEW
« no previous file with comments | « ui/gl/init/gl_factory_ozone.cc ('k') | ui/gl/init/gl_factory_x11.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698