Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-cw
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-cw
Commits
2485305b
Commit
2485305b
authored
Jun 02, 2017
by
Henri Verbeet
Committed by
Alexandre Julliard
Jun 02, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
d2d1: Implement d2d_rectangle_geometry_GetBounds().
Signed-off-by:
Henri Verbeet
<
hverbeet@codeweavers.com
>
Signed-off-by:
Alexandre Julliard
<
julliard@winehq.org
>
parent
bc47dc3f
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
94 additions
and
32 deletions
+94
-32
d2d1_private.h
dlls/d2d1/d2d1_private.h
+12
-0
geometry.c
dlls/d2d1/geometry.c
+29
-16
render_target.c
dlls/d2d1/render_target.c
+0
-12
d2d1.c
dlls/d2d1/tests/d2d1.c
+53
-4
No files found.
dlls/d2d1/d2d1_private.h
View file @
2485305b
...
...
@@ -449,4 +449,16 @@ static inline void d2d_point_transform(D2D1_POINT_2F *dst, const D2D1_MATRIX_3X2
dst
->
y
=
x
*
matrix
->
_12
+
y
*
matrix
->
_22
+
matrix
->
_32
;
}
static
inline
void
d2d_rect_expand
(
D2D1_RECT_F
*
dst
,
const
D2D1_POINT_2F
*
point
)
{
if
(
point
->
x
<
dst
->
left
)
dst
->
left
=
point
->
x
;
if
(
point
->
x
>
dst
->
right
)
dst
->
right
=
point
->
x
;
if
(
point
->
y
<
dst
->
top
)
dst
->
top
=
point
->
y
;
if
(
point
->
y
>
dst
->
bottom
)
dst
->
bottom
=
point
->
y
;
}
#endif
/* __WINE_D2D1_PRIVATE_H */
dlls/d2d1/geometry.c
View file @
2485305b
...
...
@@ -510,18 +510,6 @@ static BOOL d2d_array_reserve(void **elements, size_t *capacity, size_t element_
return
TRUE
;
}
static
void
d2d_figure_update_bounds
(
struct
d2d_figure
*
figure
,
D2D1_POINT_2F
vertex
)
{
if
(
vertex
.
x
<
figure
->
bounds
.
left
)
figure
->
bounds
.
left
=
vertex
.
x
;
if
(
vertex
.
x
>
figure
->
bounds
.
right
)
figure
->
bounds
.
right
=
vertex
.
x
;
if
(
vertex
.
y
<
figure
->
bounds
.
top
)
figure
->
bounds
.
top
=
vertex
.
y
;
if
(
vertex
.
y
>
figure
->
bounds
.
bottom
)
figure
->
bounds
.
bottom
=
vertex
.
y
;
}
static
BOOL
d2d_figure_insert_vertex
(
struct
d2d_figure
*
figure
,
size_t
idx
,
D2D1_POINT_2F
vertex
)
{
if
(
!
d2d_array_reserve
((
void
**
)
&
figure
->
vertices
,
&
figure
->
vertices_size
,
...
...
@@ -544,7 +532,7 @@ static BOOL d2d_figure_insert_vertex(struct d2d_figure *figure, size_t idx, D2D1
(
figure
->
vertex_count
-
idx
)
*
sizeof
(
*
figure
->
vertex_types
));
figure
->
vertices
[
idx
]
=
vertex
;
figure
->
vertex_types
[
idx
]
=
D2D_VERTEX_TYPE_NONE
;
d2d_
figure_update_bounds
(
figure
,
vertex
);
d2d_
rect_expand
(
&
figure
->
bounds
,
&
vertex
);
++
figure
->
vertex_count
;
return
TRUE
;
}
...
...
@@ -573,7 +561,7 @@ static BOOL d2d_figure_add_vertex(struct d2d_figure *figure, D2D1_POINT_2F verte
figure
->
vertices
[
figure
->
vertex_count
]
=
vertex
;
figure
->
vertex_types
[
figure
->
vertex_count
]
=
D2D_VERTEX_TYPE_NONE
;
d2d_
figure_update_bounds
(
figure
,
vertex
);
d2d_
rect_expand
(
&
figure
->
bounds
,
&
vertex
);
++
figure
->
vertex_count
;
return
TRUE
;
}
...
...
@@ -2756,9 +2744,34 @@ static void STDMETHODCALLTYPE d2d_rectangle_geometry_GetFactory(ID2D1RectangleGe
static
HRESULT
STDMETHODCALLTYPE
d2d_rectangle_geometry_GetBounds
(
ID2D1RectangleGeometry
*
iface
,
const
D2D1_MATRIX_3X2_F
*
transform
,
D2D1_RECT_F
*
bounds
)
{
FIXME
(
"iface %p, transform %p, bounds %p stub!
\n
"
,
iface
,
transform
,
bounds
);
struct
d2d_geometry
*
geometry
=
impl_from_ID2D1RectangleGeometry
(
iface
);
D2D1_RECT_F
*
rect
;
D2D1_POINT_2F
p
;
return
E_NOTIMPL
;
TRACE
(
"iface %p, transform %p, bounds %p.
\n
"
,
iface
,
transform
,
bounds
);
rect
=
&
geometry
->
u
.
rectangle
.
rect
;
if
(
!
transform
)
{
*
bounds
=
*
rect
;
return
S_OK
;
}
bounds
->
left
=
FLT_MAX
;
bounds
->
top
=
FLT_MAX
;
bounds
->
right
=
-
FLT_MAX
;
bounds
->
bottom
=
-
FLT_MAX
;
d2d_point_transform
(
&
p
,
transform
,
rect
->
left
,
rect
->
top
);
d2d_rect_expand
(
bounds
,
&
p
);
d2d_point_transform
(
&
p
,
transform
,
rect
->
left
,
rect
->
bottom
);
d2d_rect_expand
(
bounds
,
&
p
);
d2d_point_transform
(
&
p
,
transform
,
rect
->
right
,
rect
->
bottom
);
d2d_rect_expand
(
bounds
,
&
p
);
d2d_point_transform
(
&
p
,
transform
,
rect
->
right
,
rect
->
top
);
d2d_rect_expand
(
bounds
,
&
p
);
return
S_OK
;
}
static
HRESULT
STDMETHODCALLTYPE
d2d_rectangle_geometry_GetWidenedBounds
(
ID2D1RectangleGeometry
*
iface
,
...
...
dlls/d2d1/render_target.c
View file @
2485305b
...
...
@@ -49,18 +49,6 @@ static ID2D1Brush *d2d_draw_get_text_brush(struct d2d_draw_text_layout_ctx *cont
return
context
->
brush
;
}
static
void
d2d_rect_expand
(
D2D1_RECT_F
*
dst
,
const
D2D1_POINT_2F
*
point
)
{
if
(
point
->
x
<
dst
->
left
)
dst
->
left
=
point
->
x
;
if
(
point
->
y
<
dst
->
top
)
dst
->
top
=
point
->
y
;
if
(
point
->
x
>
dst
->
right
)
dst
->
right
=
point
->
x
;
if
(
point
->
y
>
dst
->
bottom
)
dst
->
bottom
=
point
->
y
;
}
static
void
d2d_rect_intersect
(
D2D1_RECT_F
*
dst
,
const
D2D1_RECT_F
*
src
)
{
if
(
src
->
left
>
dst
->
left
)
...
...
dlls/d2d1/tests/d2d1.c
View file @
2485305b
...
...
@@ -169,6 +169,14 @@ static BOOL compare_float(float f, float g, unsigned int ulps)
return
TRUE
;
}
static
BOOL
compare_rect
(
const
D2D1_RECT_F
*
rect
,
float
left
,
float
top
,
float
right
,
float
bottom
,
unsigned
int
ulps
)
{
return
compare_float
(
rect
->
left
,
left
,
ulps
)
&&
compare_float
(
rect
->
top
,
top
,
ulps
)
&&
compare_float
(
rect
->
right
,
right
,
ulps
)
&&
compare_float
(
rect
->
bottom
,
bottom
,
ulps
);
}
static
BOOL
compare_sha1
(
void
*
data
,
unsigned
int
pitch
,
unsigned
int
bpp
,
unsigned
int
w
,
unsigned
int
h
,
const
char
*
ref_sha1
)
{
...
...
@@ -1831,11 +1839,13 @@ static void test_path_geometry(void)
static
void
test_rectangle_geometry
(
void
)
{
ID2D1RectangleGeometry
*
geometry
;
D2D1_MATRIX_3X2_F
matrix
;
D2D1_RECT_F
rect
,
rect2
;
ID2D1Factory
*
factory
;
D2D1_POINT_2F
point
;
BOOL
contains
;
HRESULT
hr
;
BOOL
match
;
hr
=
D2D1CreateFactory
(
D2D1_FACTORY_TYPE_SINGLE_THREADED
,
&
IID_ID2D1Factory
,
NULL
,
(
void
**
)
&
factory
);
ok
(
SUCCEEDED
(
hr
),
"Failed to create factory, hr %#x.
\n
"
,
hr
);
...
...
@@ -1844,7 +1854,8 @@ static void test_rectangle_geometry(void)
hr
=
ID2D1Factory_CreateRectangleGeometry
(
factory
,
&
rect
,
&
geometry
);
ok
(
SUCCEEDED
(
hr
),
"Failed to create geometry, hr %#x.
\n
"
,
hr
);
ID2D1RectangleGeometry_GetRect
(
geometry
,
&
rect2
);
ok
(
!
memcmp
(
&
rect
,
&
rect2
,
sizeof
(
rect
)),
"Got unexpected rectangle {%.8e, %.8e, %.8e, %.8e}.
\n
"
,
match
=
compare_rect
(
&
rect2
,
0
.
0
f
,
0
.
0
f
,
0
.
0
f
,
0
.
0
f
,
0
);
ok
(
match
,
"Got unexpected rectangle {%.8e, %.8e, %.8e, %.8e}.
\n
"
,
rect2
.
left
,
rect2
.
top
,
rect2
.
right
,
rect2
.
bottom
);
ID2D1RectangleGeometry_Release
(
geometry
);
...
...
@@ -1852,7 +1863,8 @@ static void test_rectangle_geometry(void)
hr
=
ID2D1Factory_CreateRectangleGeometry
(
factory
,
&
rect
,
&
geometry
);
ok
(
SUCCEEDED
(
hr
),
"Failed to create geometry, hr %#x.
\n
"
,
hr
);
ID2D1RectangleGeometry_GetRect
(
geometry
,
&
rect2
);
ok
(
!
memcmp
(
&
rect
,
&
rect2
,
sizeof
(
rect
)),
"Got unexpected rectangle {%.8e, %.8e, %.8e, %.8e}.
\n
"
,
match
=
compare_rect
(
&
rect2
,
50
.
0
f
,
0
.
0
f
,
40
.
0
f
,
100
.
0
f
,
0
);
ok
(
match
,
"Got unexpected rectangle {%.8e, %.8e, %.8e, %.8e}.
\n
"
,
rect2
.
left
,
rect2
.
top
,
rect2
.
right
,
rect2
.
bottom
);
ID2D1RectangleGeometry_Release
(
geometry
);
...
...
@@ -1860,7 +1872,8 @@ static void test_rectangle_geometry(void)
hr
=
ID2D1Factory_CreateRectangleGeometry
(
factory
,
&
rect
,
&
geometry
);
ok
(
SUCCEEDED
(
hr
),
"Failed to create geometry, hr %#x.
\n
"
,
hr
);
ID2D1RectangleGeometry_GetRect
(
geometry
,
&
rect2
);
ok
(
!
memcmp
(
&
rect
,
&
rect2
,
sizeof
(
rect
)),
"Got unexpected rectangle {%.8e, %.8e, %.8e, %.8e}.
\n
"
,
match
=
compare_rect
(
&
rect2
,
0
.
0
f
,
100
.
0
f
,
40
.
0
f
,
50
.
0
f
,
0
);
ok
(
match
,
"Got unexpected rectangle {%.8e, %.8e, %.8e, %.8e}.
\n
"
,
rect2
.
left
,
rect2
.
top
,
rect2
.
right
,
rect2
.
bottom
);
ID2D1RectangleGeometry_Release
(
geometry
);
...
...
@@ -1868,7 +1881,8 @@ static void test_rectangle_geometry(void)
hr
=
ID2D1Factory_CreateRectangleGeometry
(
factory
,
&
rect
,
&
geometry
);
ok
(
SUCCEEDED
(
hr
),
"Failed to create geometry, hr %#x.
\n
"
,
hr
);
ID2D1RectangleGeometry_GetRect
(
geometry
,
&
rect2
);
ok
(
!
memcmp
(
&
rect
,
&
rect2
,
sizeof
(
rect
)),
"Got unexpected rectangle {%.8e, %.8e, %.8e, %.8e}.
\n
"
,
match
=
compare_rect
(
&
rect2
,
50
.
0
f
,
100
.
0
f
,
40
.
0
f
,
50
.
0
f
,
0
);
ok
(
match
,
"Got unexpected rectangle {%.8e, %.8e, %.8e, %.8e}.
\n
"
,
rect2
.
left
,
rect2
.
top
,
rect2
.
right
,
rect2
.
bottom
);
ID2D1RectangleGeometry_Release
(
geometry
);
...
...
@@ -1915,6 +1929,41 @@ static void test_rectangle_geometry(void)
ok
(
SUCCEEDED
(
hr
),
"FillContainsPoint() failed, hr %#x.
\n
"
,
hr
);
ok
(
!!
contains
,
"Got wrong hit test result %d.
\n
"
,
contains
);
/* Test GetBounds(). */
hr
=
ID2D1RectangleGeometry_GetBounds
(
geometry
,
NULL
,
&
rect
);
ok
(
SUCCEEDED
(
hr
),
"Failed to get bounds.
\n
"
);
match
=
compare_rect
(
&
rect
,
0
.
0
f
,
0
.
0
f
,
10
.
0
f
,
20
.
0
f
,
0
);
ok
(
match
,
"Got unexpected bounds {%.8e, %.8e, %.8e, %.8e}.
\n
"
,
rect
.
left
,
rect
.
top
,
rect
.
right
,
rect
.
bottom
);
set_matrix_identity
(
&
matrix
);
translate_matrix
(
&
matrix
,
20
.
0
f
,
30
.
0
f
);
scale_matrix
(
&
matrix
,
3
.
0
f
,
2
.
0
f
);
rotate_matrix
(
&
matrix
,
M_PI
/
-
5
.
0
f
);
hr
=
ID2D1RectangleGeometry_GetBounds
(
geometry
,
&
matrix
,
&
rect
);
ok
(
SUCCEEDED
(
hr
),
"Failed to get bounds.
\n
"
);
match
=
compare_rect
(
&
rect
,
2.00000000e+01
f
,
1.82442951e+01
f
,
7.95376282e+01
f
,
6.23606796e+01
f
,
0
);
ok
(
match
,
"Got unexpected bounds {%.8e, %.8e, %.8e, %.8e}.
\n
"
,
rect
.
left
,
rect
.
top
,
rect
.
right
,
rect
.
bottom
);
set_matrix_identity
(
&
matrix
);
translate_matrix
(
&
matrix
,
25
.
0
f
,
15
.
0
f
);
scale_matrix
(
&
matrix
,
0
.
0
f
,
2
.
0
f
);
hr
=
ID2D1RectangleGeometry_GetBounds
(
geometry
,
&
matrix
,
&
rect
);
ok
(
SUCCEEDED
(
hr
),
"Failed to get bounds.
\n
"
);
match
=
compare_rect
(
&
rect
,
25
.
0
f
,
15
.
0
f
,
25
.
0
f
,
55
.
0
f
,
0
);
ok
(
match
,
"Got unexpected bounds {%.8e, %.8e, %.8e, %.8e}.
\n
"
,
rect
.
left
,
rect
.
top
,
rect
.
right
,
rect
.
bottom
);
set_matrix_identity
(
&
matrix
);
translate_matrix
(
&
matrix
,
30
.
0
f
,
45
.
0
f
);
scale_matrix
(
&
matrix
,
0
.
5
f
,
0
.
0
f
);
hr
=
ID2D1RectangleGeometry_GetBounds
(
geometry
,
&
matrix
,
&
rect
);
ok
(
SUCCEEDED
(
hr
),
"Failed to get bounds.
\n
"
);
match
=
compare_rect
(
&
rect
,
30
.
0
f
,
45
.
0
f
,
35
.
0
f
,
45
.
0
f
,
0
);
ok
(
match
,
"Got unexpected bounds {%.8e, %.8e, %.8e, %.8e}.
\n
"
,
rect
.
left
,
rect
.
top
,
rect
.
right
,
rect
.
bottom
);
ID2D1RectangleGeometry_Release
(
geometry
);
ID2D1Factory_Release
(
factory
);
...
...
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