michael@0: /* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 4 -*- michael@0: * This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #ifndef IN_GL_CONTEXT_PROVIDER_H michael@0: #error GLContextProviderImpl.h must only be included from GLContextProvider.h michael@0: #endif michael@0: michael@0: #ifndef GL_CONTEXT_PROVIDER_NAME michael@0: #error GL_CONTEXT_PROVIDER_NAME not defined michael@0: #endif michael@0: michael@0: class GL_CONTEXT_PROVIDER_NAME michael@0: { michael@0: public: michael@0: typedef gfx::SurfaceCaps SurfaceCaps; michael@0: /** michael@0: * Create a context that renders to the surface of the widget that is michael@0: * passed in. The context is always created with an RGB pixel format, michael@0: * with no alpha, depth or stencil. If any of those features are needed, michael@0: * either use a framebuffer, or use CreateOffscreen. michael@0: * michael@0: * This context will attempt to share resources with all other window michael@0: * contexts. As such, it's critical that resources allocated that are not michael@0: * needed by other contexts be deleted before the context is destroyed. michael@0: * michael@0: * The GetSharedContext() method will return non-null if sharing michael@0: * was successful. michael@0: * michael@0: * Note: a context created for a widget /must not/ hold a strong michael@0: * reference to the widget; otherwise a cycle can be created through michael@0: * a GL layer manager. michael@0: * michael@0: * @param aWidget Widget whose surface to create a context for michael@0: * michael@0: * @return Context to use for the window michael@0: */ michael@0: static already_AddRefed michael@0: CreateForWindow(nsIWidget* widget); michael@0: michael@0: /** michael@0: * Create a context for offscreen rendering. The target of this michael@0: * context should be treated as opaque -- it might be a FBO, or a michael@0: * pbuffer, or some other construct. Users of this GLContext michael@0: * should bind framebuffer 0 directly to use this offscreen buffer. michael@0: * michael@0: * The offscreen context returned by this method will always have michael@0: * the ability to be rendered into a context created by a window. michael@0: * It might or might not share resources with the global context; michael@0: * query GetSharedContext() for a non-null result to check. If michael@0: * resource sharing can be avoided on the target platform, it will michael@0: * be, in order to isolate the offscreen context. michael@0: * michael@0: * @param aSize The initial size of this offscreen context. michael@0: * @param aFormat The ContextFormat for this offscreen context. michael@0: * michael@0: * @return Context to use for offscreen rendering michael@0: */ michael@0: static already_AddRefed michael@0: CreateOffscreen(const gfxIntSize& size, michael@0: const SurfaceCaps& caps); michael@0: michael@0: /** michael@0: * Create wrapping Gecko GLContext for external gl context. michael@0: * michael@0: * @param aContext External context which will be wrapped by Gecko GLContext. michael@0: * @param aSurface External surface which is used for external context. michael@0: * michael@0: * @return Wrapping Context to use for rendering michael@0: */ michael@0: static already_AddRefed michael@0: CreateWrappingExisting(void* aContext, void* aSurface); michael@0: michael@0: /** michael@0: * Get a pointer to the global context, creating it if it doesn't exist. michael@0: */ michael@0: static GLContext* michael@0: GetGlobalContext(); michael@0: michael@0: /** michael@0: * Free any resources held by this Context Provider. michael@0: */ michael@0: static void michael@0: Shutdown(); michael@0: };