]> git.sesse.net Git - casparcg/blob - core/processor/draw_frame.cpp
0c030d9c7397de4240de0e427764fad6943eaf0f
[casparcg] / core / processor / draw_frame.cpp
1 #include "../stdafx.h"\r
2 \r
3 #include "draw_frame.h"\r
4 \r
5 #include "frame_shader.h"\r
6 \r
7 namespace caspar { namespace core {\r
8         \r
9 draw_frame::draw_frame() : type_(empty_tag){}\r
10 draw_frame::draw_frame(const draw_frame& other) : impl_(other.impl_), type_(other.type_){}\r
11 draw_frame::draw_frame(draw_frame&& other) : impl_(std::move(other.impl_)), type_(other.type_)\r
12 {\r
13         other.type_ = empty_tag;\r
14 }\r
15 \r
16 const std::vector<short>& draw_frame::audio_data() const \r
17 {\r
18         static std::vector<short> no_audio;\r
19         return impl_ ? impl_->audio_data() : no_audio;\r
20 }       \r
21 \r
22 void draw_frame::swap(draw_frame& other)\r
23 {\r
24         impl_.swap(other.impl_);\r
25         std::swap(type_, other.type_);\r
26 }\r
27         \r
28 void draw_frame::begin_write()\r
29 {\r
30         if(impl_)\r
31                 impl_->begin_write();\r
32 }\r
33 \r
34 void draw_frame::end_write()\r
35 {\r
36         if(impl_)\r
37                 impl_->end_write();\r
38 }\r
39 \r
40 void draw_frame::draw(frame_shader& shader)\r
41 {\r
42         if(impl_)\r
43                 impl_->draw(shader);\r
44 }\r
45 \r
46 eof_frame draw_frame::eof(){return eof_frame();}\r
47 empty_frame draw_frame::empty(){return empty_frame();}\r
48         \r
49 bool draw_frame::operator==(const eof_frame&){return type_ == eof_tag;}\r
50 bool draw_frame::operator==(const empty_frame&){return type_ == empty_tag;}\r
51 bool draw_frame::operator==(const draw_frame& other){return impl_ == other.impl_ && type_ == other.type_;}\r
52         \r
53 draw_frame& draw_frame::operator=(const draw_frame& other)\r
54 {\r
55         draw_frame temp(other);\r
56         temp.swap(*this);\r
57         return *this;\r
58 }\r
59 draw_frame& draw_frame::operator=(draw_frame&& other)\r
60 {\r
61         impl_ = std::move(other.impl_);\r
62         type_ = other.type_;\r
63         other.type_ = empty_tag;\r
64         return *this;\r
65 }\r
66 draw_frame& draw_frame::operator=(eof_frame&&)\r
67 {\r
68         impl_ = nullptr;\r
69         type_ = eof_tag;\r
70         return *this;\r
71 }       \r
72 draw_frame& draw_frame::operator=(empty_frame&&)\r
73 {\r
74         impl_ = nullptr;\r
75         type_ = empty_tag;\r
76         return *this;\r
77 }       \r
78 \r
79 }}