]> git.sesse.net Git - casparcg/commitdiff
git-svn-id: https://casparcg.svn.sourceforge.net/svnroot/casparcg/server/branches...
authorronag <ronag@362d55ac-95cf-4e76-9f9a-cbaa9c17b72d>
Sun, 8 May 2011 22:00:53 +0000 (22:00 +0000)
committerronag <ronag@362d55ac-95cf-4e76-9f9a-cbaa9c17b72d>
Sun, 8 May 2011 22:00:53 +0000 (22:00 +0000)
modules/bluefish/bluefish.cpp
modules/flash/producer/cg_producer.cpp
modules/flash/producer/flash_producer.cpp
modules/flash/producer/flash_producer.h

index eeea99eb542e7c5fc90c337da3f09b445da4660e..2e39229aaef51983a45e8a60f4098a38bb698567 100644 (file)
@@ -28,9 +28,9 @@ void init_bluefish()
        try\r
        {\r
                blue_initialize();\r
+               core::register_consumer_factory([](const std::vector<std::wstring>& params){return create_bluefish_consumer(params);});\r
        }\r
        catch(...){}\r
-       core::register_consumer_factory([](const std::vector<std::wstring>& params){return create_bluefish_consumer(params);});\r
 }\r
 \r
 }
\ No newline at end of file
index 39461dd655fb25bcd7e12f4a9982836e5f82c85d..f5ac48954bec1ce4421facbb9e7c82e2a7f04725 100644 (file)
 */\r
 #include "../StdAfx.h"\r
 \r
-#include <common/env.h>\r
-\r
 #include "cg_producer.h"\r
 \r
 #include "flash_producer.h"\r
 \r
+#include <common/env.h>\r
+\r
 #include <boost/filesystem.hpp>\r
 #include <boost/format.hpp>\r
-\r
-#include <boost/assign.hpp>\r
-\r
-using boost::format;\r
-using boost::io::group;\r
                \r
 namespace caspar {\r
        \r
index 1992a559549364cfcb6276e4e9aa5f5204675cd4..c602bbfd0145deb7b36599c17d7e4f9cc5661ae0 100644 (file)
 \r
 namespace caspar {\r
                \r
+class bitmap\r
+{\r
+public:\r
+       bitmap(size_t width, size_t height)\r
+               : bmp_data_(nullptr)\r
+               , hdc_(CreateCompatibleDC(0), DeleteDC)\r
+       {       \r
+               BITMAPINFO info;\r
+               memset(&info, 0, sizeof(BITMAPINFO));\r
+               info.bmiHeader.biBitCount = 32;\r
+               info.bmiHeader.biCompression = BI_RGB;\r
+               info.bmiHeader.biHeight = -height;\r
+               info.bmiHeader.biPlanes = 1;\r
+               info.bmiHeader.biSize = sizeof(BITMAPINFO);\r
+               info.bmiHeader.biWidth = width;\r
+\r
+               bmp_.reset(CreateDIBSection(static_cast<HDC>(hdc_.get()), &info, DIB_RGB_COLORS, reinterpret_cast<void**>(&bmp_data_), 0, 0), DeleteObject);\r
+               SelectObject(static_cast<HDC>(hdc_.get()), bmp_.get()); \r
+       }\r
+\r
+       operator HDC() {return static_cast<HDC>(hdc_.get());}\r
+\r
+       BYTE* data() { return bmp_data_;}\r
+       const BYTE* data() const { return bmp_data_;}\r
+\r
+private:\r
+       BYTE* bmp_data_;        \r
+       std::shared_ptr<void> hdc_;\r
+       std::shared_ptr<void> bmp_;\r
+};\r
+\r
 class flash_renderer\r
 {      \r
        const std::wstring filename_;\r
@@ -56,12 +87,9 @@ class flash_renderer
 \r
        const std::shared_ptr<core::frame_factory> frame_factory_;\r
        \r
-       BYTE* bmp_data_;        \r
-       std::shared_ptr<void> hdc_;\r
-       std::shared_ptr<void> bmp_;\r
-\r
        CComObject<caspar::flash::FlashAxContainer>* ax_;\r
        safe_ptr<core::basic_frame> head_;\r
+       bitmap bmp_;\r
        \r
        safe_ptr<diagnostics::graph> graph_;\r
        boost::timer frame_timer_;\r
@@ -75,10 +103,9 @@ public:
                , filename_(filename)\r
                , format_desc_(frame_factory->get_video_format_desc())\r
                , frame_factory_(frame_factory)\r
-               , bmp_data_(nullptr)\r
-               , hdc_(CreateCompatibleDC(0), DeleteDC)\r
                , ax_(nullptr)\r
                , head_(core::basic_frame::empty())\r
+               , bmp_(format_desc_.width, format_desc_.height)\r
        {\r
                graph_->add_guide("frame-time", 0.5f);\r
                graph_->set_color("frame-time", diagnostics::color(1.0f, 0.0f, 0.0f));  \r
@@ -108,19 +135,8 @@ public:
                if(FAILED(spFlash->put_ScaleMode(2)))  //Exact fit. Scale without respect to the aspect ratio.\r
                        BOOST_THROW_EXCEPTION(caspar_exception() << msg_info(narrow(print()) + " Failed to Set Scale Mode"));\r
                                                \r
-               ax_->SetFormat(format_desc_);\r
-               \r
-               BITMAPINFO info;\r
-               memset(&info, 0, sizeof(BITMAPINFO));\r
-               info.bmiHeader.biBitCount = 32;\r
-               info.bmiHeader.biCompression = BI_RGB;\r
-               info.bmiHeader.biHeight = -format_desc_.height;\r
-               info.bmiHeader.biPlanes = 1;\r
-               info.bmiHeader.biSize = sizeof(BITMAPINFO);\r
-               info.bmiHeader.biWidth = format_desc_.width;\r
-\r
-               bmp_.reset(CreateDIBSection(static_cast<HDC>(hdc_.get()), &info, DIB_RGB_COLORS, reinterpret_cast<void**>(&bmp_data_), 0, 0), DeleteObject);\r
-               SelectObject(static_cast<HDC>(hdc_.get()), bmp_.get()); \r
+               ax_->SetFormat(format_desc_);           \r
+       \r
                CASPAR_LOG(info) << print() << L" Thread started.";\r
        }\r
 \r
@@ -164,11 +180,11 @@ public:
                ax_->Tick();\r
                if(ax_->InvalidRect())\r
                {                       \r
-                       fast_memclr(bmp_data_,  format_desc_.size);\r
-                       ax_->DrawControl(static_cast<HDC>(hdc_.get()));\r
+                       fast_memclr(bmp_.data(),  format_desc_.size);\r
+                       ax_->DrawControl(bmp_);\r
                \r
                        auto frame = frame_factory_->create_frame(this);\r
-                       fast_memcpy(frame->image_data().begin(), bmp_data_, format_desc_.size);\r
+                       fast_memcpy(frame->image_data().begin(), bmp_.data(), format_desc_.size);\r
                        head_ = frame;\r
                }               \r
                                \r
index dd47d9b9d89583d21358bd9bff8768067f49228b..a5362d2067dd454f2d8a1976436689029d4f9813 100644 (file)
 \r
 #include <core/producer/frame_producer.h>\r
 \r
-#include <memory>\r
+#include <common/memory/safe_ptr.h>\r
+\r
+#include <vector>\r
+#include <string>\r
 \r
 namespace caspar {\r
 \r