Fix compilation with unofficial DirectWrite headers
Reportedly, some unofficial DirectWrite ports are missing the default values to the arguments for IDWritePaintReader's MoveToFirstChild() and MoveToNextSibling(), so we make this explicit to work around the problem. Fixes: QTBUG-133336 Change-Id: Ia9a01e371e7424508db0d5ad3c75037caaf16854 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> (cherry picked from commit cbce69ebd643bb4841de20f34c5b23bddbcde0c6) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
parent
9ffc3b0705
commit
b6557e4be8
@ -635,6 +635,20 @@ int main(int, char **)
|
|||||||
IUnknown *factory = nullptr;
|
IUnknown *factory = nullptr;
|
||||||
// Just check that the API is available for the build
|
// Just check that the API is available for the build
|
||||||
DWRITE_PAINT_ELEMENT paintElement;
|
DWRITE_PAINT_ELEMENT paintElement;
|
||||||
|
|
||||||
|
if (false) {
|
||||||
|
DWRITE_COLOR_F dwColor;
|
||||||
|
dwColor.r = 0;
|
||||||
|
dwColor.g = 0;
|
||||||
|
dwColor.b = 0;
|
||||||
|
dwColor.a = 0;
|
||||||
|
IDWritePaintReader *paintReader = nullptr;
|
||||||
|
// Some versions of MinGW has a dwrite_3.h header with buggy generated APIs. One of these
|
||||||
|
// is that the SetTextColor() function takes a pointer instead of a const-ref. We check
|
||||||
|
// for this to disable the COLRv1 feature for broken headers.
|
||||||
|
paintReader->SetTextColor(dwColor);
|
||||||
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
")
|
")
|
||||||
|
@ -1031,13 +1031,13 @@ bool QWindowsFontEngineDirectWrite::traverseColr1(IDWritePaintReader *paintReade
|
|||||||
|
|
||||||
auto traverseChildren = [&](quint32 childCount) {
|
auto traverseChildren = [&](quint32 childCount) {
|
||||||
DWRITE_PAINT_ELEMENT childPaintElement;
|
DWRITE_PAINT_ELEMENT childPaintElement;
|
||||||
if (FAILED(paintReader->MoveToFirstChild(&childPaintElement)))
|
if (FAILED(paintReader->MoveToFirstChild(&childPaintElement, sizeof(DWRITE_PAINT_ELEMENT))))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
while (childCount-- > 0) {
|
while (childCount-- > 0) {
|
||||||
traverseColr1(paintReader, face7, &childPaintElement, paintGraphRenderer);
|
traverseColr1(paintReader, face7, &childPaintElement, paintGraphRenderer);
|
||||||
if (childCount > 0) {
|
if (childCount > 0) {
|
||||||
if (FAILED(paintReader->MoveToNextSibling(&childPaintElement))) {
|
if (FAILED(paintReader->MoveToNextSibling(&childPaintElement, sizeof(DWRITE_PAINT_ELEMENT)))) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1100,7 +1100,7 @@ bool QWindowsFontEngineDirectWrite::traverseColr1(IDWritePaintReader *paintReade
|
|||||||
} else {
|
} else {
|
||||||
DWRITE_PAINT_ELEMENT childElement;
|
DWRITE_PAINT_ELEMENT childElement;
|
||||||
|
|
||||||
HRESULT hr = paintReader->MoveToFirstChild(&childElement);
|
HRESULT hr = paintReader->MoveToFirstChild(&childElement, sizeof(DWRITE_PAINT_ELEMENT));
|
||||||
if (FAILED(hr)) {
|
if (FAILED(hr)) {
|
||||||
qErrnoWarning(hr, "%s: Cannot move to first child of composite node",
|
qErrnoWarning(hr, "%s: Cannot move to first child of composite node",
|
||||||
__FUNCTION__);
|
__FUNCTION__);
|
||||||
@ -1108,7 +1108,7 @@ bool QWindowsFontEngineDirectWrite::traverseColr1(IDWritePaintReader *paintReade
|
|||||||
}
|
}
|
||||||
|
|
||||||
// First draw back drop which is the second child
|
// First draw back drop which is the second child
|
||||||
hr = paintReader->MoveToNextSibling(&childElement);
|
hr = paintReader->MoveToNextSibling(&childElement, sizeof(DWRITE_PAINT_ELEMENT));
|
||||||
if (FAILED(hr)) {
|
if (FAILED(hr)) {
|
||||||
qErrnoWarning(hr, "%s: Cannot move to second child of composite node",
|
qErrnoWarning(hr, "%s: Cannot move to second child of composite node",
|
||||||
__FUNCTION__);
|
__FUNCTION__);
|
||||||
@ -1132,7 +1132,7 @@ bool QWindowsFontEngineDirectWrite::traverseColr1(IDWritePaintReader *paintReade
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
hr = paintReader->MoveToFirstChild(&childElement);
|
hr = paintReader->MoveToFirstChild(&childElement, sizeof(DWRITE_PAINT_ELEMENT));
|
||||||
if (FAILED(hr)) {
|
if (FAILED(hr)) {
|
||||||
qErrnoWarning(hr, "%s: Cannot move to first child of composite node",
|
qErrnoWarning(hr, "%s: Cannot move to first child of composite node",
|
||||||
__FUNCTION__);
|
__FUNCTION__);
|
||||||
@ -1239,7 +1239,7 @@ bool QWindowsFontEngineDirectWrite::traverseColr1(IDWritePaintReader *paintReade
|
|||||||
}
|
}
|
||||||
|
|
||||||
DWRITE_PAINT_ELEMENT childElement;
|
DWRITE_PAINT_ELEMENT childElement;
|
||||||
if (FAILED(paintReader->MoveToFirstChild(&childElement)))
|
if (FAILED(paintReader->MoveToFirstChild(&childElement, sizeof(DWRITE_PAINT_ELEMENT))))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (!traverseColr1(paintReader, face7, &childElement, paintGraphRenderer))
|
if (!traverseColr1(paintReader, face7, &childElement, paintGraphRenderer))
|
||||||
@ -1301,6 +1301,7 @@ bool QWindowsFontEngineDirectWrite::renderColr1GlyphRun(QImage *image,
|
|||||||
D2D_RECT_F clipBox;
|
D2D_RECT_F clipBox;
|
||||||
hr = paintReader->SetCurrentGlyph(glyphRun->glyphIndices[0],
|
hr = paintReader->SetCurrentGlyph(glyphRun->glyphIndices[0],
|
||||||
&paintElement,
|
&paintElement,
|
||||||
|
sizeof(DWRITE_PAINT_ELEMENT),
|
||||||
&clipBox,
|
&clipBox,
|
||||||
nullptr);
|
nullptr);
|
||||||
if (FAILED(hr)) {
|
if (FAILED(hr)) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user