GLContextProviderImpl.h (2291B)
1 /* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 2 -*- 2 * This Source Code Form is subject to the terms of the Mozilla Public 3 * License, v. 2.0. If a copy of the MPL was not distributed with this 4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 5 6 #ifndef IN_GL_CONTEXT_PROVIDER_H 7 # error GLContextProviderImpl.h must only be included from GLContextProvider.h 8 #endif 9 10 #ifndef GL_CONTEXT_PROVIDER_NAME 11 # error GL_CONTEXT_PROVIDER_NAME not defined 12 #endif 13 #if defined(MOZ_WIDGET_ANDROID) 14 # include "GLTypes.h" // for EGLSurface and EGLConfig 15 #endif // defined(MOZ_WIDGET_ANDROID) 16 17 class GL_CONTEXT_PROVIDER_NAME { 18 public: 19 /** 20 * Create a context that renders to the surface of the widget represented by 21 * the compositor widget that is passed in. The context is always created 22 * with an RGB pixel format, with no alpha, depth or stencil. 23 * If any of those features are needed, either use a framebuffer, or 24 * use CreateOffscreen. 25 * 26 * This context will attempt to share resources with all other window 27 * contexts. As such, it's critical that resources allocated that are not 28 * needed by other contexts be deleted before the context is destroyed. 29 * 30 * The GetSharedContext() method will return non-null if sharing 31 * was successful. 32 * 33 * Note: a context created for a widget /must not/ hold a strong 34 * reference to the widget; otherwise a cycle can be created through 35 * a GL layer manager. 36 * 37 * @param aCompositorWidget Widget whose surface to create a context for 38 * @param aForceAccelerated true if only accelerated contexts are allowed 39 * 40 * @return Context to use for the window 41 */ 42 static already_AddRefed<GLContext> CreateForCompositorWidget( 43 mozilla::widget::CompositorWidget* aCompositorWidget, 44 bool aHardwareWebRender, bool aForceAccelerated); 45 46 /// Just create a context. We'll add offscreen stuff ourselves. 47 static already_AddRefed<GLContext> CreateHeadless( 48 const GLContextCreateDesc&, nsACString* const out_failureId); 49 50 /** 51 * Get a pointer to the global context, creating it if it doesn't exist. 52 */ 53 static GLContext* GetGlobalContext(); 54 55 /** 56 * Free any resources held by this Context Provider. 57 */ 58 static void Shutdown(); 59 };