1 #include "../StdAfx.h"
\r
3 #include "composite_gpu_frame.h"
\r
4 #include "../../common/image/copy.h"
\r
5 #include "../../common/gl/utility.h"
\r
12 struct composite_gpu_frame::implementation
\r
14 implementation(composite_gpu_frame* self) : self_(self){}
\r
18 std::for_each(frames_.begin(), frames_.end(), std::mem_fn(&gpu_frame::write_lock));
\r
23 return std::all_of(frames_.begin(), frames_.end(), std::mem_fn(&gpu_frame::write_unlock));
\r
26 void read_lock(GLenum mode)
\r
28 std::for_each(frames_.begin(), frames_.end(), std::bind(&gpu_frame::read_lock, std::placeholders::_1, mode));
\r
33 return std::all_of(frames_.begin(), frames_.end(), std::mem_fn(&gpu_frame::read_unlock));
\r
39 glTranslatef(self_->x()*2.0f, self_->y()*2.0f, 0.0f);
\r
40 std::for_each(frames_.begin(), frames_.end(), std::mem_fn(&gpu_frame::draw));
\r
44 void add(const gpu_frame_ptr& frame)
\r
46 frames_.push_back(frame);
\r
47 mix_audio_safe(audio_data_, frame->audio_data());
\r
50 unsigned char* data()
\r
52 BOOST_THROW_EXCEPTION(invalid_operation());
\r
55 composite_gpu_frame* self_;
\r
56 std::vector<gpu_frame_ptr> frames_;
\r
58 std::vector<short> audio_data_;
\r
61 #pragma warning (disable : 4355)
\r
63 composite_gpu_frame::composite_gpu_frame(size_t width, size_t height) : gpu_frame(width, height), impl_(new implementation(this)){}
\r
64 void composite_gpu_frame::write_lock(){impl_->write_lock();}
\r
65 bool composite_gpu_frame::write_unlock(){return impl_->write_unlock();}
\r
66 void composite_gpu_frame::read_lock(GLenum mode){impl_->read_lock(mode);}
\r
67 bool composite_gpu_frame::read_unlock(){return impl_->read_unlock();}
\r
68 void composite_gpu_frame::draw(){impl_->draw();}
\r
69 unsigned char* composite_gpu_frame::data(){return impl_->data();}
\r
70 const std::vector<short>& composite_gpu_frame::audio_data() const { return impl_->audio_data_; }
\r
71 std::vector<short>& composite_gpu_frame::audio_data() { return impl_->audio_data_; }
\r
72 void composite_gpu_frame::reset(){impl_->audio_data_.clear();}
\r
73 void composite_gpu_frame::add(const gpu_frame_ptr& frame){impl_->add(frame);}
\r