Kaydet (Commit) cbda019e authored tarafından Tomaž Vajngerl's avatar Tomaž Vajngerl Kaydeden (comit) Tomaž Vajngerl

DWrite: HRESULT checks for debug mode

Change-Id: I4913b6e3d3c1766151571c467416e62409c8e260
Reviewed-on: https://gerrit.libreoffice.org/40020Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarTomaž Vajngerl <quikee@gmail.com>
üst 27b8376e
...@@ -107,6 +107,25 @@ IDWriteRenderingParams* lclSetRenderingMode(IDWriteFactory* pDWriteFactory, DWRI ...@@ -107,6 +107,25 @@ IDWriteRenderingParams* lclSetRenderingMode(IDWriteFactory* pDWriteFactory, DWRI
return pParameters; return pParameters;
} }
#ifdef SAL_LOG_WARN
HRESULT checkResult(HRESULT hr, const char* file, size_t line)
{
if (FAILED(hr))
{
OUString sLocationString = OUString::createFromAscii(file) + ":" + OUString::number(line) + " ";
SAL_DETAIL_LOG_STREAM(SAL_DETAIL_ENABLE_LOG_WARN, ::SAL_DETAIL_LOG_LEVEL_WARN,
"vcl.gdi", sLocationString.toUtf8().getStr(),
"HRESULT failed with: " << (int(hr)));
}
return hr;
}
#define CHECKHR(funct) checkResult(funct, __FILE__, __LINE__)
#else
#define CHECKHR(funct) (funct)
#endif
} // end anonymous namespace } // end anonymous namespace
D2DWriteTextOutRenderer::D2DWriteTextOutRenderer() D2DWriteTextOutRenderer::D2DWriteTextOutRenderer()
...@@ -176,7 +195,7 @@ HRESULT D2DWriteTextOutRenderer::CreateRenderTarget() ...@@ -176,7 +195,7 @@ HRESULT D2DWriteTextOutRenderer::CreateRenderTarget()
mpRT->Release(); mpRT->Release();
mpRT = nullptr; mpRT = nullptr;
} }
return mpD2DFactory->CreateDCRenderTarget(&mRTProps, &mpRT); return CHECKHR(mpD2DFactory->CreateDCRenderTarget(&mRTProps, &mpRT));
} }
bool D2DWriteTextOutRenderer::Ready() const bool D2DWriteTextOutRenderer::Ready() const
...@@ -189,7 +208,7 @@ bool D2DWriteTextOutRenderer::BindDC(HDC hDC, tools::Rectangle const & rRect) ...@@ -189,7 +208,7 @@ bool D2DWriteTextOutRenderer::BindDC(HDC hDC, tools::Rectangle const & rRect)
if (rRect.GetWidth() == 0 || rRect.GetHeight() == 0) if (rRect.GetWidth() == 0 || rRect.GetHeight() == 0)
return false; return false;
RECT const rc = { rRect.Left(), rRect.Top(), rRect.Right(), rRect.Bottom() }; RECT const rc = { rRect.Left(), rRect.Top(), rRect.Right(), rRect.Bottom() };
return SUCCEEDED(mpRT->BindDC(hDC, &rc)); return SUCCEEDED(CHECKHR(mpRT->BindDC(hDC, &rc)));
} }
bool D2DWriteTextOutRenderer::operator ()(CommonSalLayout const &rLayout, bool D2DWriteTextOutRenderer::operator ()(CommonSalLayout const &rLayout,
...@@ -211,7 +230,8 @@ bool D2DWriteTextOutRenderer::operator ()(CommonSalLayout const &rLayout, ...@@ -211,7 +230,8 @@ bool D2DWriteTextOutRenderer::operator ()(CommonSalLayout const &rLayout,
ID2D1SolidColorBrush* pBrush = nullptr; ID2D1SolidColorBrush* pBrush = nullptr;
COLORREF bgrTextColor = GetTextColor(mhDC); COLORREF bgrTextColor = GetTextColor(mhDC);
succeeded &= SUCCEEDED(mpRT->CreateSolidColorBrush(D2D1::ColorF(GetRValue(bgrTextColor) / 255.0f, GetGValue(bgrTextColor) / 255.0f, GetBValue(bgrTextColor) / 255.0f), &pBrush)); D2D1::ColorF aD2DColor(GetRValue(bgrTextColor) / 255.0f, GetGValue(bgrTextColor) / 255.0f, GetBValue(bgrTextColor) / 255.0f);
succeeded &= SUCCEEDED(CHECKHR(mpRT->CreateSolidColorBrush(aD2DColor, &pBrush)));
HRESULT hr = S_OK; HRESULT hr = S_OK;
if (succeeded) if (succeeded)
...@@ -242,7 +262,7 @@ bool D2DWriteTextOutRenderer::operator ()(CommonSalLayout const &rLayout, ...@@ -242,7 +262,7 @@ bool D2DWriteTextOutRenderer::operator ()(CommonSalLayout const &rLayout,
mpRT->DrawGlyphRun(baseline, &glyphs, pBrush); mpRT->DrawGlyphRun(baseline, &glyphs, pBrush);
} }
hr = mpRT->EndDraw(); hr = CHECKHR(mpRT->EndDraw());
} }
if (pBrush) if (pBrush)
...@@ -298,7 +318,7 @@ std::vector<tools::Rectangle> D2DWriteTextOutRenderer::GetGlyphInkBoxes(uint16_t ...@@ -298,7 +318,7 @@ std::vector<tools::Rectangle> D2DWriteTextOutRenderer::GetGlyphInkBoxes(uint16_t
mpFontFace->GetMetrics(&aFontMetrics); mpFontFace->GetMetrics(&aFontMetrics);
std::vector<DWRITE_GLYPH_METRICS> metrics(nGlyphs); std::vector<DWRITE_GLYPH_METRICS> metrics(nGlyphs);
if (!SUCCEEDED(mpFontFace->GetDesignGlyphMetrics(pGid, nGlyphs, metrics.data()))) if (!SUCCEEDED(CHECKHR(mpFontFace->GetDesignGlyphMetrics(pGid, nGlyphs, metrics.data()))))
return std::vector<tools::Rectangle>(); return std::vector<tools::Rectangle>();
std::vector<tools::Rectangle> aOut(nGlyphs); std::vector<tools::Rectangle> aOut(nGlyphs);
...@@ -327,7 +347,7 @@ bool D2DWriteTextOutRenderer::GetDWriteFaceFromHDC(HDC hDC, IDWriteFontFace ** p ...@@ -327,7 +347,7 @@ bool D2DWriteTextOutRenderer::GetDWriteFaceFromHDC(HDC hDC, IDWriteFontFace ** p
bool succeeded = false; bool succeeded = false;
try try
{ {
succeeded = SUCCEEDED(mpGdiInterop->CreateFontFaceFromHdc(hDC, ppFontFace)); succeeded = SUCCEEDED(CHECKHR(mpGdiInterop->CreateFontFaceFromHdc(hDC, ppFontFace)));
} }
catch (const std::exception& e) catch (const std::exception& e)
{ {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment