Signed-off-by: Sven Baars sbaars@codeweavers.com --- dlls/d3dx9_36/sprite.c | 18 ++++++++++++------ dlls/d3dx9_36/tests/core.c | 13 +++++++++++++ 2 files changed, 25 insertions(+), 6 deletions(-)
diff --git a/dlls/d3dx9_36/sprite.c b/dlls/d3dx9_36/sprite.c index 9ef7f9c47e0..cd244e657ef 100644 --- a/dlls/d3dx9_36/sprite.c +++ b/dlls/d3dx9_36/sprite.c @@ -112,10 +112,13 @@ static ULONG WINAPI d3dx9_sprite_Release(ID3DXSprite *iface) { int i;
- for (i = 0; i < sprite->sprite_count; ++i) + if (!(sprite->flags & D3DXSPRITE_DO_NOT_ADDREF_TEXTURE)) { - if (sprite->sprites[i].texture) - IDirect3DTexture9_Release(sprite->sprites[i].texture); + for (i = 0; i < sprite->sprite_count; ++i) + { + if (sprite->sprites[i].texture) + IDirect3DTexture9_Release(sprite->sprites[i].texture); + } }
HeapFree(GetProcessHeap(), 0, sprite->sprites); @@ -518,10 +521,13 @@ static HRESULT WINAPI d3dx9_sprite_OnResetDevice(ID3DXSprite *iface)
TRACE("iface %p.\n", iface);
- for (i = 0; i < sprite->sprite_count; ++i) + if (!(sprite->flags & D3DXSPRITE_DO_NOT_ADDREF_TEXTURE)) { - if (sprite->sprites[i].texture) - IDirect3DTexture9_Release(sprite->sprites[i].texture); + for (i = 0; i < sprite->sprite_count; ++i) + { + if (sprite->sprites[i].texture) + IDirect3DTexture9_Release(sprite->sprites[i].texture); + } }
sprite->sprite_count = 0; diff --git a/dlls/d3dx9_36/tests/core.c b/dlls/d3dx9_36/tests/core.c index 020f18e622c..a1947003c36 100644 --- a/dlls/d3dx9_36/tests/core.c +++ b/dlls/d3dx9_36/tests/core.c @@ -306,6 +306,19 @@ static void test_ID3DXSprite(IDirect3DDevice9 *device) hr = ID3DXSprite_End(sprite); ok (hr == D3DERR_INVALIDCALL, "End returned %#x, expected %#x\n", hr, D3DERR_INVALIDCALL);
+ /* Test D3DXSPRITE_DO_NOT_ADDREF_TEXTURE */ + hr = ID3DXSprite_Begin(sprite, D3DXSPRITE_DO_NOT_ADDREF_TEXTURE); + ok (hr == D3D_OK, "Begin returned %#x, expected %#x\n", hr, D3D_OK); + hr = ID3DXSprite_Draw(sprite, tex2, &rect, ¢er, &pos, D3DCOLOR_XRGB(255, 255, 255)); + ok (hr == D3D_OK, "Draw returned %#x, expected %#x\n", hr, D3D_OK); + hr = ID3DXSprite_OnResetDevice(sprite); + ok (hr == D3D_OK, "OnResetDevice returned %#x, expected %#x\n", hr, D3D_OK); + check_ref((IUnknown*)tex2, 1); + + hr = ID3DXSprite_Begin(sprite, D3DXSPRITE_DO_NOT_ADDREF_TEXTURE); + ok (hr == D3D_OK, "Begin returned %#x, expected %#x\n", hr, D3D_OK); + hr = ID3DXSprite_Draw(sprite, tex2, &rect, ¢er, &pos, D3DCOLOR_XRGB(255, 255, 255)); + IDirect3DDevice9_EndScene(device); check_release((IUnknown*)sprite, 0); check_release((IUnknown*)tex2, 0);
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=49376 Signed-off-by: Sven Baars sbaars@codeweavers.com --- dlls/d3dx9_36/font.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/dlls/d3dx9_36/font.c b/dlls/d3dx9_36/font.c index 4b909406df1..235ae11072b 100644 --- a/dlls/d3dx9_36/font.c +++ b/dlls/d3dx9_36/font.c @@ -726,7 +726,6 @@ static INT WINAPI ID3DXFontImpl_DrawTextW(ID3DXFont *iface, ID3DXSprite *sprite, { unsigned int line_len, i; GCP_RESULTSW results; - D3DXVECTOR3 pos;
string = read_line(font->hdc, string, &count, line, &line_len, width, format, &size);
@@ -756,6 +755,7 @@ static INT WINAPI ID3DXFontImpl_DrawTextW(ID3DXFont *iface, ID3DXSprite *sprite, for (i = 0; i < results.nGlyphs; ++i) { IDirect3DTexture9 *texture; + D3DXVECTOR3 pos; POINT cell_inc; RECT black_box;
@@ -766,6 +766,7 @@ static INT WINAPI ID3DXFontImpl_DrawTextW(ID3DXFont *iface, ID3DXSprite *sprite,
pos.x = cell_inc.x + x + results.lpCaretPos[i]; pos.y = cell_inc.y + y; + pos.z = 0;
ID3DXSprite_Draw(target, texture, &black_box, NULL, &pos, color); IDirect3DTexture9_Release(texture);
Signed-off-by: Matteo Bruni mbruni@codeweavers.com
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=49546 Signed-off-by: Sven Baars sbaars@codeweavers.com --- dlls/d3dx9_36/font.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-)
diff --git a/dlls/d3dx9_36/font.c b/dlls/d3dx9_36/font.c index 235ae11072b..f5775384da3 100644 --- a/dlls/d3dx9_36/font.c +++ b/dlls/d3dx9_36/font.c @@ -583,7 +583,6 @@ static const WCHAR *read_line(HDC hdc, const WCHAR *str, unsigned int *count, } else if (format & DT_SINGLELINE) { - *dest_len = num_fit; *count = 0; } } @@ -768,6 +767,21 @@ static INT WINAPI ID3DXFontImpl_DrawTextW(ID3DXFont *iface, ID3DXSprite *sprite, pos.y = cell_inc.y + y; pos.z = 0;
+ if (!(format & DT_NOCLIP)) + { + if (pos.x > rect->right) + { + IDirect3DTexture9_Release(texture); + continue; + } + + if (pos.x + black_box.right - black_box.left > rect->right) + black_box.right = black_box.left + rect->right - pos.x; + + if (pos.y + black_box.bottom - black_box.top > rect->bottom) + black_box.bottom = black_box.top + rect->bottom - pos.y; + } + ID3DXSprite_Draw(target, texture, &black_box, NULL, &pos, color); IDirect3DTexture9_Release(texture); }
On Tue, Nov 17, 2020 at 3:34 PM Sven Baars sbaars@codeweavers.com wrote:
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=49546 Signed-off-by: Sven Baars sbaars@codeweavers.com
dlls/d3dx9_36/font.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-)
diff --git a/dlls/d3dx9_36/font.c b/dlls/d3dx9_36/font.c index 235ae11072b..f5775384da3 100644 --- a/dlls/d3dx9_36/font.c +++ b/dlls/d3dx9_36/font.c @@ -583,7 +583,6 @@ static const WCHAR *read_line(HDC hdc, const WCHAR *str, unsigned int *count, } else if (format & DT_SINGLELINE) {
}*dest_len = num_fit; *count = 0; }
IIUC this is to allow drawing partial glyphs in the DT_SINGLELINE case, is that right?
@@ -768,6 +767,21 @@ static INT WINAPI ID3DXFontImpl_DrawTextW(ID3DXFont *iface, ID3DXSprite *sprite, pos.y = cell_inc.y + y; pos.z = 0;
if (!(format & DT_NOCLIP))
{
if (pos.x > rect->right)
{
IDirect3DTexture9_Release(texture);
continue;
}
if (pos.x + black_box.right - black_box.left > rect->right)
black_box.right = black_box.left + rect->right - pos.x;
if (pos.y + black_box.bottom - black_box.top > rect->bottom)
black_box.bottom = black_box.top + rect->bottom - pos.y;
}
ID3DXSprite_Draw(target, texture, &black_box, NULL, &pos, color); IDirect3DTexture9_Release(texture); }
This certainly looks correct. I'm curious how this fixes bug 49546 though. I'm not questioning that it does, just wondering how not clipping to the rect makes the text disappear altogether...
On 18-11-2020 13:23, Matteo Bruni wrote:
On Tue, Nov 17, 2020 at 3:34 PM Sven Baars sbaars@codeweavers.com wrote:
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=49546 Signed-off-by: Sven Baars sbaars@codeweavers.com
dlls/d3dx9_36/font.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-)
diff --git a/dlls/d3dx9_36/font.c b/dlls/d3dx9_36/font.c index 235ae11072b..f5775384da3 100644 --- a/dlls/d3dx9_36/font.c +++ b/dlls/d3dx9_36/font.c @@ -583,7 +583,6 @@ static const WCHAR *read_line(HDC hdc, const WCHAR *str, unsigned int *count, } else if (format & DT_SINGLELINE) {
}*dest_len = num_fit; *count = 0; }
IIUC this is to allow drawing partial glyphs in the DT_SINGLELINE case, is that right?
That is true.
@@ -768,6 +767,21 @@ static INT WINAPI ID3DXFontImpl_DrawTextW(ID3DXFont *iface, ID3DXSprite *sprite, pos.y = cell_inc.y + y; pos.z = 0;
if (!(format & DT_NOCLIP))
{
if (pos.x > rect->right)
{
IDirect3DTexture9_Release(texture);
continue;
}
if (pos.x + black_box.right - black_box.left > rect->right)
black_box.right = black_box.left + rect->right - pos.x;
if (pos.y + black_box.bottom - black_box.top > rect->bottom)
black_box.bottom = black_box.top + rect->bottom - pos.y;
}
ID3DXSprite_Draw(target, texture, &black_box, NULL, &pos, color); IDirect3DTexture9_Release(texture); }
This certainly looks correct. I'm curious how this fixes bug 49546 though. I'm not questioning that it does, just wondering how not clipping to the rect makes the text disappear altogether...
Because it passes DT_SINGLELINE | DT_NOCLIP with a 0x0 rect. This means that previously the number of characters that fit was 0. Now we don't set dest_len anymore, so we actually draw something.
Signed-off-by: Matteo Bruni mbruni@codeweavers.com
Signed-off-by: Sven Baars sbaars@codeweavers.com --- dlls/d3dx9_36/font.c | 21 +++++++-------------- 1 file changed, 7 insertions(+), 14 deletions(-)
diff --git a/dlls/d3dx9_36/font.c b/dlls/d3dx9_36/font.c index f5775384da3..13cffe4c514 100644 --- a/dlls/d3dx9_36/font.c +++ b/dlls/d3dx9_36/font.c @@ -512,7 +512,7 @@ static INT WINAPI ID3DXFontImpl_DrawTextA(ID3DXFont *iface, ID3DXSprite *sprite, }
static void word_break(HDC hdc, const WCHAR *str, unsigned int *str_len, - unsigned int chars_fit, unsigned int *chars_used, DWORD format, SIZE *size) + unsigned int chars_fit, unsigned int *chars_used, SIZE *size) { SCRIPT_LOGATTR *sla; SCRIPT_ANALYSIS sa; @@ -535,7 +535,7 @@ static void word_break(HDC hdc, const WCHAR *str, unsigned int *str_len, --i;
/* If the there is no word that fits put in all characters that do fit */ - if (!sla[i].fSoftBreak || (format & DT_SINGLELINE)) + if (!sla[i].fSoftBreak) i = chars_fit;
*chars_used = i; @@ -571,20 +571,13 @@ static const WCHAR *read_line(HDC hdc, const WCHAR *str, unsigned int *count, num_fit = 0; GetTextExtentExPointW(hdc, dest, *dest_len, width, &num_fit, NULL, size);
- if (num_fit < *dest_len) + if (num_fit < *dest_len && (format & DT_WORDBREAK)) { - if (format & DT_WORDBREAK) - { - unsigned int chars_used; + unsigned int chars_used;
- word_break(hdc, dest, dest_len, num_fit, &chars_used, format, size); - *count = orig_count - chars_used; - i = chars_used; - } - else if (format & DT_SINGLELINE) - { - *count = 0; - } + word_break(hdc, dest, dest_len, num_fit, &chars_used, size); + *count = orig_count - chars_used; + i = chars_used; }
if (*count && str[i] == '\n')
Signed-off-by: Matteo Bruni mbruni@codeweavers.com