diff options
Diffstat (limited to 'src/win/graph')
-rw-r--r-- | src/win/graph/CMakeLists.txt | 3 | ||||
-rw-r--r-- | src/win/graph/d2d_painter.cpp | 93 | ||||
-rw-r--r-- | src/win/graph/graph_manager.cpp | 61 | ||||
-rw-r--r-- | src/win/graph/win_brush.cpp | 10 | ||||
-rw-r--r-- | src/win/graph/win_font.cpp | 11 | ||||
-rw-r--r-- | src/win/graph/win_geometry.cpp | 25 | ||||
-rw-r--r-- | src/win/graph/win_graph_factory.cpp | 97 | ||||
-rw-r--r-- | src/win/graph/win_painter.cpp | 93 | ||||
-rw-r--r-- | src/win/graph/win_text_layout.cpp | 18 |
9 files changed, 207 insertions, 204 deletions
diff --git a/src/win/graph/CMakeLists.txt b/src/win/graph/CMakeLists.txt index 61749a6a..d326eb2b 100644 --- a/src/win/graph/CMakeLists.txt +++ b/src/win/graph/CMakeLists.txt @@ -1,9 +1,8 @@ add_library(cru_win_graph STATIC - d2d_painter.cpp - graph_manager.cpp win_brush.cpp win_font.cpp win_geometry.cpp win_graph_factory.cpp + win_painter.cpp win_text_layout.cpp) target_link_libraries(cru_win_graph PUBLIC D3D11 D2d1 DWrite cru_win_base) diff --git a/src/win/graph/d2d_painter.cpp b/src/win/graph/d2d_painter.cpp deleted file mode 100644 index 26f6bef0..00000000 --- a/src/win/graph/d2d_painter.cpp +++ /dev/null @@ -1,93 +0,0 @@ -#include "cru/win/graph/d2d_painter.hpp" - -#include "cru/win/exception.hpp" -#include "cru/win/graph/d2d_util.hpp" -#include "cru/win/graph/graph_manager.hpp" -#include "cru/win/graph/win_brush.hpp" -#include "cru/win/graph/win_geometry.hpp" -#include "cru/win/graph/win_text_layout.hpp" - -#include <cassert> - -namespace cru::win::graph { -D2DPainter::D2DPainter(ID2D1RenderTarget* render_target) { - assert(render_target); - render_target_ = render_target; -} - -platform::Matrix D2DPainter::GetTransform() { - assert(!IsDisposed()); - D2D1_MATRIX_3X2_F m; - render_target_->GetTransform(&m); - return util::Convert(m); -} - -void D2DPainter::SetTransform(const platform::Matrix& matrix) { - assert(!IsDisposed()); - render_target_->SetTransform(util::Convert(matrix)); -} - -void D2DPainter::Clear(const ui::Color& color) { - assert(!IsDisposed()); - render_target_->Clear(util::Convert(color)); -} - -void D2DPainter::StrokeRectangle(const ui::Rect& rectangle, - platform::graph::Brush* brush, float width) { - assert(!IsDisposed()); - const auto b = dynamic_cast<WinBrush*>(brush); - assert(b); - render_target_->DrawRectangle(util::Convert(rectangle), b->GetD2DBrush(), - width); -} - -void D2DPainter::FillRectangle(const ui::Rect& rectangle, - platform::graph::Brush* brush) { - assert(!IsDisposed()); - const auto b = dynamic_cast<WinBrush*>(brush); - assert(b); - render_target_->FillRectangle(util::Convert(rectangle), b->GetD2DBrush()); -} - -void D2DPainter::StrokeGeometry(platform::graph::Geometry* geometry, - platform::graph::Brush* brush, float width) { - assert(!IsDisposed()); - const auto g = dynamic_cast<WinGeometry*>(geometry); - assert(g); - const auto b = dynamic_cast<WinBrush*>(brush); - assert(b); - - render_target_->DrawGeometry(g->GetNative(), b->GetD2DBrush(), width); -} - -void D2DPainter::FillGeometry(platform::graph::Geometry* geometry, - platform::graph::Brush* brush) { - assert(!IsDisposed()); - const auto g = dynamic_cast<WinGeometry*>(geometry); - assert(g); - const auto b = dynamic_cast<WinBrush*>(brush); - assert(b); - - render_target_->FillGeometry(g->GetNative(), b->GetD2DBrush()); -} - -void D2DPainter::DrawText(const ui::Point& offset, - platform::graph::TextLayout* text_layout, - platform::graph::Brush* brush) { - assert(!IsDisposed()); - const auto t = dynamic_cast<WinTextLayout*>(text_layout); - assert(t); - const auto b = dynamic_cast<WinBrush*>(brush); - assert(b); - - render_target_->DrawTextLayout(util::Convert(offset), - t->GetDWriteTextLayout(), b->GetD2DBrush()); -} - -void D2DPainter::EndDraw() { - if (!is_disposed_) { - is_disposed_ = true; - DoEndDraw(); - } -} -} // namespace cru::win::graph diff --git a/src/win/graph/graph_manager.cpp b/src/win/graph/graph_manager.cpp deleted file mode 100644 index 30e1a14e..00000000 --- a/src/win/graph/graph_manager.cpp +++ /dev/null @@ -1,61 +0,0 @@ -#include "cru/win/graph/graph_manager.hpp" - -#include "cru/win/exception.hpp" - -#include <cassert> - -namespace cru::win::graph { -GraphManager* GraphManager::GetInstance() { - static GraphManager* instance = new GraphManager(); - return instance; -} - -GraphManager::GraphManager() { - UINT creation_flags = D3D11_CREATE_DEVICE_BGRA_SUPPORT; - -#ifdef CRU_DEBUG - creation_flags |= D3D11_CREATE_DEVICE_DEBUG; -#endif - - const D3D_FEATURE_LEVEL feature_levels[] = { - D3D_FEATURE_LEVEL_11_1, D3D_FEATURE_LEVEL_11_0, D3D_FEATURE_LEVEL_10_1, - D3D_FEATURE_LEVEL_10_0, D3D_FEATURE_LEVEL_9_3, D3D_FEATURE_LEVEL_9_2, - D3D_FEATURE_LEVEL_9_1}; - - Microsoft::WRL::ComPtr<ID3D11DeviceContext> d3d11_device_context; - - ThrowIfFailed(D3D11CreateDevice( - nullptr, D3D_DRIVER_TYPE_HARDWARE, nullptr, creation_flags, - feature_levels, ARRAYSIZE(feature_levels), D3D11_SDK_VERSION, - &d3d11_device_, nullptr, &d3d11_device_context)); - - Microsoft::WRL::ComPtr<IDXGIDevice> dxgi_device; - ThrowIfFailed(d3d11_device_->QueryInterface(dxgi_device.GetAddressOf())); - - ThrowIfFailed(D2D1CreateFactory(D2D1_FACTORY_TYPE_SINGLE_THREADED, - IID_PPV_ARGS(&d2d1_factory_))); - - Microsoft::WRL::ComPtr<ID2D1Device> d2d1_device; - - ThrowIfFailed(d2d1_factory_->CreateDevice(dxgi_device.Get(), &d2d1_device)); - - ThrowIfFailed(d2d1_device->CreateDeviceContext( - D2D1_DEVICE_CONTEXT_OPTIONS_NONE, &d2d1_device_context_)); - - // Identify the physical adapter (GPU or card) this device is runs on. - Microsoft::WRL::ComPtr<IDXGIAdapter> dxgi_adapter; - ThrowIfFailed(dxgi_device->GetAdapter(&dxgi_adapter)); - - // Get the factory object that created the DXGI device. - ThrowIfFailed(dxgi_adapter->GetParent(IID_PPV_ARGS(&dxgi_factory_))); - - ThrowIfFailed(DWriteCreateFactory( - DWRITE_FACTORY_TYPE_SHARED, __uuidof(IDWriteFactory), - reinterpret_cast<IUnknown**>(dwrite_factory_.GetAddressOf()))); - - ThrowIfFailed(dwrite_factory_->GetSystemFontCollection( - &dwrite_system_font_collection_)); - - graph_factory_.reset(new WinGraphFactory(this)); -} -} // namespace cru::win::graph diff --git a/src/win/graph/win_brush.cpp b/src/win/graph/win_brush.cpp index 262c3302..0c783366 100644 --- a/src/win/graph/win_brush.cpp +++ b/src/win/graph/win_brush.cpp @@ -1,16 +1,16 @@ #include "cru/win/graph/win_brush.hpp" #include "cru/win/exception.hpp" -#include "cru/win/graph/d2d_util.hpp" -#include "cru/win/graph/graph_manager.hpp" +#include "cru/win/graph/win_native_factory.hpp" +#include "cru/win/graph/util/convert_util.hpp" #include <cassert> namespace cru::win::graph { -WinSolidColorBrush::WinSolidColorBrush(GraphManager* graph_manager, +WinSolidColorBrush::WinSolidColorBrush(IWinNativeFactory* factory, const ui::Color& color) { - assert(graph_manager); - ThrowIfFailed(graph_manager->GetD2D1DeviceContext()->CreateSolidColorBrush( + assert(factory); + ThrowIfFailed(factory->GetD2D1DeviceContext()->CreateSolidColorBrush( util::Convert(color), &brush_)); } diff --git a/src/win/graph/win_font.cpp b/src/win/graph/win_font.cpp index 96983d3e..a359d73e 100644 --- a/src/win/graph/win_font.cpp +++ b/src/win/graph/win_font.cpp @@ -1,22 +1,23 @@ #include "cru/win/graph/win_font.hpp" #include "cru/win/exception.hpp" -#include "cru/win/graph/graph_manager.hpp" +#include "cru/win/graph/win_native_factory.hpp" #include <array> #include <cassert> #include <utility> namespace cru::win::graph { -WinFontDescriptor::WinFontDescriptor(GraphManager* graph_manager, +WinFontDescriptor::WinFontDescriptor(IWinNativeFactory* factory, const std::wstring_view& font_family, float font_size) { - assert(graph_manager); + assert(factory); std::array<wchar_t, LOCALE_NAME_MAX_LENGTH> buffer; - if (!::GetUserDefaultLocaleName(buffer.data(), static_cast<int>(buffer.size()))) + if (!::GetUserDefaultLocaleName(buffer.data(), + static_cast<int>(buffer.size()))) throw Win32Error(::GetLastError(), "Failed to get locale."); - ThrowIfFailed(graph_manager->GetDWriteFactory()->CreateTextFormat( + ThrowIfFailed(factory->GetDWriteFactory()->CreateTextFormat( font_family.data(), nullptr, DWRITE_FONT_WEIGHT_NORMAL, DWRITE_FONT_STYLE_NORMAL, DWRITE_FONT_STRETCH_NORMAL, font_size, buffer.data(), &text_format_)); diff --git a/src/win/graph/win_geometry.cpp b/src/win/graph/win_geometry.cpp index 22c4b8a7..a725eff6 100644 --- a/src/win/graph/win_geometry.cpp +++ b/src/win/graph/win_geometry.cpp @@ -1,16 +1,15 @@ #include "cru/win/graph/win_geometry.hpp" #include "cru/win/exception.hpp" -#include "cru/win/graph/d2d_util.hpp" -#include "cru/win/graph/graph_manager.hpp" +#include "cru/win/graph/util/convert_util.hpp" +#include "cru/win/graph/win_native_factory.hpp" #include <cassert> namespace cru::win::graph { -WinGeometryBuilder::WinGeometryBuilder(GraphManager* graph_manager) { - assert(graph_manager); - ThrowIfFailed( - graph_manager->GetD2D1Factory()->CreatePathGeometry(&geometry_)); +WinGeometryBuilder::WinGeometryBuilder(IWinNativeFactory* factory) { + assert(factory); + ThrowIfFailed(factory->GetD2D1Factory()->CreatePathGeometry(&geometry_)); ThrowIfFailed(geometry_->Open(&geometry_sink_)); } @@ -21,33 +20,33 @@ WinGeometryBuilder::~WinGeometryBuilder() { } void WinGeometryBuilder::BeginFigure(const ui::Point& point) { - assert(IsValid()); + assert(IsEnded()); geometry_sink_->BeginFigure(util::Convert(point), D2D1_FIGURE_BEGIN_FILLED); } void WinGeometryBuilder::LineTo(const ui::Point& point) { - assert(IsValid()); + assert(IsEnded()); geometry_sink_->AddLine(util::Convert(point)); } void WinGeometryBuilder::QuadraticBezierTo(const ui::Point& control_point, const ui::Point& end_point) { - assert(IsValid()); + assert(IsEnded()); geometry_sink_->AddQuadraticBezier(D2D1::QuadraticBezierSegment( util::Convert(control_point), util::Convert(end_point))); } void WinGeometryBuilder::CloseFigure(bool close) { - assert(IsValid()); + assert(IsEnded()); geometry_sink_->EndFigure(close ? D2D1_FIGURE_END_CLOSED : D2D1_FIGURE_END_OPEN); } -platform::graph::Geometry* WinGeometryBuilder::Build() { - assert(IsValid()); +platform::graph::IGeometry* WinGeometryBuilder::End() { + assert(IsEnded()); ThrowIfFailed(geometry_sink_->Close()); geometry_sink_ = nullptr; - const auto geometry = new WinGeometry(geometry_); + const auto geometry = new WinGeometry(std::move(geometry_)); geometry_ = nullptr; return geometry; } diff --git a/src/win/graph/win_graph_factory.cpp b/src/win/graph/win_graph_factory.cpp index 5ab905b6..de1d28f9 100644 --- a/src/win/graph/win_graph_factory.cpp +++ b/src/win/graph/win_graph_factory.cpp @@ -1,46 +1,111 @@ #include "cru/win/graph/win_graph_factory.hpp" #include "cru/win/exception.hpp" -#include "cru/win/graph/d2d_util.hpp" -#include "cru/win/graph/graph_manager.hpp" #include "cru/win/graph/win_brush.hpp" #include "cru/win/graph/win_font.hpp" #include "cru/win/graph/win_geometry.hpp" #include "cru/win/graph/win_text_layout.hpp" #include <cassert> +#include <cstdlib> #include <utility> +namespace cru::win::graph { +namespace { +WinGraphFactory* instance = nullptr; +} +} // namespace cru::win::graph + namespace cru::platform::graph { -GraphFactory* GraphFactory::GetInstance() { - return win::graph::GraphManager::GetInstance()->GetGraphFactory(); +void GraphFactoryAutoDeleteExitHandler() { + const auto i = ::cru::win::graph::instance; // avoid long namespace prefix + if (i == nullptr) return; + if (i->IsAutoDelete()) delete i; } + +IGraphFactory* IGraphFactory::CreateInstance() { + auto& i = ::cru::win::graph::instance; // avoid long namespace prefix + assert(i == nullptr); + i = new cru::win::graph::WinGraphFactory(); + std::atexit(&GraphFactoryAutoDeleteExitHandler); + return i; } +IGraphFactory* IGraphFactory::GetInstance() { + return ::cru::win::graph::instance; +} +} // namespace cru::platform::graph + namespace cru::win::graph { -WinGraphFactory::WinGraphFactory(GraphManager* graph_manager) { - assert(graph_manager); - graph_manager_ = graph_manager; +WinGraphFactory* WinGraphFactory::GetInstance() { return instance; } + +WinGraphFactory::WinGraphFactory() { + UINT creation_flags = D3D11_CREATE_DEVICE_BGRA_SUPPORT; + +#ifdef CRU_DEBUG + creation_flags |= D3D11_CREATE_DEVICE_DEBUG; +#endif + + const D3D_FEATURE_LEVEL feature_levels[] = { + D3D_FEATURE_LEVEL_11_1, D3D_FEATURE_LEVEL_11_0, D3D_FEATURE_LEVEL_10_1, + D3D_FEATURE_LEVEL_10_0, D3D_FEATURE_LEVEL_9_3, D3D_FEATURE_LEVEL_9_2, + D3D_FEATURE_LEVEL_9_1}; + + Microsoft::WRL::ComPtr<ID3D11DeviceContext> d3d11_device_context; + + ThrowIfFailed(D3D11CreateDevice( + nullptr, D3D_DRIVER_TYPE_HARDWARE, nullptr, creation_flags, + feature_levels, ARRAYSIZE(feature_levels), D3D11_SDK_VERSION, + &d3d11_device_, nullptr, &d3d11_device_context)); + + Microsoft::WRL::ComPtr<IDXGIDevice> dxgi_device; + ThrowIfFailed(d3d11_device_->QueryInterface(dxgi_device.GetAddressOf())); + + ThrowIfFailed(D2D1CreateFactory(D2D1_FACTORY_TYPE_SINGLE_THREADED, + IID_PPV_ARGS(&d2d1_factory_))); + + Microsoft::WRL::ComPtr<ID2D1Device> d2d1_device; + + ThrowIfFailed(d2d1_factory_->CreateDevice(dxgi_device.Get(), &d2d1_device)); + + ThrowIfFailed(d2d1_device->CreateDeviceContext( + D2D1_DEVICE_CONTEXT_OPTIONS_NONE, &d2d1_device_context_)); + + // Identify the physical adapter (GPU or card) this device is runs on. + Microsoft::WRL::ComPtr<IDXGIAdapter> dxgi_adapter; + ThrowIfFailed(dxgi_device->GetAdapter(&dxgi_adapter)); + + // Get the factory object that created the DXGI device. + ThrowIfFailed(dxgi_adapter->GetParent(IID_PPV_ARGS(&dxgi_factory_))); + + ThrowIfFailed(DWriteCreateFactory( + DWRITE_FACTORY_TYPE_SHARED, __uuidof(IDWriteFactory), + reinterpret_cast<IUnknown**>(dwrite_factory_.GetAddressOf()))); + + ThrowIfFailed(dwrite_factory_->GetSystemFontCollection( + &dwrite_system_font_collection_)); } -platform::graph::SolidColorBrush* WinGraphFactory::CreateSolidColorBrush( +WinGraphFactory::~WinGraphFactory() { instance = nullptr; } + +platform::graph::ISolidColorBrush* WinGraphFactory::CreateSolidColorBrush( const ui::Color& color) { - return new WinSolidColorBrush(graph_manager_, color); + return new WinSolidColorBrush(this, color); } -platform::graph::GeometryBuilder* WinGraphFactory::CreateGeometryBuilder() { - return new WinGeometryBuilder(graph_manager_); +platform::graph::IGeometryBuilder* WinGraphFactory::CreateGeometryBuilder() { + return new WinGeometryBuilder(this); } -platform::graph::FontDescriptor* WinGraphFactory::CreateFontDescriptor( +platform::graph::IFontDescriptor* WinGraphFactory::CreateFontDescriptor( const std::wstring_view& font_family, float font_size) { - return new WinFontDescriptor(graph_manager_, font_family, font_size); + return new WinFontDescriptor(this, font_family, font_size); } -platform::graph::TextLayout* WinGraphFactory::CreateTextLayout( - std::shared_ptr<platform::graph::FontDescriptor> font, std::wstring text) { +platform::graph::ITextLayout* WinGraphFactory::CreateTextLayout( + std::shared_ptr<platform::graph::IFontDescriptor> font, std::wstring text) { const auto f = std::dynamic_pointer_cast<WinFontDescriptor>(font); assert(f); - return new WinTextLayout(graph_manager_, std::move(f), std::move(text)); + return new WinTextLayout(this, std::move(f), std::move(text)); } } // namespace cru::win::graph diff --git a/src/win/graph/win_painter.cpp b/src/win/graph/win_painter.cpp new file mode 100644 index 00000000..f75cf4e0 --- /dev/null +++ b/src/win/graph/win_painter.cpp @@ -0,0 +1,93 @@ +#include "cru/win/graph/win_painter.hpp" + +#include "cru/win/exception.hpp" +#include "cru/win/graph/win_native_factory.hpp" +#include "cru/win/graph/util/convert_util.hpp" +#include "cru/win/graph/win_brush.hpp" +#include "cru/win/graph/win_geometry.hpp" +#include "cru/win/graph/win_text_layout.hpp" + +#include <cassert> + +namespace cru::win::graph { +WinPainter::WinPainter(ID2D1RenderTarget* render_target) { + assert(render_target); + render_target_ = render_target; +} + +platform::Matrix WinPainter::GetTransform() { + assert(!IsEnded()); + D2D1_MATRIX_3X2_F m; + render_target_->GetTransform(&m); + return util::Convert(m); +} + +void WinPainter::SetTransform(const platform::Matrix& matrix) { + assert(!IsEnded()); + render_target_->SetTransform(util::Convert(matrix)); +} + +void WinPainter::Clear(const ui::Color& color) { + assert(!IsEnded()); + render_target_->Clear(util::Convert(color)); +} + +void WinPainter::StrokeRectangle(const ui::Rect& rectangle, + platform::graph::IBrush* brush, float width) { + assert(!IsEnded()); + const auto b = dynamic_cast<IWinBrush*>(brush); + assert(b); + render_target_->DrawRectangle(util::Convert(rectangle), b->GetD2DBrush(), + width); +} + +void WinPainter::FillRectangle(const ui::Rect& rectangle, + platform::graph::IBrush* brush) { + assert(!IsEnded()); + const auto b = dynamic_cast<IWinBrush*>(brush); + assert(b); + render_target_->FillRectangle(util::Convert(rectangle), b->GetD2DBrush()); +} + +void WinPainter::StrokeGeometry(platform::graph::IGeometry* geometry, + platform::graph::IBrush* brush, float width) { + assert(!IsEnded()); + const auto g = dynamic_cast<WinGeometry*>(geometry); + assert(g); + const auto b = dynamic_cast<IWinBrush*>(brush); + assert(b); + + render_target_->DrawGeometry(g->GetNative(), b->GetD2DBrush(), width); +} + +void WinPainter::FillGeometry(platform::graph::IGeometry* geometry, + platform::graph::IBrush* brush) { + assert(!IsEnded()); + const auto g = dynamic_cast<WinGeometry*>(geometry); + assert(g); + const auto b = dynamic_cast<IWinBrush*>(brush); + assert(b); + + render_target_->FillGeometry(g->GetNative(), b->GetD2DBrush()); +} + +void WinPainter::DrawText(const ui::Point& offset, + platform::graph::ITextLayout* text_layout, + platform::graph::IBrush* brush) { + assert(!IsEnded()); + const auto t = dynamic_cast<WinTextLayout*>(text_layout); + assert(t); + const auto b = dynamic_cast<IWinBrush*>(brush); + assert(b); + + render_target_->DrawTextLayout(util::Convert(offset), + t->GetDWriteTextLayout(), b->GetD2DBrush()); +} + +void WinPainter::End() { + if (!is_draw_ended_) { + is_draw_ended_ = true; + DoEndDraw(); + } +} +} // namespace cru::win::graph diff --git a/src/win/graph/win_text_layout.cpp b/src/win/graph/win_text_layout.cpp index 0506320a..997309ad 100644 --- a/src/win/graph/win_text_layout.cpp +++ b/src/win/graph/win_text_layout.cpp @@ -1,23 +1,23 @@ #include "cru/win/graph/win_text_layout.hpp" #include "cru/win/exception.hpp" -#include "cru/win/graph/graph_manager.hpp" #include "cru/win/graph/win_font.hpp" +#include "cru/win/graph/win_native_factory.hpp" #include <cassert> #include <utility> namespace cru::win::graph { -WinTextLayout::WinTextLayout(GraphManager* graph_manager, +WinTextLayout::WinTextLayout(IWinNativeFactory* factory, std::shared_ptr<WinFontDescriptor> font, std::wstring text) { - assert(graph_manager); + assert(factory); assert(font); - graph_manager_ = graph_manager; + factory_ = factory; text_.swap(text); font_descriptor_.swap(font); - ThrowIfFailed(graph_manager_->GetDWriteFactory()->CreateTextLayout( + ThrowIfFailed(factory->GetDWriteFactory()->CreateTextLayout( text_.c_str(), static_cast<UINT32>(text_.size()), font_descriptor_->GetDWriteTextFormat(), max_width_, max_height_, &text_layout_)); @@ -27,22 +27,22 @@ std::wstring WinTextLayout::GetText() { return text_; } void WinTextLayout::SetText(std::wstring new_text) { text_.swap(new_text); - ThrowIfFailed(graph_manager_->GetDWriteFactory()->CreateTextLayout( + ThrowIfFailed(factory_->GetDWriteFactory()->CreateTextLayout( text_.c_str(), static_cast<UINT32>(text_.size()), font_descriptor_->GetDWriteTextFormat(), max_width_, max_height_, &text_layout_)); } -std::shared_ptr<platform::graph::FontDescriptor> WinTextLayout::GetFont() { +std::shared_ptr<platform::graph::IFontDescriptor> WinTextLayout::GetFont() { return font_descriptor_; } void WinTextLayout::SetFont( - std::shared_ptr<platform::graph::FontDescriptor> font) { + std::shared_ptr<platform::graph::IFontDescriptor> font) { auto f = std::dynamic_pointer_cast<WinFontDescriptor>(font); assert(f); f.swap(font_descriptor_); - ThrowIfFailed(graph_manager_->GetDWriteFactory()->CreateTextLayout( + ThrowIfFailed(factory_->GetDWriteFactory()->CreateTextLayout( text_.c_str(), static_cast<UINT32>(text_.size()), font_descriptor_->GetDWriteTextFormat(), max_width_, max_height_, &text_layout_)); |