gfx/gl/GLSharedHandleHelpers.h

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

     1 /* This Source Code Form is subject to the terms of the Mozilla Public
     2  * License, v. 2.0. If a copy of the MPL was not distributed with this
     3  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     5 #ifndef GLSHAREDHANDLEHELPERS_H_
     6 #define GLSHAREDHANDLEHELPERS_H_
     8 #include "GLContextTypes.h"
     9 #include "mozilla/gfx/Types.h"
    11 namespace mozilla {
    12 namespace gl {
    14 /**
    15   * Create a new shared GLContext content handle, using the passed buffer as a source.
    16   * Must be released by ReleaseSharedHandle.
    17   */
    18 SharedTextureHandle CreateSharedHandle(GLContext* gl,
    19                                        SharedTextureShareType shareType,
    20                                        void* buffer,
    21                                        SharedTextureBufferType bufferType);
    23 /**
    24   * - It is better to call ReleaseSharedHandle before original GLContext destroyed,
    25   *     otherwise warning will be thrown on attempt to destroy Texture associated with SharedHandle, depends on backend implementation.
    26   * - It does not require to be called on context where it was created,
    27   *     because SharedHandle suppose to keep Context reference internally,
    28   *     or don't require specific context at all, for example IPC SharedHandle.
    29   * - Not recommended to call this between AttachSharedHandle and Draw Target call.
    30   *      if it is really required for some special backend, then DetachSharedHandle API must be added with related implementation.
    31   * - It is recommended to stop any possible access to SharedHandle (Attachments, pending GL calls) before calling Release,
    32   *      otherwise some artifacts might appear or even crash if API backend implementation does not expect that.
    33   * SharedHandle (currently EGLImage) does not require GLContext because it is EGL call, and can be destroyed
    34   *   at any time, unless EGLImage have siblings (which are not expected with current API).
    35   */
    36 void ReleaseSharedHandle(GLContext* gl,
    37                          SharedTextureShareType shareType,
    38                          SharedTextureHandle sharedHandle);
    41 typedef struct {
    42     GLenum mTarget;
    43     gfx::SurfaceFormat mTextureFormat;
    44     gfx::Matrix4x4 mTextureTransform;
    45 } SharedHandleDetails;
    47 /**
    48   * Returns information necessary for rendering a shared handle.
    49   * These values change depending on what sharing mechanism is in use
    50   */
    51 bool GetSharedHandleDetails(GLContext* gl,
    52                             SharedTextureShareType shareType,
    53                             SharedTextureHandle sharedHandle,
    54                             SharedHandleDetails& details);
    55 /**
    56   * Attach Shared GL Handle to GL_TEXTURE_2D target
    57   * GLContext must be current before this call
    58   */
    59 bool AttachSharedHandle(GLContext* gl,
    60                         SharedTextureShareType shareType,
    61                         SharedTextureHandle sharedHandle);
    63 /**
    64   * Detach Shared GL Handle from GL_TEXTURE_2D target
    65   */
    66 void DetachSharedHandle(GLContext* gl,
    67                         SharedTextureShareType shareType,
    68                         SharedTextureHandle sharedHandle);
    70 }
    71 }
    73 #endif

mercurial