mirror of
https://github.com/chibicitiberiu/rainmeter-studio.git
synced 2024-02-24 04:33:31 +00:00
Gfx: Cosmetics
This commit is contained in:
parent
2f8f67e2cf
commit
12bd890aef
@ -53,10 +53,10 @@ D2D1_RECT_F ToRectF(const Gdiplus::RectF& rect)
|
|||||||
namespace Gfx {
|
namespace Gfx {
|
||||||
|
|
||||||
UINT CanvasD2D::c_Instances = 0;
|
UINT CanvasD2D::c_Instances = 0;
|
||||||
ID2D1Factory* CanvasD2D::c_D2D = nullptr;
|
ID2D1Factory* CanvasD2D::c_D2DFactory = nullptr;
|
||||||
IDWriteFactory* CanvasD2D::c_DW = nullptr;
|
IDWriteFactory* CanvasD2D::c_DWFactory = nullptr;
|
||||||
IDWriteGdiInterop* CanvasD2D::c_DWGDIInterop = nullptr;
|
IDWriteGdiInterop* CanvasD2D::c_DWGDIInterop = nullptr;
|
||||||
IWICImagingFactory* CanvasD2D::c_WIC = nullptr;
|
IWICImagingFactory* CanvasD2D::c_WICFactory = nullptr;
|
||||||
|
|
||||||
CanvasD2D::CanvasD2D() : Canvas(),
|
CanvasD2D::CanvasD2D() : Canvas(),
|
||||||
m_Target(),
|
m_Target(),
|
||||||
@ -87,7 +87,7 @@ bool CanvasD2D::Initialize()
|
|||||||
HRESULT hr = D2D1CreateFactory(
|
HRESULT hr = D2D1CreateFactory(
|
||||||
D2D1_FACTORY_TYPE_SINGLE_THREADED,
|
D2D1_FACTORY_TYPE_SINGLE_THREADED,
|
||||||
fo,
|
fo,
|
||||||
&c_D2D);
|
&c_D2DFactory);
|
||||||
if (FAILED(hr)) return false;
|
if (FAILED(hr)) return false;
|
||||||
|
|
||||||
hr = CoCreateInstance(
|
hr = CoCreateInstance(
|
||||||
@ -95,16 +95,16 @@ bool CanvasD2D::Initialize()
|
|||||||
nullptr,
|
nullptr,
|
||||||
CLSCTX_INPROC_SERVER,
|
CLSCTX_INPROC_SERVER,
|
||||||
IID_IWICImagingFactory,
|
IID_IWICImagingFactory,
|
||||||
(LPVOID*)&c_WIC);
|
(LPVOID*)&c_WICFactory);
|
||||||
if (FAILED(hr)) return false;
|
if (FAILED(hr)) return false;
|
||||||
|
|
||||||
hr = DWriteCreateFactory(
|
hr = DWriteCreateFactory(
|
||||||
DWRITE_FACTORY_TYPE_SHARED,
|
DWRITE_FACTORY_TYPE_SHARED,
|
||||||
__uuidof(IDWriteFactory),
|
__uuidof(IDWriteFactory),
|
||||||
(IUnknown**)&c_DW);
|
(IUnknown**)&c_DWFactory);
|
||||||
if (FAILED(hr)) return false;
|
if (FAILED(hr)) return false;
|
||||||
|
|
||||||
hr = c_DW->GetGdiInterop(&c_DWGDIInterop);
|
hr = c_DWFactory->GetGdiInterop(&c_DWGDIInterop);
|
||||||
if (FAILED(hr)) return false;
|
if (FAILED(hr)) return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -116,10 +116,10 @@ void CanvasD2D::Finalize()
|
|||||||
--c_Instances;
|
--c_Instances;
|
||||||
if (c_Instances == 0)
|
if (c_Instances == 0)
|
||||||
{
|
{
|
||||||
SafeRelease(&c_D2D);
|
SafeRelease(&c_D2DFactory);
|
||||||
SafeRelease(&c_WIC);
|
SafeRelease(&c_WICFactory);
|
||||||
SafeRelease(&c_DWGDIInterop);
|
SafeRelease(&c_DWGDIInterop);
|
||||||
SafeRelease(&c_DW);
|
SafeRelease(&c_DWFactory);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -178,7 +178,7 @@ bool CanvasD2D::BeginTargetDraw()
|
|||||||
// before the next GDI+ draw operations, we ensure that the pixel data result is as expected
|
// before the next GDI+ draw operations, we ensure that the pixel data result is as expected
|
||||||
// Once GDI+ drawing is no longer needed, we change to recreate the render target only when the
|
// Once GDI+ drawing is no longer needed, we change to recreate the render target only when the
|
||||||
// bitmap size is changed.
|
// bitmap size is changed.
|
||||||
HRESULT hr = c_D2D->CreateWicBitmapRenderTarget(&m_Bitmap, properties, &m_Target);
|
HRESULT hr = c_D2DFactory->CreateWicBitmapRenderTarget(&m_Bitmap, properties, &m_Target);
|
||||||
if (SUCCEEDED(hr))
|
if (SUCCEEDED(hr))
|
||||||
{
|
{
|
||||||
SetTextAntiAliasing(m_TextAntiAliasing);
|
SetTextAntiAliasing(m_TextAntiAliasing);
|
||||||
@ -352,7 +352,7 @@ void CanvasD2D::DrawTextW(const WCHAR* str, UINT strLen, const TextFormat& forma
|
|||||||
bool CanvasD2D::MeasureTextW(const WCHAR* str, UINT strLen, const TextFormat& format, Gdiplus::RectF& rect)
|
bool CanvasD2D::MeasureTextW(const WCHAR* str, UINT strLen, const TextFormat& format, Gdiplus::RectF& rect)
|
||||||
{
|
{
|
||||||
IDWriteTextLayout* textLayout;
|
IDWriteTextLayout* textLayout;
|
||||||
HRESULT hr = c_DW->CreateTextLayout(
|
HRESULT hr = c_DWFactory->CreateTextLayout(
|
||||||
str,
|
str,
|
||||||
strLen,
|
strLen,
|
||||||
((TextFormatD2D&)format).m_TextFormat,
|
((TextFormatD2D&)format).m_TextFormat,
|
||||||
@ -378,7 +378,7 @@ bool CanvasD2D::MeasureTextLinesW(const WCHAR* str, UINT strLen, const TextForma
|
|||||||
((TextFormatD2D&)format).m_TextFormat->SetWordWrapping(DWRITE_WORD_WRAPPING_WRAP);
|
((TextFormatD2D&)format).m_TextFormat->SetWordWrapping(DWRITE_WORD_WRAPPING_WRAP);
|
||||||
|
|
||||||
IDWriteTextLayout* textLayout;
|
IDWriteTextLayout* textLayout;
|
||||||
HRESULT hr = c_DW->CreateTextLayout(
|
HRESULT hr = c_DWFactory->CreateTextLayout(
|
||||||
str,
|
str,
|
||||||
strLen,
|
strLen,
|
||||||
((TextFormatD2D&)format).m_TextFormat,
|
((TextFormatD2D&)format).m_TextFormat,
|
||||||
|
@ -96,10 +96,10 @@ private:
|
|||||||
bool m_TextAntiAliasing;
|
bool m_TextAntiAliasing;
|
||||||
|
|
||||||
static UINT c_Instances;
|
static UINT c_Instances;
|
||||||
static ID2D1Factory* c_D2D;
|
static ID2D1Factory* c_D2DFactory;
|
||||||
static IDWriteFactory* c_DW;
|
static IDWriteFactory* c_DWFactory;
|
||||||
static IDWriteGdiInterop* c_DWGDIInterop;
|
static IDWriteGdiInterop* c_DWGDIInterop;
|
||||||
static IWICImagingFactory* c_WIC;
|
static IWICImagingFactory* c_WICFactory;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Gfx
|
} // namespace Gfx
|
||||||
|
@ -84,7 +84,7 @@ void TextFormatD2D::CreateLayout(const WCHAR* str, UINT strLen, float maxW, floa
|
|||||||
m_TextLayout = nullptr;
|
m_TextLayout = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
CanvasD2D::c_DW->CreateTextLayout(str, strLen, m_TextFormat, maxW, maxH, &m_TextLayout);
|
CanvasD2D::c_DWFactory->CreateTextLayout(str, strLen, m_TextFormat, maxW, maxH, &m_TextLayout);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -105,7 +105,7 @@ void TextFormatD2D::SetProperties(const WCHAR* fontFamily, int size, bool bold,
|
|||||||
{
|
{
|
||||||
// TODO: If |fontFamily| is e.g. 'Segoe UI Semibold' and |bold| is true, we might want
|
// TODO: If |fontFamily| is e.g. 'Segoe UI Semibold' and |bold| is true, we might want
|
||||||
// to make the weight heaver to match GDI+.
|
// to make the weight heaver to match GDI+.
|
||||||
hr = CanvasD2D::c_DW->CreateTextFormat(
|
hr = CanvasD2D::c_DWFactory->CreateTextFormat(
|
||||||
buffer,
|
buffer,
|
||||||
nullptr,
|
nullptr,
|
||||||
dwFont->GetWeight(),
|
dwFont->GetWeight(),
|
||||||
@ -122,7 +122,7 @@ void TextFormatD2D::SetProperties(const WCHAR* fontFamily, int size, bool bold,
|
|||||||
if (FAILED(hr))
|
if (FAILED(hr))
|
||||||
{
|
{
|
||||||
// Fallback in case above fails.
|
// Fallback in case above fails.
|
||||||
hr = CanvasD2D::c_DW->CreateTextFormat(
|
hr = CanvasD2D::c_DWFactory->CreateTextFormat(
|
||||||
fontFamily,
|
fontFamily,
|
||||||
nullptr,
|
nullptr,
|
||||||
bold ? DWRITE_FONT_WEIGHT_BOLD : DWRITE_FONT_WEIGHT_REGULAR,
|
bold ? DWRITE_FONT_WEIGHT_BOLD : DWRITE_FONT_WEIGHT_REGULAR,
|
||||||
@ -153,7 +153,7 @@ void TextFormatD2D::SetTrimming(bool trim)
|
|||||||
{
|
{
|
||||||
if (!m_InlineEllipsis)
|
if (!m_InlineEllipsis)
|
||||||
{
|
{
|
||||||
CanvasD2D::c_DW->CreateEllipsisTrimmingSign(m_TextFormat, &m_InlineEllipsis);
|
CanvasD2D::c_DWFactory->CreateEllipsisTrimmingSign(m_TextFormat, &m_InlineEllipsis);
|
||||||
}
|
}
|
||||||
|
|
||||||
inlineObject = m_InlineEllipsis;
|
inlineObject = m_InlineEllipsis;
|
||||||
@ -194,7 +194,7 @@ void TextFormatD2D::SetVerticalAlignment(VerticalAlignment alignment)
|
|||||||
IDWriteFont* TextFormatD2D::CreateDWFontFromGDIFamilyName(const WCHAR* fontFamily, bool bold, bool italic)
|
IDWriteFont* TextFormatD2D::CreateDWFontFromGDIFamilyName(const WCHAR* fontFamily, bool bold, bool italic)
|
||||||
{
|
{
|
||||||
IDWriteGdiInterop* dwGdiInterop;
|
IDWriteGdiInterop* dwGdiInterop;
|
||||||
HRESULT hr = CanvasD2D::c_DW->GetGdiInterop(&dwGdiInterop);
|
HRESULT hr = CanvasD2D::c_DWFactory->GetGdiInterop(&dwGdiInterop);
|
||||||
if (SUCCEEDED(hr))
|
if (SUCCEEDED(hr))
|
||||||
{
|
{
|
||||||
LOGFONT lf = {};
|
LOGFONT lf = {};
|
||||||
|
Loading…
Reference in New Issue
Block a user