Skip to content

Commit e8babc9

Browse files
tati-frogivyl
authored andcommitted
gdiplus: Replace HDC with GpGraphics in parameters.
(cherry picked from commit 1454ffe)
1 parent c3e3bfe commit e8babc9

File tree

3 files changed

+23
-25
lines changed

3 files changed

+23
-25
lines changed

dlls/gdiplus/gdiplus_private.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -606,13 +606,13 @@ static inline const void *buffer_read(struct memory_buffer *mbuf, INT size)
606606
return NULL;
607607
}
608608

609-
typedef GpStatus (*gdip_format_string_callback)(HDC hdc,
609+
typedef GpStatus (*gdip_format_string_callback)(GpGraphics *graphics,
610610
GDIPCONST WCHAR *string, INT index, INT length, GDIPCONST GpFont *font,
611611
GDIPCONST RectF *rect, GDIPCONST GpStringFormat *format,
612612
INT lineno, const RectF *bounds, INT *underlined_indexes,
613613
INT underlined_index_count, void *user_data);
614614

615-
GpStatus gdip_format_string(HDC hdc,
615+
GpStatus gdip_format_string(GpGraphics *graphics,
616616
GDIPCONST WCHAR *string, INT length, GDIPCONST GpFont *font,
617617
GDIPCONST RectF *rect, GDIPCONST GpStringFormat *format, int ignore_empty_clip,
618618
gdip_format_string_callback callback, void *user_data);

dlls/gdiplus/graphics.c

+17-19
Original file line numberDiff line numberDiff line change
@@ -5161,7 +5161,7 @@ GpStatus WINGDIPAPI GdipIsVisibleRectI(GpGraphics *graphics, INT x, INT y, INT w
51615161
return GdipIsVisibleRect(graphics, (REAL)x, (REAL)y, (REAL)width, (REAL)height, result);
51625162
}
51635163

5164-
GpStatus gdip_format_string(HDC hdc,
5164+
GpStatus gdip_format_string(GpGraphics *graphics,
51655165
GDIPCONST WCHAR *string, INT length, GDIPCONST GpFont *font,
51665166
GDIPCONST RectF *rect, GDIPCONST GpStringFormat *format, int ignore_empty_clip,
51675167
gdip_format_string_callback callback, void *user_data)
@@ -5243,7 +5243,7 @@ GpStatus gdip_format_string(HDC hdc,
52435243
halign = format->align;
52445244

52455245
while(sum < length){
5246-
GetTextExtentExPointW(hdc, stringdup + sum, length - sum,
5246+
GetTextExtentExPointW(graphics->hdc, stringdup + sum, length - sum,
52475247
nwidth, &fit, NULL, &size);
52485248
fitcpy = fit;
52495249

@@ -5292,7 +5292,7 @@ GpStatus gdip_format_string(HDC hdc,
52925292
else
52935293
lineend = fit;
52945294

5295-
GetTextExtentExPointW(hdc, stringdup + sum, lineend,
5295+
GetTextExtentExPointW(graphics->hdc, stringdup + sum, lineend,
52965296
nwidth, &j, NULL, &size);
52975297

52985298
bounds.Width = size.cx;
@@ -5326,7 +5326,7 @@ GpStatus gdip_format_string(HDC hdc,
53265326
if (hotkeyprefix_offsets[hotkeyprefix_end_pos] >= sum + lineend)
53275327
break;
53285328

5329-
stat = callback(hdc, stringdup, sum, lineend,
5329+
stat = callback(graphics, stringdup, sum, lineend,
53305330
font, rect, format, lineno, &bounds,
53315331
&hotkeyprefix_offsets[hotkeyprefix_pos],
53325332
hotkeyprefix_end_pos-hotkeyprefix_pos, user_data);
@@ -5392,7 +5392,7 @@ struct measure_ranges_args {
53925392
REAL rel_width, rel_height;
53935393
};
53945394

5395-
static GpStatus measure_ranges_callback(HDC hdc,
5395+
static GpStatus measure_ranges_callback(GpGraphics *graphics,
53965396
GDIPCONST WCHAR *string, INT index, INT length, GDIPCONST GpFont *font,
53975397
GDIPCONST RectF *rect, GDIPCONST GpStringFormat *format,
53985398
INT lineno, const RectF *bounds, INT *underlined_indexes,
@@ -5414,11 +5414,11 @@ static GpStatus measure_ranges_callback(HDC hdc,
54145414
range_rect.Y = bounds->Y / args->rel_height;
54155415
range_rect.Height = bounds->Height / args->rel_height;
54165416

5417-
GetTextExtentExPointW(hdc, string + index, range_start - index,
5417+
GetTextExtentExPointW(graphics->hdc, string + index, range_start - index,
54185418
INT_MAX, NULL, NULL, &range_size);
54195419
range_rect.X = (bounds->X + range_size.cx) / args->rel_width;
54205420

5421-
GetTextExtentExPointW(hdc, string + index, range_end - index,
5421+
GetTextExtentExPointW(graphics->hdc, string + index, range_end - index,
54225422
INT_MAX, NULL, NULL, &range_size);
54235423
range_rect.Width = (bounds->X + range_size.cx) / args->rel_width - range_rect.X;
54245424

@@ -5496,7 +5496,7 @@ GpStatus WINGDIPAPI GdipMeasureCharacterRanges(GpGraphics* graphics,
54965496

54975497
gdi_transform_acquire(graphics);
54985498

5499-
stat = gdip_format_string(hdc, string, length, font, &scaled_rect, stringFormat,
5499+
stat = gdip_format_string(graphics, string, length, font, &scaled_rect, stringFormat,
55005500
(stringFormat->attr & StringFormatFlagsNoClip) != 0, measure_ranges_callback, &args);
55015501

55025502
gdi_transform_release(graphics);
@@ -5517,7 +5517,7 @@ struct measure_string_args {
55175517
REAL rel_width, rel_height;
55185518
};
55195519

5520-
static GpStatus measure_string_callback(HDC hdc,
5520+
static GpStatus measure_string_callback(GpGraphics *graphics,
55215521
GDIPCONST WCHAR *string, INT index, INT length, GDIPCONST GpFont *font,
55225522
GDIPCONST RectF *rect, GDIPCONST GpStringFormat *format,
55235523
INT lineno, const RectF *bounds, INT *underlined_indexes,
@@ -5619,7 +5619,7 @@ GpStatus WINGDIPAPI GdipMeasureString(GpGraphics *graphics,
56195619

56205620
gdi_transform_acquire(graphics);
56215621

5622-
gdip_format_string(hdc, string, length, font, &scaled_rect, format, TRUE,
5622+
gdip_format_string(graphics, string, length, font, &scaled_rect, format, TRUE,
56235623
measure_string_callback, &args);
56245624

56255625
gdi_transform_release(graphics);
@@ -5640,12 +5640,11 @@ GpStatus WINGDIPAPI GdipMeasureString(GpGraphics *graphics,
56405640
}
56415641

56425642
struct draw_string_args {
5643-
GpGraphics *graphics;
56445643
GDIPCONST GpBrush *brush;
56455644
REAL x, y, rel_width, rel_height, ascent;
56465645
};
56475646

5648-
static GpStatus draw_string_callback(HDC hdc,
5647+
static GpStatus draw_string_callback(GpGraphics *graphics,
56495648
GDIPCONST WCHAR *string, INT index, INT length, GDIPCONST GpFont *font,
56505649
GDIPCONST RectF *rect, GDIPCONST GpStringFormat *format,
56515650
INT lineno, const RectF *bounds, INT *underlined_indexes,
@@ -5658,7 +5657,7 @@ static GpStatus draw_string_callback(HDC hdc,
56585657
position.X = args->x + bounds->X / args->rel_width;
56595658
position.Y = args->y + bounds->Y / args->rel_height + args->ascent;
56605659

5661-
stat = draw_driver_string(args->graphics, &string[index], length, font, format,
5660+
stat = draw_driver_string(graphics, &string[index], length, font, format,
56625661
args->brush, &position,
56635662
DriverStringOptionsCmapLookup|DriverStringOptionsRealizedAdvance, NULL);
56645663

@@ -5668,7 +5667,7 @@ static GpStatus draw_string_callback(HDC hdc,
56685667
REAL underline_y, underline_height;
56695668
int i;
56705669

5671-
GetOutlineTextMetricsW(hdc, sizeof(otm), &otm);
5670+
GetOutlineTextMetricsW(graphics->hdc, sizeof(otm), &otm);
56725671

56735672
underline_height = otm.otmsUnderscoreSize / args->rel_height;
56745673
underline_y = position.Y - otm.otmsUnderscorePosition / args->rel_height - underline_height / 2;
@@ -5679,13 +5678,13 @@ static GpStatus draw_string_callback(HDC hdc,
56795678
SIZE text_size;
56805679
INT ofs = underlined_indexes[i] - index;
56815680

5682-
GetTextExtentExPointW(hdc, string + index, ofs, INT_MAX, NULL, NULL, &text_size);
5681+
GetTextExtentExPointW(graphics->hdc, string + index, ofs, INT_MAX, NULL, NULL, &text_size);
56835682
start_x = text_size.cx / args->rel_width;
56845683

5685-
GetTextExtentExPointW(hdc, string + index, ofs+1, INT_MAX, NULL, NULL, &text_size);
5684+
GetTextExtentExPointW(graphics->hdc, string + index, ofs+1, INT_MAX, NULL, NULL, &text_size);
56865685
end_x = text_size.cx / args->rel_width;
56875686

5688-
GdipFillRectangle(args->graphics, (GpBrush*)args->brush, position.X+start_x, underline_y, end_x-start_x, underline_height);
5687+
GdipFillRectangle(graphics, (GpBrush*)args->brush, position.X+start_x, underline_y, end_x-start_x, underline_height);
56895688
}
56905689
}
56915690

@@ -5783,7 +5782,6 @@ GpStatus WINGDIPAPI GdipDrawString(GpGraphics *graphics, GDIPCONST WCHAR *string
57835782
get_font_hfont(graphics, font, format, &gdifont, NULL, NULL);
57845783
SelectObject(hdc, gdifont);
57855784

5786-
args.graphics = graphics;
57875785
args.brush = brush;
57885786

57895787
args.x = rect->X;
@@ -5797,7 +5795,7 @@ GpStatus WINGDIPAPI GdipDrawString(GpGraphics *graphics, GDIPCONST WCHAR *string
57975795
GetTextMetricsW(hdc, &textmetric);
57985796
args.ascent = textmetric.tmAscent / rel_height;
57995797

5800-
gdip_format_string(hdc, string, length, font, &scaled_rect, format, TRUE,
5798+
gdip_format_string(graphics, string, length, font, &scaled_rect, format, TRUE,
58015799
draw_string_callback, &args);
58025800

58035801
gdi_transform_release(graphics);

dlls/gdiplus/graphicspath.c

+4-4
Original file line numberDiff line numberDiff line change
@@ -949,7 +949,7 @@ struct format_string_args
949949
float ascent;
950950
};
951951

952-
static GpStatus format_string_callback(HDC dc,
952+
static GpStatus format_string_callback(GpGraphics *graphics,
953953
GDIPCONST WCHAR *string, INT index, INT length, GDIPCONST GpFont *font,
954954
GDIPCONST RectF *rect, GDIPCONST GpStringFormat *format,
955955
INT lineno, const RectF *bounds, INT *underlined_indexes,
@@ -975,7 +975,7 @@ static GpStatus format_string_callback(HDC dc,
975975
TTPOLYGONHEADER *ph = NULL, *origph;
976976
char *start;
977977
DWORD len, ofs = 0;
978-
len = GetGlyphOutlineW(dc, string[i], GGO_BEZIER, &gm, 0, NULL, &identity);
978+
len = GetGlyphOutlineW(graphics->hdc, string[i], GGO_BEZIER, &gm, 0, NULL, &identity);
979979
if (len == GDI_ERROR)
980980
{
981981
status = GenericError;
@@ -989,7 +989,7 @@ static GpStatus format_string_callback(HDC dc,
989989
status = OutOfMemory;
990990
break;
991991
}
992-
GetGlyphOutlineW(dc, string[i], GGO_BEZIER, &gm, len, start, &identity);
992+
GetGlyphOutlineW(graphics->hdc, string[i], GGO_BEZIER, &gm, len, start, &identity);
993993

994994
ofs = 0;
995995
while (ofs < len)
@@ -1117,7 +1117,7 @@ GpStatus WINGDIPAPI GdipAddPathString(GpPath* path, GDIPCONST WCHAR* string, INT
11171117
args.maxY = 0;
11181118
args.scale = emSize / native_height;
11191119
args.ascent = textmetric.tmAscent * args.scale;
1120-
status = gdip_format_string(dc, string, length, NULL, &scaled_layout_rect,
1120+
status = gdip_format_string(graphics, string, length, NULL, &scaled_layout_rect,
11211121
format, TRUE, format_string_callback, &args);
11221122

11231123
DeleteDC(dc);

0 commit comments

Comments
 (0)