]> git.sesse.net Git - mlt/blob - src/modules/opengl/filter_glsl_manager.h
Rename glsl_manager.h to filter_glsl_manager.h, to be consistent with the .cpp file.
[mlt] / src / modules / opengl / filter_glsl_manager.h
1 /*
2  * filter_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         void* context;
57 };
58 typedef struct glsl_fbo_s *glsl_fbo;
59
60 struct glsl_pbo_s
61 {
62         int size;
63         GLuint pbo;
64 };
65 typedef struct glsl_pbo_s *glsl_pbo;
66
67 class Effect;
68 class EffectChain;
69 class MltInput;
70
71 class GlslManager : public Mlt::Filter
72 {
73 public:
74         GlslManager();
75         ~GlslManager();
76         static GlslManager* get_instance();
77
78         glsl_fbo get_fbo(int width, int height);
79         static void release_fbo(glsl_fbo);
80         glsl_texture get_texture(int width, int height, GLint internal_format);
81         static void release_texture(glsl_texture);
82         glsl_pbo get_pbo(int size);
83         void cleanupContext();
84
85         Properties effect_list( Mlt::Service &service );
86         static bool init_chain(mlt_service);
87         static EffectChain* get_chain(mlt_service);
88         static MltInput* get_input(mlt_service);
89         static void reset_finalized(mlt_service);
90         static Effect* get_effect(mlt_filter, mlt_frame);
91         static Effect* add_effect(mlt_filter, mlt_frame, Effect*);
92         static Effect* add_effect(mlt_filter, mlt_frame, Effect*, Effect* input_b);
93         static void render_fbo(mlt_service, void *chain, GLuint fbo, int width, int height);
94         int render_frame_texture(mlt_service, mlt_frame, int width, int height, uint8_t **image);
95         int render_frame_rgba(mlt_service, mlt_frame, int width, int height, uint8_t **image);
96         static void lock_service(mlt_frame frame);
97         static void unlock_service(mlt_frame frame);
98
99 private:
100         static void onInit( mlt_properties owner, GlslManager* filter );
101         static void onClose( mlt_properties owner, GlslManager* filter );
102         static void onServiceChanged( mlt_properties owner, mlt_service service );
103         static void onPropertyChanged( mlt_properties owner, mlt_service service, const char* property );
104         Mlt::Deque fbo_list;
105         Mlt::Deque texture_list;
106         glsl_pbo  pbo;
107         Mlt::Event* initEvent;
108         Mlt::Event* closeEvent;
109 };
110
111 #endif // GLSL_MANAGER_H