Bug 1470678 [wpt PR 11640] - Add a test for text-decoration in tables quirk, a=testonly
[gecko.git] / gfx / gl / GLReadTexImageHelper.h
blob8e9fb0eaf4719434f0736d4cdcaaa8cbcf6746c6
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 "mozilla/RefPtr.h"
14 #include "mozilla/gfx/Types.h"
16 namespace mozilla {
18 namespace gfx {
19 class DataSourceSurface;
20 } // namespace gfx
22 namespace gl {
24 // Returns true if the `dest{Format,Type}` are the same as the
25 // `read{Format,Type}`.
26 bool GetActualReadFormats(GLContext* gl,
27 GLenum destFormat, GLenum destType,
28 GLenum* out_readFormat, GLenum* out_readType);
30 void ReadPixelsIntoDataSurface(GLContext* aGL,
31 gfx::DataSourceSurface* aSurface);
33 already_AddRefed<gfx::DataSourceSurface>
34 ReadBackSurface(GLContext* gl, GLuint aTexture, bool aYInvert, gfx::SurfaceFormat aFormat);
36 already_AddRefed<gfx::DataSourceSurface>
37 YInvertImageSurface(gfx::DataSourceSurface* aSurf, uint32_t aStride);
39 void
40 SwapRAndBComponents(gfx::DataSourceSurface* surf);
42 class GLReadTexImageHelper final
44 // The GLContext is the sole owner of the GLBlitHelper.
45 GLContext* mGL;
47 GLuint mPrograms[4];
49 GLuint TextureImageProgramFor(GLenum aTextureTarget, int aShader);
51 bool DidGLErrorOccur(const char* str);
53 public:
55 explicit GLReadTexImageHelper(GLContext* gl);
56 ~GLReadTexImageHelper();
58 /**
59 * Read the image data contained in aTexture, and return it as an ImageSurface.
60 * If GL_RGBA is given as the format, a SurfaceFormat::A8R8G8B8_UINT32 surface is returned.
61 * Not implemented yet:
62 * If GL_RGB is given as the format, a SurfaceFormat::X8R8G8B8_UINT32 surface is returned.
63 * If GL_LUMINANCE is given as the format, a SurfaceFormat::A8 surface is returned.
65 * THIS IS EXPENSIVE. It is ridiculously expensive. Only do this
66 * if you absolutely positively must, and never in any performance
67 * critical path.
69 * NOTE: aShaderProgram is really mozilla::layers::ShaderProgramType. It is
70 * passed as int to eliminate including LayerManagerOGLProgram.h here.
72 already_AddRefed<gfx::DataSourceSurface> ReadTexImage(GLuint aTextureId,
73 GLenum aTextureTarget,
74 const gfx::IntSize& aSize,
75 /* ShaderProgramType */ int aShaderProgram,
76 bool aYInvert = false);
78 bool ReadTexImage(gfx::DataSourceSurface* aDest,
79 GLuint aTextureId,
80 GLenum aTextureTarget,
81 const gfx::IntSize& aSize,
82 int aShaderProgram,
83 bool aYInvert = false);
86 } // namespace gl
87 } // namespace mozilla
89 #endif