]> git.sesse.net Git - mlt/blob - src/modules/opengl/glsl_manager.h
Refactor movit.convert, movit.mix, and movit.overlay.
[mlt] / src / modules / opengl / glsl_manager.h
1 /*
2  * glsl_manager.h
3  * Copyright (C) 2013 Dan Dennedy <dan@dennedy.org>
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; either version 2 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, write to the Free Software Foundation,
17  * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18  */
19
20 #ifndef GLSL_MANAGER_H
21 #define GLSL_MANAGER_H
22
23 #include <glew.h>
24 #include <mlt++/MltFilter.h>
25 #include <mlt++/MltDeque.h>
26
27 #define MAXLISTCOUNT 1024
28 typedef struct glsl_list_s *glsl_list;
29 struct glsl_list_s
30 {
31         void *items[MAXLISTCOUNT];
32         int count;
33
34         int ( *add )( glsl_list, void* );
35         void* ( *at )( glsl_list, int );
36         void* ( *take_at )( glsl_list, int );
37         void* ( *take )( glsl_list, void* );
38 };
39
40 struct glsl_texture_s
41 {
42         int used;
43         GLuint texture;
44         int width;
45         int height;
46         GLint internal_format;
47 };
48 typedef struct glsl_texture_s *glsl_texture;
49
50 struct glsl_fbo_s
51 {
52         int used;
53         int width;
54         int height;
55         GLuint fbo;
56 };
57 typedef struct glsl_fbo_s *glsl_fbo;
58
59 struct glsl_pbo_s
60 {
61         int size;
62         GLuint pbo;
63 };
64 typedef struct glsl_pbo_s *glsl_pbo;
65
66 class Effect;
67 class EffectChain;
68 class MltInput;
69
70 class GlslManager : public Mlt::Filter
71 {
72 public:
73         GlslManager();
74         ~GlslManager();
75         static GlslManager* get_instance();
76
77         glsl_fbo get_fbo(int width, int height);
78         static void release_fbo(glsl_fbo);
79         glsl_texture get_texture(int width, int height, GLint internal_format);
80         static void release_texture(glsl_texture);
81         glsl_pbo get_pbo(int size);
82         void cleanupContext();
83
84         Properties effect_list( Mlt::Service &service );
85         static bool init_chain(mlt_service);
86         static EffectChain* get_chain(mlt_service);
87         static MltInput* get_input(mlt_service);
88         static void reset_finalized(mlt_service);
89         static Effect* get_effect(mlt_filter, mlt_frame);
90         static Effect* add_effect(mlt_filter, mlt_frame, Effect*);
91         static Effect* add_effect(mlt_filter, mlt_frame, Effect*, Effect* input_b);
92         static void render_fbo(mlt_service, void *chain, GLuint fbo, int width, int height);
93         int render_frame_texture(mlt_service, mlt_frame, int width, int height, uint8_t **image);
94         int render_frame_rgba(mlt_service, mlt_frame, int width, int height, uint8_t **image);
95         static void lock_service(mlt_frame frame);
96         static void unlock_service(mlt_frame frame);
97
98 private:
99         static void onInit( mlt_properties owner, GlslManager* filter );
100         static void onClose( mlt_properties owner, GlslManager* filter );
101         static void onServiceChanged( mlt_properties owner, mlt_service service );
102         static void onPropertyChanged( mlt_properties owner, mlt_service service, const char* property );
103         Mlt::Deque fbo_list;
104         Mlt::Deque texture_list;
105         glsl_pbo  pbo;
106         Mlt::Event* initEvent;
107         Mlt::Event* closeEvent;
108 };
109
110 #endif // GLSL_MANAGER_H