gfx/gl/GLUploadHelpers.h

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/gfx/gl/GLUploadHelpers.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,88 @@
     1.4 +/* -*- Mode: c++; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 40; -*- */
     1.5 +/* This Source Code Form is subject to the terms of the Mozilla Public
     1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this
     1.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.8 +
     1.9 +#ifndef GLUploadHelpers_h_
    1.10 +#define GLUploadHelpers_h_
    1.11 +
    1.12 +#include "GLDefs.h"
    1.13 +#include "mozilla/gfx/Types.h"
    1.14 +#include "nsPoint.h"
    1.15 +
    1.16 +class nsIntRegion;
    1.17 +
    1.18 +namespace mozilla {
    1.19 +
    1.20 +namespace gfx {
    1.21 +class DataSourceSurface;
    1.22 +}
    1.23 +
    1.24 +namespace gl {
    1.25 +
    1.26 +class GLContext;
    1.27 +
    1.28 +/**
    1.29 +  * Creates a RGB/RGBA texture (or uses one provided) and uploads the surface
    1.30 +  * contents to it within aSrcRect.
    1.31 +  *
    1.32 +  * aSrcRect.x/y will be uploaded to 0/0 in the texture, and the size
    1.33 +  * of the texture with be aSrcRect.width/height.
    1.34 +  *
    1.35 +  * If an existing texture is passed through aTexture, it is assumed it
    1.36 +  * has already been initialised with glTexImage2D (or this function),
    1.37 +  * and that its size is equal to or greater than aSrcRect + aDstPoint.
    1.38 +  * You can alternatively set the overwrite flag to true and have a new
    1.39 +  * texture memory block allocated.
    1.40 +  *
    1.41 +  * The aDstPoint parameter is ignored if no texture was provided
    1.42 +  * or aOverwrite is true.
    1.43 +  *
    1.44 +  * \param aData Image data to upload.
    1.45 +  * \param aDstRegion Region of texture to upload to.
    1.46 +  * \param aTexture Texture to use, or 0 to have one created for you.
    1.47 +  * \param aOverwrite Over an existing texture with a new one.
    1.48 +  * \param aSrcPoint Offset into aSrc where the region's bound's
    1.49 +  *  TopLeft() sits.
    1.50 +  * \param aPixelBuffer Pass true to upload texture data with an
    1.51 +  *  offset from the base data (generally for pixel buffer objects),
    1.52 +  *  otherwise textures are upload with an absolute pointer to the data.
    1.53 +  * \param aTextureUnit, the texture unit used temporarily to upload the
    1.54 +  *  surface. This testure may be overridden, clients should not rely on
    1.55 +  *  the contents of this texture after this call or even on this
    1.56 +  *  texture unit being active.
    1.57 +  * \return Surface format of this texture.
    1.58 +  */
    1.59 +gfx::SurfaceFormat
    1.60 +UploadImageDataToTexture(GLContext* gl,
    1.61 +                         unsigned char* aData,
    1.62 +                         int32_t aStride,
    1.63 +                         gfx::SurfaceFormat aFormat,
    1.64 +                         const nsIntRegion& aDstRegion,
    1.65 +                         GLuint& aTexture,
    1.66 +                         bool aOverwrite = false,
    1.67 +                         bool aPixelBuffer = false,
    1.68 +                         GLenum aTextureUnit = LOCAL_GL_TEXTURE0,
    1.69 +                         GLenum aTextureTarget = LOCAL_GL_TEXTURE_2D);
    1.70 +
    1.71 +/**
    1.72 +  * Convenience wrapper around UploadImageDataToTexture for gfx::DataSourceSurface's.
    1.73 +  */
    1.74 +gfx::SurfaceFormat
    1.75 +UploadSurfaceToTexture(GLContext* gl,
    1.76 +                       gfx::DataSourceSurface *aSurface,
    1.77 +                       const nsIntRegion& aDstRegion,
    1.78 +                       GLuint& aTexture,
    1.79 +                       bool aOverwrite = false,
    1.80 +                       const nsIntPoint& aSrcPoint = nsIntPoint(0, 0),
    1.81 +                       bool aPixelBuffer = false,
    1.82 +                       GLenum aTextureUnit = LOCAL_GL_TEXTURE0,
    1.83 +                       GLenum aTextureTarget = LOCAL_GL_TEXTURE_2D);
    1.84 +
    1.85 +bool CanUploadSubTextures(GLContext* gl);
    1.86 +bool CanUploadNonPowerOfTwo(GLContext* gl);
    1.87 +
    1.88 +}
    1.89 +}
    1.90 +
    1.91 +#endif

mercurial