Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-winehq
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wine
wine-winehq
Commits
6906117b
Commit
6906117b
authored
Nov 14, 2018
by
Nikolay Sivov
Committed by
Alexandre Julliard
Nov 28, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
gdiplus: Add a helper to create gradient brush from rectangle.
Signed-off-by:
Nikolay Sivov
<
nsivov@codeweavers.com
>
Signed-off-by:
Alexandre Julliard
<
julliard@winehq.org
>
parent
1f95fd48
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
107 additions
and
78 deletions
+107
-78
brush.c
dlls/gdiplus/brush.c
+107
-78
No files found.
dlls/gdiplus/brush.c
View file @
6906117b
...
@@ -265,12 +265,49 @@ GpStatus WINGDIPAPI GdipCreateHatchBrush(GpHatchStyle hatchstyle, ARGB forecol,
...
@@ -265,12 +265,49 @@ GpStatus WINGDIPAPI GdipCreateHatchBrush(GpHatchStyle hatchstyle, ARGB forecol,
return
Ok
;
return
Ok
;
}
}
static
void
linegradient_init_transform
(
GpLineGradient
*
line
)
static
GpStatus
create_line_brush
(
const
GpRectF
*
rect
,
ARGB
startcolor
,
ARGB
endcolor
,
GpWrapMode
wrap
,
GpLineGradient
**
line
)
{
*
line
=
heap_alloc_zero
(
sizeof
(
GpLineGradient
));
if
(
!*
line
)
return
OutOfMemory
;
(
*
line
)
->
brush
.
bt
=
BrushTypeLinearGradient
;
(
*
line
)
->
startcolor
=
startcolor
;
(
*
line
)
->
endcolor
=
endcolor
;
(
*
line
)
->
wrap
=
wrap
;
(
*
line
)
->
gamma
=
FALSE
;
(
*
line
)
->
rect
=
*
rect
;
(
*
line
)
->
blendcount
=
1
;
(
*
line
)
->
blendfac
=
heap_alloc_zero
(
sizeof
(
REAL
));
(
*
line
)
->
blendpos
=
heap_alloc_zero
(
sizeof
(
REAL
));
if
(
!
(
*
line
)
->
blendfac
||
!
(
*
line
)
->
blendpos
)
{
heap_free
((
*
line
)
->
blendfac
);
heap_free
((
*
line
)
->
blendpos
);
heap_free
(
*
line
);
*
line
=
NULL
;
return
OutOfMemory
;
}
(
*
line
)
->
blendfac
[
0
]
=
1
.
0
f
;
(
*
line
)
->
blendpos
[
0
]
=
1
.
0
f
;
(
*
line
)
->
pblendcolor
=
NULL
;
(
*
line
)
->
pblendpos
=
NULL
;
(
*
line
)
->
pblendcount
=
0
;
GdipSetMatrixElements
(
&
(
*
line
)
->
transform
,
1
.
0
f
,
0
.
0
f
,
0
.
0
f
,
1
.
0
f
,
0
.
0
f
,
0
.
0
f
);
return
Ok
;
}
static
void
linegradient_init_transform
(
const
GpPointF
*
startpoint
,
const
GpPointF
*
endpoint
,
GpLineGradient
*
line
)
{
{
float
trans_x
=
line
->
rect
.
X
+
(
line
->
rect
.
Width
/
2
.
f
);
float
trans_x
=
line
->
rect
.
X
+
(
line
->
rect
.
Width
/
2
.
f
);
float
trans_y
=
line
->
rect
.
Y
+
(
line
->
rect
.
Height
/
2
.
f
);
float
trans_y
=
line
->
rect
.
Y
+
(
line
->
rect
.
Height
/
2
.
f
);
float
dx
=
line
->
endpoint
.
X
-
line
->
startpoint
.
X
;
float
dx
=
endpoint
->
X
-
startpoint
->
X
;
float
dy
=
line
->
endpoint
.
Y
-
line
->
startpoint
.
Y
;
float
dy
=
endpoint
->
Y
-
startpoint
->
Y
;
float
t_cos
,
t_sin
,
w_ratio
,
h_ratio
;
float
t_cos
,
t_sin
,
w_ratio
,
h_ratio
;
float
h
;
float
h
;
GpMatrix
rot
;
GpMatrix
rot
;
...
@@ -307,6 +344,9 @@ GpStatus WINGDIPAPI GdipCreateLineBrush(GDIPCONST GpPointF* startpoint,
...
@@ -307,6 +344,9 @@ GpStatus WINGDIPAPI GdipCreateLineBrush(GDIPCONST GpPointF* startpoint,
GDIPCONST
GpPointF
*
endpoint
,
ARGB
startcolor
,
ARGB
endcolor
,
GDIPCONST
GpPointF
*
endpoint
,
ARGB
startcolor
,
ARGB
endcolor
,
GpWrapMode
wrap
,
GpLineGradient
**
line
)
GpWrapMode
wrap
,
GpLineGradient
**
line
)
{
{
GpStatus
stat
;
GpRectF
rect
;
TRACE
(
"(%s, %s, %x, %x, %d, %p)
\n
"
,
debugstr_pointf
(
startpoint
),
TRACE
(
"(%s, %s, %x, %x, %d, %p)
\n
"
,
debugstr_pointf
(
startpoint
),
debugstr_pointf
(
endpoint
),
startcolor
,
endcolor
,
wrap
,
line
);
debugstr_pointf
(
endpoint
),
startcolor
,
endcolor
,
wrap
,
line
);
...
@@ -316,57 +356,27 @@ GpStatus WINGDIPAPI GdipCreateLineBrush(GDIPCONST GpPointF* startpoint,
...
@@ -316,57 +356,27 @@ GpStatus WINGDIPAPI GdipCreateLineBrush(GDIPCONST GpPointF* startpoint,
if
(
startpoint
->
X
==
endpoint
->
X
&&
startpoint
->
Y
==
endpoint
->
Y
)
if
(
startpoint
->
X
==
endpoint
->
X
&&
startpoint
->
Y
==
endpoint
->
Y
)
return
OutOfMemory
;
return
OutOfMemory
;
*
line
=
heap_alloc_zero
(
sizeof
(
GpLineGradient
));
rect
.
X
=
startpoint
->
X
<
endpoint
->
X
?
startpoint
->
X
:
endpoint
->
X
;
if
(
!*
line
)
return
OutOfMemory
;
rect
.
Y
=
startpoint
->
Y
<
endpoint
->
Y
?
startpoint
->
Y
:
endpoint
->
Y
;
rect
.
Width
=
fabs
(
startpoint
->
X
-
endpoint
->
X
);
rect
.
Height
=
fabs
(
startpoint
->
Y
-
endpoint
->
Y
);
(
*
line
)
->
brush
.
bt
=
BrushTypeLinearGradient
;
if
(
rect
.
Width
==
0
.
0
f
)
(
*
line
)
->
startpoint
.
X
=
startpoint
->
X
;
(
*
line
)
->
startpoint
.
Y
=
startpoint
->
Y
;
(
*
line
)
->
endpoint
.
X
=
endpoint
->
X
;
(
*
line
)
->
endpoint
.
Y
=
endpoint
->
Y
;
(
*
line
)
->
startcolor
=
startcolor
;
(
*
line
)
->
endcolor
=
endcolor
;
(
*
line
)
->
wrap
=
wrap
;
(
*
line
)
->
gamma
=
FALSE
;
(
*
line
)
->
rect
.
X
=
(
startpoint
->
X
<
endpoint
->
X
?
startpoint
->
X
:
endpoint
->
X
);
(
*
line
)
->
rect
.
Y
=
(
startpoint
->
Y
<
endpoint
->
Y
?
startpoint
->
Y
:
endpoint
->
Y
);
(
*
line
)
->
rect
.
Width
=
fabs
(
startpoint
->
X
-
endpoint
->
X
);
(
*
line
)
->
rect
.
Height
=
fabs
(
startpoint
->
Y
-
endpoint
->
Y
);
if
((
*
line
)
->
rect
.
Width
==
0
)
{
{
(
*
line
)
->
rect
.
X
-=
(
*
line
)
->
rect
.
Height
/
2
.
0
f
;
rect
.
X
-=
rect
.
Height
/
2
.
0
f
;
(
*
line
)
->
rect
.
Width
=
(
*
line
)
->
rect
.
Height
;
rect
.
Width
=
rect
.
Height
;
}
}
else
if
(
(
*
line
)
->
rect
.
Height
==
0
)
else
if
(
rect
.
Height
==
0
.
0
f
)
{
{
(
*
line
)
->
rect
.
Y
-=
(
*
line
)
->
rect
.
Width
/
2
.
0
f
;
rect
.
Y
-=
rect
.
Width
/
2
.
0
f
;
(
*
line
)
->
rect
.
Height
=
(
*
line
)
->
rect
.
Width
;
rect
.
Height
=
rect
.
Width
;
}
(
*
line
)
->
blendcount
=
1
;
(
*
line
)
->
blendfac
=
heap_alloc_zero
(
sizeof
(
REAL
));
(
*
line
)
->
blendpos
=
heap_alloc_zero
(
sizeof
(
REAL
));
if
(
!
(
*
line
)
->
blendfac
||
!
(
*
line
)
->
blendpos
)
{
heap_free
((
*
line
)
->
blendfac
);
heap_free
((
*
line
)
->
blendpos
);
heap_free
(
*
line
);
*
line
=
NULL
;
return
OutOfMemory
;
}
}
(
*
line
)
->
blendfac
[
0
]
=
1
.
0
f
;
stat
=
create_line_brush
(
&
rect
,
startcolor
,
endcolor
,
wrap
,
line
);
(
*
line
)
->
blendpos
[
0
]
=
1
.
0
f
;
if
(
stat
!=
Ok
)
return
stat
;
(
*
line
)
->
pblendcolor
=
NULL
;
(
*
line
)
->
pblendpos
=
NULL
;
(
*
line
)
->
pblendcount
=
0
;
linegradient_init_transform
(
*
line
);
linegradient_init_transform
(
startpoint
,
endpoint
,
*
line
);
TRACE
(
"<-- %p
\n
"
,
*
line
);
TRACE
(
"<-- %p
\n
"
,
*
line
);
...
@@ -474,9 +484,9 @@ GpStatus WINGDIPAPI GdipCreateLineBrushFromRectWithAngle(GDIPCONST GpRectF* rect
...
@@ -474,9 +484,9 @@ GpStatus WINGDIPAPI GdipCreateLineBrushFromRectWithAngle(GDIPCONST GpRectF* rect
GpLineGradient
**
line
)
GpLineGradient
**
line
)
{
{
GpStatus
stat
;
GpStatus
stat
;
LinearGradientMode
mode
;
REAL
exofs
,
eyofs
,
far_x
,
far_y
;
REAL
exofs
,
eyofs
;
REAL
sin_angle
,
cos_angle
,
sin_cos_angle
;
REAL
sin_angle
,
cos_angle
,
sin_cos_angle
;
GpPointF
start
,
end
;
TRACE
(
"(%p, %x, %x, %.2f, %d, %d, %p)
\n
"
,
rect
,
startcolor
,
endcolor
,
angle
,
isAngleScalable
,
TRACE
(
"(%p, %x, %x, %.2f, %d, %d, %p)
\n
"
,
rect
,
startcolor
,
endcolor
,
angle
,
isAngleScalable
,
wrap
,
line
);
wrap
,
line
);
...
@@ -515,42 +525,61 @@ GpStatus WINGDIPAPI GdipCreateLineBrushFromRectWithAngle(GDIPCONST GpRectF* rect
...
@@ -515,42 +525,61 @@ GpStatus WINGDIPAPI GdipCreateLineBrushFromRectWithAngle(GDIPCONST GpRectF* rect
cos_angle
=
cosf
(
angle
);
cos_angle
=
cosf
(
angle
);
sin_cos_angle
=
sin_angle
*
cos_angle
;
sin_cos_angle
=
sin_angle
*
cos_angle
;
if
(
sin_cos_angle
>=
0
)
far_x
=
rect
->
X
+
rect
->
Width
;
mode
=
LinearGradientModeForwardDiagonal
;
far_y
=
rect
->
Y
+
rect
->
Height
;
if
(
angle
==
0
.
0
f
)
{
start
.
X
=
min
(
rect
->
X
,
far_x
);
start
.
Y
=
rect
->
Y
;
end
.
X
=
max
(
rect
->
X
,
far_x
);
end
.
Y
=
rect
->
Y
;
}
else
if
(
sin_cos_angle
>=
0
)
{
start
.
X
=
min
(
rect
->
X
,
far_x
);
start
.
Y
=
min
(
rect
->
Y
,
far_y
);
end
.
X
=
max
(
rect
->
X
,
far_x
);
end
.
Y
=
max
(
rect
->
Y
,
far_y
);
}
else
else
mode
=
LinearGradientModeBackwardDiagonal
;
{
start
.
X
=
max
(
rect
->
X
,
far_x
);
start
.
Y
=
min
(
rect
->
Y
,
far_y
);
end
.
X
=
min
(
rect
->
X
,
far_x
);
end
.
Y
=
max
(
rect
->
Y
,
far_y
);
}
stat
=
GdipCreateLineBrushFromRect
(
rect
,
startcolor
,
endcolor
,
mode
,
wrap
,
line
);
stat
=
create_line_brush
(
rect
,
startcolor
,
endcolor
,
wrap
,
line
);
if
(
stat
!=
Ok
||
angle
==
0
.
0
f
)
return
stat
;
if
(
s
tat
==
Ok
)
if
(
s
in_cos_angle
>=
0
)
{
{
if
(
sin_cos_angle
>=
0
)
exofs
=
rect
->
Height
*
sin_cos_angle
+
rect
->
Width
*
cos_angle
*
cos_angle
;
{
eyofs
=
rect
->
Height
*
sin_angle
*
sin_angle
+
rect
->
Width
*
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
}
{
else
exofs
=
rect
->
Width
*
sin_angle
*
sin_angle
+
rect
->
Height
*
sin_cos_angle
;
{
eyofs
=
-
rect
->
Width
*
sin_cos_angle
+
rect
->
Height
*
sin_angle
*
sin_angle
;
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
)
{
(
*
line
)
->
endpoint
.
X
=
rect
->
X
+
exofs
;
(
*
line
)
->
endpoint
.
Y
=
rect
->
Y
+
eyofs
;
}
else
{
(
*
line
)
->
endpoint
.
X
=
(
*
line
)
->
startpoint
.
X
;
(
*
line
)
->
endpoint
.
Y
=
(
*
line
)
->
startpoint
.
Y
;
(
*
line
)
->
startpoint
.
X
=
rect
->
X
+
exofs
;
(
*
line
)
->
startpoint
.
Y
=
rect
->
Y
+
eyofs
;
}
linegradient_init_transform
(
*
line
);
if
(
sin_angle
>=
0
)
{
end
.
X
=
rect
->
X
+
exofs
;
end
.
Y
=
rect
->
Y
+
eyofs
;
}
else
{
end
.
X
=
start
.
X
;
end
.
Y
=
start
.
Y
;
start
.
X
=
rect
->
X
+
exofs
;
start
.
Y
=
rect
->
Y
+
eyofs
;
}
}
linegradient_init_transform
(
&
start
,
&
end
,
*
line
);
return
stat
;
return
stat
;
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment