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
da9bc7cd
Commit
da9bc7cd
authored
Aug 19, 2019
by
Huw Davies
Committed by
Alexandre Julliard
Aug 19, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
riched20: Move release_font_cache() further up the file.
Signed-off-by:
Huw Davies
<
huw@codeweavers.com
>
Signed-off-by:
Alexandre Julliard
<
julliard@winehq.org
>
parent
b9e1ed06
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
55 additions
and
50 deletions
+55
-50
style.c
dlls/riched20/style.c
+55
-50
No files found.
dlls/riched20/style.c
View file @
da9bc7cd
...
@@ -357,64 +357,69 @@ static BOOL ME_IsFontEqual(const LOGFONTW *p1, const LOGFONTW *p2)
...
@@ -357,64 +357,69 @@ static BOOL ME_IsFontEqual(const LOGFONTW *p1, const LOGFONTW *p2)
return
TRUE
;
return
TRUE
;
}
}
HFONT
ME_SelectStyleFont
(
ME_Context
*
c
,
ME_Style
*
s
)
static
void
release_font_cache
(
ME_FontCacheItem
*
item
)
{
{
HFONT
hOldFont
;
if
(
item
->
nRefs
>
0
)
LOGFONTW
lf
;
int
i
,
nEmpty
,
nAge
=
0x7FFFFFFF
;
ME_FontCacheItem
*
item
;
assert
(
s
);
ME_LogFontFromStyle
(
c
,
&
lf
,
s
);
for
(
i
=
0
;
i
<
HFONT_CACHE_SIZE
;
i
++
)
c
->
editor
->
pFontCache
[
i
].
nAge
++
;
for
(
i
=
0
,
nEmpty
=-
1
,
nAge
=
0
;
i
<
HFONT_CACHE_SIZE
;
i
++
)
{
item
=
&
c
->
editor
->
pFontCache
[
i
];
if
(
!
item
->
nRefs
)
{
{
if
(
item
->
nAge
>
nAge
)
item
->
nRefs
--
;
nEmpty
=
i
,
nAge
=
item
->
nAge
;
item
->
nAge
=
0
;
}
if
(
item
->
hFont
&&
ME_IsFontEqual
(
&
item
->
lfSpecs
,
&
lf
))
break
;
}
if
(
i
<
HFONT_CACHE_SIZE
)
/* found */
{
item
=
&
c
->
editor
->
pFontCache
[
i
];
TRACE_
(
richedit_style
)(
"font reused %d
\n
"
,
i
);
item
->
nRefs
++
;
}
else
{
item
=
&
c
->
editor
->
pFontCache
[
nEmpty
];
/* this legal even when nEmpty == -1, as we don't dereference it */
assert
(
nEmpty
!=
-
1
);
/* otherwise we leak cache entries or get too many fonts at once*/
if
(
item
->
hFont
)
{
TRACE_
(
richedit_style
)(
"font deleted %d
\n
"
,
nEmpty
);
DeleteObject
(
item
->
hFont
);
item
->
hFont
=
NULL
;
}
}
item
->
hFont
=
CreateFontIndirectW
(
&
lf
);
TRACE_
(
richedit_style
)(
"font created %d
\n
"
,
nEmpty
);
item
->
nRefs
=
1
;
item
->
lfSpecs
=
lf
;
}
s
->
font_cache
=
item
;
hOldFont
=
SelectObject
(
c
->
hDC
,
item
->
hFont
);
/* should be cached too, maybe ? */
GetTextMetricsW
(
c
->
hDC
,
&
s
->
tm
);
return
hOldFont
;
}
}
static
void
release_font_cache
(
ME_FontCacheItem
*
item
)
HFONT
ME_SelectStyleFont
(
ME_Context
*
c
,
ME_Style
*
s
)
{
{
if
(
item
->
nRefs
>
0
)
HFONT
old_font
;
LOGFONTW
lf
;
int
i
,
empty
,
age
=
0x7FFFFFFF
;
ME_FontCacheItem
*
item
;
assert
(
s
);
ME_LogFontFromStyle
(
c
,
&
lf
,
s
);
for
(
i
=
0
;
i
<
HFONT_CACHE_SIZE
;
i
++
)
c
->
editor
->
pFontCache
[
i
].
nAge
++
;
for
(
i
=
0
,
empty
=
-
1
,
age
=
0
;
i
<
HFONT_CACHE_SIZE
;
i
++
)
{
{
item
->
nRefs
--
;
item
=
&
c
->
editor
->
pFontCache
[
i
];
item
->
nAge
=
0
;
if
(
!
item
->
nRefs
)
{
if
(
item
->
nAge
>
age
)
{
empty
=
i
;
age
=
item
->
nAge
;
}
}
if
(
item
->
hFont
&&
ME_IsFontEqual
(
&
item
->
lfSpecs
,
&
lf
))
break
;
}
if
(
i
<
HFONT_CACHE_SIZE
)
/* found */
{
item
=
&
c
->
editor
->
pFontCache
[
i
];
TRACE_
(
richedit_style
)(
"font reused %d
\n
"
,
i
);
item
->
nRefs
++
;
}
else
{
assert
(
empty
!=
-
1
);
item
=
&
c
->
editor
->
pFontCache
[
empty
];
if
(
item
->
hFont
)
{
TRACE_
(
richedit_style
)(
"font deleted %d
\n
"
,
empty
);
DeleteObject
(
item
->
hFont
);
item
->
hFont
=
NULL
;
}
item
->
hFont
=
CreateFontIndirectW
(
&
lf
);
TRACE_
(
richedit_style
)(
"font created %d
\n
"
,
empty
);
item
->
nRefs
=
1
;
item
->
lfSpecs
=
lf
;
}
}
s
->
font_cache
=
item
;
old_font
=
SelectObject
(
c
->
hDC
,
item
->
hFont
);
GetTextMetricsW
(
c
->
hDC
,
&
s
->
tm
);
return
old_font
;
}
}
void
ME_UnselectStyleFont
(
ME_Context
*
c
,
ME_Style
*
s
,
HFONT
hOldFont
)
void
ME_UnselectStyleFont
(
ME_Context
*
c
,
ME_Style
*
s
,
HFONT
hOldFont
)
...
...
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