]> git.sesse.net Git - casparcg/blobdiff - core/producer/text/text_producer.cpp
[text_producer] Removed unused member function measure_string()
[casparcg] / core / producer / text / text_producer.cpp
index 4bcf08519a69a4419c26c8ef73f95a14184ac971..dc7e0e0774ea8b479b9602e02231f0b5b2768643 100644 (file)
@@ -145,6 +145,7 @@ struct text_producer::impl
        draw_frame                                                              frame_;
        text::texture_atlas                                             atlas_                                          { 1024, 512, 4 };
        text::texture_font                                              font_;
+       const_frame                                                             atlas_frame_;
 
 public:
        explicit impl(const spl::shared_ptr<frame_factory>& frame_factory, int x, int y, const std::wstring& str, text::text_info& text_info, long parent_width, long parent_height, bool standalone)
@@ -159,6 +160,8 @@ public:
                font_.load_glyphs(text::unicode_block::Latin_1_Supplement, text_info.color);
                font_.load_glyphs(text::unicode_block::Latin_Extended_A, text_info.color);
 
+               atlas_frame_ = create_atlas_frame();
+
                tracking_.value().set(text_info.tracking);
                scale_x_.value().set(text_info.scale_x);
                scale_y_.value().set(text_info.scale_y);
@@ -183,18 +186,22 @@ public:
                CASPAR_LOG(info) << print() << L" Initialized";
        }
 
-       void generate_frame()
+       core::const_frame create_atlas_frame() const
        {
                core::pixel_format_desc pfd(core::pixel_format::bgra);
                pfd.planes.push_back(core::pixel_format_desc::plane(static_cast<int>(atlas_.width()), static_cast<int>(atlas_.height()), static_cast<int>(atlas_.depth())));
+               auto frame = frame_factory_->create_frame(this, pfd, core::audio_channel_layout::invalid());
+               memcpy(frame.image_data().data(), atlas_.data(), frame.image_data().size());
+               return std::move(frame);
+       }
 
+       void generate_frame()
+       {
                text::string_metrics metrics;
-               font_.set_tracking(static_cast<int>(tracking_.value().get()));
+               font_.set_tracking(tracking_.value().get());
 
                auto vertex_stream = font_.create_vertex_stream(text_.value().get(), x_, y_, parent_width_, parent_height_, &metrics, shear_.value().get());
-               auto frame = frame_factory_->create_frame(vertex_stream.data(), pfd, core::audio_channel_layout::invalid());
-               memcpy(frame.image_data().data(), atlas_.data(), frame.image_data().size());
-               frame.set_geometry(frame_geometry(frame_geometry::geometry_type::quad_list, std::move(vertex_stream)));
+               auto frame = atlas_frame_.with_geometry(frame_geometry(frame_geometry::geometry_type::quad_list, std::move(vertex_stream)));
 
                this->constraints_.width.set(metrics.width * this->scale_x_.value().get());
                this->constraints_.height.set(metrics.height * this->scale_y_.value().get());
@@ -203,11 +210,6 @@ public:
                frame_ = core::draw_frame(std::move(frame));
        }
 
-       text::string_metrics measure_string(const std::wstring& str)
-       {
-               return font_.measure_string(str);
-       }
-
        // frame_producer
 
        draw_frame receive_impl()
@@ -303,7 +305,6 @@ draw_frame text_producer::receive_impl() { return impl_->receive_impl(); }
 std::future<std::wstring> text_producer::call(const std::vector<std::wstring>& param) { return impl_->call(param); }
 variable& text_producer::get_variable(const std::wstring& name) { return impl_->get_variable(name); }
 const std::vector<std::wstring>& text_producer::get_variables() const { return impl_->get_variables(); }
-text::string_metrics text_producer::measure_string(const std::wstring& str) { return impl_->measure_string(str); }
 
 constraints& text_producer::pixel_constraints() { return impl_->pixel_constraints(); }
 std::wstring text_producer::print() const { return impl_->print(); }