Bug 1032573 part 4 - Add AnimationTimeline::ToTimelineTime helper method; r=dbaron
[gecko.git] / gfx / gl / GLReadTexImageHelper.h
blob38f4ca3bfc7412d618c3a023cc6f9fbd8743f570
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/. */
7 #ifndef GLREADTEXIMAGEHELPER_H_
8 #define GLREADTEXIMAGEHELPER_H_
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"
17 namespace mozilla {
19 namespace gfx {
20 class DataSourceSurface;
23 namespace gl {
25 void ReadPixelsIntoDataSurface(GLContext* aGL,
26 gfx::DataSourceSurface* aSurface);
28 TemporaryRef<gfx::DataSourceSurface>
29 ReadBackSurface(GLContext* gl, GLuint aTexture, bool aYInvert, gfx::SurfaceFormat aFormat);
31 class GLReadTexImageHelper MOZ_FINAL
33 // The GLContext is the sole owner of the GLBlitHelper.
34 GLContext* mGL;
36 GLuint mPrograms[4];
38 GLuint TextureImageProgramFor(GLenum aTextureTarget, int aShader);
40 bool DidGLErrorOccur(const char* str);
42 public:
44 GLReadTexImageHelper(GLContext* gl);
45 ~GLReadTexImageHelper();
47 /**
48 * Read the image data contained in aTexture, and return it as an ImageSurface.
49 * If GL_RGBA is given as the format, a gfxImageFormat::ARGB32 surface is returned.
50 * Not implemented yet:
51 * If GL_RGB is given as the format, a gfxImageFormat::RGB24 surface is returned.
52 * If GL_LUMINANCE is given as the format, a gfxImageFormat::A8 surface is returned.
54 * THIS IS EXPENSIVE. It is ridiculously expensive. Only do this
55 * if you absolutely positively must, and never in any performance
56 * critical path.
58 * NOTE: aShaderProgram is really mozilla::layers::ShaderProgramType. It is
59 * passed as int to eliminate including LayerManagerOGLProgram.h here.
61 TemporaryRef<gfx::DataSourceSurface> ReadTexImage(GLuint aTextureId,
62 GLenum aTextureTarget,
63 const gfx::IntSize& aSize,
64 /* ShaderProgramType */ int aShaderProgram,
65 bool aYInvert = false);
73 #endif