DXR is a code search and navigation tool aimed at making sense of large projects. It supports full-text and regex searches as well as structural queries.

Implementation

Mercurial (27a812186ff4)

VCS Links

Line Code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73
/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */

#ifndef GLSHAREDHANDLEHELPERS_H_
#define GLSHAREDHANDLEHELPERS_H_

#include "GLContextTypes.h"
#include "mozilla/gfx/Types.h"

namespace mozilla {
namespace gl {

/**
  * Create a new shared GLContext content handle, using the passed buffer as a source.
  * Must be released by ReleaseSharedHandle.
  */
SharedTextureHandle CreateSharedHandle(GLContext* gl,
                                       SharedTextureShareType shareType,
                                       void* buffer,
                                       SharedTextureBufferType bufferType);

/**
  * - It is better to call ReleaseSharedHandle before original GLContext destroyed,
  *     otherwise warning will be thrown on attempt to destroy Texture associated with SharedHandle, depends on backend implementation.
  * - It does not require to be called on context where it was created,
  *     because SharedHandle suppose to keep Context reference internally,
  *     or don't require specific context at all, for example IPC SharedHandle.
  * - Not recommended to call this between AttachSharedHandle and Draw Target call.
  *      if it is really required for some special backend, then DetachSharedHandle API must be added with related implementation.
  * - It is recommended to stop any possible access to SharedHandle (Attachments, pending GL calls) before calling Release,
  *      otherwise some artifacts might appear or even crash if API backend implementation does not expect that.
  * SharedHandle (currently EGLImage) does not require GLContext because it is EGL call, and can be destroyed
  *   at any time, unless EGLImage have siblings (which are not expected with current API).
  */
void ReleaseSharedHandle(GLContext* gl,
                         SharedTextureShareType shareType,
                         SharedTextureHandle sharedHandle);


typedef struct {
    GLenum mTarget;
    gfx::SurfaceFormat mTextureFormat;
    gfx::Matrix4x4 mTextureTransform;
} SharedHandleDetails;

/**
  * Returns information necessary for rendering a shared handle.
  * These values change depending on what sharing mechanism is in use
  */
bool GetSharedHandleDetails(GLContext* gl,
                            SharedTextureShareType shareType,
                            SharedTextureHandle sharedHandle,
                            SharedHandleDetails& details);
/**
  * Attach Shared GL Handle to GL_TEXTURE_2D target
  * GLContext must be current before this call
  */
bool AttachSharedHandle(GLContext* gl,
                        SharedTextureShareType shareType,
                        SharedTextureHandle sharedHandle);

/**
  * Detach Shared GL Handle from GL_TEXTURE_2D target
  */
void DetachSharedHandle(GLContext* gl,
                        SharedTextureShareType shareType,
                        SharedTextureHandle sharedHandle);

}
}

#endif