Gfx: Tweaks

This commit is contained in:
Birunthan Mohanathas 2013-03-28 14:45:10 +02:00
parent 5bf776090d
commit 056277ce4f

View File

@ -275,9 +275,10 @@ void CanvasD2D::DrawTextW(const WCHAR* str, UINT strLen, const TextFormat& forma
brush.GetColor(&color); brush.GetColor(&color);
ID2D1SolidColorBrush* solidBrush; ID2D1SolidColorBrush* solidBrush;
m_Target->CreateSolidColorBrush(ToColorF(color), &solidBrush); HRESULT hr = m_Target->CreateSolidColorBrush(ToColorF(color), &solidBrush);
if (SUCCEEDED(hr))
bool right = ((TextFormatD2D&)format).GetHorizontalAlignment() == Gfx::HorizontalAlignment::Right; {
const bool right = ((TextFormatD2D&)format).GetHorizontalAlignment() == Gfx::HorizontalAlignment::Right;
// TODO: Draw cached layout? // TODO: Draw cached layout?
//m_Target->DrawTextLayout( //m_Target->DrawTextLayout(
@ -285,16 +286,17 @@ void CanvasD2D::DrawTextW(const WCHAR* str, UINT strLen, const TextFormat& forma
// textLayout, // textLayout,
// solidBrush); // solidBrush);
m_Target->DrawTextW( auto dst = D2D1::RectF(
str, right ? rect.X - 2 : rect.X + 2.0f,
strLen, rect.Y - 1.0f,
((TextFormatD2D&)format).m_TextFormat, (right ? rect.X - 2 : rect.X + 2.0f) + rect.Width,
D2D1::RectF(right ? rect.X - 2 : rect.X + 2.0f, rect.Y - 1.0f, (right ? rect.X - 2 : rect.X + 2.0f) + rect.Width, rect.Y + rect.Height - 1.0f), rect.Y + rect.Height - 1.0f);
solidBrush,
D2D1_DRAW_TEXT_OPTIONS_NONE); m_Target->DrawTextW(str, strLen, ((TextFormatD2D&)format).m_TextFormat, dst, solidBrush);
solidBrush->Release(); solidBrush->Release();
} }
}
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)
{ {
@ -396,11 +398,12 @@ void CanvasD2D::FillRectangle(Gdiplus::Rect& rect, const Gdiplus::SolidBrush& br
brush.GetColor(&color); brush.GetColor(&color);
ID2D1SolidColorBrush* solidBrush; ID2D1SolidColorBrush* solidBrush;
m_Target->CreateSolidColorBrush(ToColorF(color), &solidBrush); HRESULT hr = m_Target->CreateSolidColorBrush(ToColorF(color), &solidBrush);
if (SUCCEEDED(hr))
{
m_Target->FillRectangle(ToRectF(rect), solidBrush); m_Target->FillRectangle(ToRectF(rect), solidBrush);
solidBrush->Release(); solidBrush->Release();
} }
}
} // namespace Gfx } // namespace Gfx