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
1315098a
Commit
1315098a
authored
May 14, 2019
by
Nikolay Sivov
Committed by
Alexandre Julliard
May 14, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
dwrite/layout: Use array allocation helper for line metrics.
Signed-off-by:
Nikolay Sivov
<
nsivov@codeweavers.com
>
Signed-off-by:
Alexandre Julliard
<
julliard@winehq.org
>
parent
0a3aef62
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
50 additions
and
64 deletions
+50
-64
layout.c
dlls/dwrite/layout.c
+50
-64
No files found.
dlls/dwrite/layout.c
View file @
1315098a
...
...
@@ -227,9 +227,11 @@ struct layout_cluster {
UINT32
position
;
/* relative to run, first cluster has 0 position */
};
struct
layout_line
{
FLOAT
height
;
/* height based on content */
FLOAT
baseline
;
/* baseline based on content */
struct
layout_line
{
float
height
;
/* height based on content */
float
baseline
;
/* baseline based on content */
DWRITE_LINE_METRICS1
metrics
;
};
enum
layout_recompute_mask
{
...
...
@@ -276,8 +278,7 @@ struct dwrite_textlayout {
FLOAT
minwidth
;
struct
layout_line
*
lines
;
DWRITE_LINE_METRICS1
*
linemetrics
;
UINT32
line_alloc
;
size_t
lines_size
;
DWRITE_TEXT_METRICS1
metrics
;
DWRITE_OVERHANG_METRICS
overhangs
;
...
...
@@ -1364,16 +1365,16 @@ static void layout_apply_line_spacing(struct dwrite_textlayout *layout, UINT32 l
switch
(
layout
->
format
.
spacing
.
method
)
{
case
DWRITE_LINE_SPACING_METHOD_DEFAULT
:
layout
->
line
metrics
[
line
]
.
height
=
layout
->
lines
[
line
].
height
;
layout
->
line
metrics
[
line
]
.
baseline
=
layout
->
lines
[
line
].
baseline
;
layout
->
line
s
[
line
].
metrics
.
height
=
layout
->
lines
[
line
].
height
;
layout
->
line
s
[
line
].
metrics
.
baseline
=
layout
->
lines
[
line
].
baseline
;
break
;
case
DWRITE_LINE_SPACING_METHOD_UNIFORM
:
layout
->
line
metrics
[
line
]
.
height
=
layout
->
format
.
spacing
.
height
;
layout
->
line
metrics
[
line
]
.
baseline
=
layout
->
format
.
spacing
.
baseline
;
layout
->
line
s
[
line
].
metrics
.
height
=
layout
->
format
.
spacing
.
height
;
layout
->
line
s
[
line
].
metrics
.
baseline
=
layout
->
format
.
spacing
.
baseline
;
break
;
case
DWRITE_LINE_SPACING_METHOD_PROPORTIONAL
:
layout
->
line
metrics
[
line
]
.
height
=
layout
->
lines
[
line
].
height
*
layout
->
format
.
spacing
.
height
;
layout
->
line
metrics
[
line
]
.
baseline
=
layout
->
lines
[
line
].
baseline
*
layout
->
format
.
spacing
.
baseline
;
layout
->
line
s
[
line
].
metrics
.
height
=
layout
->
lines
[
line
].
height
*
layout
->
format
.
spacing
.
height
;
layout
->
line
s
[
line
].
metrics
.
baseline
=
layout
->
lines
[
line
].
baseline
*
layout
->
format
.
spacing
.
baseline
;
break
;
default:
ERR
(
"Unknown spacing method %u
\n
"
,
layout
->
format
.
spacing
.
method
);
...
...
@@ -1382,37 +1383,15 @@ static void layout_apply_line_spacing(struct dwrite_textlayout *layout, UINT32 l
static
HRESULT
layout_set_line_metrics
(
struct
dwrite_textlayout
*
layout
,
DWRITE_LINE_METRICS1
*
metrics
)
{
UINT32
i
=
layout
->
metrics
.
lineCount
;
if
(
!
layout
->
line_alloc
)
{
layout
->
line_alloc
=
5
;
layout
->
linemetrics
=
heap_calloc
(
layout
->
line_alloc
,
sizeof
(
*
layout
->
linemetrics
));
layout
->
lines
=
heap_calloc
(
layout
->
line_alloc
,
sizeof
(
*
layout
->
lines
));
if
(
!
layout
->
linemetrics
||
!
layout
->
lines
)
{
heap_free
(
layout
->
linemetrics
);
heap_free
(
layout
->
lines
);
layout
->
linemetrics
=
NULL
;
layout
->
lines
=
NULL
;
return
E_OUTOFMEMORY
;
}
}
size_t
i
=
layout
->
metrics
.
lineCount
;
if
(
layout
->
metrics
.
lineCount
==
layout
->
line_alloc
)
{
DWRITE_LINE_METRICS1
*
metrics
;
struct
layout_line
*
lines
;
if
((
metrics
=
heap_realloc
(
layout
->
linemetrics
,
layout
->
line_alloc
*
2
*
sizeof
(
*
layout
->
linemetrics
))))
layout
->
linemetrics
=
metrics
;
if
((
lines
=
heap_realloc
(
layout
->
lines
,
layout
->
line_alloc
*
2
*
sizeof
(
*
layout
->
lines
))))
layout
->
lines
=
lines
;
if
(
!
metrics
||
!
lines
)
if
(
!
dwrite_array_reserve
((
void
**
)
&
layout
->
lines
,
&
layout
->
lines_size
,
layout
->
metrics
.
lineCount
+
1
,
sizeof
(
*
layout
->
lines
)))
{
return
E_OUTOFMEMORY
;
layout
->
line_alloc
*=
2
;
}
layout
->
line
metrics
[
i
]
=
*
metrics
;
layout
->
line
s
[
i
].
metrics
=
*
metrics
;
layout
->
lines
[
i
].
height
=
metrics
->
height
;
layout
->
lines
[
i
].
baseline
=
metrics
->
baseline
;
...
...
@@ -1674,8 +1653,9 @@ static void layout_apply_par_alignment(struct dwrite_textlayout *layout)
erun
=
layout_get_next_erun
(
layout
,
NULL
);
inrun
=
layout_get_next_inline_run
(
layout
,
NULL
);
for
(
line
=
0
;
line
<
layout
->
metrics
.
lineCount
;
line
++
)
{
FLOAT
pos_y
=
origin_y
+
layout
->
linemetrics
[
line
].
baseline
;
for
(
line
=
0
;
line
<
layout
->
metrics
.
lineCount
;
line
++
)
{
float
pos_y
=
origin_y
+
layout
->
lines
[
line
].
metrics
.
baseline
;
while
(
erun
&&
erun
->
line
==
line
)
{
erun
->
origin
.
y
=
pos_y
;
...
...
@@ -1687,7 +1667,7 @@ static void layout_apply_par_alignment(struct dwrite_textlayout *layout)
inrun
=
layout_get_next_inline_run
(
layout
,
inrun
);
}
origin_y
+=
layout
->
line
metrics
[
line
]
.
height
;
origin_y
+=
layout
->
line
s
[
line
].
metrics
.
height
;
}
}
...
...
@@ -1992,8 +1972,9 @@ static void layout_set_line_positions(struct dwrite_textlayout *layout)
erun
=
layout_get_next_erun
(
layout
,
NULL
);
inrun
=
layout_get_next_inline_run
(
layout
,
NULL
);
for
(
line
=
0
,
origin_y
=
0
.
0
f
;
line
<
layout
->
metrics
.
lineCount
;
line
++
)
{
FLOAT
pos_y
=
origin_y
+
layout
->
linemetrics
[
line
].
baseline
;
for
(
line
=
0
,
origin_y
=
0
.
0
f
;
line
<
layout
->
metrics
.
lineCount
;
line
++
)
{
float
pos_y
=
origin_y
+
layout
->
lines
[
line
].
metrics
.
baseline
;
/* For all runs on this line */
while
(
erun
&&
erun
->
line
==
line
)
{
...
...
@@ -2007,7 +1988,7 @@ static void layout_set_line_positions(struct dwrite_textlayout *layout)
inrun
=
layout_get_next_inline_run
(
layout
,
inrun
);
}
origin_y
+=
layout
->
line
metrics
[
line
]
.
height
;
origin_y
+=
layout
->
line
s
[
line
].
metrics
.
height
;
}
layout
->
metrics
.
height
=
origin_y
;
...
...
@@ -2862,7 +2843,6 @@ static ULONG WINAPI dwritetextlayout_Release(IDWriteTextLayout3 *iface)
heap_free
(
This
->
actual_breakpoints
);
heap_free
(
This
->
clustermetrics
);
heap_free
(
This
->
clusters
);
heap_free
(
This
->
linemetrics
);
heap_free
(
This
->
lines
);
heap_free
(
This
->
str
);
heap_free
(
This
);
...
...
@@ -3574,23 +3554,25 @@ static HRESULT WINAPI dwritetextlayout_Draw(IDWriteTextLayout3 *iface,
static
HRESULT
WINAPI
dwritetextlayout_GetLineMetrics
(
IDWriteTextLayout3
*
iface
,
DWRITE_LINE_METRICS
*
metrics
,
UINT32
max_count
,
UINT32
*
count
)
{
struct
dwrite_textlayout
*
This
=
impl_from_IDWriteTextLayout3
(
iface
);
struct
dwrite_textlayout
*
layout
=
impl_from_IDWriteTextLayout3
(
iface
);
unsigned
int
line_count
;
HRESULT
hr
;
size_t
i
;
TRACE
(
"
(%p)->(%p %u %p)
\n
"
,
This
,
metrics
,
max_count
,
count
);
TRACE
(
"
%p, %p, %u, %p.
\n
"
,
iface
,
metrics
,
max_count
,
count
);
hr
=
layout_compute_effective_runs
(
This
);
if
(
FAILED
(
hr
))
if
(
FAILED
(
hr
=
layout_compute_effective_runs
(
layout
)))
return
hr
;
if
(
metrics
)
{
UINT32
i
,
c
=
min
(
max_count
,
This
->
metrics
.
lineCount
);
for
(
i
=
0
;
i
<
c
;
i
++
)
memcpy
(
metrics
+
i
,
This
->
linemetrics
+
i
,
sizeof
(
*
metrics
));
if
(
metrics
)
{
line_count
=
min
(
max_count
,
layout
->
metrics
.
lineCount
);
for
(
i
=
0
;
i
<
line_count
;
++
i
)
memcpy
(
&
metrics
[
i
],
&
layout
->
lines
[
i
].
metrics
,
sizeof
(
*
metrics
));
}
*
count
=
This
->
metrics
.
lineCount
;
return
max_count
>=
This
->
metrics
.
lineCount
?
S_OK
:
E_NOT_SUFFICIENT_BUFFER
;
*
count
=
layout
->
metrics
.
lineCount
;
return
max_count
>=
layout
->
metrics
.
lineCount
?
S_OK
:
E_NOT_SUFFICIENT_BUFFER
;
}
static
HRESULT
layout_update_metrics
(
struct
dwrite_textlayout
*
layout
)
...
...
@@ -4061,20 +4043,25 @@ static HRESULT WINAPI dwritetextlayout3_GetLineSpacing(IDWriteTextLayout3 *iface
static
HRESULT
WINAPI
dwritetextlayout3_GetLineMetrics
(
IDWriteTextLayout3
*
iface
,
DWRITE_LINE_METRICS1
*
metrics
,
UINT32
max_count
,
UINT32
*
count
)
{
struct
dwrite_textlayout
*
This
=
impl_from_IDWriteTextLayout3
(
iface
);
struct
dwrite_textlayout
*
layout
=
impl_from_IDWriteTextLayout3
(
iface
);
unsigned
int
line_count
;
HRESULT
hr
;
size_t
i
;
TRACE
(
"
(%p)->(%p %u %p)
\n
"
,
This
,
metrics
,
max_count
,
count
);
TRACE
(
"
%p, %p, %u, %p.
\n
"
,
iface
,
metrics
,
max_count
,
count
);
hr
=
layout_compute_effective_runs
(
This
);
if
(
FAILED
(
hr
))
if
(
FAILED
(
hr
=
layout_compute_effective_runs
(
layout
)))
return
hr
;
if
(
metrics
)
memcpy
(
metrics
,
This
->
linemetrics
,
sizeof
(
*
metrics
)
*
min
(
max_count
,
This
->
metrics
.
lineCount
));
{
line_count
=
min
(
max_count
,
layout
->
metrics
.
lineCount
);
for
(
i
=
0
;
i
<
line_count
;
++
i
)
metrics
[
i
]
=
layout
->
lines
[
i
].
metrics
;
}
*
count
=
This
->
metrics
.
lineCount
;
return
max_count
>=
This
->
metrics
.
lineCount
?
S_OK
:
E_NOT_SUFFICIENT_BUFFER
;
*
count
=
layout
->
metrics
.
lineCount
;
return
max_count
>=
layout
->
metrics
.
lineCount
?
S_OK
:
E_NOT_SUFFICIENT_BUFFER
;
}
static
const
IDWriteTextLayout3Vtbl
dwritetextlayoutvtbl
=
{
...
...
@@ -4978,9 +4965,8 @@ static HRESULT init_textlayout(const struct textlayout_desc *desc, struct dwrite
layout
->
cluster_count
=
0
;
layout
->
clustermetrics
=
NULL
;
layout
->
clusters
=
NULL
;
layout
->
linemetrics
=
NULL
;
layout
->
lines
=
NULL
;
layout
->
line
_alloc
=
0
;
layout
->
line
s_size
=
0
;
layout
->
minwidth
=
0
.
0
f
;
list_init
(
&
layout
->
eruns
);
list_init
(
&
layout
->
inlineobjects
);
...
...
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