Piotr Caban : gdiplus: Fix GdipCreateLineBrushFromRectWithAngle implementation.
Alexandre Julliard
julliard at winehq.org
Tue Oct 25 14:58:22 CDT 2016
Module: wine
Branch: master
Commit: befb8603e2c31afe9ac8ca737469b78fd5432997
URL: http://source.winehq.org/git/wine.git/?a=commit;h=befb8603e2c31afe9ac8ca737469b78fd5432997
Author: Piotr Caban <piotr at codeweavers.com>
Date: Mon Oct 24 20:46:14 2016 +0200
gdiplus: Fix GdipCreateLineBrushFromRectWithAngle implementation.
The patch fixes isAngleScalable==TRUE argument handling. It also fixes a
mistake when width was used instead of height.
Signed-off-by: Piotr Caban <piotr at codeweavers.com>
Signed-off-by: Vincent Povirk <vincent at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
dlls/gdiplus/brush.c | 45 ++++++++++++++++++++++++++++-----------------
1 file changed, 28 insertions(+), 17 deletions(-)
diff --git a/dlls/gdiplus/brush.c b/dlls/gdiplus/brush.c
index ed29990..a184276 100644
--- a/dlls/gdiplus/brush.c
+++ b/dlls/gdiplus/brush.c
@@ -428,26 +428,43 @@ GpStatus WINGDIPAPI GdipCreateLineBrushFromRectWithAngle(GDIPCONST GpRectF* rect
{
GpStatus stat;
LinearGradientMode mode;
- REAL width, height, exofs, eyofs;
+ REAL exofs, eyofs;
REAL sin_angle, cos_angle, sin_cos_angle;
TRACE("(%p, %x, %x, %.2f, %d, %d, %p)\n", rect, startcolor, endcolor, angle, isAngleScalable,
wrap, line);
- sin_angle = sinf(deg2rad(angle));
- cos_angle = cosf(deg2rad(angle));
- sin_cos_angle = sin_angle * cos_angle;
+ if (!rect || !rect->Width || !rect->Height)
+ return InvalidParameter;
+
+ angle = fmodf(angle, 360);
+ if (angle < 0)
+ angle += 360;
if (isAngleScalable)
{
- width = height = 1.0;
+ float add_angle = 0;
+
+ while(angle >= 90) {
+ angle -= 180;
+ add_angle += M_PI;
+ }
+
+ if (angle != 90 && angle != -90)
+ angle = atan((rect->Width / rect->Height) * tan(deg2rad(angle)));
+ else
+ angle = deg2rad(angle);
+ angle += add_angle;
}
else
{
- width = rect->Width;
- height = rect->Height;
+ angle = deg2rad(angle);
}
+ sin_angle = sinf(angle);
+ cos_angle = cosf(angle);
+ sin_cos_angle = sin_angle * cos_angle;
+
if (sin_cos_angle >= 0)
mode = LinearGradientModeForwardDiagonal;
else
@@ -459,19 +476,13 @@ GpStatus WINGDIPAPI GdipCreateLineBrushFromRectWithAngle(GDIPCONST GpRectF* rect
{
if (sin_cos_angle >= 0)
{
- exofs = width * sin_cos_angle + height * cos_angle * cos_angle;
- eyofs = width * sin_angle * sin_angle + height * sin_cos_angle;
+ exofs = rect->Height * sin_cos_angle + rect->Width * cos_angle * cos_angle;
+ eyofs = rect->Height * sin_angle * sin_angle + rect->Width * sin_cos_angle;
}
else
{
- exofs = width * sin_angle * sin_angle + height * sin_cos_angle;
- eyofs = -width * sin_cos_angle + height * sin_angle * sin_angle;
- }
-
- if (isAngleScalable)
- {
- exofs = exofs * rect->Width;
- eyofs = eyofs * rect->Height;
+ exofs = rect->Width * sin_angle * sin_angle + rect->Height * sin_cos_angle;
+ eyofs = -rect->Width * sin_cos_angle + rect->Height * sin_angle * sin_angle;
}
if (sin_angle >= 0)
More information about the wine-cvs
mailing list