X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=core%2Fproducer%2Ftext%2Ftext_producer.cpp;h=4a00b460892822a6b69f9fcf83a93fb7f68d89e3;hb=1678432d8cabef093a58e27791f68499c031dba9;hp=4bcf08519a69a4419c26c8ef73f95a14184ac971;hpb=0785de812ac018afdd50ed9d7042a7c2d0c4d6e4;p=casparcg diff --git a/core/producer/text/text_producer.cpp b/core/producer/text/text_producer.cpp index 4bcf08519..4a00b4608 100644 --- a/core/producer/text/text_producer.cpp +++ b/core/producer/text/text_producer.cpp @@ -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, 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(atlas_.width()), static_cast(atlas_.height()), static_cast(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 frame; + } + void generate_frame() + { text::string_metrics metrics; - font_.set_tracking(static_cast(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());