Skip to content
Permalink
Browse files

TextDrawerUWP: oops, forgot to release the objects used.

  • Loading branch information...
driver1998 committed Jun 7, 2019
1 parent 56a8793 commit 2db67e17059980651feace13f927cd299b455bbf
Showing with 10 additions and 1 deletion.
  1. +10 −0 ext/native/gfx_es2/draw_text_uwp.cpp
  2. +0 −1 ext/native/gfx_es2/draw_text_uwp.h
@@ -151,6 +151,11 @@ TextDrawerUWP::~TextDrawerUWP() {
m_d2dContext->Release();
m_d2dDevice->Release();
m_d2dFactory->Release();

m_fontCollection->Release();
m_fontSet->Release();
m_fontFile->Release();
m_fontSetBuilder->Release();
m_dwriteFactory->Release();
delete ctx_;
}
@@ -206,6 +211,7 @@ void TextDrawerUWP::MeasureString(const char *str, size_t len, float *w, float *
if (iter != fontMap_.end()) {
format = iter->second->textFmt;
}
if (!format) return;

std::wstring wstr = ConvertUTF8ToWString(ReplaceAll(ReplaceAll(std::string(str, len), "\n", "\r\n"), "&&", "&"));

@@ -223,6 +229,7 @@ void TextDrawerUWP::MeasureString(const char *str, size_t len, float *w, float *

DWRITE_TEXT_METRICS metrics;
layout->GetMetrics(&metrics);
layout->Release();

entry = new TextMeasureEntry();
entry->width = metrics.width + 1;
@@ -242,6 +249,7 @@ void TextDrawerUWP::MeasureStringRect(const char *str, size_t len, const Bounds
if (iter != fontMap_.end()) {
format = iter->second->textFmt;
}
if (!format) return;

std::string toMeasure = std::string(str, len);
if (align & FLAG_WRAP_TEXT) {
@@ -282,6 +290,7 @@ void TextDrawerUWP::MeasureStringRect(const char *str, size_t len, const Bounds

DWRITE_TEXT_METRICS metrics;
layout->GetMetrics(&metrics);
layout->Release();

entry = new TextMeasureEntry();
entry->width = metrics.width + 1;
@@ -325,6 +334,7 @@ void TextDrawerUWP::DrawString(DrawBuffer &target, const char *str, float x, flo
if (iter != fontMap_.end()) {
format = iter->second->textFmt;
}
if (!format) return;

if (align & ALIGN_HCENTER)
format->SetTextAlignment(DWRITE_TEXT_ALIGNMENT_CENTER);
@@ -44,7 +44,6 @@ class TextDrawerUWP : public TextDrawer {
ID2D1Factory5* m_d2dFactory;
ID2D1Device4* m_d2dDevice;
ID2D1DeviceContext4* m_d2dContext;
ID2D1Bitmap1* m_d2dTargetBitmap;
ID2D1SolidColorBrush* m_d2dWhiteBrush;

// DirectWrite drawing components.

0 comments on commit 2db67e1

Please sign in to comment.
You can’t perform that action at this time.