[Wine-patches] [eter-2.1 7/7] gdiplus: GdipMeasureCharacterRanges should treat empty layout extents as infinite when StringFormatFlagsNoClip is specified. (eterbug #9086)

Dmitry Timoshkov dtimoshkov на etersoft.ru
Пн Мар 18 07:41:14 MSK 2013


Unlike GdipMeasureString which always treats empty layout extents as infinite.

(cherry picked from commit 6ab04040e52465e77558a067309e8a54bdc0f32c)
---
 dlls/gdiplus/gdiplus_private.h |  2 +-
 dlls/gdiplus/graphics.c        | 21 +++++++++++++--------
 dlls/gdiplus/graphicspath.c    |  3 ++-
 dlls/gdiplus/tests/graphics.c  |  8 --------
 4 files changed, 16 insertions(+), 18 deletions(-)

diff --git a/dlls/gdiplus/gdiplus_private.h b/dlls/gdiplus/gdiplus_private.h
index cb7330e..0dc0cd1 100644
--- a/dlls/gdiplus/gdiplus_private.h
+++ b/dlls/gdiplus/gdiplus_private.h
@@ -441,7 +441,7 @@ typedef GpStatus (*gdip_format_string_callback)(HDC hdc,
 
 GpStatus gdip_format_string(HDC hdc,
     GDIPCONST WCHAR *string, INT length, GDIPCONST GpFont *font,
-    GDIPCONST RectF *rect, GDIPCONST GpStringFormat *format,
+    GDIPCONST RectF *rect, GDIPCONST GpStringFormat *format, int ignore_empty_clip,
     gdip_format_string_callback callback, void *user_data) DECLSPEC_HIDDEN;
 
 void get_log_fontW(const GpFont *, GpGraphics *, LOGFONTW *) DECLSPEC_HIDDEN;
diff --git a/dlls/gdiplus/graphics.c b/dlls/gdiplus/graphics.c
index 85ff3f4..1185457 100644
--- a/dlls/gdiplus/graphics.c
+++ b/dlls/gdiplus/graphics.c
@@ -4415,7 +4415,7 @@ GpStatus WINGDIPAPI GdipIsVisibleRectI(GpGraphics *graphics, INT x, INT y, INT w
 
 GpStatus gdip_format_string(HDC hdc,
     GDIPCONST WCHAR *string, INT length, GDIPCONST GpFont *font,
-    GDIPCONST RectF *rect, GDIPCONST GpStringFormat *format,
+    GDIPCONST RectF *rect, GDIPCONST GpStringFormat *format, int ignore_empty_clip,
     gdip_format_string_callback callback, void *user_data)
 {
     WCHAR* stringdup;
@@ -4438,6 +4438,11 @@ GpStatus gdip_format_string(HDC hdc,
 
     nwidth = rect->Width;
     nheight = rect->Height;
+    if (ignore_empty_clip)
+    {
+        if (!nwidth) nwidth = INT_MAX;
+        if (!nheight) nheight = INT_MAX;
+    }
 
     if (format)
         hkprefix = format->hkprefix;
@@ -4695,7 +4700,7 @@ GpStatus WINGDIPAPI GdipMeasureCharacterRanges(GpGraphics* graphics,
     args.regions = regions;
 
     stat = gdip_format_string(hdc, string, length, font, &scaled_rect, stringFormat,
-        measure_ranges_callback, &args);
+        (stringFormat->attr & StringFormatFlagsNoClip) != 0, measure_ranges_callback, &args);
 
     SelectObject(hdc, oldfont);
     DeleteObject(gdifont);
@@ -4803,8 +4808,8 @@ GpStatus WINGDIPAPI GdipMeasureString(GpGraphics *graphics,
         if (scaled_rect.Width < 0.5) return Ok; /* doesn't fit */
     }
 
-    if (scaled_rect.Width >= 1 << 23 || scaled_rect.Width < 0.5) scaled_rect.Width = 1 << 23;
-    if (scaled_rect.Height >= 1 << 23 || scaled_rect.Height < 0.5) scaled_rect.Height = 1 << 23;
+    if (scaled_rect.Width >= 1 << 23) scaled_rect.Width = 1 << 23;
+    if (scaled_rect.Height >= 1 << 23) scaled_rect.Height = 1 << 23;
 
     get_font_hfont(graphics, font, format, &gdifont, NULL);
     oldfont = SelectObject(hdc, gdifont);
@@ -4819,7 +4824,7 @@ GpStatus WINGDIPAPI GdipMeasureString(GpGraphics *graphics,
     args.linesfilled = &lines;
     lines = glyphs = 0;
 
-    gdip_format_string(hdc, string, length, font, &scaled_rect, format,
+    gdip_format_string(hdc, string, length, font, &scaled_rect, format, TRUE,
         measure_string_callback, &args);
 
     if (linesfilled) *linesfilled = lines;
@@ -4976,8 +4981,8 @@ GpStatus WINGDIPAPI GdipDrawString(GpGraphics *graphics, GDIPCONST WCHAR *string
         if (scaled_rect.Width < 0.5) return Ok; /* doesn't fit */
     }
 
-    if (scaled_rect.Width >= 1 << 23 || scaled_rect.Width < 0.5) scaled_rect.Width = 1 << 23;
-    if (scaled_rect.Height >= 1 << 23 || scaled_rect.Height < 0.5) scaled_rect.Height = 1 << 23;
+    if (scaled_rect.Width >= 1 << 23) scaled_rect.Width = 1 << 23;
+    if (scaled_rect.Height >= 1 << 23) scaled_rect.Height = 1 << 23;
 
     if (!(format_flags & StringFormatFlagsNoClip) &&
         scaled_rect.Width != 1 << 23 && scaled_rect.Height != 1 << 23)
@@ -5002,7 +5007,7 @@ GpStatus WINGDIPAPI GdipDrawString(GpGraphics *graphics, GDIPCONST WCHAR *string
     GetTextMetricsW(hdc, &textmetric);
     args.ascent = textmetric.tmAscent / rel_height;
 
-    gdip_format_string(hdc, string, length, font, &scaled_rect, format,
+    gdip_format_string(hdc, string, length, font, &scaled_rect, format, TRUE,
         draw_string_callback, &args);
 
     DeleteObject(rgn);
diff --git a/dlls/gdiplus/graphicspath.c b/dlls/gdiplus/graphicspath.c
index f4d1a4b..62f8490 100644
--- a/dlls/gdiplus/graphicspath.c
+++ b/dlls/gdiplus/graphicspath.c
@@ -1009,7 +1009,8 @@ GpStatus WINGDIPAPI GdipAddPathString(GpPath* path, GDIPCONST WCHAR* string, INT
     args.maxY = 0;
     args.scale = emSize / native_height;
     args.ascent = textmetric.tmAscent * args.scale;
-    status = gdip_format_string(dc, string, length, NULL, &scaled_layout_rect, format, format_string_callback, &args);
+    status = gdip_format_string(dc, string, length, NULL, &scaled_layout_rect,
+                                format, TRUE, format_string_callback, &args);
 
     DeleteDC(dc);
     DeleteObject(hfont);
diff --git a/dlls/gdiplus/tests/graphics.c b/dlls/gdiplus/tests/graphics.c
index c27be28..6ef7dd2 100644
--- a/dlls/gdiplus/tests/graphics.c
+++ b/dlls/gdiplus/tests/graphics.c
@@ -4050,13 +4050,9 @@ todo_wine
     set_rect_empty(&bounds);
     status = GdipGetRegionBounds(region, graphics, &bounds);
     expect(Ok, status);
-todo_wine
     expectf_(5.0 + margin_x, bounds.X, 1.0);
-todo_wine
     expectf(5.0, bounds.Y);
-todo_wine
     expectf(width_rgn, bounds.Width);
-todo_wine
     expectf(height_rgn, bounds.Height);
 
     rect.X = 5.0;
@@ -4247,9 +4243,7 @@ todo_wine
     expectf_(5.0 - width_rgn/2.0, bounds.X, 1.0);
 todo_wine
     expectf_(5.0 - height_rgn/2.0, bounds.Y, 1.0);
-todo_wine
     expectf_(width_rgn, bounds.Width, 1.0);
-todo_wine
     expectf_(height_rgn, bounds.Height, 1.0);
 
     /* Far alignment */
@@ -4317,9 +4311,7 @@ todo_wine
     expectf_(5.0 - width_rgn, bounds.X, 2.0);
 todo_wine
     expectf_(5.0 - height_rgn, bounds.Y, 1.0);
-todo_wine
     expectf_(width_rgn, bounds.Width, 1.0);
-todo_wine
     expectf_(height_rgn, bounds.Height, 1.0);
 
     status = GdipDeleteFont(font);
-- 
1.8.2



Подробная информация о списке рассылки Wine-patches