diff --git a/Common/Render/Text/draw_text.h b/Common/Render/Text/draw_text.h index 7f651c1f65..f1d1a39ab8 100644 --- a/Common/Render/Text/draw_text.h +++ b/Common/Render/Text/draw_text.h @@ -51,8 +51,7 @@ public: virtual void MeasureString(std::string_view str, float *w, float *h) = 0; virtual void MeasureStringRect(std::string_view str, const Bounds &bounds, float *w, float *h, int align = ALIGN_TOPLEFT) = 0; - virtual void DrawString(DrawBuffer &target, std::string_view str, float x, float y, uint32_t color, int align = ALIGN_TOPLEFT); - + void DrawString(DrawBuffer &target, std::string_view str, float x, float y, uint32_t color, int align = ALIGN_TOPLEFT); void DrawStringRect(DrawBuffer &target, std::string_view str, const Bounds &bounds, uint32_t color, int align); virtual bool DrawStringBitmap(std::vector &bitmapData, TextStringEntry &entry, Draw::DataFormat texFormat, std::string_view str, int align, bool fullColor) = 0; bool DrawStringBitmapRect(std::vector &bitmapData, TextStringEntry &entry, Draw::DataFormat texFormat, std::string_view str, const Bounds &bounds, int align, bool fullColor); diff --git a/Common/Render/Text/draw_text_qt.cpp b/Common/Render/Text/draw_text_qt.cpp index 7d1a18e5d3..e0570c1e5f 100644 --- a/Common/Render/Text/draw_text_qt.cpp +++ b/Common/Render/Text/draw_text_qt.cpp @@ -16,8 +16,7 @@ #include #include -TextDrawerQt::TextDrawerQt(Draw::DrawContext *draw) : TextDrawer(draw) { -} +TextDrawerQt::TextDrawerQt(Draw::DrawContext *draw) : TextDrawer(draw) {} TextDrawerQt::~TextDrawerQt() { ClearCache(); @@ -141,53 +140,6 @@ bool TextDrawerQt::DrawStringBitmap(std::vector &bitmapData, TextString return true; } -void TextDrawerQt::DrawString(DrawBuffer &target, std::string_view str, float x, float y, uint32_t color, int align) { - using namespace Draw; - if (str.empty()) { - return; - } - - CacheKey key{ std::string(str), fontHash_ }; - target.Flush(true); - - TextStringEntry *entry; - - auto iter = cache_.find(key); - if (iter != cache_.end()) { - entry = iter->second.get(); - entry->lastUsedFrame = frameCount_; - } else { - DataFormat texFormat = Draw::DataFormat::R4G4B4A4_UNORM_PACK16; - - entry = new TextStringEntry(frameCount_); - - TextureDesc desc{}; - std::vector bitmapData; - DrawStringBitmap(bitmapData, *entry, texFormat, str, align, false); - desc.initData.push_back(&bitmapData[0]); - - desc.type = TextureType::LINEAR2D; - desc.format = texFormat; - desc.width = entry->bmWidth; - desc.height = entry->bmHeight; - desc.depth = 1; - desc.mipLevels = 1; - desc.tag = "TextDrawer"; - entry->texture = draw_->CreateTexture(desc); - cache_[key] = std::unique_ptr(entry); - } - - if (entry->texture) { - draw_->BindTexture(0, entry->texture); - - float w = entry->bmWidth * fontScaleX_ * dpiScale_; - float h = entry->bmHeight * fontScaleY_ * dpiScale_; - DrawBuffer::DoAlign(align, &x, &y, &w, &h); - target.DrawTexRect(x, y, x + w, y + h, 0.0f, 0.0f, 1.0f, 1.0f, color); - target.Flush(true); - } -} - void TextDrawerQt::ClearCache() { for (auto &iter : cache_) { if (iter.second->texture) diff --git a/Common/Render/Text/draw_text_qt.h b/Common/Render/Text/draw_text_qt.h index e0c3490e9c..300ed09a60 100644 --- a/Common/Render/Text/draw_text_qt.h +++ b/Common/Render/Text/draw_text_qt.h @@ -18,7 +18,6 @@ public: void SetFont(uint32_t fontHandle) override; // Shortcut once you've set the font once. void MeasureString(std::string_view str, float *w, float *h) override; void MeasureStringRect(std::string_view str, const Bounds &bounds, float *w, float *h, int align = ALIGN_TOPLEFT) override; - void DrawString(DrawBuffer &target, std::string_view str, float x, float y, uint32_t color, int align = ALIGN_TOPLEFT) override; bool DrawStringBitmap(std::vector &bitmapData, TextStringEntry &entry, Draw::DataFormat texFormat, std::string_view str, int align, bool fullColor) override; // Use for housekeeping like throwing out old strings. void OncePerFrame() override;