#include "cpu/image/image_mixer.h"\r
#include "ogl/image/image_mixer.h"\r
\r
-#include "ogl/util/context.h"\r
+#include "ogl/util/device.h"\r
\r
#include <tbb/mutex.h>\r
\r
{\r
const std::wstring path_;\r
tbb::mutex mutex_;\r
- std::shared_ptr<ogl::context> ogl_context_;\r
+ std::shared_ptr<ogl::device> ogl_device_;\r
\r
impl(const std::wstring& path)\r
: path_(path)\r
{\r
tbb::mutex::scoped_lock lock(mutex_);\r
\r
- if(!ogl_context_)\r
- ogl_context_.reset(new ogl::context());\r
+ if(!ogl_device_)\r
+ ogl_device_.reset(new ogl::device());\r
\r
- return spl::make_unique<ogl::image_mixer>(spl::make_shared_ptr(ogl_context_));\r
+ return spl::make_unique<ogl::image_mixer>(spl::make_shared_ptr(ogl_device_));\r
}\r
}\r
catch(...)\r
<ClInclude Include="ogl\image\image_kernel.h" />\r
<ClInclude Include="ogl\image\image_mixer.h" />\r
<ClInclude Include="ogl\image\image_shader.h" />\r
- <ClInclude Include="ogl\util\context.h" />\r
+ <ClInclude Include="ogl\util\device.h" />\r
<ClInclude Include="ogl\util\device_buffer.h" />\r
<ClInclude Include="ogl\util\host_buffer.h" />\r
<ClInclude Include="ogl\util\shader.h" />\r
<PrecompiledHeaderFile Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">../../StdAfx.h</PrecompiledHeaderFile>\r
<PrecompiledHeaderFile Condition="'$(Configuration)|$(Platform)'=='Release|x64'">../../StdAfx.h</PrecompiledHeaderFile>\r
</ClCompile>\r
- <ClCompile Include="ogl\util\context.cpp">\r
+ <ClCompile Include="ogl\util\device.cpp">\r
<PrecompiledHeaderFile Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">../../StdAfx.h</PrecompiledHeaderFile>\r
<PrecompiledHeaderFile Condition="'$(Configuration)|$(Platform)'=='Release|x64'">../../StdAfx.h</PrecompiledHeaderFile>\r
</ClCompile>\r
<ClInclude Include="ogl\image\image_kernel.h">\r
<Filter>source\ogl\image</Filter>\r
</ClInclude>\r
- <ClInclude Include="ogl\util\context.h">\r
- <Filter>source\ogl\util</Filter>\r
- </ClInclude>\r
<ClInclude Include="ogl\util\device_buffer.h">\r
<Filter>source\ogl\util</Filter>\r
</ClInclude>\r
<ClInclude Include="ogl\util\data_frame.h">\r
<Filter>source\ogl\util</Filter>\r
</ClInclude>\r
+ <ClInclude Include="ogl\util\device.h">\r
+ <Filter>source\ogl\util</Filter>\r
+ </ClInclude>\r
</ItemGroup>\r
<ItemGroup>\r
<ClCompile Include="StdAfx.cpp" />\r
<ClCompile Include="ogl\image\image_kernel.cpp">\r
<Filter>source\ogl\image</Filter>\r
</ClCompile>\r
- <ClCompile Include="ogl\util\context.cpp">\r
- <Filter>source\ogl\util</Filter>\r
- </ClCompile>\r
<ClCompile Include="ogl\util\device_buffer.cpp">\r
<Filter>source\ogl\util</Filter>\r
</ClCompile>\r
<ClCompile Include="ogl\util\data_frame.cpp">\r
<Filter>source\ogl\util</Filter>\r
</ClCompile>\r
+ <ClCompile Include="ogl\util\device.cpp">\r
+ <Filter>source\ogl\util</Filter>\r
+ </ClCompile>\r
</ItemGroup>\r
</Project>
\ No newline at end of file
class image_renderer\r
{\r
std::pair<std::vector<item>, boost::shared_future<boost::iterator_range<const uint8_t*>>> last_image_;\r
- tbb::concurrent_unordered_map<int, tbb::concurrent_bounded_queue<std::shared_ptr<SwsContext>>> sws_contexts_;\r
+ tbb::concurrent_unordered_map<int, tbb::concurrent_bounded_queue<std::shared_ptr<SwsContext>>> sws_devices_;\r
tbb::concurrent_bounded_queue<spl::shared_ptr<host_buffer>> temp_buffers_;\r
public: \r
boost::shared_future<boost::iterator_range<const uint8_t*>> operator()(std::vector<item> items, const core::video_format_desc& format_desc)\r
\r
int key = ((input_av_frame->width << 22) & 0xFFC00000) | ((input_av_frame->height << 6) & 0x003FC000) | ((input_av_frame->format << 7) & 0x00007F00);\r
\r
- auto& pool = sws_contexts_[key];\r
+ auto& pool = sws_devices_[key];\r
\r
- std::shared_ptr<SwsContext> sws_context;\r
- if(!pool.try_pop(sws_context))\r
+ std::shared_ptr<SwsContext> sws_device;\r
+ if(!pool.try_pop(sws_device))\r
{\r
double param;\r
- sws_context.reset(sws_getContext(input_av_frame->width, input_av_frame->height, static_cast<PixelFormat>(input_av_frame->format), width, height, PIX_FMT_BGRA, SWS_BILINEAR, nullptr, nullptr, ¶m), sws_freeContext);\r
+ sws_device.reset(sws_getContext(input_av_frame->width, input_av_frame->height, static_cast<PixelFormat>(input_av_frame->format), width, height, PIX_FMT_BGRA, SWS_BILINEAR, nullptr, nullptr, ¶m), sws_freeContext);\r
}\r
\r
- if(!sws_context) \r
- BOOST_THROW_EXCEPTION(operation_failed() << msg_info("Could not create software scaling context.") << boost::errinfo_api_function("sws_getContext")); \r
+ if(!sws_device) \r
+ BOOST_THROW_EXCEPTION(operation_failed() << msg_info("Could not create software scaling device.") << boost::errinfo_api_function("sws_getContext")); \r
\r
auto dest_frame = spl::make_shared<host_buffer>(width*height*4);\r
temp_buffers_.push(dest_frame);\r
avcodec_get_frame_defaults(dest_av_frame.get()); \r
avpicture_fill(reinterpret_cast<AVPicture*>(dest_av_frame.get()), dest_frame->data(), PIX_FMT_BGRA, width, height);\r
\r
- sws_scale(sws_context.get(), input_av_frame->data, input_av_frame->linesize, 0, input_av_frame->height, dest_av_frame->data, dest_av_frame->linesize); \r
- pool.push(sws_context);\r
+ sws_scale(sws_device.get(), input_av_frame->data, input_av_frame->linesize, 0, input_av_frame->height, dest_av_frame->data, dest_av_frame->linesize); \r
+ pool.push(sws_device);\r
}\r
\r
for(std::size_t n = 0; n < source_items.size(); ++n)\r
\r
#include "../util/shader.h"\r
#include "../util/device_buffer.h"\r
-#include "../util/context.h"\r
+#include "../util/device.h"\r
\r
#include <common/except.h>\r
#include <common/gl/gl_check.h>\r
\r
struct image_kernel::impl : boost::noncopyable\r
{ \r
- spl::shared_ptr<context> ogl_;\r
+ spl::shared_ptr<device> ogl_;\r
spl::shared_ptr<shader> shader_;\r
bool blend_modes_;\r
\r
- impl(const spl::shared_ptr<context>& ogl)\r
+ impl(const spl::shared_ptr<device>& ogl)\r
: ogl_(ogl)\r
, shader_(ogl_->invoke([&]{return get_image_shader(blend_modes_);}))\r
{\r
}\r
};\r
\r
-image_kernel::image_kernel(const spl::shared_ptr<context>& ogl) : impl_(new impl(ogl)){}\r
+image_kernel::image_kernel(const spl::shared_ptr<device>& ogl) : impl_(new impl(ogl)){}\r
void image_kernel::draw(draw_params&& params)\r
{\r
impl_->draw(std::move(params));\r
class image_kernel sealed : boost::noncopyable\r
{\r
public:\r
- image_kernel(const spl::shared_ptr<class context>& ogl);\r
+ image_kernel(const spl::shared_ptr<class device>& ogl);\r
void draw(draw_params&& params);\r
bool has_blend_modes() const;\r
private:\r
#include "image_kernel.h"\r
\r
#include "../util/data_frame.h"\r
-#include "../util/context.h"\r
+#include "../util/device.h"\r
#include "../util/host_buffer.h"\r
#include "../util/device_buffer.h"\r
\r
\r
class image_renderer\r
{\r
- spl::shared_ptr<context> ogl_;\r
+ spl::shared_ptr<device> ogl_;\r
image_kernel kernel_;\r
std::pair<std::vector<layer>, boost::shared_future<boost::iterator_range<const uint8_t*>>> last_image_; \r
public:\r
- image_renderer(const spl::shared_ptr<context>& ogl)\r
+ image_renderer(const spl::shared_ptr<device>& ogl)\r
: ogl_(ogl)\r
, kernel_(ogl_)\r
{\r
\r
struct image_mixer::impl : boost::noncopyable\r
{ \r
- spl::shared_ptr<context> ogl_;\r
+ spl::shared_ptr<device> ogl_;\r
image_renderer renderer_;\r
std::vector<core::image_transform> transform_stack_;\r
std::vector<layer> layers_; // layer/stream/items\r
public:\r
- impl(const spl::shared_ptr<context>& ogl) \r
+ impl(const spl::shared_ptr<device>& ogl) \r
: ogl_(ogl)\r
, renderer_(ogl)\r
, transform_stack_(1) \r
}\r
};\r
\r
-image_mixer::image_mixer(const spl::shared_ptr<context>& ogl) : impl_(new impl(ogl)){}\r
+image_mixer::image_mixer(const spl::shared_ptr<device>& ogl) : impl_(new impl(ogl)){}\r
void image_mixer::push(const core::frame_transform& transform){impl_->push(transform);}\r
void image_mixer::visit(const core::data_frame& frame){impl_->visit(frame);}\r
void image_mixer::pop(){impl_->pop();}\r
class image_mixer sealed : public core::image_mixer\r
{\r
public:\r
- image_mixer(const spl::shared_ptr<class context>& ogl);\r
+ image_mixer(const spl::shared_ptr<class device>& ogl);\r
\r
virtual void push(const core::frame_transform& frame);\r
virtual void visit(const core::data_frame& frame);\r
#include "image_shader.h"\r
\r
#include "../util/shader.h"\r
-#include "../util/context.h"\r
+#include "../util/device.h"\r
\r
#include "blending_glsl.h"\r
\r
namespace caspar { namespace accelerator { namespace ogl {\r
\r
class shader;\r
-class context;\r
+class device;\r
\r
struct texture_id\r
{\r
\r
#include "data_frame.h"\r
\r
-#include "context.h"\r
+#include "device.h"\r
#include "host_buffer.h"\r
#include "device_buffer.h"\r
\r
\r
struct data_frame::impl : boost::noncopyable\r
{ \r
- std::shared_ptr<context> ogl_;\r
+ std::shared_ptr<device> ogl_;\r
std::vector<spl::shared_ptr<ogl::host_buffer>> buffers_;\r
core::audio_buffer audio_data_;\r
const core::pixel_format_desc desc_;\r
{\r
}\r
\r
- impl(const spl::shared_ptr<ogl::context>& ogl, const void* tag, const core::pixel_format_desc& desc, double frame_rate, core::field_mode field_mode) \r
+ impl(const spl::shared_ptr<ogl::device>& ogl, const void* tag, const core::pixel_format_desc& desc, double frame_rate, core::field_mode field_mode) \r
: ogl_(ogl)\r
, desc_(desc)\r
, tag_(tag)\r
};\r
\r
data_frame::data_frame(const void* tag) : impl_(new impl(tag)){}\r
-data_frame::data_frame(const spl::shared_ptr<ogl::context>& ogl, const void* tag, const core::pixel_format_desc& desc, double frame_rate, core::field_mode field_mode) \r
+data_frame::data_frame(const spl::shared_ptr<ogl::device>& ogl, const void* tag, const core::pixel_format_desc& desc, double frame_rate, core::field_mode field_mode) \r
: impl_(new impl(ogl, tag, desc, frame_rate, field_mode)){}\r
data_frame::data_frame(data_frame&& other) : impl_(std::move(other.impl_)){}\r
data_frame& data_frame::operator=(data_frame&& other)\r
data_frame& operator=(const data_frame);\r
public: \r
explicit data_frame(const void* tag);\r
- explicit data_frame(const spl::shared_ptr<class context>& ogl, const void* tag, const core::pixel_format_desc& desc, double frame_rate, core::field_mode field_mode);\r
+ explicit data_frame(const spl::shared_ptr<class device>& ogl, const void* tag, const core::pixel_format_desc& desc, double frame_rate, core::field_mode field_mode);\r
\r
data_frame(data_frame&& other);\r
data_frame& operator=(data_frame&& other);\r
\r
#include "../../stdafx.h"\r
\r
-#include "context.h"\r
+#include "device.h"\r
\r
#include "shader.h"\r
\r
\r
namespace caspar { namespace accelerator { namespace ogl {\r
\r
-struct context::impl : public std::enable_shared_from_this<impl>\r
+struct device::impl : public std::enable_shared_from_this<impl>\r
{\r
- std::unique_ptr<sf::Context> context_;\r
- std::unique_ptr<sf::Context> host_alloc_context_;\r
+ std::unique_ptr<sf::Context> device_;\r
+ std::unique_ptr<sf::Context> host_alloc_device_;\r
\r
std::array<tbb::concurrent_unordered_map<int, tbb::concurrent_bounded_queue<std::shared_ptr<device_buffer>>>, 4> device_pools_;\r
std::array<tbb::concurrent_unordered_map<int, tbb::concurrent_bounded_queue<std::shared_ptr<host_buffer>>>, 2> host_pools_;\r
\r
impl(executor& executor) \r
: executor_(executor)\r
- , host_alloc_executor_(L"OpenGL allocation context")\r
+ , host_alloc_executor_(L"OpenGL allocation device")\r
{\r
if(g_count++ > 1)\r
- CASPAR_LOG(warning) << L"Multiple OGL contexts.";\r
+ CASPAR_LOG(warning) << L"Multiple OGL devices.";\r
\r
CASPAR_LOG(info) << L"Initializing OpenGL Device.";\r
\r
auto ctx1 = executor_.invoke([=]() -> HGLRC \r
{\r
- context_.reset(new sf::Context());\r
- context_->SetActive(true); \r
+ device_.reset(new sf::Context());\r
+ device_->SetActive(true); \r
\r
if (glewInit() != GLEW_OK)\r
BOOST_THROW_EXCEPTION(gl::ogl_exception() << msg_info("Failed to initialize GLEW."));\r
\r
auto ctx1 = wglGetCurrentContext();\r
\r
- context_->SetActive(false);\r
+ device_->SetActive(false);\r
\r
return ctx1;\r
});\r
\r
host_alloc_executor_.invoke([=]\r
{\r
- host_alloc_context_.reset(new sf::Context());\r
- host_alloc_context_->SetActive(true); \r
+ host_alloc_device_.reset(new sf::Context());\r
+ host_alloc_device_->SetActive(true); \r
auto ctx2 = wglGetCurrentContext();\r
\r
if(!wglShareLists(ctx1, ctx2))\r
- BOOST_THROW_EXCEPTION(gl::ogl_exception() << msg_info("Failed to share OpenGL contexts."));\r
+ BOOST_THROW_EXCEPTION(gl::ogl_exception() << msg_info("Failed to share OpenGL devices."));\r
});\r
\r
executor_.invoke([=]\r
{ \r
- context_->SetActive(true);\r
+ device_->SetActive(true);\r
});\r
\r
CASPAR_LOG(info) << L"Successfully initialized OpenGL " << version();\r
{\r
host_alloc_executor_.invoke([=]\r
{\r
- host_alloc_context_.reset();\r
+ host_alloc_device_.reset();\r
BOOST_FOREACH(auto& pool, host_pools_)\r
pool.clear();\r
});\r
pool.clear();\r
glDeleteFramebuffers(1, &fbo_);\r
\r
- context_.reset();\r
+ device_.reset();\r
});\r
}\r
\r
}\r
};\r
\r
-context::context() \r
- : executor_(L"context")\r
+device::device() \r
+ : executor_(L"device")\r
, impl_(new impl(executor_))\r
{\r
}\r
\r
-spl::shared_ptr<device_buffer> context::create_device_buffer(int width, int height, int stride){return impl_->create_device_buffer(width, height, stride);}\r
-spl::shared_ptr<host_buffer> context::create_host_buffer(int size, host_buffer::usage usage){return impl_->create_host_buffer(size, usage);}\r
-boost::unique_future<spl::shared_ptr<device_buffer>> context::copy_async(spl::shared_ptr<host_buffer>& source, int width, int height, int stride){return impl_->copy_async(source, width, height, stride);}\r
-std::wstring context::version(){return impl_->version();}\r
+spl::shared_ptr<device_buffer> device::create_device_buffer(int width, int height, int stride){return impl_->create_device_buffer(width, height, stride);}\r
+spl::shared_ptr<host_buffer> device::create_host_buffer(int size, host_buffer::usage usage){return impl_->create_host_buffer(size, usage);}\r
+boost::unique_future<spl::shared_ptr<device_buffer>> device::copy_async(spl::shared_ptr<host_buffer>& source, int width, int height, int stride){return impl_->copy_async(source, width, height, stride);}\r
+std::wstring device::version(){return impl_->version();}\r
\r
\r
}}}\r
\r
namespace caspar { namespace accelerator { namespace ogl {\r
\r
-class context : public std::enable_shared_from_this<context>, boost::noncopyable\r
+class device : public std::enable_shared_from_this<device>, boost::noncopyable\r
{ \r
executor executor_;\r
public: \r
- context();\r
+ device();\r
\r
spl::shared_ptr<device_buffer> create_device_buffer(int width, int height, int stride);\r
spl::shared_ptr<host_buffer> create_host_buffer(int size, host_buffer::usage usage);\r
#include "../../stdafx.h"\r
\r
#include "device_buffer.h"\r
-#include "context.h"\r
+#include "device.h"\r
\r
#include <common/except.h>\r
#include <common/gl/gl_check.h>\r
namespace caspar { namespace accelerator { namespace ogl {\r
\r
class host_buffer;\r
-class context;\r
+class device;\r
\r
class device_buffer : boost::noncopyable\r
{\r
#include "host_buffer.h"\r
\r
#include "device_buffer.h"\r
-#include "context.h"\r
+#include "device.h"\r
\r
#include <common/except.h>\r
#include <common/gl/gl_check.h>\r
void set(const std::string& name, double value);\r
void use() const;\r
private:\r
- friend class context;\r
+ friend class device;\r
struct impl;\r
spl::shared_ptr<impl> impl_;\r
\r