1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/gfx/gl/GLContextProviderImpl.h Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,86 @@ 1.4 +/* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 4 -*- 1.5 + * This Source Code Form is subject to the terms of the Mozilla Public 1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.8 + 1.9 +#ifndef IN_GL_CONTEXT_PROVIDER_H 1.10 +#error GLContextProviderImpl.h must only be included from GLContextProvider.h 1.11 +#endif 1.12 + 1.13 +#ifndef GL_CONTEXT_PROVIDER_NAME 1.14 +#error GL_CONTEXT_PROVIDER_NAME not defined 1.15 +#endif 1.16 + 1.17 +class GL_CONTEXT_PROVIDER_NAME 1.18 +{ 1.19 +public: 1.20 + typedef gfx::SurfaceCaps SurfaceCaps; 1.21 + /** 1.22 + * Create a context that renders to the surface of the widget that is 1.23 + * passed in. The context is always created with an RGB pixel format, 1.24 + * with no alpha, depth or stencil. If any of those features are needed, 1.25 + * either use a framebuffer, or use CreateOffscreen. 1.26 + * 1.27 + * This context will attempt to share resources with all other window 1.28 + * contexts. As such, it's critical that resources allocated that are not 1.29 + * needed by other contexts be deleted before the context is destroyed. 1.30 + * 1.31 + * The GetSharedContext() method will return non-null if sharing 1.32 + * was successful. 1.33 + * 1.34 + * Note: a context created for a widget /must not/ hold a strong 1.35 + * reference to the widget; otherwise a cycle can be created through 1.36 + * a GL layer manager. 1.37 + * 1.38 + * @param aWidget Widget whose surface to create a context for 1.39 + * 1.40 + * @return Context to use for the window 1.41 + */ 1.42 + static already_AddRefed<GLContext> 1.43 + CreateForWindow(nsIWidget* widget); 1.44 + 1.45 + /** 1.46 + * Create a context for offscreen rendering. The target of this 1.47 + * context should be treated as opaque -- it might be a FBO, or a 1.48 + * pbuffer, or some other construct. Users of this GLContext 1.49 + * should bind framebuffer 0 directly to use this offscreen buffer. 1.50 + * 1.51 + * The offscreen context returned by this method will always have 1.52 + * the ability to be rendered into a context created by a window. 1.53 + * It might or might not share resources with the global context; 1.54 + * query GetSharedContext() for a non-null result to check. If 1.55 + * resource sharing can be avoided on the target platform, it will 1.56 + * be, in order to isolate the offscreen context. 1.57 + * 1.58 + * @param aSize The initial size of this offscreen context. 1.59 + * @param aFormat The ContextFormat for this offscreen context. 1.60 + * 1.61 + * @return Context to use for offscreen rendering 1.62 + */ 1.63 + static already_AddRefed<GLContext> 1.64 + CreateOffscreen(const gfxIntSize& size, 1.65 + const SurfaceCaps& caps); 1.66 + 1.67 + /** 1.68 + * Create wrapping Gecko GLContext for external gl context. 1.69 + * 1.70 + * @param aContext External context which will be wrapped by Gecko GLContext. 1.71 + * @param aSurface External surface which is used for external context. 1.72 + * 1.73 + * @return Wrapping Context to use for rendering 1.74 + */ 1.75 + static already_AddRefed<GLContext> 1.76 + CreateWrappingExisting(void* aContext, void* aSurface); 1.77 + 1.78 + /** 1.79 + * Get a pointer to the global context, creating it if it doesn't exist. 1.80 + */ 1.81 + static GLContext* 1.82 + GetGlobalContext(); 1.83 + 1.84 + /** 1.85 + * Free any resources held by this Context Provider. 1.86 + */ 1.87 + static void 1.88 + Shutdown(); 1.89 +};