Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell8_jdk
提交
07db24f9
D
dragonwell8_jdk
项目概览
openanolis
/
dragonwell8_jdk
通知
4
Star
2
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
D
dragonwell8_jdk
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
07db24f9
编写于
6月 17, 2013
作者:
P
prr
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
8015334: Memory leak when kerning is used on Windows.
Reviewed-by: srl, bae
上级
261d8b80
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
90 addition
and
22 deletion
+90
-22
src/share/native/sun/font/layout/KernTable.cpp
src/share/native/sun/font/layout/KernTable.cpp
+24
-20
src/share/native/sun/font/layout/KernTable.h
src/share/native/sun/font/layout/KernTable.h
+0
-1
src/share/native/sun/font/layout/LayoutEngine.cpp
src/share/native/sun/font/layout/LayoutEngine.cpp
+0
-1
test/java/awt/font/TextLayout/KerningLeak.java
test/java/awt/font/TextLayout/KerningLeak.java
+66
-0
未找到文件。
src/share/native/sun/font/layout/KernTable.cpp
浏览文件 @
07db24f9
...
@@ -96,7 +96,7 @@ LE_CORRECT_SIZE(KernTableHeader, KERN_TABLE_HEADER_SIZE)
...
@@ -96,7 +96,7 @@ LE_CORRECT_SIZE(KernTableHeader, KERN_TABLE_HEADER_SIZE)
* TODO: respect header flags
* TODO: respect header flags
*/
*/
KernTable
::
KernTable
(
const
LETableReference
&
base
,
LEErrorCode
&
success
)
KernTable
::
KernTable
(
const
LETableReference
&
base
,
LEErrorCode
&
success
)
:
pairs
(),
pairs
Swapped
(
NULL
),
fTable
(
base
)
:
pairsSwapped
(
NULL
),
fTable
(
base
)
{
{
if
(
LE_FAILURE
(
success
)
||
(
fTable
.
isEmpty
()))
{
if
(
LE_FAILURE
(
success
)
||
(
fTable
.
isEmpty
()))
{
#if DEBUG
#if DEBUG
...
@@ -143,32 +143,36 @@ KernTable::KernTable(const LETableReference& base, LEErrorCode &success)
...
@@ -143,32 +143,36 @@ KernTable::KernTable(const LETableReference& base, LEErrorCode &success)
#endif
#endif
if
(
LE_SUCCESS
(
success
)
&&
nPairs
>
0
)
{
if
(
LE_SUCCESS
(
success
)
&&
nPairs
>
0
)
{
// pairs is an instance member, and table is on the stack.
// pairsSwapped is an instance member, and table is on the stack.
// set 'pairs' based on table.getAlias(). This will range check it.
// set 'pairsSwapped' based on table.getAlias(). This will range check it.
pairs
=
LEReferenceToArrayOf
<
PairInfo
>
(
fTable
,
// based on overall table
pairsSwapped
=
(
PairInfo
*
)(
fTable
.
getFont
()
->
getKernPairs
());
success
,
if
(
pairsSwapped
==
NULL
)
{
(
const
PairInfo
*
)
table
.
getAlias
(),
// subtable 0 + ..
LEReferenceToArrayOf
<
PairInfo
>
pairs
=
KERN_SUBTABLE_0_HEADER_SIZE
,
// .. offset of header size
LEReferenceToArrayOf
<
PairInfo
>
(
fTable
,
// based on overall table
nPairs
);
// count
success
,
}
(
const
PairInfo
*
)
table
.
getAlias
(),
// subtable 0 + ..
if
(
LE_SUCCESS
(
success
)
&&
pairs
.
isValid
())
{
KERN_SUBTABLE_0_HEADER_SIZE
,
// .. offset of header size
pairsSwapped
=
(
PairInfo
*
)(
malloc
(
nPairs
*
sizeof
(
PairInfo
)));
nPairs
);
// count
PairInfo
*
p
=
(
PairInfo
*
)
pairsSwapped
;
if
(
LE_SUCCESS
(
success
)
&&
pairs
.
isValid
())
{
for
(
int
i
=
0
;
LE_SUCCESS
(
success
)
&&
i
<
nPairs
;
i
++
,
p
++
)
{
pairsSwapped
=
(
PairInfo
*
)(
malloc
(
nPairs
*
sizeof
(
PairInfo
)));
memcpy
(
p
,
pairs
.
getAlias
(
i
,
success
),
KERN_PAIRINFO_SIZE
);
PairInfo
*
p
=
(
PairInfo
*
)
pairsSwapped
;
p
->
key
=
SWAPL
(
p
->
key
);
for
(
int
i
=
0
;
LE_SUCCESS
(
success
)
&&
i
<
nPairs
;
i
++
,
p
++
)
{
memcpy
(
p
,
pairs
.
getAlias
(
i
,
success
),
KERN_PAIRINFO_SIZE
);
p
->
key
=
SWAPL
(
p
->
key
);
}
fTable
.
getFont
()
->
setKernPairs
((
void
*
)
pairsSwapped
);
// store it
}
}
fTable
.
getFont
()
->
setKernPairs
((
void
*
)
pairsSwapped
);
// store it
}
}
}
#if 0
#if 0
fprintf(stderr, "coverage: %0.4x nPairs: %d pairs %p\n", coverage, nPairs, pairs
.getAlias()
);
fprintf(stderr, "coverage: %0.4x nPairs: %d pairs %p\n", coverage, nPairs, pairs
Swapped
);
fprintf(stderr, " searchRange: %d entrySelector: %d rangeShift: %d\n", searchRange, entrySelector, rangeShift);
fprintf(stderr, " searchRange: %d entrySelector: %d rangeShift: %d\n", searchRange, entrySelector, rangeShift);
fprintf(stderr, "[[ ignored font table entries: range %d selector %d shift %d ]]\n", SWAPW(table->searchRange), SWAPW(table->entrySelector), SWAPW(table->rangeShift));
fprintf(stderr, "[[ ignored font table entries: range %d selector %d shift %d ]]\n", SWAPW(table->searchRange), SWAPW(table->entrySelector), SWAPW(table->rangeShift));
#endif
#endif
#if DEBUG
#if DEBUG
fprintf
(
stderr
,
"coverage: %0.4x nPairs: %d pairs 0x%x
\n
"
,
coverage
,
nPairs
,
pairs
);
fprintf
(
stderr
,
"coverage: %0.4x nPairs: %d pairs 0x%x
\n
"
,
coverage
,
nPairs
,
pairs
Swapped
);
fprintf
(
stderr
,
fprintf
(
stderr
,
" searchRange(pairs): %d entrySelector: %d rangeShift(pairs): %d
\n
"
,
" searchRange(pairs): %d entrySelector: %d rangeShift(pairs): %d
\n
"
,
searchRange
,
entrySelector
,
rangeShift
);
searchRange
,
entrySelector
,
rangeShift
);
...
@@ -182,7 +186,7 @@ KernTable::KernTable(const LETableReference& base, LEErrorCode &success)
...
@@ -182,7 +186,7 @@ KernTable::KernTable(const LETableReference& base, LEErrorCode &success)
ids
[
id
]
=
(
char
)
i
;
ids
[
id
]
=
(
char
)
i
;
}
}
}
}
PairInfo
*
p
=
pairs
;
PairInfo
*
p
=
pairs
Swapped
;
for
(
int
i
=
0
;
i
<
nPairs
;
++
i
,
p
++
)
{
for
(
int
i
=
0
;
i
<
nPairs
;
++
i
,
p
++
)
{
le_uint32
k
=
p
->
key
;
le_uint32
k
=
p
->
key
;
le_uint16
left
=
(
k
>>
16
)
&
0xffff
;
le_uint16
left
=
(
k
>>
16
)
&
0xffff
;
...
...
src/share/native/sun/font/layout/KernTable.h
浏览文件 @
07db24f9
...
@@ -57,7 +57,6 @@ class U_LAYOUT_API KernTable
...
@@ -57,7 +57,6 @@ class U_LAYOUT_API KernTable
private:
private:
le_uint16
coverage
;
le_uint16
coverage
;
le_uint16
nPairs
;
le_uint16
nPairs
;
LEReferenceToArrayOf
<
PairInfo
>
pairs
;
PairInfo
*
pairsSwapped
;
PairInfo
*
pairsSwapped
;
const
LETableReference
&
fTable
;
const
LETableReference
&
fTable
;
le_uint16
searchRange
;
le_uint16
searchRange
;
...
...
src/share/native/sun/font/layout/LayoutEngine.cpp
浏览文件 @
07db24f9
...
@@ -569,7 +569,6 @@ void LayoutEngine::reset()
...
@@ -569,7 +569,6 @@ void LayoutEngine::reset()
{
{
if
(
fGlyphStorage
!=
NULL
)
{
if
(
fGlyphStorage
!=
NULL
)
{
fGlyphStorage
->
reset
();
fGlyphStorage
->
reset
();
fGlyphStorage
=
NULL
;
}
}
}
}
...
...
test/java/awt/font/TextLayout/KerningLeak.java
0 → 100644
浏览文件 @
07db24f9
/*
* Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/**
* @bug 8015334
* @summary Memory leak with kerning.
*/
import
java.awt.EventQueue
;
import
java.awt.Font
;
import
java.awt.FontMetrics
;
import
java.awt.font.TextAttribute
;
import
java.util.HashMap
;
import
java.util.Map
;
import
javax.swing.JLabel
;
import
javax.swing.SwingUtilities
;
public
class
KerningLeak
{
public
static
void
main
(
String
[]
args
)
{
EventQueue
.
invokeLater
(
new
Runnable
()
{
@Override
public
void
run
()
{
leak
();
}
});
}
private
static
void
leak
()
{
Map
<
TextAttribute
,
Object
>
textAttributes
=
new
HashMap
<>();
textAttributes
.
put
(
TextAttribute
.
FAMILY
,
"Sans Serif"
);
textAttributes
.
put
(
TextAttribute
.
SIZE
,
12
);
textAttributes
.
put
(
TextAttribute
.
KERNING
,
TextAttribute
.
KERNING_ON
);
Font
font
=
Font
.
getFont
(
textAttributes
);
JLabel
label
=
new
JLabel
();
int
dummy
=
0
;
for
(
int
i
=
0
;
i
<
500
;
i
++)
{
if
(
i
%
10
==
0
)
System
.
out
.
println
(
"Starting iter "
+
(
i
+
1
));
for
(
int
j
=
0
;
j
<
1000
;
j
++)
{
FontMetrics
fm
=
label
.
getFontMetrics
(
font
);
dummy
+=
SwingUtilities
.
computeStringWidth
(
fm
,
Integer
.
toString
(
j
));
}
}
System
.
out
.
println
(
"done "
+
dummy
);
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录