tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

GLUploadHelpers.h (2976B)


      1 /* -*- Mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; tab-width: 4; -*- */
      2 /* This Source Code Form is subject to the terms of the Mozilla Public
      3 * License, v. 2.0. If a copy of the MPL was not distributed with this
      4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
      5 
      6 #ifndef GLUploadHelpers_h_
      7 #define GLUploadHelpers_h_
      8 
      9 #include "GLDefs.h"
     10 #include "mozilla/gfx/Types.h"
     11 #include "nsPoint.h"
     12 #include "nsRegionFwd.h"
     13 
     14 namespace mozilla {
     15 
     16 namespace gfx {
     17 class DataSourceSurface;
     18 }  // namespace gfx
     19 
     20 namespace gl {
     21 
     22 class GLContext;
     23 
     24 /**
     25 * Uploads image data to an OpenGL texture, initializing the texture
     26 * first if necessary.
     27 *
     28 * \param gl The GL Context to use.
     29 * \param aData Start of image data of surface to upload.
     30 *              Corresponds to the first pixel of the texture.
     31 * \param aDataSize The image data's size.
     32 * \param aStride The image data's stride.
     33 * \param aFormat The image data's format.
     34 * \param aDstRegion Region of the texture to upload.
     35 * \param aTexture The OpenGL texture to use. Must refer to a valid texture.
     36 * \param aSize The full size of the texture.
     37 * \param aOutUploadSize If set, the number of bytes the texture requires will
     38 *                       be returned here.
     39 * \param aNeedInit Indicates whether a new texture must be allocated.
     40 * \param aTextureUnit The texture unit used temporarily to upload the surface.
     41 *                     This may be overridden, so clients should not rely on
     42 *                     the aTexture being bound to aTextureUnit after this call,
     43 *                     or even on aTextureUnit being active.
     44 * \param aTextureTarget The texture target to use.
     45 * \return Surface format of this texture.
     46 */
     47 gfx::SurfaceFormat UploadImageDataToTexture(
     48    GLContext* gl, unsigned char* aData, const gfx::IntSize& aDataSize,
     49    const gfx::IntPoint& aDstOffset, int32_t aStride,
     50    gfx::SurfaceFormat aFormat, const nsIntRegion& aDstRegion, GLuint aTexture,
     51    const gfx::IntSize& aSize, size_t* aOutUploadSize = nullptr,
     52    bool aNeedInit = false, GLenum aTextureUnit = LOCAL_GL_TEXTURE0,
     53    GLenum aTextureTarget = LOCAL_GL_TEXTURE_2D);
     54 
     55 /**
     56 * Convenience wrapper around UploadImageDataToTexture for
     57 * gfx::DataSourceSurface's.
     58 *
     59 * \param aSurface The surface from which to upload image data.
     60 * \param aSrcPoint Offset into aSurface where this texture's data begins.
     61 */
     62 gfx::SurfaceFormat UploadSurfaceToTexture(
     63    GLContext* gl, gfx::DataSourceSurface* aSurface,
     64    const nsIntRegion& aDstRegion, GLuint aTexture, const gfx::IntSize& aSize,
     65    size_t* aOutUploadSize = nullptr, bool aNeedInit = false,
     66    const gfx::IntPoint& aSrcOffset = gfx::IntPoint(0, 0),
     67    const gfx::IntPoint& aDstOffset = gfx::IntPoint(0, 0),
     68    GLenum aTextureUnit = LOCAL_GL_TEXTURE0,
     69    GLenum aTextureTarget = LOCAL_GL_TEXTURE_2D);
     70 
     71 bool ShouldUploadSubTextures(GLContext* gl);
     72 bool CanUploadNonPowerOfTwo(GLContext* gl);
     73 
     74 }  // namespace gl
     75 }  // namespace mozilla
     76 
     77 #endif