]> git.sesse.net Git - casparcg/commitdiff
#222 Modified html_producer so that Caspar ticks the web browser. The javascript...
authorHelge Norberg <helge.norberg@gmail.com>
Wed, 15 Jan 2014 17:42:07 +0000 (18:42 +0100)
committerHelge Norberg <helge.norberg@gmail.com>
Wed, 15 Jan 2014 17:42:07 +0000 (18:42 +0100)
modules/html/html.vcxproj.filters [new file with mode: 0644]
modules/html/producer/html_producer.cpp

diff --git a/modules/html/html.vcxproj.filters b/modules/html/html.vcxproj.filters
new file mode 100644 (file)
index 0000000..01f5f1b
--- /dev/null
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <ItemGroup>
+    <ClCompile Include="html.cpp" />
+    <ClCompile Include="producer\html_producer.cpp">
+      <Filter>producer</Filter>
+    </ClCompile>
+  </ItemGroup>
+  <ItemGroup>
+    <ClInclude Include="html.h" />
+    <ClInclude Include="producer\html_producer.h">
+      <Filter>producer</Filter>
+    </ClInclude>
+  </ItemGroup>
+  <ItemGroup>
+    <Filter Include="producer">
+      <UniqueIdentifier>{03836375-dd07-4eb0-bcc7-08942aed1900}</UniqueIdentifier>
+    </Filter>
+  </ItemGroup>
+</Project>
\ No newline at end of file
index 7995f67c88f61afc7a37109b800a1ac59d34662d..8ac3ae1d0f874aa8bf6825887d3a42f932fc4c08 100644 (file)
@@ -74,8 +74,6 @@ class html_producer
 
        std::unique_ptr<Berkelium::Window>      window_;
 
-       high_prec_timer                                         timer_;
-
        executor                                                        executor_;
        
 public:
@@ -132,6 +130,8 @@ public:
                
        safe_ptr<core::basic_frame> receive(int) override
        {                               
+               executor_.begin_invoke([this]{ tick(); });
+
                return last_frame();
        }
 
@@ -240,7 +240,7 @@ public:
                                                bitmap_in + ((y + copy_rects[i].top() - bitmap_rect.top()) * bitmap_rect.width() + copy_rects[i].left() - bitmap_rect.left()) * 4,
                                                copy_rects[i].width() * 4);
                                });
-                       });             
+                       });
                });
        }
 
@@ -253,6 +253,15 @@ public:
        }
 
        // html_producer
+
+       void invoke_on_enter_frame()
+       {
+               html::invoke([this]
+               {
+                       static const std::wstring javascript = L"onEnterFrame()";
+                       window_->executeJavascript(Berkelium::WideString::point_to(javascript.data(), javascript.length()));
+               });
+       }
                
        safe_ptr<core::basic_frame> draw(
                safe_ptr<core::write_frame> frame, 
@@ -265,6 +274,8 @@ public:
                const auto& height = pixel_desc.planes[0].height;
                const auto& linesize = pixel_desc.planes[0].linesize;
 
+               invoke_on_enter_frame();
+
                lock(frame_mutex_, [&]
                {                               
                        tbb::parallel_for<int>(
@@ -287,6 +298,9 @@ public:
        {
                if(invalidated_.fetch_and_store(false))
                {
+                       high_prec_timer timer;
+                       timer.tick(0.0);
+
                        core::pixel_format_desc pixel_desc;
                        pixel_desc.pix_fmt = core::pixel_format::bgra;
                        pixel_desc.planes.push_back(
@@ -304,7 +318,7 @@ public:
                                draw(frame, format_desc.field_mode);
                                
                                executor_.yield();
-                               timer_.tick(1.0 / (format_desc.fps * format_desc.field_count));
+                               timer.tick(1.0 / (format_desc.fps * format_desc.field_count));
                
                                draw(frame, static_cast<core::field_mode::type>(format_desc.field_mode ^ core::field_mode::progressive));
                        }
@@ -319,13 +333,7 @@ public:
                        {       
                                last_frame_ = frame;
                        });
-                       
-                       executor_.yield();
-
-                       timer_.tick(1.0 / (format_desc.fps * format_desc.field_count));
                }
-
-               executor_.begin_invoke([this]{ tick(); });
        }
 };