Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell8_jdk
提交
b867a6a0
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看板
提交
b867a6a0
编写于
6月 12, 2014
作者:
S
serb
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
8029455: [JLightweightFrame] support scaled painting
Reviewed-by: anthony, ant
上级
e1dbfd73
变更
7
显示空白变更内容
内联
并排
Showing
7 changed file
with
331 addition
and
67 deletion
+331
-67
src/macosx/classes/sun/lwawt/macosx/CPlatformLWWindow.java
src/macosx/classes/sun/lwawt/macosx/CPlatformLWWindow.java
+26
-5
src/share/classes/sun/awt/LightweightFrame.java
src/share/classes/sun/awt/LightweightFrame.java
+45
-0
src/share/classes/sun/java2d/SunGraphics2D.java
src/share/classes/sun/java2d/SunGraphics2D.java
+20
-3
src/share/classes/sun/swing/JLightweightFrame.java
src/share/classes/sun/swing/JLightweightFrame.java
+89
-43
src/share/classes/sun/swing/LightweightContent.java
src/share/classes/sun/swing/LightweightContent.java
+38
-16
test/java/awt/Graphics2D/ScaledCopyArea/ScaledCopyArea.java
test/java/awt/Graphics2D/ScaledCopyArea/ScaledCopyArea.java
+60
-0
test/javax/swing/JFrame/HangNonVolatileBuffer/HangNonVolatileBuffer.java
...g/JFrame/HangNonVolatileBuffer/HangNonVolatileBuffer.java
+53
-0
未找到文件。
src/macosx/classes/sun/lwawt/macosx/CPlatformLWWindow.java
浏览文件 @
b867a6a0
...
@@ -29,12 +29,18 @@ import java.awt.Font;
...
@@ -29,12 +29,18 @@ import java.awt.Font;
import
java.awt.FontMetrics
;
import
java.awt.FontMetrics
;
import
java.awt.Graphics
;
import
java.awt.Graphics
;
import
java.awt.GraphicsDevice
;
import
java.awt.GraphicsDevice
;
import
java.awt.GraphicsEnvironment
;
import
java.awt.Insets
;
import
java.awt.Insets
;
import
java.awt.MenuBar
;
import
java.awt.MenuBar
;
import
java.awt.Point
;
import
java.awt.Point
;
import
java.awt.Rectangle
;
import
java.awt.Window
;
import
java.awt.Window
;
import
sun.awt.CGraphicsDevice
;
import
sun.awt.CGraphicsEnvironment
;
import
sun.awt.CausedFocusEvent
;
import
sun.awt.CausedFocusEvent
;
import
sun.awt.LightweightFrame
;
import
sun.java2d.SurfaceData
;
import
sun.java2d.SurfaceData
;
import
sun.lwawt.LWLightweightFramePeer
;
import
sun.lwawt.LWWindowPeer
;
import
sun.lwawt.LWWindowPeer
;
import
sun.lwawt.PlatformWindow
;
import
sun.lwawt.PlatformWindow
;
...
@@ -72,11 +78,6 @@ public class CPlatformLWWindow extends CPlatformWindow {
...
@@ -72,11 +78,6 @@ public class CPlatformLWWindow extends CPlatformWindow {
return
null
;
return
null
;
}
}
@Override
public
GraphicsDevice
getGraphicsDevice
()
{
return
null
;
}
@Override
@Override
public
SurfaceData
getScreenSurface
()
{
public
SurfaceData
getScreenSurface
()
{
return
null
;
return
null
;
...
@@ -199,4 +200,24 @@ public class CPlatformLWWindow extends CPlatformWindow {
...
@@ -199,4 +200,24 @@ public class CPlatformLWWindow extends CPlatformWindow {
public
long
getLayerPtr
()
{
public
long
getLayerPtr
()
{
return
0
;
return
0
;
}
}
@Override
public
GraphicsDevice
getGraphicsDevice
()
{
CGraphicsEnvironment
ge
=
(
CGraphicsEnvironment
)
GraphicsEnvironment
.
getLocalGraphicsEnvironment
();
LWLightweightFramePeer
peer
=
(
LWLightweightFramePeer
)
getPeer
();
int
scale
=
((
LightweightFrame
)
peer
.
getTarget
()).
getScaleFactor
();
Rectangle
bounds
=
((
LightweightFrame
)
peer
.
getTarget
()).
getHostBounds
();
for
(
GraphicsDevice
d
:
ge
.
getScreenDevices
())
{
if
(
d
.
getDefaultConfiguration
().
getBounds
().
intersects
(
bounds
)
&&
((
CGraphicsDevice
)
d
).
getScaleFactor
()
==
scale
)
{
return
d
;
}
}
// We shouldn't be here...
return
ge
.
getDefaultScreenDevice
();
}
}
}
src/share/classes/sun/awt/LightweightFrame.java
浏览文件 @
b867a6a0
...
@@ -31,6 +31,7 @@ import java.awt.Graphics;
...
@@ -31,6 +31,7 @@ import java.awt.Graphics;
import
java.awt.Image
;
import
java.awt.Image
;
import
java.awt.MenuBar
;
import
java.awt.MenuBar
;
import
java.awt.MenuComponent
;
import
java.awt.MenuComponent
;
import
java.awt.Rectangle
;
import
java.awt.Toolkit
;
import
java.awt.Toolkit
;
import
java.awt.peer.FramePeer
;
import
java.awt.peer.FramePeer
;
...
@@ -124,4 +125,48 @@ public abstract class LightweightFrame extends Frame {
...
@@ -124,4 +125,48 @@ public abstract class LightweightFrame extends Frame {
* @see SunToolkit#ungrab(java.awt.Window)
* @see SunToolkit#ungrab(java.awt.Window)
*/
*/
public
abstract
void
ungrabFocus
();
public
abstract
void
ungrabFocus
();
/**
* Returns the scale factor of this frame. The default value is 1.
*
* @return the scale factor
* @see #notifyDisplayChanged(int)
*/
public
abstract
int
getScaleFactor
();
/**
* Called when display of the hosted frame is changed.
*
* @param scaleFactor the scale factor
*/
public
abstract
void
notifyDisplayChanged
(
int
scaleFactor
);
/**
* Host window absolute bounds.
*/
private
int
hostX
,
hostY
,
hostW
,
hostH
;
/**
* Returns the absolute bounds of the host (embedding) window.
*
* @return the host window bounds
*/
public
Rectangle
getHostBounds
()
{
if
(
hostX
==
0
&&
hostY
==
0
&&
hostW
==
0
&&
hostH
==
0
)
{
// The client app is probably unaware of the setHostBounds.
// A safe fall-back:
return
getBounds
();
}
return
new
Rectangle
(
hostX
,
hostY
,
hostW
,
hostH
);
}
/**
* Sets the absolute bounds of the host (embedding) window.
*/
public
void
setHostBounds
(
int
x
,
int
y
,
int
w
,
int
h
)
{
hostX
=
x
;
hostY
=
y
;
hostW
=
w
;
hostH
=
h
;
}
}
}
src/share/classes/sun/java2d/SunGraphics2D.java
浏览文件 @
b867a6a0
...
@@ -2105,7 +2105,7 @@ public final class SunGraphics2D
...
@@ -2105,7 +2105,7 @@ public final class SunGraphics2D
if
(
theData
.
copyArea
(
this
,
x
,
y
,
w
,
h
,
dx
,
dy
))
{
if
(
theData
.
copyArea
(
this
,
x
,
y
,
w
,
h
,
dx
,
dy
))
{
return
;
return
;
}
}
if
(
transformState
>
=
TRANSFORM_TRANSLATESCALE
)
{
if
(
transformState
>
TRANSFORM_TRANSLATESCALE
)
{
throw
new
InternalError
(
"transformed copyArea not implemented yet"
);
throw
new
InternalError
(
"transformed copyArea not implemented yet"
);
}
}
// REMIND: This method does not deal with missing data from the
// REMIND: This method does not deal with missing data from the
...
@@ -2126,8 +2126,25 @@ public final class SunGraphics2D
...
@@ -2126,8 +2126,25 @@ public final class SunGraphics2D
lastCAcomp
=
comp
;
lastCAcomp
=
comp
;
}
}
x
+=
transX
;
double
[]
coords
=
{
x
,
y
,
x
+
w
,
y
+
h
,
x
+
dx
,
y
+
dy
};
y
+=
transY
;
transform
.
transform
(
coords
,
0
,
coords
,
0
,
3
);
x
=
(
int
)
Math
.
ceil
(
coords
[
0
]
-
0.5
);
y
=
(
int
)
Math
.
ceil
(
coords
[
1
]
-
0.5
);
w
=
((
int
)
Math
.
ceil
(
coords
[
2
]
-
0.5
))
-
x
;
h
=
((
int
)
Math
.
ceil
(
coords
[
3
]
-
0.5
))
-
y
;
dx
=
((
int
)
Math
.
ceil
(
coords
[
4
]
-
0.5
))
-
x
;
dy
=
((
int
)
Math
.
ceil
(
coords
[
5
]
-
0.5
))
-
y
;
// In case of negative scale transform, reflect the rect coords.
if
(
w
<
0
)
{
w
*=
-
1
;
x
-=
w
;
}
if
(
h
<
0
)
{
h
*=
-
1
;
y
-=
h
;
}
Blit
ob
=
lastCAblit
;
Blit
ob
=
lastCAblit
;
if
(
dy
==
0
&&
dx
>
0
&&
dx
<
w
)
{
if
(
dy
==
0
&&
dx
>
0
&&
dx
<
w
)
{
...
...
src/share/classes/sun/swing/JLightweightFrame.java
浏览文件 @
b867a6a0
...
@@ -54,6 +54,7 @@ import javax.swing.RepaintManager;
...
@@ -54,6 +54,7 @@ import javax.swing.RepaintManager;
import
javax.swing.RootPaneContainer
;
import
javax.swing.RootPaneContainer
;
import
javax.swing.SwingUtilities
;
import
javax.swing.SwingUtilities
;
import
sun.awt.DisplayChangedListener
;
import
sun.awt.LightweightFrame
;
import
sun.awt.LightweightFrame
;
import
sun.security.action.GetPropertyAction
;
import
sun.security.action.GetPropertyAction
;
import
sun.swing.SwingUtilities2.RepaintListener
;
import
sun.swing.SwingUtilities2.RepaintListener
;
...
@@ -79,6 +80,8 @@ public final class JLightweightFrame extends LightweightFrame implements RootPan
...
@@ -79,6 +80,8 @@ public final class JLightweightFrame extends LightweightFrame implements RootPan
private
BufferedImage
bbImage
;
private
BufferedImage
bbImage
;
private
volatile
int
scaleFactor
=
1
;
/**
/**
* {@code copyBufferEnabled}, true by default, defines the following strategy.
* {@code copyBufferEnabled}, true by default, defines the following strategy.
* A duplicating (copy) buffer is created for the original pixel buffer.
* A duplicating (copy) buffer is created for the original pixel buffer.
...
@@ -89,7 +92,7 @@ public final class JLightweightFrame extends LightweightFrame implements RootPan
...
@@ -89,7 +92,7 @@ public final class JLightweightFrame extends LightweightFrame implements RootPan
* by the lock (managed with the {@link LightweightContent#paintLock()},
* by the lock (managed with the {@link LightweightContent#paintLock()},
* {@link LightweightContent#paintUnlock()} methods).
* {@link LightweightContent#paintUnlock()} methods).
*/
*/
private
boolean
copyBufferEnabled
;
private
static
boolean
copyBufferEnabled
;
private
int
[]
copyBuffer
;
private
int
[]
copyBuffer
;
private
PropertyChangeListener
layoutSizeListener
;
private
PropertyChangeListener
layoutSizeListener
;
...
@@ -102,6 +105,8 @@ public final class JLightweightFrame extends LightweightFrame implements RootPan
...
@@ -102,6 +105,8 @@ public final class JLightweightFrame extends LightweightFrame implements RootPan
frame
.
updateClientCursor
();
frame
.
updateClientCursor
();
}
}
});
});
copyBufferEnabled
=
"true"
.
equals
(
AccessController
.
doPrivileged
(
new
GetPropertyAction
(
"swing.jlf.copyBufferEnabled"
,
"true"
)));
}
}
/**
/**
...
@@ -143,7 +148,8 @@ public final class JLightweightFrame extends LightweightFrame implements RootPan
...
@@ -143,7 +148,8 @@ public final class JLightweightFrame extends LightweightFrame implements RootPan
}
}
Point
p
=
SwingUtilities
.
convertPoint
(
c
,
x
,
y
,
jlf
);
Point
p
=
SwingUtilities
.
convertPoint
(
c
,
x
,
y
,
jlf
);
Rectangle
r
=
new
Rectangle
(
p
.
x
,
p
.
y
,
w
,
h
).
intersection
(
Rectangle
r
=
new
Rectangle
(
p
.
x
,
p
.
y
,
w
,
h
).
intersection
(
new
Rectangle
(
0
,
0
,
bbImage
.
getWidth
(),
bbImage
.
getHeight
()));
new
Rectangle
(
0
,
0
,
bbImage
.
getWidth
()
/
scaleFactor
,
bbImage
.
getHeight
()
/
scaleFactor
));
if
(!
r
.
isEmpty
())
{
if
(!
r
.
isEmpty
())
{
notifyImageUpdated
(
r
.
x
,
r
.
y
,
r
.
width
,
r
.
height
);
notifyImageUpdated
(
r
.
x
,
r
.
y
,
r
.
width
,
r
.
height
);
...
@@ -197,6 +203,7 @@ public final class JLightweightFrame extends LightweightFrame implements RootPan
...
@@ -197,6 +203,7 @@ public final class JLightweightFrame extends LightweightFrame implements RootPan
g
.
setBackground
(
getBackground
());
g
.
setBackground
(
getBackground
());
g
.
setColor
(
getForeground
());
g
.
setColor
(
getForeground
());
g
.
setFont
(
getFont
());
g
.
setFont
(
getFont
());
g
.
scale
(
scaleFactor
,
scaleFactor
);
return
g
;
return
g
;
}
}
...
@@ -220,7 +227,39 @@ public final class JLightweightFrame extends LightweightFrame implements RootPan
...
@@ -220,7 +227,39 @@ public final class JLightweightFrame extends LightweightFrame implements RootPan
if
(
content
!=
null
)
content
.
focusUngrabbed
();
if
(
content
!=
null
)
content
.
focusUngrabbed
();
}
}
private
void
syncCopyBuffer
(
boolean
reset
,
int
x
,
int
y
,
int
w
,
int
h
)
{
@Override
public
int
getScaleFactor
()
{
return
scaleFactor
;
}
@Override
public
void
notifyDisplayChanged
(
final
int
scaleFactor
)
{
if
(
scaleFactor
!=
this
.
scaleFactor
)
{
if
(!
copyBufferEnabled
)
content
.
paintLock
();
try
{
if
(
bbImage
!=
null
)
{
resizeBuffer
(
getWidth
(),
getHeight
(),
scaleFactor
);
}
}
finally
{
if
(!
copyBufferEnabled
)
content
.
paintUnlock
();
}
this
.
scaleFactor
=
scaleFactor
;
}
if
(
getPeer
()
instanceof
DisplayChangedListener
)
{
((
DisplayChangedListener
)
getPeer
()).
displayChanged
();
}
repaint
();
}
@Override
public
void
addNotify
()
{
super
.
addNotify
();
if
(
getPeer
()
instanceof
DisplayChangedListener
)
{
((
DisplayChangedListener
)
getPeer
()).
displayChanged
();
}
}
private
void
syncCopyBuffer
(
boolean
reset
,
int
x
,
int
y
,
int
w
,
int
h
,
int
scale
)
{
content
.
paintLock
();
content
.
paintLock
();
try
{
try
{
int
[]
srcBuffer
=
((
DataBufferInt
)
bbImage
.
getRaster
().
getDataBuffer
()).
getData
();
int
[]
srcBuffer
=
((
DataBufferInt
)
bbImage
.
getRaster
().
getDataBuffer
()).
getData
();
...
@@ -229,6 +268,11 @@ public final class JLightweightFrame extends LightweightFrame implements RootPan
...
@@ -229,6 +268,11 @@ public final class JLightweightFrame extends LightweightFrame implements RootPan
}
}
int
linestride
=
bbImage
.
getWidth
();
int
linestride
=
bbImage
.
getWidth
();
x
*=
scale
;
y
*=
scale
;
w
*=
scale
;
h
*=
scale
;
for
(
int
i
=
0
;
i
<
h
;
i
++)
{
for
(
int
i
=
0
;
i
<
h
;
i
++)
{
int
from
=
(
y
+
i
)
*
linestride
+
x
;
int
from
=
(
y
+
i
)
*
linestride
+
x
;
System
.
arraycopy
(
srcBuffer
,
from
,
copyBuffer
,
from
,
w
);
System
.
arraycopy
(
srcBuffer
,
from
,
copyBuffer
,
from
,
w
);
...
@@ -240,7 +284,7 @@ public final class JLightweightFrame extends LightweightFrame implements RootPan
...
@@ -240,7 +284,7 @@ public final class JLightweightFrame extends LightweightFrame implements RootPan
private
void
notifyImageUpdated
(
int
x
,
int
y
,
int
width
,
int
height
)
{
private
void
notifyImageUpdated
(
int
x
,
int
y
,
int
width
,
int
height
)
{
if
(
copyBufferEnabled
)
{
if
(
copyBufferEnabled
)
{
syncCopyBuffer
(
false
,
x
,
y
,
width
,
height
);
syncCopyBuffer
(
false
,
x
,
y
,
width
,
height
,
scaleFactor
);
}
}
content
.
imageUpdated
(
x
,
y
,
width
,
height
);
content
.
imageUpdated
(
x
,
y
,
width
,
height
);
}
}
...
@@ -267,7 +311,8 @@ public final class JLightweightFrame extends LightweightFrame implements RootPan
...
@@ -267,7 +311,8 @@ public final class JLightweightFrame extends LightweightFrame implements RootPan
EventQueue
.
invokeLater
(
new
Runnable
()
{
EventQueue
.
invokeLater
(
new
Runnable
()
{
@Override
@Override
public
void
run
()
{
public
void
run
()
{
notifyImageUpdated
(
clip
.
x
,
clip
.
y
,
clip
.
width
,
clip
.
height
);
Rectangle
c
=
contentPane
.
getBounds
().
intersection
(
clip
);
notifyImageUpdated
(
c
.
x
,
c
.
y
,
c
.
width
,
c
.
height
);
}
}
});
});
}
finally
{
}
finally
{
...
@@ -321,13 +366,17 @@ public final class JLightweightFrame extends LightweightFrame implements RootPan
...
@@ -321,13 +366,17 @@ public final class JLightweightFrame extends LightweightFrame implements RootPan
content
.
paintLock
();
content
.
paintLock
();
}
}
try
{
try
{
if
((
bbImage
==
null
)
||
(
width
!=
bbImage
.
getWidth
())
||
(
height
!=
bbImage
.
getHeight
()))
{
boolean
createBB
=
(
bbImage
==
null
);
boolean
createBB
=
true
;
int
newW
=
width
;
int
newW
=
width
;
int
newH
=
height
;
int
newH
=
height
;
if
(
bbImage
!=
null
)
{
if
(
bbImage
!=
null
)
{
int
oldW
=
bbImage
.
getWidth
();
int
imgWidth
=
bbImage
.
getWidth
()
/
scaleFactor
;
int
oldH
=
bbImage
.
getHeight
();
int
imgHeight
=
bbImage
.
getHeight
()
/
scaleFactor
;
if
(
width
!=
imgWidth
||
height
!=
imgHeight
)
{
createBB
=
true
;
if
(
bbImage
!=
null
)
{
int
oldW
=
imgWidth
;
int
oldH
=
imgHeight
;
if
((
oldW
>=
newW
)
&&
(
oldH
>=
newH
))
{
if
((
oldW
>=
newW
)
&&
(
oldH
>=
newH
))
{
createBB
=
false
;
createBB
=
false
;
}
else
{
}
else
{
...
@@ -343,27 +392,12 @@ public final class JLightweightFrame extends LightweightFrame implements RootPan
...
@@ -343,27 +392,12 @@ public final class JLightweightFrame extends LightweightFrame implements RootPan
}
}
}
}
}
}
if
(
createBB
)
{
BufferedImage
oldBB
=
bbImage
;
bbImage
=
new
BufferedImage
(
newW
,
newH
,
BufferedImage
.
TYPE_INT_ARGB_PRE
);
if
(
oldBB
!=
null
)
{
Graphics
g
=
bbImage
.
getGraphics
();
try
{
g
.
drawImage
(
oldBB
,
0
,
0
,
newW
,
newH
,
null
);
}
finally
{
g
.
dispose
();
oldBB
.
flush
();
}
}
}
}
int
[]
pixels
=
((
DataBufferInt
)
bbImage
.
getRaster
().
getDataBuffer
()).
getData
();
if
(
createBB
)
{
if
(
copyBufferEnabled
)
{
resizeBuffer
(
newW
,
newH
,
scaleFactor
);
syncCopyBuffer
(
true
,
0
,
0
,
width
,
height
);
pixels
=
copyBuffer
;
}
content
.
imageBufferReset
(
pixels
,
0
,
0
,
width
,
height
,
bbImage
.
getWidth
());
return
;
return
;
}
}
}
content
.
imageReshaped
(
0
,
0
,
width
,
height
);
content
.
imageReshaped
(
0
,
0
,
width
,
height
);
}
finally
{
}
finally
{
...
@@ -373,6 +407,18 @@ public final class JLightweightFrame extends LightweightFrame implements RootPan
...
@@ -373,6 +407,18 @@ public final class JLightweightFrame extends LightweightFrame implements RootPan
}
}
}
}
private
void
resizeBuffer
(
int
width
,
int
height
,
int
newScaleFactor
)
{
bbImage
=
new
BufferedImage
(
width
*
newScaleFactor
,
height
*
newScaleFactor
,
BufferedImage
.
TYPE_INT_ARGB_PRE
);
int
[]
pixels
=
((
DataBufferInt
)
bbImage
.
getRaster
().
getDataBuffer
()).
getData
();
if
(
copyBufferEnabled
)
{
syncCopyBuffer
(
true
,
0
,
0
,
width
,
height
,
newScaleFactor
);
pixels
=
copyBuffer
;
}
content
.
imageBufferReset
(
pixels
,
0
,
0
,
width
,
height
,
width
*
newScaleFactor
,
newScaleFactor
);
}
@Override
@Override
public
JRootPane
getRootPane
()
{
public
JRootPane
getRootPane
()
{
return
rootPane
;
return
rootPane
;
...
...
src/share/classes/sun/swing/LightweightContent.java
浏览文件 @
b867a6a0
...
@@ -85,31 +85,53 @@ public interface LightweightContent {
...
@@ -85,31 +85,53 @@ public interface LightweightContent {
* {@code JLightweightFrame} calls this method to notify the client
* {@code JLightweightFrame} calls this method to notify the client
* application that a new data buffer has been set as a content pixel
* application that a new data buffer has been set as a content pixel
* buffer. Typically this occurs when a buffer of a larger size is
* buffer. Typically this occurs when a buffer of a larger size is
* created in response to a content resize event. The method reports
* created in response to a content resize event.
* a reference to the pixel data buffer, the content image bounds
* within the buffer and the line stride of the buffer. These values
* have the following correlation.
* <p>
* <p>
* The {@code width} and {@code height} matches the size of the content
* The method reports a reference to the pixel data buffer, the content
* image bounds within the buffer and the line stride of the buffer.
* These values have the following correlation.
* The {@code width} and {@code height} matches the layout size of the content
* (the component returned from the {@link #getComponent} method). The
* (the component returned from the {@link #getComponent} method). The
* {@code x} and {@code y} is the origin of the content, {@code (0, 0)}
* {@code x} and {@code y} is the origin of the content, {@code (0, 0)}
* in the coordinate space of the content, appearing at
* in the layout coordinate space of the content, appearing at
* {@code data[y * linestride + x]} in the buffer. All indices
* {@code data[y * scale * linestride + x * scale]} in the buffer.
* {@code data[(y + j) * linestride + (x + i)]} where
* A pixel with indices {@code (i, j)}, where {@code (0 <= i < width)} and
* {@code (0 <= i < width)} and {@code (0 <= j < height)} will represent
* {@code (0 <= j < height)}, in the layout coordinate space of the content
* valid pixel data, {@code (i, j)} in the coordinate space of the content.
* is represented by a {@code scale^2} square of pixels in the physical
* coordinate space of the buffer. The top-left corner of the square has the
* following physical coordinate in the buffer:
* {@code data[(y + j) * scale * linestride + (x + i) * scale]}.
*
*
* @param data the content pixel data buffer of INT_ARGB_PRE type
* @param data the content pixel data buffer of INT_ARGB_PRE type
* @param x the x coordinate of the image
* @param x the
logical
x coordinate of the image
* @param y the y coordinate of the image
* @param y the
logical
y coordinate of the image
* @param width the width of the image
* @param width the
logical
width of the image
* @param height the height of the image
* @param height the
logical
height of the image
* @param linestride the line stride of the pixel buffer
* @param linestride the line stride of the pixel buffer
* @param scale the scale factor of the pixel buffer
*/
default
public
void
imageBufferReset
(
int
[]
data
,
int
x
,
int
y
,
int
width
,
int
height
,
int
linestride
,
int
scale
)
{
imageBufferReset
(
data
,
x
,
y
,
width
,
height
,
linestride
);
}
/**
* The default implementation for #imageBufferReset uses a hard-coded value
* of 1 for the scale factor. Both the old and the new methods provide
* default implementations in order to allow a client application to run
* with any JDK version without breaking backward compatibility.
*/
*/
public
void
imageBufferReset
(
int
[]
data
,
default
public
void
imageBufferReset
(
int
[]
data
,
int
x
,
int
y
,
int
x
,
int
y
,
int
width
,
int
height
,
int
width
,
int
height
,
int
linestride
);
int
linestride
)
{
imageBufferReset
(
data
,
x
,
y
,
width
,
height
,
linestride
,
1
);
}
/**
/**
* {@code JLightweightFrame} calls this method to notify the client
* {@code JLightweightFrame} calls this method to notify the client
...
...
test/java/awt/Graphics2D/ScaledCopyArea/ScaledCopyArea.java
0 → 100644
浏览文件 @
b867a6a0
/*
* Copyright (c) 2014, 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.
*/
import
java.awt.Color
;
import
java.awt.Graphics2D
;
import
java.awt.image.BufferedImage
;
/**
* @test
* @bug 8029455
* @summary Tests that copyarea on offscreen images works as expected when
* scaled transform is set
* @run main ScaledCopyArea
*/
public
final
class
ScaledCopyArea
{
public
static
void
main
(
final
String
[]
args
)
{
final
BufferedImage
bi
=
new
BufferedImage
(
100
,
300
,
BufferedImage
.
TYPE_INT_RGB
);
final
Graphics2D
g
=
bi
.
createGraphics
();
g
.
scale
(
2
,
2
);
g
.
setColor
(
Color
.
RED
);
g
.
fillRect
(
0
,
0
,
100
,
300
);
g
.
setColor
(
Color
.
GREEN
);
g
.
fillRect
(
0
,
100
,
100
,
100
);
g
.
copyArea
(
0
,
100
,
100
,
100
,
0
,
-
100
);
g
.
dispose
();
for
(
int
x
=
0
;
x
<
100
;
++
x
)
{
for
(
int
y
=
0
;
y
<
100
;
++
y
)
{
final
int
actual
=
bi
.
getRGB
(
x
,
y
);
final
int
exp
=
Color
.
GREEN
.
getRGB
();
if
(
actual
!=
exp
)
{
System
.
err
.
println
(
"Expected:"
+
Integer
.
toHexString
(
exp
));
System
.
err
.
println
(
"Actual:"
+
Integer
.
toHexString
(
actual
));
throw
new
RuntimeException
(
"Test "
+
"failed"
);
}
}
}
}
}
test/javax/swing/JFrame/HangNonVolatileBuffer/HangNonVolatileBuffer.java
0 → 100644
浏览文件 @
b867a6a0
/*
* Copyright (c) 2014, 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.
*/
import
java.lang.reflect.InvocationTargetException
;
import
javax.swing.JFrame
;
import
javax.swing.SwingUtilities
;
/**
* @test
* @bug 8029455
* @summary Swing should not hang if non-volatile image is used as a backbuffer.
* @run main/othervm -Dswing.volatileImageBufferEnabled=false HangNonVolatileBuffer
*/
public
final
class
HangNonVolatileBuffer
{
private
static
JFrame
f
;
public
static
void
main
(
final
String
[]
args
)
throws
InvocationTargetException
,
InterruptedException
{
SwingUtilities
.
invokeAndWait
(()
->
{
f
=
new
JFrame
(
"JFrame"
);
f
.
setSize
(
300
,
300
);
f
.
setLocationRelativeTo
(
null
);
f
.
setVisible
(
true
);
});
SwingUtilities
.
invokeAndWait
(()
->
{
// flush the EDT
});
Thread
.
sleep
(
1000
);
SwingUtilities
.
invokeAndWait
(
f:
:
dispose
);
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录