gfx/gl/GLContextProviderImpl.h

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

michael@0 1 /* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 4 -*-
michael@0 2 * This Source Code Form is subject to the terms of the Mozilla Public
michael@0 3 * License, v. 2.0. If a copy of the MPL was not distributed with this
michael@0 4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
michael@0 5
michael@0 6 #ifndef IN_GL_CONTEXT_PROVIDER_H
michael@0 7 #error GLContextProviderImpl.h must only be included from GLContextProvider.h
michael@0 8 #endif
michael@0 9
michael@0 10 #ifndef GL_CONTEXT_PROVIDER_NAME
michael@0 11 #error GL_CONTEXT_PROVIDER_NAME not defined
michael@0 12 #endif
michael@0 13
michael@0 14 class GL_CONTEXT_PROVIDER_NAME
michael@0 15 {
michael@0 16 public:
michael@0 17 typedef gfx::SurfaceCaps SurfaceCaps;
michael@0 18 /**
michael@0 19 * Create a context that renders to the surface of the widget that is
michael@0 20 * passed in. The context is always created with an RGB pixel format,
michael@0 21 * with no alpha, depth or stencil. If any of those features are needed,
michael@0 22 * either use a framebuffer, or use CreateOffscreen.
michael@0 23 *
michael@0 24 * This context will attempt to share resources with all other window
michael@0 25 * contexts. As such, it's critical that resources allocated that are not
michael@0 26 * needed by other contexts be deleted before the context is destroyed.
michael@0 27 *
michael@0 28 * The GetSharedContext() method will return non-null if sharing
michael@0 29 * was successful.
michael@0 30 *
michael@0 31 * Note: a context created for a widget /must not/ hold a strong
michael@0 32 * reference to the widget; otherwise a cycle can be created through
michael@0 33 * a GL layer manager.
michael@0 34 *
michael@0 35 * @param aWidget Widget whose surface to create a context for
michael@0 36 *
michael@0 37 * @return Context to use for the window
michael@0 38 */
michael@0 39 static already_AddRefed<GLContext>
michael@0 40 CreateForWindow(nsIWidget* widget);
michael@0 41
michael@0 42 /**
michael@0 43 * Create a context for offscreen rendering. The target of this
michael@0 44 * context should be treated as opaque -- it might be a FBO, or a
michael@0 45 * pbuffer, or some other construct. Users of this GLContext
michael@0 46 * should bind framebuffer 0 directly to use this offscreen buffer.
michael@0 47 *
michael@0 48 * The offscreen context returned by this method will always have
michael@0 49 * the ability to be rendered into a context created by a window.
michael@0 50 * It might or might not share resources with the global context;
michael@0 51 * query GetSharedContext() for a non-null result to check. If
michael@0 52 * resource sharing can be avoided on the target platform, it will
michael@0 53 * be, in order to isolate the offscreen context.
michael@0 54 *
michael@0 55 * @param aSize The initial size of this offscreen context.
michael@0 56 * @param aFormat The ContextFormat for this offscreen context.
michael@0 57 *
michael@0 58 * @return Context to use for offscreen rendering
michael@0 59 */
michael@0 60 static already_AddRefed<GLContext>
michael@0 61 CreateOffscreen(const gfxIntSize& size,
michael@0 62 const SurfaceCaps& caps);
michael@0 63
michael@0 64 /**
michael@0 65 * Create wrapping Gecko GLContext for external gl context.
michael@0 66 *
michael@0 67 * @param aContext External context which will be wrapped by Gecko GLContext.
michael@0 68 * @param aSurface External surface which is used for external context.
michael@0 69 *
michael@0 70 * @return Wrapping Context to use for rendering
michael@0 71 */
michael@0 72 static already_AddRefed<GLContext>
michael@0 73 CreateWrappingExisting(void* aContext, void* aSurface);
michael@0 74
michael@0 75 /**
michael@0 76 * Get a pointer to the global context, creating it if it doesn't exist.
michael@0 77 */
michael@0 78 static GLContext*
michael@0 79 GetGlobalContext();
michael@0 80
michael@0 81 /**
michael@0 82 * Free any resources held by this Context Provider.
michael@0 83 */
michael@0 84 static void
michael@0 85 Shutdown();
michael@0 86 };

mercurial