Basic watermark.
authorCarl Hetherington <cth@carlh.net>
Thu, 27 Sep 2018 21:05:24 +0000 (22:05 +0100)
committerCarl Hetherington <cth@carlh.net>
Thu, 27 Sep 2018 21:05:24 +0000 (22:05 +0100)
src/lib/config.h
src/wx/film_viewer.cc
src/wx/film_viewer.h

index 8ddc036..629828d 100644 (file)
@@ -1188,7 +1188,9 @@ private:
        boost::optional<boost::filesystem::path> _player_background_image;
        std::string _kdm_server_url;
        std::string _player_watermark_theatre;
+       /** watermark period in minutes */
        int _player_watermark_period;
+       /** watermark duration in milliseconds */
        int _player_watermark_duration;
 #endif
 
index 0f18f2e..54de78f 100644 (file)
@@ -85,6 +85,9 @@ FilmViewer::FilmViewer (wxWindow* p)
        , _closed_captions_dialog (new ClosedCaptionsDialog(p))
        , _outline_content (false)
        , _eyes (EYES_LEFT)
+#ifdef DCPOMATIC_VARIANT_SWAROOP
+       , _in_watermark (false)
+#endif
 {
 #ifndef __WXOSX__
        _panel->SetDoubleBuffered (true);
@@ -328,7 +331,21 @@ FilmViewer::paint_panel ()
        dc.DrawBitmap (frame_bitmap, 0, max(0, (_panel_size.height - _out_size.height) / 2));
 
 #ifdef DCPOMATIC_VARIANT_SWAROOP
-       /* XXX: watermark */
+       DCPTime const period = DCPTime::from_seconds(Config::instance()->player_watermark_period() * 60);
+       int64_t n = _video_position.get() / period.get();
+       DCPTime from(n * period.get());
+       DCPTime to = from + DCPTime::from_seconds(Config::instance()->player_watermark_duration() / 1000.0);
+       if (from <= _video_position && _video_position <= to) {
+               if (!_in_watermark) {
+                       _in_watermark = true;
+                       _watermark_x = rand() % _panel_size.width;
+                       _watermark_y = rand() % _panel_size.height;
+               }
+               dc.SetTextForeground(*wxWHITE);
+               dc.DrawText(std_to_wx(Config::instance()->player_watermark_theatre()), _watermark_x, _watermark_y);
+       } else {
+               _in_watermark = false;
+       }
 #endif
 
        if (_out_size.width < _panel_size.width) {
index 94690da..ef124fa 100644 (file)
@@ -154,5 +154,11 @@ private:
        bool _outline_content;
        Eyes _eyes;
 
+#ifdef DCPOMATIC_VARIANT_SWAROOP
+       bool _in_watermark;
+       int _watermark_x;
+       int _watermark_y;
+#endif
+
        boost::signals2::scoped_connection _config_changed_connection;
 };