gfx/gl/GLReadTexImageHelper.h

branch
TOR_BUG_9701
changeset 8
97036ab72558
equal deleted inserted replaced
-1:000000000000 0:8d96d4e9e395
1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /* vim: set ts=8 sts=4 et sw=4 tw=80: */
3 /* This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6
7 #ifndef GLREADTEXIMAGEHELPER_H_
8 #define GLREADTEXIMAGEHELPER_H_
9
10 #include "GLContextTypes.h"
11 #include "mozilla/Attributes.h"
12 #include "nsSize.h"
13 #include "nsAutoPtr.h"
14 #include "mozilla/RefPtr.h"
15 #include "mozilla/gfx/Types.h"
16
17 class gfxImageSurface;
18
19 namespace mozilla {
20
21 namespace gfx {
22 class DataSourceSurface;
23 }
24
25 namespace gl {
26
27 void ReadPixelsIntoImageSurface(GLContext* aGL, gfxImageSurface* aSurface);
28 void ReadScreenIntoImageSurface(GLContext* aGL, gfxImageSurface* aSurface);
29
30 TemporaryRef<gfx::DataSourceSurface>
31 ReadBackSurface(GLContext* gl, GLuint aTexture, bool aYInvert, gfx::SurfaceFormat aFormat);
32
33 class GLReadTexImageHelper MOZ_FINAL
34 {
35 // The GLContext is the sole owner of the GLBlitHelper.
36 GLContext* mGL;
37
38 GLuint mPrograms[4];
39
40 GLuint TextureImageProgramFor(GLenum aTextureTarget, int aShader);
41
42 bool DidGLErrorOccur(const char* str);
43
44 public:
45
46 GLReadTexImageHelper(GLContext* gl);
47 ~GLReadTexImageHelper();
48
49 /**
50 * Read the image data contained in aTexture, and return it as an ImageSurface.
51 * If GL_RGBA is given as the format, a gfxImageFormat::ARGB32 surface is returned.
52 * Not implemented yet:
53 * If GL_RGB is given as the format, a gfxImageFormat::RGB24 surface is returned.
54 * If GL_LUMINANCE is given as the format, a gfxImageFormat::A8 surface is returned.
55 *
56 * THIS IS EXPENSIVE. It is ridiculously expensive. Only do this
57 * if you absolutely positively must, and never in any performance
58 * critical path.
59 *
60 * NOTE: aShaderProgram is really mozilla::layers::ShaderProgramType. It is
61 * passed as int to eliminate including LayerManagerOGLProgram.h here.
62 */
63 TemporaryRef<gfx::DataSourceSurface> ReadTexImage(GLuint aTextureId,
64 GLenum aTextureTarget,
65 const gfx::IntSize& aSize,
66 /* ShaderProgramType */ int aShaderProgram,
67 bool aYInvert = false);
68
69
70 };
71
72 }
73 }
74
75 #endif

mercurial