]> git.vomp.tv Git - vompclient.git/blob - omx/omxeglrender.h
Rewrite of ImageOMX to fix the PNG problem
[vompclient.git] / omx / omxeglrender.h
1 /*
2     Copyright 2021 Chris Tallon
3
4     This file is part of VOMP.
5
6     VOMP is free software; you can redistribute it and/or modify
7     it under the terms of the GNU General Public License as published by
8     the Free Software Foundation; either version 2 of the License, or
9     (at your option) any later version.
10
11     VOMP is distributed in the hope that it will be useful,
12     but WITHOUT ANY WARRANTY; without even the implied warranty of
13     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14     GNU General Public License for more details.
15
16     You should have received a copy of the GNU General Public License
17     along with VOMP.  If not, see <https://www.gnu.org/licenses/>.
18 */
19
20 #ifndef OMXEGLRENDER_H
21 #define OMXEGLRENDER_H
22
23 #include <VG/openvg.h>
24 #include <EGL/egl.h>
25 #include <EGL/eglext.h>
26
27 #include "omx.h"
28
29 class OMX_EGL_Render : public OMX
30 {
31   friend class OMX;
32
33   public:
34     OMX_EGL_Render();
35     virtual ~OMX_EGL_Render();
36
37     bool init();
38     void shutdown();
39
40     void prepareInputPort(OMX_U32 frameWidth, OMX_U32 frameHeight, OMX_U32 stride);  // throws
41     void prepareOutputPort(EGLDisplay egldisplay);  // throws
42
43     void allocateInputBuffers(char* buffer);  // throws
44     void allocateEGLImageKHR(EGLImageKHR eglimagekhr);  // throws
45
46     void deallocateInputBuffers();  // throws
47     void deallocateEGLImageKHR();  // throws
48
49     void sendToInput(char* data, int dataSize);  // throws
50     void render();  // throws
51
52     void printPortSettings(bool which);  // throws
53
54     // Buffers callback overrides
55
56     OMX_ERRORTYPE cb_FillBufferDone(
57       OMX_IN OMX_HANDLETYPE handle, OMX_IN OMX_PTR appdata, OMX_IN OMX_BUFFERHEADERTYPE* buffer) override;
58
59     OMX_ERRORTYPE cb_EmptyBufferDone(
60       OMX_IN OMX_HANDLETYPE handle, OMX_IN OMX_PTR appdata, OMX_IN OMX_BUFFERHEADERTYPE* buffer) override;
61
62     void enableInput(bool wait = true) { enablePort(inputPort, true, wait); }  // throws
63     void disableInput(bool wait = true) { enablePort(inputPort, false, wait); }  // throws
64     void enableOutput(bool wait = true) { enablePort(outputPort, true, wait); }  // throws
65     void disableOutput(bool wait = true) { enablePort(outputPort, false, wait); }  // throws
66     void flushInputCommands(bool wait = true) { flushCommands(inputPort, wait); }  // throws
67     void flushOutputCommands(bool wait = true) { flushCommands(outputPort, wait); }  // throws
68
69   protected:
70
71     OMX_U32 inputPort;
72     OMX_U32 outputPort;
73
74     OMX_BUFFERHEADERTYPE* inBuffer1 = NULL;
75     OMX_BUFFERHEADERTYPE* eglRenderOutputBufferHeader;
76
77     int inputPortBufferSize{};
78 };
79
80 #endif