diff --git a/src/renderer/atlas/BackendD2D.cpp b/src/renderer/atlas/BackendD2D.cpp index 1d0db35803b..7155d842ad4 100644 --- a/src/renderer/atlas/BackendD2D.cpp +++ b/src/renderer/atlas/BackendD2D.cpp @@ -75,6 +75,7 @@ void BackendD2D::_handleSettingsUpdate(const RenderingPayload& p) { wil::com_ptr buffer; THROW_IF_FAILED(p.swapChain.swapChain->GetBuffer(0, __uuidof(ID3D11Texture2D), reinterpret_cast(buffer.addressof()))); + const auto surface = buffer.query(); const D2D1_RENDER_TARGET_PROPERTIES props{ .type = D2D1_RENDER_TARGET_TYPE_DEFAULT, @@ -83,8 +84,8 @@ void BackendD2D::_handleSettingsUpdate(const RenderingPayload& p) .dpiY = static_cast(p.s->font->dpi), }; // ID2D1RenderTarget and ID2D1DeviceContext are the same and I'm tired of pretending they're not. - THROW_IF_FAILED(p.d2dFactory->CreateDxgiSurfaceRenderTarget(buffer.query().get(), &props, reinterpret_cast(_renderTarget.addressof()))); - _renderTarget.query_to(_renderTarget4.addressof()); + THROW_IF_FAILED(p.d2dFactory->CreateDxgiSurfaceRenderTarget(surface.get(), &props, reinterpret_cast(_renderTarget.addressof()))); + _renderTarget.try_query_to(_renderTarget4.addressof()); _renderTarget->SetUnitMode(D2D1_UNIT_MODE_PIXELS); _renderTarget->SetAntialiasMode(D2D1_ANTIALIAS_MODE_ALIASED); diff --git a/src/renderer/atlas/BackendD3D.cpp b/src/renderer/atlas/BackendD3D.cpp index d1990e309c7..fb549acaf7b 100644 --- a/src/renderer/atlas/BackendD3D.cpp +++ b/src/renderer/atlas/BackendD3D.cpp @@ -782,6 +782,7 @@ void BackendD3D::_resizeGlyphAtlas(const RenderingPayload& p, const u16 u, const // We have our own glyph cache so Direct2D's cache doesn't help much. // This saves us 1MB of RAM, which is not much, but also not nothing. + if (_d2dRenderTarget4) { wil::com_ptr device; _d2dRenderTarget4->GetDevice(device.addressof()); @@ -1370,12 +1371,12 @@ bool BackendD3D::_drawGlyph(const RenderingPayload& p, const AtlasFontFaceEntryI static_cast(rect.x + rect.w) / transform.m11, static_cast(rect.y + rect.h) / transform.m22, }; - _d2dRenderTarget4->PushAxisAlignedClip(&clipRect, D2D1_ANTIALIAS_MODE_ALIASED); + _d2dRenderTarget->PushAxisAlignedClip(&clipRect, D2D1_ANTIALIAS_MODE_ALIASED); } const auto boxGlyphCleanup = wil::scope_exit([&]() { if (isBoxGlyph) { - _d2dRenderTarget4->PopAxisAlignedClip(); + _d2dRenderTarget->PopAxisAlignedClip(); } });