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 #ifndef UI_GL_INIT_GL_FACTORY_H_ 6 #define UI_GL_INIT_GL_FACTORY_H_ 7 8 #include <memory> 9 #include <string> 10 #include <vector> 11 12 #include "base/memory/ref_counted.h" 13 #include "ui/gfx/geometry/size.h" 14 #include "ui/gfx/native_widget_types.h" 15 #include "ui/gl/gl_implementation.h" 16 #include "ui/gl/gl_surface_format.h" 17 #include "ui/gl/gpu_preference.h" 18 #include "ui/gl/init/gl_init_export.h" 19 20 namespace gl { 21 22 class GLContext; 23 class GLShareGroup; 24 class GLSurface; 25 26 struct GLContextAttribs; 27 struct GLVersionInfo; 28 29 namespace init { 30 31 // Returns a list of allowed GL implementations. The default implementation will 32 // be the first item. 33 GL_INIT_EXPORT std::vector<GLImplementation> GetAllowedGLImplementations(); 34 35 // Initializes GL bindings and extension settings. 36 GL_INIT_EXPORT bool InitializeGLOneOff(); 37 38 // Initializes GL bindings without initializing extension settings. 39 GL_INIT_EXPORT bool InitializeGLNoExtensionsOneOff(bool init_bindings); 40 41 // Initializes GL bindings - load dlls and get proc address according to gl 42 // command line switch. 43 GL_INIT_EXPORT bool InitializeStaticGLBindingsOneOff(); 44 45 // Initialize plaiform dependent extension settings, including bindings, 46 // capabilities, etc. 47 GL_INIT_EXPORT bool InitializeExtensionSettingsOneOffPlatform(); 48 49 // Initializes GL bindings using the provided parameters. This might be required 50 // for use in tests. 51 GL_INIT_EXPORT bool InitializeStaticGLBindingsImplementation( 52 GLImplementation impl, 53 bool fallback_to_software_gl); 54 55 // Initializes GL platform using the provided parameters. This might be required 56 // for use in tests. This should be called only after GL bindings are initilzed 57 // successfully. 58 GL_INIT_EXPORT bool InitializeGLOneOffPlatformImplementation( 59 bool fallback_to_software_gl, 60 bool disable_gl_drawing, 61 bool init_extensions); 62 63 // Clears GL bindings and resets GL implementation. 64 GL_INIT_EXPORT void ShutdownGL(bool due_to_fallback); 65 66 // Return information about the GL window system binding implementation (e.g., 67 // EGL, GLX, WGL). Returns true if the information was retrieved successfully. 68 GL_INIT_EXPORT bool GetGLWindowSystemBindingInfo( 69 const GLVersionInfo& gl_info, 70 GLWindowSystemBindingInfo* info); 71 72 // Creates a GL context that is compatible with the given surface. 73 // |share_group|, if non-null, is a group of contexts which the internally 74 // created OpenGL context shares textures and other resources. 75 GL_INIT_EXPORT scoped_refptr<GLContext> CreateGLContext( 76 GLShareGroup* share_group, 77 GLSurface* compatible_surface, 78 const GLContextAttribs& attribs); 79 80 // Creates a GL surface that renders directly to a view. 81 GL_INIT_EXPORT scoped_refptr<GLSurface> CreateViewGLSurface( 82 gfx::AcceleratedWidget window); 83 84 #if defined(USE_OZONE) 85 // Creates a GL surface that renders directly into a window with surfaceless 86 // semantics - there is no default framebuffer and the primary surface must 87 // be presented as an overlay. If surfaceless mode is not supported or 88 // enabled it will return a null pointer. 89 GL_INIT_EXPORT scoped_refptr<GLSurface> CreateSurfacelessViewGLSurface( 90 gfx::AcceleratedWidget window); 91 #endif // defined(USE_OZONE) 92 93 // Creates a GL surface used for offscreen rendering. 94 GL_INIT_EXPORT scoped_refptr<GLSurface> CreateOffscreenGLSurface( 95 const gfx::Size& size); 96 97 GL_INIT_EXPORT scoped_refptr<GLSurface> CreateOffscreenGLSurfaceWithFormat( 98 const gfx::Size& size, GLSurfaceFormat format); 99 100 // Set platform dependent disabled extensions and re-initialize extension 101 // bindings. 102 GL_INIT_EXPORT void SetDisabledExtensionsPlatform( 103 const std::string& disabled_extensions); 104 105 } // namespace init 106 } // namespace gl 107 108 #endif // UI_GL_INIT_GL_FACTORY_H_ 109