2 * filter_glsl_manager.h
3 * Copyright (C) 2013 Dan Dennedy <dan@dennedy.org>
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.
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.
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.
20 #ifndef GLSL_MANAGER_H
21 #define GLSL_MANAGER_H
24 #include <mlt++/MltFilter.h>
25 #include <mlt++/MltDeque.h>
27 #define MAXLISTCOUNT 1024
28 typedef struct glsl_list_s *glsl_list;
31 void *items[MAXLISTCOUNT];
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* );
46 GLint internal_format;
48 typedef struct glsl_texture_s *glsl_texture;
58 typedef struct glsl_fbo_s *glsl_fbo;
65 typedef struct glsl_pbo_s *glsl_pbo;
71 class GlslManager : public Mlt::Filter
76 static GlslManager* get_instance();
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();
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);
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 );
105 Mlt::Deque texture_list;
107 Mlt::Event* initEvent;
108 Mlt::Event* closeEvent;
111 #endif // GLSL_MANAGER_H