winehq.org
Sign In
Sign Up
Sign In
Sign Up
Manage this list
×
Keyboard Shortcuts
Thread View
j
: Next unread message
k
: Previous unread message
j a
: Jump to all threads
j l
: Jump to MailingList overview
2025
July
June
May
April
March
February
January
2024
December
November
October
September
August
July
June
May
April
March
February
January
2023
December
November
October
September
August
July
June
May
April
March
February
January
2022
December
November
October
September
August
July
June
May
April
March
February
January
2021
December
November
October
September
August
July
June
May
April
March
February
January
2020
December
November
October
September
August
July
June
May
April
March
February
January
2019
December
November
October
September
August
July
June
May
April
March
February
January
2018
December
November
October
September
August
July
June
May
April
March
February
January
2017
December
November
October
September
August
July
June
May
April
March
February
January
2016
December
November
October
September
August
July
June
May
April
March
February
January
2015
December
November
October
September
August
July
June
May
April
March
February
January
2014
December
November
October
September
August
July
June
May
April
March
February
January
2013
December
November
October
September
August
July
June
May
April
March
February
January
2012
December
November
October
September
August
July
June
May
April
March
February
January
2011
December
November
October
September
August
July
June
May
April
March
February
January
2010
December
November
October
September
August
July
June
May
April
March
February
January
2009
December
November
October
September
August
July
June
May
April
March
February
January
2008
December
November
October
September
August
July
June
May
April
March
February
January
2007
December
November
October
September
August
July
June
May
April
March
February
January
2006
December
November
October
September
August
July
June
May
April
March
February
January
2005
December
November
October
September
August
July
June
May
April
March
February
January
2004
December
November
October
September
August
July
June
May
April
March
February
January
2003
December
November
October
September
August
July
June
May
April
March
February
January
2002
December
November
October
September
August
July
June
May
April
March
February
January
2001
December
November
October
September
August
July
June
May
April
March
February
List overview
wine-commits
March 2021
----- 2025 -----
July 2025
June 2025
May 2025
April 2025
March 2025
February 2025
January 2025
----- 2024 -----
December 2024
November 2024
October 2024
September 2024
August 2024
July 2024
June 2024
May 2024
April 2024
March 2024
February 2024
January 2024
----- 2023 -----
December 2023
November 2023
October 2023
September 2023
August 2023
July 2023
June 2023
May 2023
April 2023
March 2023
February 2023
January 2023
----- 2022 -----
December 2022
November 2022
October 2022
September 2022
August 2022
July 2022
June 2022
May 2022
April 2022
March 2022
February 2022
January 2022
----- 2021 -----
December 2021
November 2021
October 2021
September 2021
August 2021
July 2021
June 2021
May 2021
April 2021
March 2021
February 2021
January 2021
----- 2020 -----
December 2020
November 2020
October 2020
September 2020
August 2020
July 2020
June 2020
May 2020
April 2020
March 2020
February 2020
January 2020
----- 2019 -----
December 2019
November 2019
October 2019
September 2019
August 2019
July 2019
June 2019
May 2019
April 2019
March 2019
February 2019
January 2019
----- 2018 -----
December 2018
November 2018
October 2018
September 2018
August 2018
July 2018
June 2018
May 2018
April 2018
March 2018
February 2018
January 2018
----- 2017 -----
December 2017
November 2017
October 2017
September 2017
August 2017
July 2017
June 2017
May 2017
April 2017
March 2017
February 2017
January 2017
----- 2016 -----
December 2016
November 2016
October 2016
September 2016
August 2016
July 2016
June 2016
May 2016
April 2016
March 2016
February 2016
January 2016
----- 2015 -----
December 2015
November 2015
October 2015
September 2015
August 2015
July 2015
June 2015
May 2015
April 2015
March 2015
February 2015
January 2015
----- 2014 -----
December 2014
November 2014
October 2014
September 2014
August 2014
July 2014
June 2014
May 2014
April 2014
March 2014
February 2014
January 2014
----- 2013 -----
December 2013
November 2013
October 2013
September 2013
August 2013
July 2013
June 2013
May 2013
April 2013
March 2013
February 2013
January 2013
----- 2012 -----
December 2012
November 2012
October 2012
September 2012
August 2012
July 2012
June 2012
May 2012
April 2012
March 2012
February 2012
January 2012
----- 2011 -----
December 2011
November 2011
October 2011
September 2011
August 2011
July 2011
June 2011
May 2011
April 2011
March 2011
February 2011
January 2011
----- 2010 -----
December 2010
November 2010
October 2010
September 2010
August 2010
July 2010
June 2010
May 2010
April 2010
March 2010
February 2010
January 2010
----- 2009 -----
December 2009
November 2009
October 2009
September 2009
August 2009
July 2009
June 2009
May 2009
April 2009
March 2009
February 2009
January 2009
----- 2008 -----
December 2008
November 2008
October 2008
September 2008
August 2008
July 2008
June 2008
May 2008
April 2008
March 2008
February 2008
January 2008
----- 2007 -----
December 2007
November 2007
October 2007
September 2007
August 2007
July 2007
June 2007
May 2007
April 2007
March 2007
February 2007
January 2007
----- 2006 -----
December 2006
November 2006
October 2006
September 2006
August 2006
July 2006
June 2006
May 2006
April 2006
March 2006
February 2006
January 2006
----- 2005 -----
December 2005
November 2005
October 2005
September 2005
August 2005
July 2005
June 2005
May 2005
April 2005
March 2005
February 2005
January 2005
----- 2004 -----
December 2004
November 2004
October 2004
September 2004
August 2004
July 2004
June 2004
May 2004
April 2004
March 2004
February 2004
January 2004
----- 2003 -----
December 2003
November 2003
October 2003
September 2003
August 2003
July 2003
June 2003
May 2003
April 2003
March 2003
February 2003
January 2003
----- 2002 -----
December 2002
November 2002
October 2002
September 2002
August 2002
July 2002
June 2002
May 2002
April 2002
March 2002
February 2002
January 2002
----- 2001 -----
December 2001
November 2001
October 2001
September 2001
August 2001
July 2001
June 2001
May 2001
April 2001
March 2001
February 2001
wine-commits@winehq.org
2 participants
1163 discussions
Start a n
N
ew thread
Nikolay Sivov : dwrite: Use ntdll exports for freetype mutex.
by Alexandre Julliard
29 Mar '21
29 Mar '21
Module: wine Branch: master Commit: aab6ebb73444688175b14c3ec128d554e2092086 URL:
https://source.winehq.org/git/wine.git/?a=commit;h=aab6ebb73444688175b14c3e…
Author: Nikolay Sivov <nsivov(a)codeweavers.com> Date: Mon Mar 29 10:48:55 2021 +0300 dwrite: Use ntdll exports for freetype mutex. Signed-off-by: Nikolay Sivov <nsivov(a)codeweavers.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- dlls/dwrite/freetype.c | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/dlls/dwrite/freetype.c b/dlls/dwrite/freetype.c index 21e2b9d0320..efa0f24d96c 100644 --- a/dlls/dwrite/freetype.c +++ b/dlls/dwrite/freetype.c @@ -42,14 +42,14 @@ WINE_DEFAULT_DEBUG_CHANNEL(dwrite); -static CRITICAL_SECTION freetype_cs; -static CRITICAL_SECTION_DEBUG critsect_debug = +static RTL_CRITICAL_SECTION freetype_cs; +static RTL_CRITICAL_SECTION_DEBUG critsect_debug = { 0, 0, &freetype_cs, { &critsect_debug.ProcessLocksList, &critsect_debug.ProcessLocksList }, 0, 0, { (DWORD_PTR)(__FILE__ ": freetype_cs") } }; -static CRITICAL_SECTION freetype_cs = { &critsect_debug, -1, 0, 0, 0, 0 }; +static RTL_CRITICAL_SECTION freetype_cs = { &critsect_debug, -1, 0, 0, 0, 0 }; static void *ft_handle = NULL; static FT_Library library = 0; @@ -209,9 +209,9 @@ sym_not_found: static void CDECL freetype_notify_release(void *key) { - EnterCriticalSection(&freetype_cs); + RtlEnterCriticalSection(&freetype_cs); pFTC_Manager_RemoveFaceID(cache_manager, key); - LeaveCriticalSection(&freetype_cs); + RtlLeaveCriticalSection(&freetype_cs); } static void CDECL freetype_get_design_glyph_metrics(void *key, UINT16 upem, UINT16 ascent, @@ -227,7 +227,7 @@ static void CDECL freetype_get_design_glyph_metrics(void *key, UINT16 upem, UINT scaler.x_res = 0; scaler.y_res = 0; - EnterCriticalSection(&freetype_cs); + RtlEnterCriticalSection(&freetype_cs); if (pFTC_Manager_LookupSize(cache_manager, &scaler, &size) == 0) { if (pFT_Load_Glyph(size->face, glyph, FT_LOAD_NO_SCALE) == 0) { FT_Glyph_Metrics *metrics = &size->face->glyph->metrics; @@ -250,7 +250,7 @@ static void CDECL freetype_get_design_glyph_metrics(void *key, UINT16 upem, UINT } } } - LeaveCriticalSection(&freetype_cs); + RtlLeaveCriticalSection(&freetype_cs); } struct decompose_context @@ -450,7 +450,7 @@ static int CDECL freetype_get_glyph_outline(void *key, float emSize, unsigned in scaler.x_res = 0; scaler.y_res = 0; - EnterCriticalSection(&freetype_cs); + RtlEnterCriticalSection(&freetype_cs); if (!(ret = pFTC_Manager_LookupSize(cache_manager, &scaler, &size))) { if (pFT_Load_Glyph(size->face, glyph, FT_LOAD_NO_BITMAP) == 0) @@ -471,7 +471,7 @@ static int CDECL freetype_get_glyph_outline(void *key, float emSize, unsigned in ret = decompose_outline(ft_outline, outline); } } - LeaveCriticalSection(&freetype_cs); + RtlLeaveCriticalSection(&freetype_cs); return ret; } @@ -481,10 +481,10 @@ static UINT16 CDECL freetype_get_glyph_count(void *key) UINT16 count = 0; FT_Face face; - EnterCriticalSection(&freetype_cs); + RtlEnterCriticalSection(&freetype_cs); if (pFTC_Manager_LookupFace(cache_manager, key, &face) == 0) count = face->num_glyphs; - LeaveCriticalSection(&freetype_cs); + RtlLeaveCriticalSection(&freetype_cs); return count; } @@ -545,7 +545,7 @@ static void CDECL freetype_get_glyph_bbox(struct dwrite_glyphbitmap *bitmap) FT_Glyph glyph; FT_Matrix m; - EnterCriticalSection(&freetype_cs); + RtlEnterCriticalSection(&freetype_cs); needs_transform = get_glyph_transform(bitmap, &m); @@ -572,7 +572,7 @@ static void CDECL freetype_get_glyph_bbox(struct dwrite_glyphbitmap *bitmap) pFT_Glyph_Get_CBox(glyph, FT_GLYPH_BBOX_PIXELS, &bbox); } - LeaveCriticalSection(&freetype_cs); + RtlLeaveCriticalSection(&freetype_cs); /* flip Y axis */ SetRect(&bitmap->bbox, bbox.xMin, -bbox.yMax, bbox.xMax, -bbox.yMin); @@ -677,7 +677,7 @@ static BOOL CDECL freetype_get_glyph_bitmap(struct dwrite_glyphbitmap *bitmap) FT_Glyph glyph; FT_Matrix m; - EnterCriticalSection(&freetype_cs); + RtlEnterCriticalSection(&freetype_cs); needs_transform = get_glyph_transform(bitmap, &m); @@ -711,7 +711,7 @@ static BOOL CDECL freetype_get_glyph_bitmap(struct dwrite_glyphbitmap *bitmap) pFT_Done_Glyph(glyph_copy); } - LeaveCriticalSection(&freetype_cs); + RtlLeaveCriticalSection(&freetype_cs); return ret; } @@ -730,7 +730,7 @@ static INT32 CDECL freetype_get_glyph_advance(void *key, float emSize, UINT16 in if (mode == DWRITE_MEASURING_MODE_NATURAL) imagetype.flags |= FT_LOAD_NO_HINTING; - EnterCriticalSection(&freetype_cs); + RtlEnterCriticalSection(&freetype_cs); if (pFTC_ImageCache_Lookup(image_cache, &imagetype, index, &glyph, NULL) == 0) { *has_contours = glyph->format == FT_GLYPH_FORMAT_OUTLINE && ((FT_OutlineGlyph)glyph)->outline.n_contours; advance = glyph->advance.x >> 16; @@ -739,7 +739,7 @@ static INT32 CDECL freetype_get_glyph_advance(void *key, float emSize, UINT16 in *has_contours = FALSE; advance = 0; } - LeaveCriticalSection(&freetype_cs); + RtlLeaveCriticalSection(&freetype_cs); return advance; }
1
0
0
0
Nikolay Sivov : dwrite: Pass simulation mask when getting a glyph outline.
by Alexandre Julliard
29 Mar '21
29 Mar '21
Module: wine Branch: master Commit: 3bb778a6379fb80beafefb304aa5f1037cf0a4d2 URL:
https://source.winehq.org/git/wine.git/?a=commit;h=3bb778a6379fb80beafefb30…
Author: Nikolay Sivov <nsivov(a)codeweavers.com> Date: Mon Mar 29 10:48:54 2021 +0300 dwrite: Pass simulation mask when getting a glyph outline. Signed-off-by: Nikolay Sivov <nsivov(a)codeweavers.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- dlls/dwrite/dwrite_private.h | 3 ++- dlls/dwrite/font.c | 3 ++- dlls/dwrite/freetype.c | 12 +++++------- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/dlls/dwrite/dwrite_private.h b/dlls/dwrite/dwrite_private.h index e748535ddff..8536e3c6a36 100644 --- a/dlls/dwrite/dwrite_private.h +++ b/dlls/dwrite/dwrite_private.h @@ -732,7 +732,8 @@ struct font_callback_funcs struct font_backend_funcs { void (CDECL *notify_release)(void *key); - int (CDECL *get_glyph_outline)(void *key, float em_size, UINT16 glyph, struct dwrite_outline *outline); + int (CDECL *get_glyph_outline)(void *key, float em_size, unsigned int simulations, UINT16 glyph, + struct dwrite_outline *outline); UINT16 (CDECL *get_glyph_count)(void *key); INT32 (CDECL *get_glyph_advance)(void *key, float em_size, UINT16 index, DWRITE_MEASURING_MODE measuring_mode, BOOL *has_contours); diff --git a/dlls/dwrite/font.c b/dlls/dwrite/font.c index 24110db1197..57c64e4622d 100644 --- a/dlls/dwrite/font.c +++ b/dlls/dwrite/font.c @@ -870,6 +870,7 @@ static HRESULT WINAPI dwritefontface_GetGlyphRunOutline(IDWriteFontFace5 *iface, UINT16 const *glyphs, FLOAT const* advances, DWRITE_GLYPH_OFFSET const *offsets, UINT32 count, BOOL is_sideways, BOOL is_rtl, IDWriteGeometrySink *sink) { + struct dwrite_fontface *fontface = impl_from_IDWriteFontFace5(iface); D2D1_POINT_2F *origins, baseline_origin = { 0 }; struct dwrite_outline outline = {{ 0 }}; D2D1_BEZIER_SEGMENT segment; @@ -910,7 +911,7 @@ static HRESULT WINAPI dwritefontface_GetGlyphRunOutline(IDWriteFontFace5 *iface, for (i = 0; i < count; ++i) { outline.tags.count = outline.points.count = 0; - if (font_funcs->get_glyph_outline(iface, emSize, glyphs[i], &outline)) + if (font_funcs->get_glyph_outline(iface, emSize, fontface->simulations, glyphs[i], &outline)) { WARN("Failed to get glyph outline for glyph %u.\n", glyphs[i]); continue; diff --git a/dlls/dwrite/freetype.c b/dlls/dwrite/freetype.c index 581d6eab802..21e2b9d0320 100644 --- a/dlls/dwrite/freetype.c +++ b/dlls/dwrite/freetype.c @@ -436,17 +436,14 @@ static void embolden_glyph(FT_Glyph glyph, FLOAT emsize) embolden_glyph_outline(&outline_glyph->outline, emsize); } -static int CDECL freetype_get_glyph_outline(void *key, float emSize, UINT16 glyph, struct dwrite_outline *outline) +static int CDECL freetype_get_glyph_outline(void *key, float emSize, unsigned int simulations, + UINT16 glyph, struct dwrite_outline *outline) { - IDWriteFontFace5 *fontface = key; FTC_ScalerRec scaler; - USHORT simulations; FT_Size size; int ret; - simulations = IDWriteFontFace5_GetSimulations(fontface); - - scaler.face_id = fontface; + scaler.face_id = key; scaler.width = emSize; scaler.height = emSize; scaler.pixel = 1; @@ -779,7 +776,8 @@ static void CDECL null_notify_release(void *key) { } -static int CDECL null_get_glyph_outline(void *key, float emSize, UINT16 glyph, struct dwrite_outline *outline) +static int CDECL null_get_glyph_outline(void *key, float emSize, unsigned int simulations, + UINT16 glyph, struct dwrite_outline *outline) { return 1; }
1
0
0
0
Nikolay Sivov : dwrite: Introduce interface to font backend.
by Alexandre Julliard
29 Mar '21
29 Mar '21
Module: wine Branch: master Commit: ca08a5e722517aed42474773b4a128e30d9eeb17 URL:
https://source.winehq.org/git/wine.git/?a=commit;h=ca08a5e722517aed42474773…
Author: Nikolay Sivov <nsivov(a)codeweavers.com> Date: Mon Mar 29 10:48:53 2021 +0300 dwrite: Introduce interface to font backend. Signed-off-by: Nikolay Sivov <nsivov(a)codeweavers.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- dlls/dwrite/dwrite_private.h | 30 +++++++------ dlls/dwrite/font.c | 37 ++++++++++------ dlls/dwrite/freetype.c | 100 ++++++++++++++++++++++++++----------------- dlls/dwrite/layout.c | 4 +- 4 files changed, 102 insertions(+), 69 deletions(-) Diff:
https://source.winehq.org/git/wine.git/?a=commitdiff;h=ca08a5e722517aed4247…
1
0
0
0
Nikolay Sivov : dwrite: Use FT_MulDiv() in freetype integration.
by Alexandre Julliard
29 Mar '21
29 Mar '21
Module: wine Branch: master Commit: d77110a40c570488b5edfc802d210cfa5959811b URL:
https://source.winehq.org/git/wine.git/?a=commit;h=d77110a40c570488b5edfc80…
Author: Nikolay Sivov <nsivov(a)codeweavers.com> Date: Mon Mar 29 10:48:52 2021 +0300 dwrite: Use FT_MulDiv() in freetype integration. Signed-off-by: Nikolay Sivov <nsivov(a)codeweavers.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- dlls/dwrite/freetype.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/dlls/dwrite/freetype.c b/dlls/dwrite/freetype.c index c4bbbd4624c..675d1cf0672 100644 --- a/dlls/dwrite/freetype.c +++ b/dlls/dwrite/freetype.c @@ -77,6 +77,7 @@ MAKE_FUNCPTR(FT_Init_FreeType); MAKE_FUNCPTR(FT_Library_Version); MAKE_FUNCPTR(FT_Load_Glyph); MAKE_FUNCPTR(FT_Matrix_Multiply); +MAKE_FUNCPTR(FT_MulDiv); MAKE_FUNCPTR(FT_New_Memory_Face); MAKE_FUNCPTR(FT_Outline_Copy); MAKE_FUNCPTR(FT_Outline_Decompose); @@ -156,6 +157,7 @@ static BOOL init_freetype(void) LOAD_FUNCPTR(FT_Library_Version) LOAD_FUNCPTR(FT_Load_Glyph) LOAD_FUNCPTR(FT_Matrix_Multiply) + LOAD_FUNCPTR(FT_MulDiv) LOAD_FUNCPTR(FT_New_Memory_Face) LOAD_FUNCPTR(FT_Outline_Copy) LOAD_FUNCPTR(FT_Outline_Decompose) @@ -418,7 +420,7 @@ static void embolden_glyph_outline(FT_Outline *outline, FLOAT emsize) { FT_Pos strength; - strength = MulDiv(emsize, 1 << 6, 24); + strength = pFT_MulDiv(emsize, 1 << 6, 24); if (pFT_Outline_EmboldenXY) pFT_Outline_EmboldenXY(outline, strength, 0); else
1
0
0
0
Nikolay Sivov : dwrite: Introduce callback interface to initialize freetype face objects.
by Alexandre Julliard
29 Mar '21
29 Mar '21
Module: wine Branch: master Commit: f3d777ba7dd9ca662c984bfd7e3a90fddb30e311 URL:
https://source.winehq.org/git/wine.git/?a=commit;h=f3d777ba7dd9ca662c984bfd…
Author: Nikolay Sivov <nsivov(a)codeweavers.com> Date: Mon Mar 29 10:48:51 2021 +0300 dwrite: Introduce callback interface to initialize freetype face objects. Signed-off-by: Nikolay Sivov <nsivov(a)codeweavers.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- dlls/dwrite/dwrite_private.h | 17 +++++-- dlls/dwrite/font.c | 79 +++++++++++++++++++++++++++++++ dlls/dwrite/freetype.c | 108 ++++++++++++++++++------------------------- dlls/dwrite/main.c | 6 ++- 4 files changed, 141 insertions(+), 69 deletions(-) diff --git a/dlls/dwrite/dwrite_private.h b/dlls/dwrite/dwrite_private.h index 47be661555c..5e41455f66d 100644 --- a/dlls/dwrite/dwrite_private.h +++ b/dlls/dwrite/dwrite_private.h @@ -486,9 +486,6 @@ extern int dwrite_outline_push_tag(struct dwrite_outline *outline, unsigned char extern int dwrite_outline_push_points(struct dwrite_outline *outline, const D2D1_POINT_2F *points, unsigned int count) DECLSPEC_HIDDEN; -extern BOOL init_freetype(void) DECLSPEC_HIDDEN; -extern void release_freetype(void) DECLSPEC_HIDDEN; - extern HRESULT freetype_get_design_glyph_metrics(struct dwrite_fontface *fontface, UINT16 glyph, DWRITE_GLYPH_METRICS *metrics) DECLSPEC_HIDDEN; extern void freetype_notify_cacheremove(IDWriteFontFace5 *fontface) DECLSPEC_HIDDEN; @@ -734,3 +731,17 @@ extern HRESULT shape_get_typographic_features(struct scriptshaping_context *cont unsigned int max_tagcount, unsigned int *actual_tagcount, unsigned int *tags) DECLSPEC_HIDDEN; extern HRESULT shape_check_typographic_feature(struct scriptshaping_context *context, const unsigned int *scripts, unsigned int tag, unsigned int glyph_count, const UINT16 *glyphs, UINT8 *feature_applies) DECLSPEC_HIDDEN; + +struct font_data_context; +extern HMODULE dwrite_module DECLSPEC_HIDDEN; + +struct font_callback_funcs +{ + int (CDECL *get_font_data)(void *key, const void **data_ptr, UINT64 *data_size, unsigned int *index, + struct font_data_context **context); + void (CDECL *release_font_data)(struct font_data_context *context); +}; + +extern NTSTATUS CDECL init_font_lib(HMODULE module, DWORD reason, const void *ptr_in, void *ptr_out) DECLSPEC_HIDDEN; +extern void init_font_backend(void) DECLSPEC_HIDDEN; +extern void release_font_backend(void) DECLSPEC_HIDDEN; diff --git a/dlls/dwrite/font.c b/dlls/dwrite/font.c index 245a59d5f54..ca7ce8ca53a 100644 --- a/dlls/dwrite/font.c +++ b/dlls/dwrite/font.c @@ -7958,3 +7958,82 @@ HRESULT create_fontset_builder(IDWriteFactory7 *factory, IDWriteFontSetBuilder2 return S_OK; } + +struct font_data_context +{ + IDWriteFontFileStream *stream; + void *context; +}; + +static int CDECL get_font_data_cb(void *key, const void **data_ptr, UINT64 *data_size, + unsigned int *index, struct font_data_context **ret_context) +{ + IDWriteFontFace *fontface = key; + struct font_data_context *context; + IDWriteFontFileStream *stream; + IDWriteFontFile *file; + unsigned int count; + void *data_context; + HRESULT hr; + + *ret_context = NULL; + + count = 1; + if (FAILED(IDWriteFontFace_GetFiles(fontface, &count, &file))) return 1; + + hr = get_filestream_from_file(file, &stream); + IDWriteFontFile_Release(file); + if (FAILED(hr)) return 1; + + hr = IDWriteFontFileStream_GetFileSize(stream, data_size); + if (FAILED(hr)) + { + IDWriteFontFileStream_Release(stream); + return 1; + } + + hr = IDWriteFontFileStream_ReadFileFragment(stream, data_ptr, 0, *data_size, &data_context); + if (FAILED(hr)) + { + IDWriteFontFileStream_Release(stream); + return 1; + } + + if (!(context = heap_alloc(sizeof(*context)))) + { + IDWriteFontFileStream_Release(stream); + return 1; + } + + context->stream = stream; + context->context = data_context; + + *ret_context = context; + *index = IDWriteFontFace_GetIndex(fontface); + + return 0; +} + +static void CDECL release_font_data_cb(struct font_data_context *context) +{ + if (!context) return; + IDWriteFontFileStream_ReleaseFileFragment(context->stream, context->context); + IDWriteFontFileStream_Release(context->stream); + heap_free(context); +} + +struct font_callback_funcs callback_funcs = +{ + get_font_data_cb, + release_font_data_cb, +}; + +void init_font_backend(void) +{ + init_font_lib(dwrite_module, DLL_PROCESS_ATTACH, &callback_funcs, NULL); +} + +void release_font_backend(void) +{ + init_font_lib(dwrite_module, DLL_PROCESS_DETACH, &callback_funcs, NULL); +} diff --git a/dlls/dwrite/freetype.c b/dlls/dwrite/freetype.c index 9e4001d11c2..c4bbbd4624c 100644 --- a/dlls/dwrite/freetype.c +++ b/dlls/dwrite/freetype.c @@ -31,6 +31,8 @@ #include FT_TRUETYPE_TABLES_H #endif /* HAVE_FT2BUILD_H */ +#include "ntstatus.h" +#define WIN32_NO_STATUS #include "windef.h" #include "wine/debug.h" @@ -60,6 +62,8 @@ typedef struct FT_Int patch; } FT_Version_t; +static const struct font_callback_funcs *callback_funcs; + #define MAKE_FUNCPTR(f) static typeof(f) * p##f = NULL MAKE_FUNCPTR(FT_Done_FreeType); MAKE_FUNCPTR(FT_Done_Glyph); @@ -92,86 +96,44 @@ MAKE_FUNCPTR(FTC_Manager_RemoveFaceID); #undef MAKE_FUNCPTR static FT_Error (*pFT_Outline_EmboldenXY)(FT_Outline *, FT_Pos, FT_Pos); -struct face_finalizer_data -{ - IDWriteFontFileStream *stream; - void *context; -}; - static void face_finalizer(void *object) { FT_Face face = object; - struct face_finalizer_data *data = (struct face_finalizer_data *)face->generic.data; - - IDWriteFontFileStream_ReleaseFileFragment(data->stream, data->context); - IDWriteFontFileStream_Release(data->stream); - heap_free(data); + callback_funcs->release_font_data((struct font_data_context *)face->generic.data); } static FT_Error face_requester(FTC_FaceID face_id, FT_Library library, FT_Pointer request_data, FT_Face *face) { - IDWriteFontFace *fontface = (IDWriteFontFace*)face_id; - IDWriteFontFileStream *stream; - IDWriteFontFile *file; + struct font_data_context *context; const void *data_ptr; - UINT32 index, count; FT_Error fterror; UINT64 data_size; - void *context; - HRESULT hr; + UINT32 index; *face = NULL; - if (!fontface) { + if (!face_id) + { WARN("NULL fontface requested.\n"); return FT_Err_Ok; } - count = 1; - hr = IDWriteFontFace_GetFiles(fontface, &count, &file); - if (FAILED(hr)) - return FT_Err_Ok; - - hr = get_filestream_from_file(file, &stream); - IDWriteFontFile_Release(file); - if (FAILED(hr)) + if (callback_funcs->get_font_data(face_id, &data_ptr, &data_size, &index, &context)) return FT_Err_Ok; - hr = IDWriteFontFileStream_GetFileSize(stream, &data_size); - if (FAILED(hr)) { - fterror = FT_Err_Invalid_Stream_Read; - goto fail; - } - - hr = IDWriteFontFileStream_ReadFileFragment(stream, &data_ptr, 0, data_size, &context); - if (FAILED(hr)) { - fterror = FT_Err_Invalid_Stream_Read; - goto fail; - } - - index = IDWriteFontFace_GetIndex(fontface); fterror = pFT_New_Memory_Face(library, data_ptr, data_size, index, face); - if (fterror == FT_Err_Ok) { - struct face_finalizer_data *data; - - data = heap_alloc(sizeof(*data)); - data->stream = stream; - data->context = context; - - (*face)->generic.data = data; + if (fterror == FT_Err_Ok) + { + (*face)->generic.data = context; (*face)->generic.finalizer = face_finalizer; - return fterror; } else - IDWriteFontFileStream_ReleaseFileFragment(stream, context); - -fail: - IDWriteFontFileStream_Release(stream); + callback_funcs->release_font_data(context); return fterror; } -BOOL init_freetype(void) +static BOOL init_freetype(void) { FT_Version_t FT_Version; @@ -243,12 +205,6 @@ sym_not_found: return FALSE; } -void release_freetype(void) -{ - pFTC_Manager_Done(cache_manager); - pFT_Done_FreeType(library); -} - void freetype_notify_cacheremove(IDWriteFontFace5 *fontface) { EnterCriticalSection(&freetype_cs); @@ -790,17 +746,22 @@ INT32 freetype_get_glyph_advance(IDWriteFontFace5 *fontface, FLOAT emSize, UINT1 return advance; } -#else /* HAVE_FREETYPE */ - -BOOL init_freetype(void) +static NTSTATUS init_freetype_lib(HMODULE module, DWORD reason, const void *ptr_in, void *ptr_out) { - return FALSE; + callback_funcs = ptr_in; + if (!init_freetype()) return STATUS_DLL_NOT_FOUND; + return STATUS_SUCCESS; } -void release_freetype(void) +static NTSTATUS release_freetype_lib(void) { + pFTC_Manager_Done(cache_manager); + pFT_Done_FreeType(library); + return STATUS_SUCCESS; } +#else /* HAVE_FREETYPE */ + void freetype_notify_cacheremove(IDWriteFontFace5 *fontface) { } @@ -838,4 +799,23 @@ INT32 freetype_get_glyph_advance(IDWriteFontFace5 *fontface, FLOAT emSize, UINT1 return 0; } +static NTSTATUS init_freetype_lib(HMODULE module, DWORD reason, const void *ptr_in, void *ptr_out) +{ + return STATUS_DLL_NOT_FOUND; +} + +static NTSTATUS release_freetype_lib(void) +{ + return STATUS_DLL_NOT_FOUND; +} + #endif /* HAVE_FREETYPE */ + +NTSTATUS CDECL init_font_lib(HMODULE module, DWORD reason, const void *ptr_in, void *ptr_out) +{ + if (reason == DLL_PROCESS_ATTACH) + return init_freetype_lib(module, reason, ptr_in, ptr_out); + else if (reason == DLL_PROCESS_DETACH) + return release_freetype_lib(); + return STATUS_SUCCESS; +} diff --git a/dlls/dwrite/main.c b/dlls/dwrite/main.c index 3326b1550ce..41b81ae951b 100644 --- a/dlls/dwrite/main.c +++ b/dlls/dwrite/main.c @@ -34,6 +34,7 @@ WINE_DEFAULT_DEBUG_CHANNEL(dwrite); +HMODULE dwrite_module = 0; static IDWriteFactory7 *shared_factory; static void release_shared_factory(IDWriteFactory7 *factory); @@ -42,14 +43,15 @@ BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD reason, LPVOID reserved) switch (reason) { case DLL_PROCESS_ATTACH: + dwrite_module = hinstDLL; DisableThreadLibraryCalls( hinstDLL ); - init_freetype(); + init_font_backend(); init_local_fontfile_loader(); break; case DLL_PROCESS_DETACH: if (reserved) break; release_shared_factory(shared_factory); - release_freetype(); + release_font_backend(); } return TRUE; }
1
0
0
0
Nikolay Sivov : dwrite/tests: Add some tests for CreateFontCollectionFromFontSet().
by Alexandre Julliard
29 Mar '21
29 Mar '21
Module: wine Branch: master Commit: ff983fe75fde1b9e17f7e46269dc04b8b02305a1 URL:
https://source.winehq.org/git/wine.git/?a=commit;h=ff983fe75fde1b9e17f7e462…
Author: Nikolay Sivov <nsivov(a)codeweavers.com> Date: Mon Mar 29 10:15:17 2021 +0300 dwrite/tests: Add some tests for CreateFontCollectionFromFontSet(). Signed-off-by: Nikolay Sivov <nsivov(a)codeweavers.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- dlls/dwrite/tests/font.c | 117 +++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 113 insertions(+), 4 deletions(-) diff --git a/dlls/dwrite/tests/font.c b/dlls/dwrite/tests/font.c index 27c2a9d0b7d..54e279ea11e 100644 --- a/dlls/dwrite/tests/font.c +++ b/dlls/dwrite/tests/font.c @@ -587,6 +587,20 @@ static BOOL has_face_variations(IDWriteFontFace *fontface) return ret; } +#define check_familymodel(a,b) _check_familymodel(a,b,__LINE__) +static void _check_familymodel(void *iface_ptr, DWRITE_FONT_FAMILY_MODEL expected_model, unsigned int line) +{ + IDWriteFontCollection2 *collection; + DWRITE_FONT_FAMILY_MODEL model; + + if (SUCCEEDED(IUnknown_QueryInterface((IUnknown *)iface_ptr, &IID_IDWriteFontCollection2, (void **)&collection))) + { + model = IDWriteFontCollection2_GetFontFamilyModel(collection); + ok_(__FILE__,line)(model == expected_model, "Unexpected family model %d, expected %d.\n", model, expected_model); + IDWriteFontCollection2_Release(collection); + } +} + struct test_fontenumerator { IDWriteFontFileEnumerator IDWriteFontFileEnumerator_iface; @@ -2441,7 +2455,6 @@ static void test_system_fontcollection(void) IDWriteFontCollection2 *collection2; IDWriteFontCollection3 *collection3; IDWriteFactory *factory, *factory2; - DWRITE_FONT_FAMILY_MODEL model; IDWriteFontFileLoader *loader; IDWriteFontFamily *family; IDWriteFontFace *fontface; @@ -2621,8 +2634,7 @@ static void test_system_fontcollection(void) todo_wine ok(!!event, "Expected event handle.\n"); - model = IDWriteFontCollection3_GetFontFamilyModel(collection3); - ok(model == DWRITE_FONT_FAMILY_MODEL_WEIGHT_STRETCH_STYLE, "Unexpected model.\n"); + check_familymodel(collection3, DWRITE_FONT_FAMILY_MODEL_WEIGHT_STRETCH_STYLE); IDWriteFontCollection3_Release(collection3); } @@ -9423,8 +9435,8 @@ static void test_AnalyzeContainerType(void) static void test_fontsetbuilder(void) { IDWriteFontFaceReference *ref, *ref2, *ref3; - IDWriteFontFaceReference1 *ref1; IDWriteFontCollection1 *collection; + IDWriteFontFaceReference1 *ref1; IDWriteFontSetBuilder1 *builder1; IDWriteFontSetBuilder *builder; DWRITE_FONT_AXIS_VALUE axis_values[4]; @@ -9457,12 +9469,36 @@ static void test_fontsetbuilder(void) hr = IDWriteFontSetBuilder1_AddFontFile(builder1, file); ok(hr == S_OK, "Unexpected hr %#x.\n",hr); + hr = IDWriteFontSetBuilder1_CreateFontSet(builder1, &fontset); + ok(hr == S_OK, "Unexpected hr %#x.\n",hr); + hr = IDWriteFactory3_CreateFontCollectionFromFontSet(factory, fontset, &collection); + todo_wine + ok(hr == S_OK, "Unexpected hr %#x.\n",hr); + if (SUCCEEDED(hr)) + { + count = IDWriteFontCollection1_GetFontFamilyCount(collection); + ok(count == 1, "Unexpected family count %u.\n", count); + IDWriteFontCollection1_Release(collection); + } + IDWriteFontSet_Release(fontset); + hr = IDWriteFontSetBuilder1_AddFontFile(builder1, file); ok(hr == S_OK, "Unexpected hr %#x.\n",hr); hr = IDWriteFontSetBuilder1_CreateFontSet(builder1, &fontset); ok(hr == S_OK, "Unexpected hr %#x.\n",hr); + hr = IDWriteFactory3_CreateFontCollectionFromFontSet(factory, fontset, &collection); + todo_wine + ok(hr == S_OK, "Unexpected hr %#x.\n",hr); + if (SUCCEEDED(hr)) + { + check_familymodel(collection, DWRITE_FONT_FAMILY_MODEL_WEIGHT_STRETCH_STYLE); + count = IDWriteFontCollection1_GetFontFamilyCount(collection); + ok(count == 1, "Unexpected family count %u.\n", count); + IDWriteFontCollection1_Release(collection); + } + /* No attempt to eliminate duplicates. */ count = IDWriteFontSet_GetFontCount(fontset); ok(count == 2, "Unexpected font count %u.\n", count); @@ -10139,6 +10175,78 @@ static void test_system_font_set(void) IDWriteFactory3_Release(factory); } +static void test_CreateFontCollectionFromFontSet(void) +{ + unsigned int index, count, refcount; + IDWriteFontCollection1 *collection; + IDWriteFontSetBuilder1 *builder; + DWRITE_FONT_PROPERTY props[1]; + IDWriteFontFaceReference *ref; + IDWriteFactory5 *factory; + IDWriteFontSet *fontset; + IDWriteFontFile *file; + WCHAR *path; + BOOL exists; + HRESULT hr; + + if (!(factory = create_factory_iid(&IID_IDWriteFactory5))) + { + win_skip("_CreateFontCollectionFromFontSet() is not available.\n"); + return; + } + + hr = IDWriteFactory5_CreateFontSetBuilder(factory, &builder); + ok(hr == S_OK, "Failed to create font set builder, hr %#x.\n", hr); + + path = create_testfontfile(test_fontfile); + + hr = IDWriteFactory5_CreateFontFileReference(factory, path, NULL, &file); + ok(hr == S_OK, "Unexpected hr %#x.\n",hr); + + hr = IDWriteFontSetBuilder1_AddFontFile(builder, file); + ok(hr == S_OK, "Unexpected hr %#x.\n",hr); + + /* Add same file, with explicit properties. */ + hr = IDWriteFactory5_CreateFontFaceReference_(factory, file, 0, DWRITE_FONT_SIMULATIONS_NONE, &ref); + ok(hr == S_OK, "Unexpected hr %#x.\n",hr); + props[0].propertyId = DWRITE_FONT_PROPERTY_ID_WEIGHT_STRETCH_STYLE_FAMILY_NAME; + props[0].propertyValue = L"Another Font"; + props[0].localeName = L"en-US"; + hr = IDWriteFontSetBuilder1_AddFontFaceReference_(builder, ref, props, 1); +todo_wine + ok(hr == S_OK, "Unexpected hr %#x.\n",hr); + IDWriteFontFaceReference_Release(ref); + + hr = IDWriteFontSetBuilder1_CreateFontSet(builder, &fontset); + ok(hr == S_OK, "Unexpected hr %#x.\n",hr); + + hr = IDWriteFactory5_CreateFontCollectionFromFontSet(factory, fontset, &collection); +todo_wine + ok(hr == S_OK, "Unexpected hr %#x.\n",hr); + +if (SUCCEEDED(hr)) +{ + count = IDWriteFontCollection1_GetFontFamilyCount(collection); + ok(count == 2, "Unexpected family count %u.\n", count); + + /* Explicit fontset properties are prioritized and not replaced by actual properties from a file. */ + exists = FALSE; + hr = IDWriteFontCollection1_FindFamilyName(collection, L"Another Font", &index, &exists); + ok(hr == S_OK, "Unexpected hr %#x.\n",hr); + ok(!!exists, "Unexpected return value %d.\n", exists); + + IDWriteFontCollection1_Release(collection); +} + IDWriteFontSet_Release(fontset); + + IDWriteFontSetBuilder1_Release(builder); + + IDWriteFontFile_Release(file); + refcount = IDWriteFactory5_Release(factory); + ok(!refcount, "Unexpected factory refcount %u.\n", refcount); + DELETE_FONTFILE(path); +} + START_TEST(font) { IDWriteFactory *factory; @@ -10212,6 +10320,7 @@ START_TEST(font) test_expiration_event(); test_family_font_set(); test_system_font_set(); + test_CreateFontCollectionFromFontSet(); IDWriteFactory_Release(factory); }
1
0
0
0
Nikolay Sivov : gdiplus/metafile: Implement rendering origin recording.
by Alexandre Julliard
29 Mar '21
29 Mar '21
Module: wine Branch: master Commit: 2c77f717c88768dbf0da02f16605c2f24cb041a4 URL:
https://source.winehq.org/git/wine.git/?a=commit;h=2c77f717c88768dbf0da02f1…
Author: Nikolay Sivov <nsivov(a)codeweavers.com> Date: Wed Mar 24 15:27:25 2021 +0300 gdiplus/metafile: Implement rendering origin recording. Signed-off-by: Nikolay Sivov <nsivov(a)codeweavers.com> Signed-off-by: Esme Povirk <esme(a)codeweavers.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- dlls/gdiplus/gdiplus_private.h | 1 + dlls/gdiplus/graphics.c | 12 ++++++++++++ dlls/gdiplus/metafile.c | 31 +++++++++++++++++++++++++++++++ dlls/gdiplus/tests/metafile.c | 11 +++++++++++ 4 files changed, 55 insertions(+) diff --git a/dlls/gdiplus/gdiplus_private.h b/dlls/gdiplus/gdiplus_private.h index 5909174d2ba..2b0f920473d 100644 --- a/dlls/gdiplus/gdiplus_private.h +++ b/dlls/gdiplus/gdiplus_private.h @@ -120,6 +120,7 @@ extern GpStatus METAFILE_DrawArc(GpMetafile *metafile, GpPen *pen, const GpRectF extern GpStatus METAFILE_OffsetClip(GpMetafile *metafile, REAL dx, REAL dy) DECLSPEC_HIDDEN; extern GpStatus METAFILE_ResetClip(GpMetafile *metafile) DECLSPEC_HIDDEN; extern GpStatus METAFILE_SetClipPath(GpMetafile *metafile, GpPath *path, CombineMode mode) DECLSPEC_HIDDEN; +extern GpStatus METAFILE_SetRenderingOrigin(GpMetafile *metafile, INT x, INT y) DECLSPEC_HIDDEN; extern void calc_curve_bezier(const GpPointF *pts, REAL tension, REAL *x1, REAL *y1, REAL *x2, REAL *y2) DECLSPEC_HIDDEN; diff --git a/dlls/gdiplus/graphics.c b/dlls/gdiplus/graphics.c index 89fce949531..df4a89e8294 100644 --- a/dlls/gdiplus/graphics.c +++ b/dlls/gdiplus/graphics.c @@ -6250,11 +6250,23 @@ GpStatus WINGDIPAPI GdipSetPixelOffsetMode(GpGraphics *graphics, PixelOffsetMode GpStatus WINGDIPAPI GdipSetRenderingOrigin(GpGraphics *graphics, INT x, INT y) { + GpStatus stat; + TRACE("(%p,%i,%i)\n", graphics, x, y); if (!graphics) return InvalidParameter; + if (graphics->origin_x == x && graphics->origin_y == y) + return Ok; + + if (is_metafile_graphics(graphics)) + { + stat = METAFILE_SetRenderingOrigin((GpMetafile *)graphics->image, x, y); + if (stat != Ok) + return stat; + } + graphics->origin_x = x; graphics->origin_y = y; diff --git a/dlls/gdiplus/metafile.c b/dlls/gdiplus/metafile.c index f3bd83196cb..f4824d4257b 100644 --- a/dlls/gdiplus/metafile.c +++ b/dlls/gdiplus/metafile.c @@ -580,6 +580,13 @@ typedef struct EmfPlusOffsetClip float dy; } EmfPlusOffsetClip; +typedef struct EmfPlusSetRenderingOrigin +{ + EmfPlusRecordHeader Header; + INT x; + INT y; +} EmfPlusSetRenderingOrigin; + static void metafile_free_object_table_entry(GpMetafile *metafile, BYTE id) { struct emfplus_object *object = &metafile->objtable[id]; @@ -5275,3 +5282,27 @@ GpStatus METAFILE_SetClipPath(GpMetafile *metafile, GpPath *path, CombineMode mo return Ok; } + +GpStatus METAFILE_SetRenderingOrigin(GpMetafile *metafile, INT x, INT y) +{ + EmfPlusSetRenderingOrigin *record; + GpStatus stat; + + if (metafile->metafile_type == MetafileTypeEmf) + { + FIXME("stub!\n"); + return NotImplemented; + } + + stat = METAFILE_AllocateRecord(metafile, EmfPlusRecordTypeSetRenderingOrigin, + sizeof(*record), (void **)&record); + if (stat != Ok) + return stat; + + record->x = x; + record->y = y; + + METAFILE_WriteRecords(metafile); + + return Ok; +} diff --git a/dlls/gdiplus/tests/metafile.c b/dlls/gdiplus/tests/metafile.c index 569c975565f..3ad3db35273 100644 --- a/dlls/gdiplus/tests/metafile.c +++ b/dlls/gdiplus/tests/metafile.c @@ -2661,6 +2661,8 @@ static const emfplus_record properties_records[] = { { EmfPlusRecordTypeSetCompositingMode, CompositingModeSourceCopy }, { EmfPlusRecordTypeSetCompositingQuality, CompositingQualityHighQuality }, { EmfPlusRecordTypeSetInterpolationMode, InterpolationModeHighQualityBicubic }, + { EmfPlusRecordTypeSetRenderingOrigin }, + { EmfPlusRecordTypeSetRenderingOrigin }, { EmfPlusRecordTypeEndOfFile }, { EMR_EOF }, { 0 } @@ -2714,6 +2716,15 @@ static void test_properties(void) stat = GdipSetInterpolationMode(graphics, InterpolationModeHighQuality); expect(Ok, stat); + stat = GdipSetRenderingOrigin(graphics, 1, 2); + expect(Ok, stat); + + stat = GdipSetRenderingOrigin(graphics, 1, 2); + expect(Ok, stat); + + stat = GdipSetRenderingOrigin(graphics, 2, 1); + expect(Ok, stat); + stat = GdipDeleteGraphics(graphics); expect(Ok, stat); sync_metafile(&metafile, "properties.emf");
1
0
0
0
Nikolay Sivov : gdiplus/metafile: Implement SetClipPath() recording.
by Alexandre Julliard
29 Mar '21
29 Mar '21
Module: wine Branch: master Commit: 42cb11b1c1978ad2dda5419c64209c75af055265 URL:
https://source.winehq.org/git/wine.git/?a=commit;h=42cb11b1c1978ad2dda5419c…
Author: Nikolay Sivov <nsivov(a)codeweavers.com> Date: Wed Mar 24 15:27:24 2021 +0300 gdiplus/metafile: Implement SetClipPath() recording. Signed-off-by: Nikolay Sivov <nsivov(a)codeweavers.com> Signed-off-by: Esme Povirk <esme(a)codeweavers.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- dlls/gdiplus/gdiplus_private.h | 1 + dlls/gdiplus/graphics.c | 7 ++++++ dlls/gdiplus/metafile.c | 27 ++++++++++++++++++++ dlls/gdiplus/tests/metafile.c | 57 ++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 92 insertions(+) diff --git a/dlls/gdiplus/gdiplus_private.h b/dlls/gdiplus/gdiplus_private.h index 04294e823b7..5909174d2ba 100644 --- a/dlls/gdiplus/gdiplus_private.h +++ b/dlls/gdiplus/gdiplus_private.h @@ -119,6 +119,7 @@ extern GpStatus METAFILE_DrawArc(GpMetafile *metafile, GpPen *pen, const GpRectF REAL startAngle, REAL sweepAngle) DECLSPEC_HIDDEN; extern GpStatus METAFILE_OffsetClip(GpMetafile *metafile, REAL dx, REAL dy) DECLSPEC_HIDDEN; extern GpStatus METAFILE_ResetClip(GpMetafile *metafile) DECLSPEC_HIDDEN; +extern GpStatus METAFILE_SetClipPath(GpMetafile *metafile, GpPath *path, CombineMode mode) DECLSPEC_HIDDEN; extern void calc_curve_bezier(const GpPointF *pts, REAL tension, REAL *x1, REAL *y1, REAL *x2, REAL *y2) DECLSPEC_HIDDEN; diff --git a/dlls/gdiplus/graphics.c b/dlls/gdiplus/graphics.c index 0eb7aa71d46..89fce949531 100644 --- a/dlls/gdiplus/graphics.c +++ b/dlls/gdiplus/graphics.c @@ -6443,6 +6443,13 @@ GpStatus WINGDIPAPI GdipSetClipPath(GpGraphics *graphics, GpPath *path, CombineM if(graphics->busy) return ObjectBusy; + if (is_metafile_graphics(graphics)) + { + status = METAFILE_SetClipPath((GpMetafile*)graphics->image, path, mode); + if (status != Ok) + return status; + } + status = GdipClonePath(path, &clip_path); if (status == Ok) { diff --git a/dlls/gdiplus/metafile.c b/dlls/gdiplus/metafile.c index c5a97246da2..f3bd83196cb 100644 --- a/dlls/gdiplus/metafile.c +++ b/dlls/gdiplus/metafile.c @@ -5248,3 +5248,30 @@ GpStatus METAFILE_ResetClip(GpMetafile *metafile) return Ok; } + +GpStatus METAFILE_SetClipPath(GpMetafile *metafile, GpPath *path, CombineMode mode) +{ + EmfPlusRecordHeader *record; + DWORD path_id; + GpStatus stat; + + if (metafile->metafile_type == MetafileTypeEmf) + { + FIXME("stub!\n"); + return NotImplemented; + } + + stat = METAFILE_AddPathObject(metafile, path, &path_id); + if (stat != Ok) return stat; + + stat = METAFILE_AllocateRecord(metafile, EmfPlusRecordTypeSetClipPath, + sizeof(*record), (void **)&record); + if (stat != Ok) + return stat; + + record->Flags = ((mode & 0xf) << 8) | path_id; + + METAFILE_WriteRecords(metafile); + + return Ok; +} diff --git a/dlls/gdiplus/tests/metafile.c b/dlls/gdiplus/tests/metafile.c index 9701a7d7ba6..569c975565f 100644 --- a/dlls/gdiplus/tests/metafile.c +++ b/dlls/gdiplus/tests/metafile.c @@ -3803,6 +3803,62 @@ static void test_resetclip(void) expect(Ok, stat); } +static void test_setclippath(void) +{ + static const GpRectF frame = { 0.0f, 0.0f, 100.0f, 100.0f }; + static const emfplus_record set_clip_path_records[] = + { + { EMR_HEADER }, + { EmfPlusRecordTypeHeader }, + { EmfPlusRecordTypeObject, ObjectTypePath << 8 }, + { EmfPlusRecordTypeSetClipPath, 0x100 }, + { EmfPlusRecordTypeEndOfFile }, + { EMR_EOF }, + { 0 }, + }; + + GpMetafile *metafile; + GpGraphics *graphics; + HENHMETAFILE hemf; + GpStatus stat; + GpPath *path; + HDC hdc; + + hdc = CreateCompatibleDC(0); + stat = GdipRecordMetafile(hdc, EmfTypeEmfPlusOnly, &frame, MetafileFrameUnitPixel, description, &metafile); + expect(Ok, stat); + DeleteDC(hdc); + + stat = GdipGetImageGraphicsContext((GpImage *)metafile, &graphics); + expect(Ok, stat); + + stat = GdipCreatePath(FillModeAlternate, &path); + expect(Ok, stat); + stat = GdipAddPathLine(path, 5, 5, 30, 30); + expect(Ok, stat); + stat = GdipAddPathLine(path, 30, 30, 5, 30); + expect(Ok, stat); + + stat = GdipSetClipPath(graphics, path, CombineModeIntersect); + expect(Ok, stat); + + stat = GdipDeletePath(path); + expect(Ok, stat); + + stat = GdipDeleteGraphics(graphics); + expect(Ok, stat); + sync_metafile(&metafile, "set_clip_path.emf"); + + stat = GdipGetHemfFromMetafile(metafile, &hemf); + expect(Ok, stat); + + check_emfplus(hemf, set_clip_path_records, "set clip path"); + DeleteEnhMetaFile(hemf); + + stat = GdipDisposeImage((GpImage*)metafile); + expect(Ok, stat); +} + START_TEST(metafile) { struct GdiplusStartupInput gdiplusStartupInput; @@ -3862,6 +3918,7 @@ START_TEST(metafile) test_drawrectangle(); test_offsetclip(); test_resetclip(); + test_setclippath(); GdiplusShutdown(gdiplusToken); }
1
0
0
0
Nikolay Sivov : gdiplus/metafile: Implement ResetClip() recording.
by Alexandre Julliard
29 Mar '21
29 Mar '21
Module: wine Branch: master Commit: 24278c4fc7e98aed5d3bbd048faf37b92260f669 URL:
https://source.winehq.org/git/wine.git/?a=commit;h=24278c4fc7e98aed5d3bbd04…
Author: Nikolay Sivov <nsivov(a)codeweavers.com> Date: Wed Mar 24 15:27:23 2021 +0300 gdiplus/metafile: Implement ResetClip() recording. Signed-off-by: Nikolay Sivov <nsivov(a)codeweavers.com> Signed-off-by: Esme Povirk <esme(a)codeweavers.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- dlls/gdiplus/gdiplus_private.h | 1 + dlls/gdiplus/graphics.c | 9 ++++++++ dlls/gdiplus/metafile.c | 21 ++++++++++++++++++ dlls/gdiplus/tests/metafile.c | 49 ++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 80 insertions(+) diff --git a/dlls/gdiplus/gdiplus_private.h b/dlls/gdiplus/gdiplus_private.h index 0745e7997ff..04294e823b7 100644 --- a/dlls/gdiplus/gdiplus_private.h +++ b/dlls/gdiplus/gdiplus_private.h @@ -118,6 +118,7 @@ extern GpStatus METAFILE_FillPie(GpMetafile *metafile, GpBrush *brush, const GpR extern GpStatus METAFILE_DrawArc(GpMetafile *metafile, GpPen *pen, const GpRectF *rect, REAL startAngle, REAL sweepAngle) DECLSPEC_HIDDEN; extern GpStatus METAFILE_OffsetClip(GpMetafile *metafile, REAL dx, REAL dy) DECLSPEC_HIDDEN; +extern GpStatus METAFILE_ResetClip(GpMetafile *metafile) DECLSPEC_HIDDEN; extern void calc_curve_bezier(const GpPointF *pts, REAL tension, REAL *x1, REAL *y1, REAL *x2, REAL *y2) DECLSPEC_HIDDEN; diff --git a/dlls/gdiplus/graphics.c b/dlls/gdiplus/graphics.c index dd34cf81ddb..0eb7aa71d46 100644 --- a/dlls/gdiplus/graphics.c +++ b/dlls/gdiplus/graphics.c @@ -5809,6 +5809,8 @@ GpStatus WINGDIPAPI GdipDrawString(GpGraphics *graphics, GDIPCONST WCHAR *string GpStatus WINGDIPAPI GdipResetClip(GpGraphics *graphics) { + GpStatus stat; + TRACE("(%p)\n", graphics); if(!graphics) @@ -5817,6 +5819,13 @@ GpStatus WINGDIPAPI GdipResetClip(GpGraphics *graphics) if(graphics->busy) return ObjectBusy; + if (is_metafile_graphics(graphics)) + { + stat = METAFILE_ResetClip((GpMetafile *)graphics->image); + if (stat != Ok) + return stat; + } + return GdipSetInfinite(graphics->clip); } diff --git a/dlls/gdiplus/metafile.c b/dlls/gdiplus/metafile.c index 8ab1acadb42..c5a97246da2 100644 --- a/dlls/gdiplus/metafile.c +++ b/dlls/gdiplus/metafile.c @@ -5227,3 +5227,24 @@ GpStatus METAFILE_OffsetClip(GpMetafile *metafile, REAL dx, REAL dy) return Ok; } + +GpStatus METAFILE_ResetClip(GpMetafile *metafile) +{ + EmfPlusRecordHeader *record; + GpStatus stat; + + if (metafile->metafile_type == MetafileTypeEmf) + { + FIXME("stub!\n"); + return NotImplemented; + } + + stat = METAFILE_AllocateRecord(metafile, EmfPlusRecordTypeResetClip, + sizeof(*record), (void **)&record); + if (stat != Ok) + return stat; + + METAFILE_WriteRecords(metafile); + + return Ok; +} diff --git a/dlls/gdiplus/tests/metafile.c b/dlls/gdiplus/tests/metafile.c index 9ffd9ef60c8..9701a7d7ba6 100644 --- a/dlls/gdiplus/tests/metafile.c +++ b/dlls/gdiplus/tests/metafile.c @@ -3755,6 +3755,54 @@ static void test_offsetclip(void) expect(Ok, stat); } +static void test_resetclip(void) +{ + static const GpRectF frame = { 0.0f, 0.0f, 100.0f, 100.0f }; + static const emfplus_record reset_clip_records[] = + { + { EMR_HEADER }, + { EmfPlusRecordTypeHeader }, + { EmfPlusRecordTypeResetClip }, + { EmfPlusRecordTypeResetClip }, + { EmfPlusRecordTypeEndOfFile }, + { EMR_EOF }, + { 0 }, + }; + + GpMetafile *metafile; + GpGraphics *graphics; + HENHMETAFILE hemf; + GpStatus stat; + HDC hdc; + + hdc = CreateCompatibleDC(0); + stat = GdipRecordMetafile(hdc, EmfTypeEmfPlusOnly, &frame, MetafileFrameUnitPixel, description, &metafile); + expect(Ok, stat); + DeleteDC(hdc); + + stat = GdipGetImageGraphicsContext((GpImage *)metafile, &graphics); + expect(Ok, stat); + + stat = GdipResetClip(graphics); + expect(Ok, stat); + + stat = GdipResetClip(graphics); + expect(Ok, stat); + + stat = GdipDeleteGraphics(graphics); + expect(Ok, stat); + sync_metafile(&metafile, "reset_clip.emf"); + + stat = GdipGetHemfFromMetafile(metafile, &hemf); + expect(Ok, stat); + + check_emfplus(hemf, reset_clip_records, "reset clip"); + DeleteEnhMetaFile(hemf); + + stat = GdipDisposeImage((GpImage*)metafile); + expect(Ok, stat); +} + START_TEST(metafile) { struct GdiplusStartupInput gdiplusStartupInput; @@ -3813,6 +3861,7 @@ START_TEST(metafile) test_fillellipse(); test_drawrectangle(); test_offsetclip(); + test_resetclip(); GdiplusShutdown(gdiplusToken); }
1
0
0
0
Nikolay Sivov : gdiplus/metafile: Implement TranslateClip() recording.
by Alexandre Julliard
29 Mar '21
29 Mar '21
Module: wine Branch: master Commit: 33d2f6b7ec4af183f433bc0fd46361bfff0741ac URL:
https://source.winehq.org/git/wine.git/?a=commit;h=33d2f6b7ec4af183f433bc0f…
Author: Nikolay Sivov <nsivov(a)codeweavers.com> Date: Wed Mar 24 15:27:22 2021 +0300 gdiplus/metafile: Implement TranslateClip() recording. Signed-off-by: Nikolay Sivov <nsivov(a)codeweavers.com> Signed-off-by: Esme Povirk <esme(a)codeweavers.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- dlls/gdiplus/gdiplus_private.h | 1 + dlls/gdiplus/graphics.c | 18 +++++++++------- dlls/gdiplus/metafile.c | 31 ++++++++++++++++++++++++++ dlls/gdiplus/tests/metafile.c | 49 ++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 91 insertions(+), 8 deletions(-) diff --git a/dlls/gdiplus/gdiplus_private.h b/dlls/gdiplus/gdiplus_private.h index 25672530313..0745e7997ff 100644 --- a/dlls/gdiplus/gdiplus_private.h +++ b/dlls/gdiplus/gdiplus_private.h @@ -117,6 +117,7 @@ extern GpStatus METAFILE_FillPie(GpMetafile *metafile, GpBrush *brush, const GpR REAL startAngle, REAL sweepAngle) DECLSPEC_HIDDEN; extern GpStatus METAFILE_DrawArc(GpMetafile *metafile, GpPen *pen, const GpRectF *rect, REAL startAngle, REAL sweepAngle) DECLSPEC_HIDDEN; +extern GpStatus METAFILE_OffsetClip(GpMetafile *metafile, REAL dx, REAL dy) DECLSPEC_HIDDEN; extern void calc_curve_bezier(const GpPointF *pts, REAL tension, REAL *x1, REAL *y1, REAL *x2, REAL *y2) DECLSPEC_HIDDEN; diff --git a/dlls/gdiplus/graphics.c b/dlls/gdiplus/graphics.c index e292afdfb2c..dd34cf81ddb 100644 --- a/dlls/gdiplus/graphics.c +++ b/dlls/gdiplus/graphics.c @@ -7011,6 +7011,8 @@ HPALETTE WINGDIPAPI GdipCreateHalftonePalette(void) */ GpStatus WINGDIPAPI GdipTranslateClip(GpGraphics *graphics, REAL dx, REAL dy) { + GpStatus stat; + TRACE("(%p, %.2f, %.2f)\n", graphics, dx, dy); if(!graphics) @@ -7019,6 +7021,13 @@ GpStatus WINGDIPAPI GdipTranslateClip(GpGraphics *graphics, REAL dx, REAL dy) if(graphics->busy) return ObjectBusy; + if (is_metafile_graphics(graphics)) + { + stat = METAFILE_OffsetClip((GpMetafile *)graphics->image, dx, dy); + if (stat != Ok) + return stat; + } + return GdipTranslateRegion(graphics->clip, dx, dy); } @@ -7029,16 +7038,9 @@ GpStatus WINGDIPAPI GdipTranslateClipI(GpGraphics *graphics, INT dx, INT dy) { TRACE("(%p, %d, %d)\n", graphics, dx, dy); - if(!graphics) - return InvalidParameter; - - if(graphics->busy) - return ObjectBusy; - - return GdipTranslateRegion(graphics->clip, (REAL)dx, (REAL)dy); + return GdipTranslateClip(graphics, dx, dy); } - /***************************************************************************** * GdipMeasureDriverString [GDIPLUS.@] */ diff --git a/dlls/gdiplus/metafile.c b/dlls/gdiplus/metafile.c index d9fa9e77c91..8ab1acadb42 100644 --- a/dlls/gdiplus/metafile.c +++ b/dlls/gdiplus/metafile.c @@ -573,6 +573,13 @@ typedef struct EmfPlusFillRegion } data; } EmfPlusFillRegion; +typedef struct EmfPlusOffsetClip +{ + EmfPlusRecordHeader Header; + float dx; + float dy; +} EmfPlusOffsetClip; + static void metafile_free_object_table_entry(GpMetafile *metafile, BYTE id) { struct emfplus_object *object = &metafile->objtable[id]; @@ -5196,3 +5203,27 @@ GpStatus METAFILE_DrawArc(GpMetafile *metafile, GpPen *pen, const GpRectF *rect, return Ok; } + +GpStatus METAFILE_OffsetClip(GpMetafile *metafile, REAL dx, REAL dy) +{ + EmfPlusOffsetClip *record; + GpStatus stat; + + if (metafile->metafile_type == MetafileTypeEmf) + { + FIXME("stub!\n"); + return NotImplemented; + } + + stat = METAFILE_AllocateRecord(metafile, EmfPlusRecordTypeOffsetClip, + sizeof(*record), (void **)&record); + if (stat != Ok) + return stat; + + record->dx = dx; + record->dy = dy; + + METAFILE_WriteRecords(metafile); + + return Ok; +} diff --git a/dlls/gdiplus/tests/metafile.c b/dlls/gdiplus/tests/metafile.c index 92c738f5116..9ffd9ef60c8 100644 --- a/dlls/gdiplus/tests/metafile.c +++ b/dlls/gdiplus/tests/metafile.c @@ -3707,6 +3707,54 @@ static void test_drawrectangle(void) expect(Ok, stat); } +static void test_offsetclip(void) +{ + static const GpRectF frame = { 0.0f, 0.0f, 100.0f, 100.0f }; + static const emfplus_record offset_clip_records[] = + { + { EMR_HEADER }, + { EmfPlusRecordTypeHeader }, + { EmfPlusRecordTypeOffsetClip }, + { EmfPlusRecordTypeOffsetClip }, + { EmfPlusRecordTypeEndOfFile }, + { EMR_EOF }, + { 0 }, + }; + + GpMetafile *metafile; + GpGraphics *graphics; + HENHMETAFILE hemf; + GpStatus stat; + HDC hdc; + + hdc = CreateCompatibleDC(0); + stat = GdipRecordMetafile(hdc, EmfTypeEmfPlusOnly, &frame, MetafileFrameUnitPixel, description, &metafile); + expect(Ok, stat); + DeleteDC(hdc); + + stat = GdipGetImageGraphicsContext((GpImage *)metafile, &graphics); + expect(Ok, stat); + + stat = GdipTranslateClip(graphics, 1.0f, -1.0f); + expect(Ok, stat); + + stat = GdipTranslateClipI(graphics, 2, 3); + expect(Ok, stat); + + stat = GdipDeleteGraphics(graphics); + expect(Ok, stat); + sync_metafile(&metafile, "offset_clip.emf"); + + stat = GdipGetHemfFromMetafile(metafile, &hemf); + expect(Ok, stat); + + check_emfplus(hemf, offset_clip_records, "offset clip"); + DeleteEnhMetaFile(hemf); + + stat = GdipDisposeImage((GpImage*)metafile); + expect(Ok, stat); +} + START_TEST(metafile) { struct GdiplusStartupInput gdiplusStartupInput; @@ -3764,6 +3812,7 @@ START_TEST(metafile) test_drawellipse(); test_fillellipse(); test_drawrectangle(); + test_offsetclip(); GdiplusShutdown(gdiplusToken); }
1
0
0
0
← Newer
1
...
8
9
10
11
12
13
14
...
117
Older →
Jump to page:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
Results per page:
10
25
50
100
200