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

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

Issue 2270463002: Add OzoneGLImpl interface. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address comments. Created 4 years, 3 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.h ('k') | ui/gl/init/gl_initializer_ozone.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_egl_api_implementation.h" 13 #include "ui/gl/gl_egl_api_implementation.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" 17 #include "ui/gl/gl_surface_egl.h"
18 #include "ui/gl/gl_surface_osmesa.h" 18 #include "ui/gl/gl_surface_osmesa.h"
19 #include "ui/gl/gl_surface_stub.h" 19 #include "ui/gl/gl_surface_stub.h"
20 #include "ui/gl/init/ozone_util.h"
20 #include "ui/ozone/public/ozone_platform.h" 21 #include "ui/ozone/public/ozone_platform.h"
21 #include "ui/ozone/public/surface_factory_ozone.h" 22 #include "ui/ozone/public/surface_factory_ozone.h"
22 23
23 namespace gl { 24 namespace gl {
24 namespace init { 25 namespace init {
25 26
26 namespace { 27 namespace {
27 28
28 ui::SurfaceFactoryOzone* GetSurfaceFactory() {
29 return ui::OzonePlatform::GetInstance()->GetSurfaceFactoryOzone();
30 }
31
32 bool HasDefaultImplementation(GLImplementation impl) { 29 bool HasDefaultImplementation(GLImplementation impl) {
33 return impl == kGLImplementationOSMesaGL || impl == kGLImplementationMockGL; 30 return impl == kGLImplementationOSMesaGL || impl == kGLImplementationMockGL;
34 } 31 }
35 32
36 scoped_refptr<GLSurface> CreateDefaultViewGLSurface( 33 scoped_refptr<GLSurface> CreateDefaultViewGLSurface(
37 gfx::AcceleratedWidget window) { 34 gfx::AcceleratedWidget window) {
38 switch (GetGLImplementation()) { 35 switch (GetGLImplementation()) {
39 case kGLImplementationOSMesaGL: 36 case kGLImplementationOSMesaGL:
40 return InitializeGLSurface(new GLSurfaceOSMesaHeadless()); 37 return InitializeGLSurface(new GLSurfaceOSMesaHeadless());
41 case kGLImplementationMockGL: 38 case kGLImplementationMockGL:
(...skipping 14 matching lines...) Expand all
56 return InitializeGLSurface(new GLSurfaceStub); 53 return InitializeGLSurface(new GLSurfaceStub);
57 default: 54 default:
58 NOTREACHED(); 55 NOTREACHED();
59 } 56 }
60 return nullptr; 57 return nullptr;
61 } 58 }
62 59
63 } // namespace 60 } // namespace
64 61
65 std::vector<GLImplementation> GetAllowedGLImplementations() { 62 std::vector<GLImplementation> GetAllowedGLImplementations() {
66 std::vector<GLImplementation> impls; 63 ui::OzonePlatform::InitializeForGPU();
67 impls.push_back(kGLImplementationEGLGLES2); 64 return GetSurfaceFactoryOzone()->GetAllowedGLImplementations();
68 impls.push_back(kGLImplementationOSMesaGL);
69 return impls;
70 } 65 }
71 66
72 bool GetGLWindowSystemBindingInfo(GLWindowSystemBindingInfo* info) { 67 bool GetGLWindowSystemBindingInfo(GLWindowSystemBindingInfo* info) {
68 if (HasGLOzone())
69 return GetGLOzone()->GetGLWindowSystemBindingInfo(info);
70
71 // TODO(kylechar): This is deprecated and can be removed once all Ozone
72 // platforms use GLOzone instead.
73 switch (GetGLImplementation()) { 73 switch (GetGLImplementation()) {
74 case kGLImplementationEGLGLES2: 74 case kGLImplementationEGLGLES2:
75 return GetGLWindowSystemBindingInfoEGL(info); 75 return GetGLWindowSystemBindingInfoEGL(info);
76 default: 76 default:
77 return false; 77 return false;
78 } 78 }
79 } 79 }
80 80
81 scoped_refptr<GLContext> CreateGLContext(GLShareGroup* share_group, 81 scoped_refptr<GLContext> CreateGLContext(GLShareGroup* share_group,
82 GLSurface* compatible_surface, 82 GLSurface* compatible_surface,
83 GpuPreference gpu_preference) { 83 GpuPreference gpu_preference) {
84 TRACE_EVENT0("gpu", "gl::init::CreateGLContext"); 84 TRACE_EVENT0("gpu", "gl::init::CreateGLContext");
85
86 if (HasGLOzone()) {
87 return GetGLOzone()->CreateGLContext(share_group, compatible_surface,
88 gpu_preference);
89 }
90
85 switch (GetGLImplementation()) { 91 switch (GetGLImplementation()) {
86 case kGLImplementationMockGL: 92 case kGLImplementationMockGL:
87 return scoped_refptr<GLContext>(new GLContextStub(share_group)); 93 return scoped_refptr<GLContext>(new GLContextStub(share_group));
88 case kGLImplementationOSMesaGL: 94 case kGLImplementationOSMesaGL:
89 return InitializeGLContext(new GLContextOSMesa(share_group), 95 return InitializeGLContext(new GLContextOSMesa(share_group),
90 compatible_surface, gpu_preference); 96 compatible_surface, gpu_preference);
91 case kGLImplementationEGLGLES2: 97 case kGLImplementationEGLGLES2:
92 return InitializeGLContext(new GLContextEGL(share_group), 98 return InitializeGLContext(new GLContextEGL(share_group),
93 compatible_surface, gpu_preference); 99 compatible_surface, gpu_preference);
94 default: 100 default:
95 NOTREACHED(); 101 NOTREACHED();
96 } 102 }
97 return nullptr; 103 return nullptr;
98 } 104 }
99 105
100 scoped_refptr<GLSurface> CreateViewGLSurface(gfx::AcceleratedWidget window) { 106 scoped_refptr<GLSurface> CreateViewGLSurface(gfx::AcceleratedWidget window) {
101 TRACE_EVENT0("gpu", "gl::init::CreateViewGLSurface"); 107 TRACE_EVENT0("gpu", "gl::init::CreateViewGLSurface");
102 108
109 if (HasGLOzone())
110 return GetGLOzone()->CreateViewGLSurface(window);
111
103 if (HasDefaultImplementation(GetGLImplementation())) 112 if (HasDefaultImplementation(GetGLImplementation()))
104 return CreateDefaultViewGLSurface(window); 113 return CreateDefaultViewGLSurface(window);
105 114
106 return GetSurfaceFactory()->CreateViewGLSurface(GetGLImplementation(), 115 // TODO(kylechar): This is deprecated and can be removed once all Ozone
107 window); 116 // platforms use GLOzone instead.
117 return GetSurfaceFactoryOzone()->CreateViewGLSurface(GetGLImplementation(),
118 window);
108 } 119 }
109 120
110 scoped_refptr<GLSurface> CreateSurfacelessViewGLSurface( 121 scoped_refptr<GLSurface> CreateSurfacelessViewGLSurface(
111 gfx::AcceleratedWidget window) { 122 gfx::AcceleratedWidget window) {
112 TRACE_EVENT0("gpu", "gl::init::CreateSurfacelessViewGLSurface"); 123 TRACE_EVENT0("gpu", "gl::init::CreateSurfacelessViewGLSurface");
113 124
114 return GetSurfaceFactory()->CreateSurfacelessViewGLSurface( 125 if (HasGLOzone())
126 return GetGLOzone()->CreateSurfacelessViewGLSurface(window);
127
128 // TODO(kylechar): This is deprecated and can be removed once all Ozone
129 // platforms use GLOzone instead.
130 return GetSurfaceFactoryOzone()->CreateSurfacelessViewGLSurface(
115 GetGLImplementation(), window); 131 GetGLImplementation(), window);
116 } 132 }
117 133
118 scoped_refptr<GLSurface> CreateOffscreenGLSurface(const gfx::Size& size) { 134 scoped_refptr<GLSurface> CreateOffscreenGLSurface(const gfx::Size& size) {
119 TRACE_EVENT0("gpu", "gl::init::CreateOffscreenGLSurface"); 135 TRACE_EVENT0("gpu", "gl::init::CreateOffscreenGLSurface");
120 136
137 if (HasGLOzone())
138 return GetGLOzone()->CreateOffscreenGLSurface(size);
139
121 if (HasDefaultImplementation(GetGLImplementation())) 140 if (HasDefaultImplementation(GetGLImplementation()))
122 return CreateDefaultOffscreenGLSurface(size); 141 return CreateDefaultOffscreenGLSurface(size);
123 142
124 return GetSurfaceFactory()->CreateOffscreenGLSurface(GetGLImplementation(), 143 // TODO(kylechar): This is deprecated and can be removed once all Ozone
125 size); 144 // platforms use GLOzone instead.
145 return GetSurfaceFactoryOzone()->CreateOffscreenGLSurface(
146 GetGLImplementation(), size);
126 } 147 }
127 148
128 } // namespace init 149 } // namespace init
129 } // namespace gl 150 } // namespace gl
OLDNEW
« no previous file with comments | « ui/gl/init/gl_factory.h ('k') | ui/gl/init/gl_initializer_ozone.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698