Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell8_jdk
提交
7c2773e9
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看板
提交
7c2773e9
编写于
5月 31, 2012
作者:
L
leonidr
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
7150089: [macosx] Default for a custom cursor created from non-existent image is not transparent
Reviewed-by: anthony, kizune
上级
e3f79369
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
37 addition
and
29 deletion
+37
-29
src/macosx/classes/sun/lwawt/macosx/CCustomCursor.java
src/macosx/classes/sun/lwawt/macosx/CCustomCursor.java
+37
-29
未找到文件。
src/macosx/classes/sun/lwawt/macosx/CCustomCursor.java
浏览文件 @
7c2773e9
...
...
@@ -26,6 +26,7 @@
package
sun.lwawt.macosx
;
import
java.awt.*
;
import
java.awt.image.BufferedImage
;
public
class
CCustomCursor
extends
Cursor
{
static
Dimension
sMaxCursorSize
;
...
...
@@ -36,7 +37,6 @@ public class CCustomCursor extends Cursor {
}
Image
fImage
;
private
boolean
isImageOk
=
false
;
Point
fHotspot
;
public
CCustomCursor
(
final
Image
cursor
,
final
Point
hotSpot
,
final
String
name
)
throws
IndexOutOfBoundsException
,
HeadlessException
{
...
...
@@ -61,21 +61,19 @@ public class CCustomCursor extends Cursor {
// Fix for bug 4212593 The Toolkit.createCustomCursor does not
// check absence of the image of cursor
// If the image is invalid, the cursor will be hidden (made completely
// transparent). In this case, getBestCursorSize() will adjust negative w and h,
// but we need to set the hotspot inside the image here.
// transparent).
if
(
tracker
.
isErrorAny
()
||
width
<
0
||
height
<
0
)
{
fHotspot
.
x
=
fHotspot
.
y
=
0
;
isImageOk
=
false
;
width
=
height
=
1
;
fImage
=
createTransparentImage
(
width
,
height
);
}
else
{
isImageOk
=
true
;
}
// Scale image to nearest supported size
final
Dimension
nativeSize
=
toolkit
.
getBestCursorSize
(
width
,
height
);
if
(
nativeSize
.
width
!=
width
||
nativeSize
.
height
!=
height
)
{
fImage
=
fImage
.
getScaledInstance
(
nativeSize
.
width
,
nativeSize
.
height
,
Image
.
SCALE_DEFAULT
);
width
=
nativeSize
.
width
;
height
=
nativeSize
.
height
;
// Scale image to nearest supported size
final
Dimension
nativeSize
=
toolkit
.
getBestCursorSize
(
width
,
height
);
if
(
nativeSize
.
width
!=
width
||
nativeSize
.
height
!=
height
)
{
fImage
=
fImage
.
getScaledInstance
(
nativeSize
.
width
,
nativeSize
.
height
,
Image
.
SCALE_DEFAULT
);
width
=
nativeSize
.
width
;
height
=
nativeSize
.
height
;
}
}
// NOTE: this was removed for 3169146, but in 1.5 the JCK tests for an exception and fails if one isn't thrown.
...
...
@@ -98,6 +96,21 @@ public class CCustomCursor extends Cursor {
}
}
private
static
BufferedImage
createTransparentImage
(
int
w
,
int
h
)
{
GraphicsEnvironment
ge
=
GraphicsEnvironment
.
getLocalGraphicsEnvironment
();
GraphicsDevice
gs
=
ge
.
getDefaultScreenDevice
();
GraphicsConfiguration
gc
=
gs
.
getDefaultConfiguration
();
BufferedImage
img
=
gc
.
createCompatibleImage
(
w
,
h
,
Transparency
.
BITMASK
);
Graphics2D
g
=
(
Graphics2D
)
img
.
getGraphics
();
g
.
setBackground
(
new
Color
(
0
,
0
,
0
,
0
));
g
.
clearRect
(
0
,
0
,
w
,
h
);
g
.
dispose
();
return
img
;
}
public
static
Dimension
getBestCursorSize
(
final
int
preferredWidth
,
final
int
preferredHeight
)
{
// With Panther, cursors have no limit on their size. So give the client their
// preferred size, but no larger than half the dimensions of the main screen
...
...
@@ -111,31 +124,26 @@ public class CCustomCursor extends Cursor {
}
// Called from native when the cursor is set
// Returns long array of [NSImage ptr, x hotspot, y hotspot]
CImage
fCImage
;
long
getImageData
()
{
if
(
fCImage
!=
null
)
{
return
fCImage
.
ptr
;
}
if
(
isImageOk
)
{
try
{
fCImage
=
CImage
.
getCreator
().
createFromImage
(
fImage
);
if
(
fCImage
==
null
)
{
isImageOk
=
false
;
return
0L
;
}
else
{
return
fCImage
.
ptr
;
}
}
catch
(
IllegalArgumentException
iae
)
{
// Silently return null - we want to hide cursor by providing an empty
// ByteArray or just null
try
{
fCImage
=
CImage
.
getCreator
().
createFromImage
(
fImage
);
if
(
fCImage
==
null
)
{
// Something unexpected happened: CCustomCursor constructor
// takes care of invalid cursor images, yet createFromImage()
// failed to do its job. Return null to keep the cursor unchanged.
return
0L
;
}
else
{
return
fCImage
.
ptr
;
}
}
catch
(
IllegalArgumentException
iae
)
{
// see comment above
return
0L
;
}
return
0L
;
}
Point
getHotSpot
()
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录