michael@0: /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ michael@0: /* vim: set ts=8 sts=4 et sw=4 tw=80: */ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #ifndef GLREADTEXIMAGEHELPER_H_ michael@0: #define GLREADTEXIMAGEHELPER_H_ michael@0: michael@0: #include "GLContextTypes.h" michael@0: #include "mozilla/Attributes.h" michael@0: #include "nsSize.h" michael@0: #include "nsAutoPtr.h" michael@0: #include "mozilla/RefPtr.h" michael@0: #include "mozilla/gfx/Types.h" michael@0: michael@0: class gfxImageSurface; michael@0: michael@0: namespace mozilla { michael@0: michael@0: namespace gfx { michael@0: class DataSourceSurface; michael@0: } michael@0: michael@0: namespace gl { michael@0: michael@0: void ReadPixelsIntoImageSurface(GLContext* aGL, gfxImageSurface* aSurface); michael@0: void ReadScreenIntoImageSurface(GLContext* aGL, gfxImageSurface* aSurface); michael@0: michael@0: TemporaryRef michael@0: ReadBackSurface(GLContext* gl, GLuint aTexture, bool aYInvert, gfx::SurfaceFormat aFormat); michael@0: michael@0: class GLReadTexImageHelper MOZ_FINAL michael@0: { michael@0: // The GLContext is the sole owner of the GLBlitHelper. michael@0: GLContext* mGL; michael@0: michael@0: GLuint mPrograms[4]; michael@0: michael@0: GLuint TextureImageProgramFor(GLenum aTextureTarget, int aShader); michael@0: michael@0: bool DidGLErrorOccur(const char* str); michael@0: michael@0: public: michael@0: michael@0: GLReadTexImageHelper(GLContext* gl); michael@0: ~GLReadTexImageHelper(); michael@0: michael@0: /** michael@0: * Read the image data contained in aTexture, and return it as an ImageSurface. michael@0: * If GL_RGBA is given as the format, a gfxImageFormat::ARGB32 surface is returned. michael@0: * Not implemented yet: michael@0: * If GL_RGB is given as the format, a gfxImageFormat::RGB24 surface is returned. michael@0: * If GL_LUMINANCE is given as the format, a gfxImageFormat::A8 surface is returned. michael@0: * michael@0: * THIS IS EXPENSIVE. It is ridiculously expensive. Only do this michael@0: * if you absolutely positively must, and never in any performance michael@0: * critical path. michael@0: * michael@0: * NOTE: aShaderProgram is really mozilla::layers::ShaderProgramType. It is michael@0: * passed as int to eliminate including LayerManagerOGLProgram.h here. michael@0: */ michael@0: TemporaryRef ReadTexImage(GLuint aTextureId, michael@0: GLenum aTextureTarget, michael@0: const gfx::IntSize& aSize, michael@0: /* ShaderProgramType */ int aShaderProgram, michael@0: bool aYInvert = false); michael@0: michael@0: michael@0: }; michael@0: michael@0: } michael@0: } michael@0: michael@0: #endif