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
3 // found in the LICENSE file.
4 
5 #include "ui/ozone/common/gl_ozone_egl.h"
6 
7 #include "ui/gl/gl_bindings.h"
8 #include "ui/gl/gl_context.h"
9 #include "ui/gl/gl_context_egl.h"
10 #include "ui/gl/gl_egl_api_implementation.h"
11 #include "ui/gl/gl_gl_api_implementation.h"
12 #include "ui/gl/gl_share_group.h"
13 #include "ui/gl/gl_surface.h"
14 #include "ui/gl/gl_surface_egl.h"
15 
16 namespace ui {
17 
InitializeGLOneOffPlatform()18 bool GLOzoneEGL::InitializeGLOneOffPlatform() {
19   if (!gl::GLSurfaceEGL::InitializeOneOff(GetNativeDisplay())) {
20     LOG(ERROR) << "GLSurfaceEGL::InitializeOneOff failed.";
21     return false;
22   }
23   return true;
24 }
25 
InitializeStaticGLBindings(gl::GLImplementation implementation)26 bool GLOzoneEGL::InitializeStaticGLBindings(
27     gl::GLImplementation implementation) {
28   if (!LoadGLES2Bindings(implementation))
29     return false;
30 
31   gl::SetGLImplementation(implementation);
32   gl::InitializeStaticGLBindingsGL();
33   gl::InitializeStaticGLBindingsEGL();
34 
35   return true;
36 }
37 
SetDisabledExtensionsPlatform(const std::string & disabled_extensions)38 void GLOzoneEGL::SetDisabledExtensionsPlatform(
39     const std::string& disabled_extensions) {
40   gl::SetDisabledExtensionsEGL(disabled_extensions);
41 }
42 
InitializeExtensionSettingsOneOffPlatform()43 bool GLOzoneEGL::InitializeExtensionSettingsOneOffPlatform() {
44   return gl::InitializeExtensionSettingsOneOffEGL();
45 }
46 
ShutdownGL()47 void GLOzoneEGL::ShutdownGL() {
48   gl::GLSurfaceEGL::ShutdownOneOff();
49   gl::ClearBindingsGL();
50   gl::ClearBindingsEGL();
51 }
52 
GetGLWindowSystemBindingInfo(const gl::GLVersionInfo & gl_info,gl::GLWindowSystemBindingInfo * info)53 bool GLOzoneEGL::GetGLWindowSystemBindingInfo(
54     const gl::GLVersionInfo& gl_info,
55     gl::GLWindowSystemBindingInfo* info) {
56   return gl::GetGLWindowSystemBindingInfoEGL(info);
57 }
58 
CreateGLContext(gl::GLShareGroup * share_group,gl::GLSurface * compatible_surface,const gl::GLContextAttribs & attribs)59 scoped_refptr<gl::GLContext> GLOzoneEGL::CreateGLContext(
60     gl::GLShareGroup* share_group,
61     gl::GLSurface* compatible_surface,
62     const gl::GLContextAttribs& attribs) {
63   return gl::InitializeGLContext(new gl::GLContextEGL(share_group),
64                                  compatible_surface, attribs);
65 }
66 
CreateSurfacelessViewGLSurface(gfx::AcceleratedWidget window)67 scoped_refptr<gl::GLSurface> GLOzoneEGL::CreateSurfacelessViewGLSurface(
68     gfx::AcceleratedWidget window) {
69   // This will usually not be implemented by the platform specific version.
70   return nullptr;
71 }
72 
73 }  // namespace ui
74