1 | /* |
2 | Copyright (C) 2016 Igalia S.L. |
3 | |
4 | This library is free software; you can redistribute it and/or |
5 | modify it under the terms of the GNU Library General Public |
6 | License as published by the Free Software Foundation; either |
7 | version 2 of the License, or (at your option) any later version. |
8 | |
9 | This library is distributed in the hope that it will be useful, |
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
12 | Library General Public License for more details. |
13 | |
14 | You should have received a copy of the GNU Library General Public License |
15 | along with this library; see the file COPYING.LIB. If not, write to |
16 | the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
17 | Boston, MA 02110-1301, USA. |
18 | */ |
19 | |
20 | #ifndef VideoTextureCopierGStreamer_h |
21 | #define VideoTextureCopierGStreamer_h |
22 | |
23 | #if USE(GSTREAMER_GL) |
24 | |
25 | #include "ImageOrientation.h" |
26 | #include "TextureMapperGLHeaders.h" |
27 | #include "TransformationMatrix.h" |
28 | #include <wtf/RefPtr.h> |
29 | |
30 | namespace WebCore { |
31 | |
32 | class TextureMapperShaderProgram; |
33 | class ImageOrientation; |
34 | |
35 | class VideoTextureCopierGStreamer { |
36 | public: |
37 | enum class ColorConversion { |
38 | ConvertBGRAToRGBA, |
39 | ConvertARGBToRGBA |
40 | }; |
41 | |
42 | VideoTextureCopierGStreamer(ColorConversion); |
43 | ~VideoTextureCopierGStreamer(); |
44 | |
45 | bool copyVideoTextureToPlatformTexture(GLuint inputTexture, IntSize& frameSize, GLuint outputTexture, GLenum outputTarget, GLint level, GLenum internalFormat, GLenum format, GLenum type, bool flipY, ImageOrientation& sourceOrientation); |
46 | void updateColorConversionMatrix(ColorConversion); |
47 | void updateTextureSpaceMatrix(); |
48 | void updateTransformationMatrix(); |
49 | GLuint resultTexture() { return m_resultTexture; } |
50 | |
51 | private: |
52 | RefPtr<TextureMapperShaderProgram> m_shaderProgram; |
53 | GLuint m_framebuffer { 0 }; |
54 | GLuint m_vbo { 0 }; |
55 | #if !USE(OPENGL_ES) |
56 | GLuint m_vao { 0 }; |
57 | #endif |
58 | bool m_flipY { false }; |
59 | ImageOrientation m_orientation; |
60 | IntSize m_size; |
61 | TransformationMatrix m_modelViewMatrix; |
62 | TransformationMatrix m_projectionMatrix; |
63 | TransformationMatrix m_textureSpaceMatrix; |
64 | TransformationMatrix m_colorConversionMatrix; |
65 | GLuint m_resultTexture { 0 }; |
66 | }; |
67 | |
68 | } // namespace WebCore |
69 | |
70 | #endif // USE(GSTREAMER_GL) |
71 | |
72 | #endif // VideoTextureCopierGStreamer_h |
73 | |