mirror of
https://github.com/microsoft/PowerToys.git
synced 2025-12-29 00:24:42 +01:00
dpi from rt for custom renderer
This commit is contained in:
@@ -71,7 +71,7 @@ D2DState::D2DState(const HWND overlayWindow, std::vector<D2D1::ColorF> solidBrus
|
||||
winrt::check_hresult(deviceContext->CreateEffect(CLSID_D2D12DAffineTransform, &affineTransformEffect));
|
||||
affineTransformEffect->SetInputEffect(0, shadowEffect.get());
|
||||
|
||||
textRenderer = winrt::make_self<PerGlyphOpacityTextRender>(d2dFactory, rt, solidBrushes[Brush::foreground], dpiScale);
|
||||
textRenderer = winrt::make_self<PerGlyphOpacityTextRender>(d2dFactory, rt, solidBrushes[Brush::foreground]);
|
||||
}
|
||||
|
||||
void D2DState::DrawTextBox(const wchar_t* text,
|
||||
|
||||
@@ -5,12 +5,10 @@
|
||||
PerGlyphOpacityTextRender::PerGlyphOpacityTextRender(
|
||||
wil::com_ptr<ID2D1Factory> pD2DFactory,
|
||||
wil::com_ptr<ID2D1HwndRenderTarget> rt,
|
||||
wil::com_ptr<ID2D1SolidColorBrush> baseBrush,
|
||||
const float dpiScale) :
|
||||
wil::com_ptr<ID2D1SolidColorBrush> baseBrush) :
|
||||
_pD2DFactory{ pD2DFactory },
|
||||
_rt{ rt },
|
||||
_baseBrush{ baseBrush },
|
||||
_dpiScale{ dpiScale }
|
||||
_baseBrush{ baseBrush }
|
||||
{
|
||||
}
|
||||
|
||||
@@ -28,7 +26,6 @@ HRESULT __stdcall PerGlyphOpacityTextRender::DrawGlyphRun(void* /*clientDrawingC
|
||||
_rt->DrawGlyphRun(D2D1_POINT_2F{ .x = baselineOriginX, .y = baselineOriginY }, glyphRun, _baseBrush.get(), measuringMode);
|
||||
return hr;
|
||||
}
|
||||
|
||||
// Create the path geometry.
|
||||
wil::com_ptr<ID2D1PathGeometry> pathGeometry;
|
||||
hr = _pD2DFactory->CreatePathGeometry(&pathGeometry);
|
||||
@@ -139,6 +136,6 @@ HRESULT __stdcall PerGlyphOpacityTextRender::GetCurrentTransform(void* /*clientD
|
||||
|
||||
HRESULT __stdcall PerGlyphOpacityTextRender::GetPixelsPerDip(void* /*clientDrawingContext*/, FLOAT* pixelsPerDip) noexcept
|
||||
{
|
||||
*pixelsPerDip = _dpiScale;
|
||||
_rt->GetDpi(pixelsPerDip, pixelsPerDip);
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
@@ -19,13 +19,11 @@ struct PerGlyphOpacityTextRender : winrt::implements<PerGlyphOpacityTextRender,
|
||||
wil::com_ptr<ID2D1Factory> _pD2DFactory;
|
||||
wil::com_ptr<ID2D1HwndRenderTarget> _rt;
|
||||
wil::com_ptr<ID2D1SolidColorBrush> _baseBrush;
|
||||
float _dpiScale = 1.f;
|
||||
|
||||
|
||||
PerGlyphOpacityTextRender(
|
||||
wil::com_ptr<ID2D1Factory> pD2DFactory,
|
||||
wil::com_ptr<ID2D1HwndRenderTarget> rt,
|
||||
wil::com_ptr<ID2D1SolidColorBrush> baseBrush,
|
||||
const float _dpiScale);
|
||||
wil::com_ptr<ID2D1SolidColorBrush> baseBrush);
|
||||
|
||||
HRESULT __stdcall DrawGlyphRun(void* clientDrawingContext,
|
||||
FLOAT baselineOriginX,
|
||||
|
||||
Reference in New Issue
Block a user