gfx/gl/GLReadTexImageHelper.h

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/gfx/gl/GLReadTexImageHelper.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,75 @@
     1.4 +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
     1.5 +/* vim: set ts=8 sts=4 et sw=4 tw=80: */
     1.6 +/* This Source Code Form is subject to the terms of the Mozilla Public
     1.7 + * License, v. 2.0. If a copy of the MPL was not distributed with this
     1.8 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.9 +
    1.10 +#ifndef GLREADTEXIMAGEHELPER_H_
    1.11 +#define GLREADTEXIMAGEHELPER_H_
    1.12 +
    1.13 +#include "GLContextTypes.h"
    1.14 +#include "mozilla/Attributes.h"
    1.15 +#include "nsSize.h"
    1.16 +#include "nsAutoPtr.h"
    1.17 +#include "mozilla/RefPtr.h"
    1.18 +#include "mozilla/gfx/Types.h"
    1.19 +
    1.20 +class gfxImageSurface;
    1.21 +
    1.22 +namespace mozilla {
    1.23 +
    1.24 +namespace gfx {
    1.25 +class DataSourceSurface;
    1.26 +}
    1.27 +
    1.28 +namespace gl {
    1.29 +
    1.30 +void ReadPixelsIntoImageSurface(GLContext* aGL, gfxImageSurface* aSurface);
    1.31 +void ReadScreenIntoImageSurface(GLContext* aGL, gfxImageSurface* aSurface);
    1.32 +
    1.33 +TemporaryRef<gfx::DataSourceSurface>
    1.34 +ReadBackSurface(GLContext* gl, GLuint aTexture, bool aYInvert, gfx::SurfaceFormat aFormat);
    1.35 +
    1.36 +class GLReadTexImageHelper MOZ_FINAL
    1.37 +{
    1.38 +    // The GLContext is the sole owner of the GLBlitHelper.
    1.39 +    GLContext* mGL;
    1.40 +
    1.41 +    GLuint mPrograms[4];
    1.42 +
    1.43 +    GLuint TextureImageProgramFor(GLenum aTextureTarget, int aShader);
    1.44 +
    1.45 +    bool DidGLErrorOccur(const char* str);
    1.46 +
    1.47 +public:
    1.48 +
    1.49 +    GLReadTexImageHelper(GLContext* gl);
    1.50 +    ~GLReadTexImageHelper();
    1.51 +
    1.52 +    /**
    1.53 +      * Read the image data contained in aTexture, and return it as an ImageSurface.
    1.54 +      * If GL_RGBA is given as the format, a gfxImageFormat::ARGB32 surface is returned.
    1.55 +      * Not implemented yet:
    1.56 +      * If GL_RGB is given as the format, a gfxImageFormat::RGB24 surface is returned.
    1.57 +      * If GL_LUMINANCE is given as the format, a gfxImageFormat::A8 surface is returned.
    1.58 +      *
    1.59 +      * THIS IS EXPENSIVE.  It is ridiculously expensive.  Only do this
    1.60 +      * if you absolutely positively must, and never in any performance
    1.61 +      * critical path.
    1.62 +      *
    1.63 +      * NOTE: aShaderProgram is really mozilla::layers::ShaderProgramType. It is
    1.64 +      * passed as int to eliminate including LayerManagerOGLProgram.h here.
    1.65 +      */
    1.66 +    TemporaryRef<gfx::DataSourceSurface> ReadTexImage(GLuint aTextureId,
    1.67 +                                                      GLenum aTextureTarget,
    1.68 +                                                      const gfx::IntSize& aSize,
    1.69 +                              /* ShaderProgramType */ int aShaderProgram,
    1.70 +                                                      bool aYInvert = false);
    1.71 +
    1.72 +
    1.73 +};
    1.74 +
    1.75 +}
    1.76 +}
    1.77 +
    1.78 +#endif

mercurial