Finish PlayerSubtitles -> PlayerText and SubtitleString -> PlainText.
authorCarl Hetherington <cth@carlh.net>
Thu, 19 Jul 2018 19:10:45 +0000 (20:10 +0100)
committerCarl Hetherington <cth@carlh.net>
Thu, 19 Jul 2018 22:45:23 +0000 (23:45 +0100)
src/lib/player.cc
src/lib/player_text.cc
src/lib/reel_writer.cc
src/lib/reel_writer.h
src/lib/render_text.cc
src/lib/render_text.h
test/render_subtitles_test.cc

index 32c2dfdfde2bd0d49f07d0d994d9849b60439d3d..35047c3aebd5cc699920a259a30a161dcfc31179 100644 (file)
@@ -901,7 +901,7 @@ Player::plain_text_start (weak_ptr<Piece> wp, ContentPlainText subtitle)
                }
 
                s.set_in (dcp::Time(from.seconds(), 1000));
-               ps.text.push_back (SubtitleString (s, piece->content->subtitle->outline_width()));
+               ps.text.push_back (PlainText (s, piece->content->subtitle->outline_width()));
                ps.add_fonts (piece->content->subtitle->fonts ());
        }
 
index 588e4ef7f8648754e253ba0dc0ec3993733edcbb..16e89b0f10681d756724dd9e0cd49cf8f57aaff0 100644 (file)
@@ -26,7 +26,7 @@ using std::list;
 using boost::shared_ptr;
 
 void
-PlayerSubtitles::add_fonts (list<shared_ptr<Font> > fonts_)
+PlayerText::add_fonts (list<shared_ptr<Font> > fonts_)
 {
        BOOST_FOREACH (shared_ptr<Font> i, fonts_) {
                bool got = false;
index 197773a20832f43820710065c190d2ff87966f91..d23ac76d1059482b48124be30b7e53f7fb566ca6 100644 (file)
@@ -528,7 +528,7 @@ ReelWriter::write (shared_ptr<const AudioBuffers> audio)
 }
 
 void
-ReelWriter::write (PlayerSubtitles subs, DCPTimePeriod period)
+ReelWriter::write (PlayerText subs, DCPTimePeriod period)
 {
        if (!_subtitle_asset) {
                string lang = _film->subtitle_language ();
@@ -556,7 +556,7 @@ ReelWriter::write (PlayerSubtitles subs, DCPTimePeriod period)
                }
        }
 
-       BOOST_FOREACH (SubtitleString i, subs.text) {
+       BOOST_FOREACH (PlainText i, subs.text) {
                /* XXX: couldn't / shouldn't we use period here rather than getting time from the subtitle? */
                i.set_in  (i.in()  - dcp::Time (_period.from.seconds(), i.in().tcr));
                i.set_out (i.out() - dcp::Time (_period.from.seconds(), i.out().tcr));
index 4357a28f2de6b885715ecd1182a3402db57dab5d..37e950ae6c0aa1e0dc8069638c9bbc630b424f67 100644 (file)
@@ -21,7 +21,7 @@
 #include "types.h"
 #include "dcpomatic_time.h"
 #include "referenced_reel_asset.h"
-#include "player_subtitles.h"
+#include "player_text.h"
 #include <dcp/picture_asset_writer.h>
 #include <boost/shared_ptr.hpp>
 
@@ -60,7 +60,7 @@ public:
        void fake_write (Frame frame, Eyes eyes, int size);
        void repeat_write (Frame frame, Eyes eyes);
        void write (boost::shared_ptr<const AudioBuffers> audio);
-       void write (PlayerSubtitles subs, DCPTimePeriod period);
+       void write (PlayerText subs, DCPTimePeriod period);
 
        void finish ();
        boost::shared_ptr<dcp::Reel> create_reel (std::list<ReferencedReelAsset> const & refs, std::list<boost::shared_ptr<Font> > const & fonts);
index 673078347980e9012b93ce8a2ef6858ab9649b72..77a8036e811e5c621869fbf64fef03d215b5371e 100644 (file)
@@ -51,11 +51,11 @@ static FcConfig* fc_config = 0;
 static list<pair<FontFiles, string> > fc_config_fonts;
 
 string
-marked_up (list<SubtitleString> subtitles, int target_height, float fade_factor)
+marked_up (list<PlainText> subtitles, int target_height, float fade_factor)
 {
        string out;
 
-       BOOST_FOREACH (SubtitleString const & i, subtitles) {
+       BOOST_FOREACH (PlainText const & i, subtitles) {
                out += "<span ";
                if (i.italic()) {
                        out += "style=\"italic\" ";
@@ -91,7 +91,7 @@ set_source_rgba (Cairo::RefPtr<Cairo::Context> context, dcp::Colour colour, floa
  *  at the same time and with the same fade in/out.
  */
 static PositionImage
-render_line (list<SubtitleString> subtitles, list<shared_ptr<Font> > fonts, dcp::Size target, DCPTime time, int frame_rate)
+render_line (list<PlainText> subtitles, list<shared_ptr<Font> > fonts, dcp::Size target, DCPTime time, int frame_rate)
 {
        /* XXX: this method can only handle italic / bold changes mid-line,
           nothing else yet.
@@ -365,12 +365,12 @@ render_line (list<SubtitleString> subtitles, list<shared_ptr<Font> > fonts, dcp:
  *  @param frame_rate DCP frame rate.
  */
 list<PositionImage>
-render_text (list<SubtitleString> subtitles, list<shared_ptr<Font> > fonts, dcp::Size target, DCPTime time, int frame_rate)
+render_text (list<PlainText> subtitles, list<shared_ptr<Font> > fonts, dcp::Size target, DCPTime time, int frame_rate)
 {
-       list<SubtitleString> pending;
+       list<PlainText> pending;
        list<PositionImage> images;
 
-       BOOST_FOREACH (SubtitleString const & i, subtitles) {
+       BOOST_FOREACH (PlainText const & i, subtitles) {
                if (!pending.empty() && fabs (i.v_position() - pending.back().v_position()) > 1e-4) {
                        images.push_back (render_line (pending, fonts, target, time, frame_rate));
                        pending.clear ();
index 496967f31713dcf5b194df3ce27efba0892b7d8f..f9c35005ebb84ef37415303a293947bba598f294 100644 (file)
@@ -25,7 +25,7 @@
 
 class Font;
 
-std::string marked_up (std::list<SubtitleString> subtitles, int target_height, float fade_factor);
+std::string marked_up (std::list<PlainText> subtitles, int target_height, float fade_factor);
 std::list<PositionImage> render_text (
-       std::list<SubtitleString>, std::list<boost::shared_ptr<Font> > fonts, dcp::Size, DCPTime, int
+       std::list<PlainText>, std::list<boost::shared_ptr<Font> > fonts, dcp::Size, DCPTime, int
        );
index bd676eab0ad2e19471b4523259042fb59badeb8b..a8db80c8b30bdc45c78e335f204afde56e1fe83b 100644 (file)
 #include <boost/test/unit_test.hpp>
 
 static void
-add (std::list<SubtitleString>& s, std::string text, bool italic, bool bold, bool underline)
+add (std::list<PlainText>& s, std::string text, bool italic, bool bold, bool underline)
 {
        s.push_back (
-               SubtitleString (
+               PlainText (
                        dcp::SubtitleString (
                                boost::optional<std::string> (),
                                italic,
@@ -60,7 +60,7 @@ add (std::list<SubtitleString>& s, std::string text, bool italic, bool bold, boo
 /** Test marked_up() in render_text.cc */
 BOOST_AUTO_TEST_CASE (render_markup_test1)
 {
-       std::list<SubtitleString> s;
+       std::list<PlainText> s;
        add (s, "Hello", false, false, false);
        BOOST_CHECK_EQUAL (marked_up (s, 1024, 1), "<span size=\"41472\" alpha=\"65535\" color=\"#FFFFFF\">Hello</span>");
 }
@@ -68,7 +68,7 @@ BOOST_AUTO_TEST_CASE (render_markup_test1)
 /** Test marked_up() in render_text.cc */
 BOOST_AUTO_TEST_CASE (render_markup_test2)
 {
-       std::list<SubtitleString> s;
+       std::list<PlainText> s;
        add (s, "Hello", false, true, false);
        BOOST_CHECK_EQUAL (marked_up (s, 1024, 1), "<span weight=\"bold\" size=\"41472\" alpha=\"65535\" color=\"#FFFFFF\">Hello</span>");
 }
@@ -77,7 +77,7 @@ BOOST_AUTO_TEST_CASE (render_markup_test2)
 /** Test marked_up() in render_text.cc */
 BOOST_AUTO_TEST_CASE (render_markup_test3)
 {
-       std::list<SubtitleString> s;
+       std::list<PlainText> s;
        add (s, "Hello", true, true, false);
        BOOST_CHECK_EQUAL (marked_up (s, 1024, 1), "<span style=\"italic\" weight=\"bold\" size=\"41472\" alpha=\"65535\" color=\"#FFFFFF\">Hello</span>");
 }
@@ -85,7 +85,7 @@ BOOST_AUTO_TEST_CASE (render_markup_test3)
 /** Test marked_up() in render_text.cc */
 BOOST_AUTO_TEST_CASE (render_markup_test4)
 {
-       std::list<SubtitleString> s;
+       std::list<PlainText> s;
        add (s, "Hello", true, true, true);
        BOOST_CHECK_EQUAL (marked_up (s, 1024, 1), "<span style=\"italic\" weight=\"bold\" underline=\"single\" size=\"41472\" alpha=\"65535\" color=\"#FFFFFF\">Hello</span>");
 }
@@ -93,7 +93,7 @@ BOOST_AUTO_TEST_CASE (render_markup_test4)
 /** Test marked_up() in render_text.cc */
 BOOST_AUTO_TEST_CASE (render_markup_test5)
 {
-       std::list<SubtitleString> s;
+       std::list<PlainText> s;
        add (s, "Hello", false, true, false);
        add (s, " world.", false, false, false);
        BOOST_CHECK_EQUAL (marked_up (s, 1024, 1), "<span weight=\"bold\" size=\"41472\" alpha=\"65535\" color=\"#FFFFFF\">Hello</span><span size=\"41472\" alpha=\"65535\" color=\"#FFFFFF\"> world.</span>");
@@ -102,7 +102,7 @@ BOOST_AUTO_TEST_CASE (render_markup_test5)
 /** Test marked_up() in render_text.cc */
 BOOST_AUTO_TEST_CASE (render_markup_test6)
 {
-       std::list<SubtitleString> s;
+       std::list<PlainText> s;
        add (s, "Hello", true, false, false);
        add (s, " world ", false, false, false);
        add (s, "we are bold.", false, true, false);