]> git.sesse.net Git - movit/blob - slice_effect.h
Revert "Reuse the VAO across all phases."
[movit] / slice_effect.h
1 #ifndef _MOVIT_SLICE_EFFECT_H
2 #define _MOVIT_SLICE_EFFECT_H 1
3
4 // SliceEffect takes an image, cuts it into (potentially overlapping) slices,
5 // and puts those slices back together again consecutively. It is primarily
6 // useful in an overlap-discard setting, where it can do both the overlap and
7 // discard roles, where one does convolutions by means of many small FFTs, but
8 // could also work as a (relatively boring) video effect on its own.
9 //
10 // Note that vertical slices happen from the top, consistent with the rest of
11 // Movit.
12
13 #include <epoxy/gl.h>
14 #include <string>
15
16 #include "effect.h"
17
18 namespace movit {
19
20 class SliceEffect : public Effect {
21 public:
22         SliceEffect();
23         virtual std::string effect_type_id() const { return "SliceEffect"; }
24         std::string output_fragment_shader();
25         virtual bool needs_texture_bounce() const { return true; }
26         virtual bool changes_output_size() const { return true; }
27         virtual bool sets_virtual_output_size() const { return false; }
28         virtual void inform_input_size(unsigned input_num, unsigned width, unsigned height);
29         virtual void get_output_size(unsigned *width, unsigned *height,
30                                      unsigned *virtual_width, unsigned *virtual_height) const;
31
32         void set_gl_state(GLuint glsl_program_num, const std::string &prefix, unsigned *sampler_num);
33         virtual void inform_added(EffectChain *chain) { this->chain = chain; }
34         
35         enum Direction { HORIZONTAL = 0, VERTICAL = 1 };
36
37 private:
38         EffectChain *chain;
39         int input_width, input_height;
40         int input_slice_size, output_slice_size;
41         int offset;
42         Direction direction;
43
44         float uniform_output_coord_to_slice_num, uniform_slice_num_to_input_coord;
45         float uniform_slice_offset_to_input_coord, uniform_offset;
46 };
47
48 }  // namespace movit
49
50 #endif // !defined(_MOVIT_SLICE_EFFECT_H)