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
89d074a3
Commit
89d074a3
authored
Mar 30, 2017
by
Nikolay Sivov
Committed by
Alexandre Julliard
Mar 30, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
dwrite: Allocate glyph buffer once per run rendering pass.
Signed-off-by:
Nikolay Sivov
<
nsivov@codeweavers.com
>
Signed-off-by:
Alexandre Julliard
<
julliard@winehq.org
>
parent
a46b81a4
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
29 additions
and
16 deletions
+29
-16
font.c
dlls/dwrite/font.c
+29
-16
No files found.
dlls/dwrite/font.c
View file @
89d074a3
...
...
@@ -180,6 +180,7 @@ struct dwrite_glyphrunanalysis {
UINT8
flags
;
RECT
bounds
;
BYTE
*
bitmap
;
UINT32
max_glyph_bitmap_size
;
};
struct
dwrite_colorglyphenum
{
...
...
@@ -4797,6 +4798,12 @@ static BOOL is_natural_rendering_mode(DWRITE_RENDERING_MODE1 mode)
}
}
static
UINT32
get_glyph_bitmap_pitch
(
DWRITE_TEXTURE_TYPE
type
,
INT
width
)
{
return
type
==
DWRITE_TEXTURE_CLEARTYPE_3x1
?
(
width
+
3
)
/
4
*
4
:
((
width
+
31
)
>>
5
)
<<
2
;
}
static
void
glyphrunanalysis_get_texturebounds
(
struct
dwrite_glyphrunanalysis
*
analysis
,
RECT
*
bounds
)
{
struct
dwrite_glyphbitmap
glyph_bitmap
;
...
...
@@ -4836,10 +4843,16 @@ static void glyphrunanalysis_get_texturebounds(struct dwrite_glyphrunanalysis *a
const
D2D_POINT_2F
*
ascenderoffset
=
analysis
->
ascenderoffsets
?
analysis
->
ascenderoffsets
+
i
:
NULL
;
const
D2D_POINT_2F
*
advance
=
analysis
->
advances
+
i
;
RECT
*
bbox
=
&
glyph_bitmap
.
bbox
;
UINT32
bitmap_size
;
glyph_bitmap
.
index
=
analysis
->
run
.
glyphIndices
[
i
];
freetype_get_glyph_bbox
(
&
glyph_bitmap
);
bitmap_size
=
get_glyph_bitmap_pitch
(
analysis
->
texture_type
,
bbox
->
right
-
bbox
->
left
)
*
(
bbox
->
bottom
-
bbox
->
top
);
if
(
bitmap_size
>
analysis
->
max_glyph_bitmap_size
)
analysis
->
max_glyph_bitmap_size
=
bitmap_size
;
if
(
is_rtl
)
OffsetRect
(
bbox
,
origin
.
x
+
advance
->
x
,
origin
.
y
+
advance
->
y
);
else
...
...
@@ -4899,7 +4912,7 @@ static inline BYTE *get_pixel_ptr(BYTE *ptr, DWRITE_TEXTURE_TYPE type, const REC
runbounds
->
left
-
bounds
->
left
;
}
static
HRESULT
glyphrunanalysis_render
(
struct
dwrite_glyphrunanalysis
*
analysis
,
DWRITE_TEXTURE_TYPE
type
)
static
HRESULT
glyphrunanalysis_render
(
struct
dwrite_glyphrunanalysis
*
analysis
)
{
static
const
BYTE
masks
[
8
]
=
{
0x80
,
0x40
,
0x20
,
0x10
,
0x08
,
0x04
,
0x02
,
0x01
};
struct
dwrite_glyphbitmap
glyph_bitmap
;
...
...
@@ -4917,11 +4930,11 @@ static HRESULT glyphrunanalysis_render(struct dwrite_glyphrunanalysis *analysis,
}
size
=
(
analysis
->
bounds
.
right
-
analysis
->
bounds
.
left
)
*
(
analysis
->
bounds
.
bottom
-
analysis
->
bounds
.
top
);
if
(
type
==
DWRITE_TEXTURE_CLEARTYPE_3x1
)
if
(
analysis
->
texture_
type
==
DWRITE_TEXTURE_CLEARTYPE_3x1
)
size
*=
3
;
if
(
!
(
analysis
->
bitmap
=
heap_alloc_zero
(
size
)))
{
WARN
(
"Failed to allocate run bitmap, %s, type %s.
\n
"
,
wine_dbgstr_rect
(
&
analysis
->
bounds
),
type
==
DWRITE_TEXTURE_CLEARTYPE_3x1
?
"3x1"
:
"1x1"
);
analysis
->
texture_
type
==
DWRITE_TEXTURE_CLEARTYPE_3x1
?
"3x1"
:
"1x1"
);
IDWriteFontFace4_Release
(
fontface
);
return
E_OUTOFMEMORY
;
}
...
...
@@ -4933,17 +4946,22 @@ static HRESULT glyphrunanalysis_render(struct dwrite_glyphrunanalysis *analysis,
glyph_bitmap
.
fontface
=
fontface
;
glyph_bitmap
.
emsize
=
analysis
->
run
.
fontEmSize
*
analysis
->
ppdip
;
glyph_bitmap
.
nohint
=
is_natural_rendering_mode
(
analysis
->
rendering_mode
);
glyph_bitmap
.
type
=
type
;
glyph_bitmap
.
type
=
analysis
->
texture_
type
;
if
(
analysis
->
flags
&
RUNANALYSIS_USE_TRANSFORM
)
glyph_bitmap
.
m
=
&
analysis
->
m
;
if
(
!
(
glyph_bitmap
.
buf
=
heap_alloc
(
analysis
->
max_glyph_bitmap_size
)))
{
IDWriteFontFace4_Release
(
fontface
);
return
E_OUTOFMEMORY
;
}
bbox
=
&
glyph_bitmap
.
bbox
;
for
(
i
=
0
;
i
<
analysis
->
run
.
glyphCount
;
i
++
)
{
const
D2D_POINT_2F
*
advanceoffset
=
analysis
->
advanceoffsets
?
analysis
->
advanceoffsets
+
i
:
NULL
;
const
D2D_POINT_2F
*
ascenderoffset
=
analysis
->
ascenderoffsets
?
analysis
->
ascenderoffsets
+
i
:
NULL
;
const
D2D_POINT_2F
*
advance
=
analysis
->
advances
+
i
;
BYTE
*
src
=
glyph_bitmap
.
buf
,
*
dst
;
int
x
,
y
,
width
,
height
;
BYTE
*
src
,
*
dst
;
BOOL
is_1bpp
;
glyph_bitmap
.
index
=
analysis
->
run
.
glyphIndices
[
i
];
...
...
@@ -4958,12 +4976,8 @@ static HRESULT glyphrunanalysis_render(struct dwrite_glyphrunanalysis *analysis,
width
=
bbox
->
right
-
bbox
->
left
;
height
=
bbox
->
bottom
-
bbox
->
top
;
if
(
type
==
DWRITE_TEXTURE_CLEARTYPE_3x1
)
glyph_bitmap
.
pitch
=
(
width
+
3
)
/
4
*
4
;
else
glyph_bitmap
.
pitch
=
((
width
+
31
)
>>
5
)
<<
2
;
glyph_bitmap
.
buf
=
src
=
heap_alloc_zero
(
height
*
glyph_bitmap
.
pitch
);
glyph_bitmap
.
pitch
=
get_glyph_bitmap_pitch
(
analysis
->
texture_type
,
width
);
memset
(
src
,
0
,
height
*
glyph_bitmap
.
pitch
);
is_1bpp
=
freetype_get_glyph_bitmap
(
&
glyph_bitmap
);
if
(
is_rtl
)
...
...
@@ -4979,11 +4993,11 @@ static HRESULT glyphrunanalysis_render(struct dwrite_glyphrunanalysis *analysis,
OffsetRect
(
bbox
,
analysis
->
m
.
dx
,
analysis
->
m
.
dy
);
/* blit to analysis bitmap */
dst
=
get_pixel_ptr
(
analysis
->
bitmap
,
type
,
bbox
,
&
analysis
->
bounds
);
dst
=
get_pixel_ptr
(
analysis
->
bitmap
,
analysis
->
texture_
type
,
bbox
,
&
analysis
->
bounds
);
if
(
is_1bpp
)
{
/* convert 1bpp to 8bpp/24bpp */
if
(
type
==
DWRITE_TEXTURE_CLEARTYPE_3x1
)
{
if
(
analysis
->
texture_
type
==
DWRITE_TEXTURE_CLEARTYPE_3x1
)
{
for
(
y
=
0
;
y
<
height
;
y
++
)
{
for
(
x
=
0
;
x
<
width
;
x
++
)
if
(
src
[
x
/
8
]
&
masks
[
x
%
8
])
...
...
@@ -5012,11 +5026,10 @@ static HRESULT glyphrunanalysis_render(struct dwrite_glyphrunanalysis *analysis,
}
}
heap_free
(
glyph_bitmap
.
buf
);
origin
.
x
+=
advance
->
x
;
origin
.
y
+=
advance
->
y
;
}
heap_free
(
glyph_bitmap
.
buf
);
IDWriteFontFace4_Release
(
fontface
);
...
...
@@ -5076,7 +5089,7 @@ static HRESULT WINAPI glyphrunanalysis_CreateAlphaTexture(IDWriteGlyphRunAnalysi
if
(
!
(
This
->
flags
&
RUNANALYSIS_BITMAP_READY
))
{
HRESULT
hr
;
if
(
FAILED
(
hr
=
glyphrunanalysis_render
(
This
,
type
)))
if
(
FAILED
(
hr
=
glyphrunanalysis_render
(
This
)))
return
hr
;
}
...
...
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