mirror of
https://github.com/chibicitiberiu/rainmeter-studio.git
synced 2024-02-24 04:33:31 +00:00
Gfx: Fix clipping with D2D when a transformation has been applied
This commit is contained in:
parent
42e8d5ee22
commit
b8333dc66d
@ -315,7 +315,9 @@ void CanvasD2D::DrawTextW(const WCHAR* str, UINT strLen, const TextFormat& forma
|
|||||||
formatD2D.CreateLayout(
|
formatD2D.CreateLayout(
|
||||||
str, strLen, rect.Width, rect.Height, !m_AccurateText && m_TextAntiAliasing);
|
str, strLen, rect.Width, rect.Height, !m_AccurateText && m_TextAntiAliasing);
|
||||||
|
|
||||||
const float xPos = [&]()
|
D2D1_POINT_2F drawPosition;
|
||||||
|
drawPosition.y = rect.Y - formatD2D.m_LineGap;
|
||||||
|
drawPosition.x = [&]()
|
||||||
{
|
{
|
||||||
if (!m_AccurateText)
|
if (!m_AccurateText)
|
||||||
{
|
{
|
||||||
@ -330,15 +332,33 @@ void CanvasD2D::DrawTextW(const WCHAR* str, UINT strLen, const TextFormat& forma
|
|||||||
return rect.X;
|
return rect.X;
|
||||||
} ();
|
} ();
|
||||||
|
|
||||||
// TODO: Check for transformation.
|
D2D1::Matrix3x2F transformMatrix;
|
||||||
m_Target->PushAxisAlignedClip(ToRectF(rect), D2D1_ANTIALIAS_MODE_ALIASED);
|
m_Target->GetTransform(&transformMatrix);
|
||||||
|
const bool identityTransform = transformMatrix.IsIdentity();
|
||||||
|
|
||||||
m_Target->DrawTextLayout(
|
// TODO: Determine if we can avoid clipping.
|
||||||
D2D1::Point2F(xPos, rect.Y - formatD2D.m_LineGap),
|
D2D1_RECT_F clipRect = ToRectF(rect);
|
||||||
formatD2D.m_TextLayout.Get(),
|
if (identityTransform)
|
||||||
solidBrush.Get());
|
{
|
||||||
|
m_Target->PushAxisAlignedClip(clipRect, D2D1_ANTIALIAS_MODE_ALIASED);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
const D2D1_LAYER_PARAMETERS layerParams =
|
||||||
|
D2D1::LayerParameters(clipRect, nullptr, D2D1_ANTIALIAS_MODE_ALIASED);
|
||||||
|
m_Target->PushLayer(layerParams, nullptr);
|
||||||
|
}
|
||||||
|
|
||||||
m_Target->PopAxisAlignedClip();
|
m_Target->DrawTextLayout(drawPosition, formatD2D.m_TextLayout.Get(), solidBrush.Get());
|
||||||
|
|
||||||
|
if (identityTransform)
|
||||||
|
{
|
||||||
|
m_Target->PopAxisAlignedClip();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
m_Target->PopLayer();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user