-- v3: gdiplus: move pointer calculation outside inner loop for alpha_blend_bmp_pixels gdiplus: reduce number of calculations for matrix rotation
From: Bartosz Kosiorek gang65@poczta.onet.pl
--- dlls/gdiplus/graphics.c | 32 ++++++++++++++++++++++++-------- 1 file changed, 24 insertions(+), 8 deletions(-)
diff --git a/dlls/gdiplus/graphics.c b/dlls/gdiplus/graphics.c index 835c2889bd1..6a045017730 100644 --- a/dlls/gdiplus/graphics.c +++ b/dlls/gdiplus/graphics.c @@ -1617,6 +1617,26 @@ static GpStatus brush_fill_pixels(GpGraphics *graphics, GpBrush *brush, } }
+/* Creates rotated and translated identity matrix. + * Equvalent (but much faster) of the: + * GdipSetMatrixElements(&matrix, 1.0, 0.0, 0.0, 1.0, 0.0, 0.0); + * GdipRotateMatrix(&matrix, angle, MatrixOrderAppend); + * GdipTranslateMatrix(&matrix, dx, dy, MatrixOrderAppend); */ +inline void create_rotated_translated_identity_matrix(GpMatrix *matrix, REAL angle, REAL dx, REAL dy) +{ + REAL cos_theta, sin_theta; + + cos_theta = cos(angle); + sin_theta = sin(angle); + + matrix->matrix[0] = cos_theta; + matrix->matrix[1] = sin_theta; + matrix->matrix[2] = -sin_theta; + matrix->matrix[3] = cos_theta; + matrix->matrix[4] = dx; + matrix->matrix[5] = dy; +} + /* Draws the linecap the specified color and size on the hdc. The linecap is in * direction of the line from x1, y1 to x2, y2 and is anchored on x2, y2. Probably * should not be called on an hdc that has a path you care about. */ @@ -1795,12 +1815,8 @@ static void draw_cap(GpGraphics *graphics, COLORREF color, GpLineCap cap, REAL s goto custend;
memcpy(custptf, custom->pathdata.Points, count * sizeof(PointF)); - - GdipSetMatrixElements(&matrix, 1.0, 0.0, 0.0, 1.0, 0.0, 0.0); + create_rotated_translated_identity_matrix(&matrix, (theta - M_PI_2), x2, y2); GdipScaleMatrix(&matrix, size, size, MatrixOrderAppend); - GdipRotateMatrix(&matrix, (180.0 / M_PI) * (theta - M_PI_2), - MatrixOrderAppend); - GdipTranslateMatrix(&matrix, x2, y2, MatrixOrderAppend); GdipTransformMatrixPoints(&matrix, custptf, count);
gdip_transform_points(graphics, WineCoordinateSpaceGdiDevice, CoordinateSpaceWorld, custptf, count); @@ -7255,9 +7271,9 @@ static GpStatus GDI32_GdipDrawDriverString(GpGraphics *graphics, GDIPCONST UINT1 memcpy(real_positions, positions, sizeof(PointF) * length);
gdip_transform_points(graphics, WineCoordinateSpaceGdiDevice, CoordinateSpaceWorld, real_positions, length); - - GdipSetMatrixElements(&rotation, 1.0, 0.0, 0.0, 1.0, 0.0, 0.0); - GdipRotateMatrix(&rotation, lfw.lfEscapement / 10.0, MatrixOrderAppend); + create_rotated_translated_identity_matrix(&rotation, + (0.1 * lfw.lfEscapement) * M_PI / 180.0, + 0.0, 0.0); GdipTransformMatrixPoints(&rotation, real_positions, length);
for (i = 0; i < (length - 1); i++)
From: Bartosz Kosiorek gang65@poczta.onet.pl
--- dlls/gdiplus/graphics.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-)
diff --git a/dlls/gdiplus/graphics.c b/dlls/gdiplus/graphics.c index 6a045017730..a591fcc7a4e 100644 --- a/dlls/gdiplus/graphics.c +++ b/dlls/gdiplus/graphics.c @@ -422,29 +422,29 @@ static GpStatus alpha_blend_bmp_pixels(GpGraphics *graphics, INT dst_x, INT dst_
for (y=0; y<src_height; y++) { + ARGB *src_color = ((ARGB*)(src + src_stride * y)); for (x=0; x<src_width; x++) { - ARGB dst_color, src_color; - src_color = ((ARGB*)(src + src_stride * y))[x]; - if (comp_mode == CompositingModeSourceCopy) { - if (!(src_color & 0xff000000)) + if (!(*src_color & 0xff000000)) GdipBitmapSetPixel(dst_bitmap, x+dst_x, y+dst_y, 0); else - GdipBitmapSetPixel(dst_bitmap, x+dst_x, y+dst_y, src_color); + GdipBitmapSetPixel(dst_bitmap, x+dst_x, y+dst_y, *src_color); } else { - if (!(src_color & 0xff000000)) + ARGB dst_color; + if (!(*src_color & 0xff000000)) continue;
GdipBitmapGetPixel(dst_bitmap, x+dst_x, y+dst_y, &dst_color); if (fmt & PixelFormatPAlpha) - GdipBitmapSetPixel(dst_bitmap, x+dst_x, y+dst_y, color_over_fgpremult(dst_color, src_color)); + GdipBitmapSetPixel(dst_bitmap, x+dst_x, y+dst_y, color_over_fgpremult(dst_color, *src_color)); else - GdipBitmapSetPixel(dst_bitmap, x+dst_x, y+dst_y, color_over(dst_color, src_color)); + GdipBitmapSetPixel(dst_bitmap, x+dst_x, y+dst_y, color_over(dst_color, *src_color)); } + src_color++; } }
Hi,
It looks like your patch introduced the new failures shown below. Please investigate and fix them before resubmitting your patch. If they are not new, fixing them anyway would help a lot. Otherwise please ask for the known failures list to be updated.
The tests also ran into some preexisting test failures. If you know how to fix them that would be helpful. See the TestBot job for the details:
The full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=133588
Your paranoid android.
=== debian11 (32 bit report) ===
gdiplus: graphics.c:6929: Test failed: Expected -16776961, got 0 graphics.c:6933: Test failed: Expected -16776961, got 0 image.c:4831: Test failed: 2: data should match image.c:4831: Test failed: 9: data should match image.c:3511: Test failed: Expected ffffffff, got 00000000 metafile.c:699: Test failed: Expected -16776961, got 00000000 metafile.c:708: Test failed: Expected -16776961, got 00000000 metafile.c:727: Test failed: Expected -16776961, got 00000000 metafile.c:907: Test failed: Expected -16776961, got 00000000 metafile.c:922: Test failed: Expected -16776961, got 00000000 metafile.c:942: Test failed: Expected -16776961, got 00000000 metafile.c:2994: Test failed: Expected -16776961, got 00000000 metafile.c:3002: Test failed: Expected -16776961, got 00000000
=== debian11 (32 bit zh:CN report) ===
gdiplus: graphics.c:6929: Test failed: Expected -16776961, got 0 graphics.c:6933: Test failed: Expected -16776961, got 0 image.c:4831: Test failed: 2: data should match image.c:4831: Test failed: 9: data should match image.c:3511: Test failed: Expected ffffffff, got 00000000 metafile.c:699: Test failed: Expected -16776961, got 00000000 metafile.c:708: Test failed: Expected -16776961, got 00000000 metafile.c:727: Test failed: Expected -16776961, got 00000000 metafile.c:907: Test failed: Expected -16776961, got 00000000 metafile.c:922: Test failed: Expected -16776961, got 00000000 metafile.c:942: Test failed: Expected -16776961, got 00000000 metafile.c:2994: Test failed: Expected -16776961, got 00000000 metafile.c:3002: Test failed: Expected -16776961, got 00000000
=== debian11b (64 bit WoW report) ===
gdiplus: graphics.c:6929: Test failed: Expected -16776961, got 0 graphics.c:6933: Test failed: Expected -16776961, got 0 image.c:4831: Test failed: 2: data should match image.c:4831: Test failed: 9: data should match image.c:3511: Test failed: Expected ffffffff, got 00000000 metafile.c:699: Test failed: Expected -16776961, got 00000000 metafile.c:708: Test failed: Expected -16776961, got 00000000 metafile.c:727: Test failed: Expected -16776961, got 00000000 metafile.c:907: Test failed: Expected -16776961, got 00000000 metafile.c:922: Test failed: Expected -16776961, got 00000000 metafile.c:942: Test failed: Expected -16776961, got 00000000 metafile.c:2994: Test failed: Expected -16776961, got 00000000 metafile.c:3002: Test failed: Expected -16776961, got 00000000