X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=core%2Fproducer%2Fcolor%2Fcolor_producer.cpp;h=002ef09d6df3200b196114075b6fd45efa2d3ca4;hb=745f022a44f0d347e56acbbd597ff71e06eab894;hp=f1e199504f4bf3f146c29a0c538ca98b034c3431;hpb=229bd75cefb4d4de8620edac3a361687dfc43596;p=casparcg diff --git a/core/producer/color/color_producer.cpp b/core/producer/color/color_producer.cpp index f1e199504..002ef09d6 100644 --- a/core/producer/color/color_producer.cpp +++ b/core/producer/color/color_producer.cpp @@ -22,7 +22,7 @@ #include "color_producer.h" -#include "../../processor/draw_frame.h" +#include #include @@ -30,30 +30,34 @@ namespace caspar { namespace core { class color_producer : public frame_producer { + safe_ptr frame_; + std::wstring color_str_; + printer parent_printer_; + public: - color_producer(color_producer&& other) : frame_(std::move(other.frame_)), color_str_(std::move(other.color_str_)){} - explicit color_producer(const std::wstring& color) : color_str_(color), frame_(draw_frame::empty()) + explicit color_producer(const std::wstring& color) + : color_str_(color) + , frame_(draw_frame::empty()) { if(color.length() != 9 || color[0] != '#') BOOST_THROW_EXCEPTION(invalid_argument() << arg_name_info("color") << arg_value_info(narrow(color)) << msg_info("Invalid color code")); } - - virtual safe_ptr receive() { return frame_; } - virtual void initialize(const safe_ptr& frame_processor) + virtual void initialize(const safe_ptr& frame_factory) { - auto frame = frame_processor->create_frame(1, 1, pixel_format::bgra); + auto frame = frame_factory->create_frame(1, 1, pixel_format::bgra); auto& value = *reinterpret_cast(frame->image_data().begin()); std::wstringstream str(color_str_.substr(1)); str >> std::hex >> value; frame_ = std::move(frame); } - - virtual std::wstring print() const { return + L"color[" + color_str_ + L"]"; } - safe_ptr frame_; - std::wstring color_str_; + virtual void set_parent_printer(const printer& parent_printer){parent_printer_ = parent_printer;} + + virtual safe_ptr receive() { return frame_; } + + virtual std::wstring print() const { return (parent_printer_ ? parent_printer_() + L"/" : L"") + L"color[" + color_str_ + L"]"; } }; safe_ptr create_color_producer(const std::vector& params) @@ -63,4 +67,9 @@ safe_ptr create_color_producer(const std::vector& return make_safe(params[0]); } +volatile struct reg +{ + reg(){register_producer_factory(create_color_producer);} +} my_reg; + }} \ No newline at end of file