Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell8_jdk
提交
90b4e7d3
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看板
提交
90b4e7d3
编写于
8月 23, 2010
作者:
L
lana
浏览文件
操作
浏览文件
下载
差异文件
Merge
上级
2c7696d6
32315d6e
变更
7
展开全部
隐藏空白更改
内联
并排
Showing
7 changed file
with
799 addition
and
1390 deletion
+799
-1390
src/share/classes/sun/java2d/pisces/Dasher.java
src/share/classes/sun/java2d/pisces/Dasher.java
+83
-116
src/share/classes/sun/java2d/pisces/LineSink.java
src/share/classes/sun/java2d/pisces/LineSink.java
+10
-10
src/share/classes/sun/java2d/pisces/PiscesMath.java
src/share/classes/sun/java2d/pisces/PiscesMath.java
+0
-155
src/share/classes/sun/java2d/pisces/PiscesRenderingEngine.java
...hare/classes/sun/java2d/pisces/PiscesRenderingEngine.java
+167
-62
src/share/classes/sun/java2d/pisces/Renderer.java
src/share/classes/sun/java2d/pisces/Renderer.java
+382
-717
src/share/classes/sun/java2d/pisces/Stroker.java
src/share/classes/sun/java2d/pisces/Stroker.java
+157
-246
src/share/classes/sun/java2d/pisces/Transform4.java
src/share/classes/sun/java2d/pisces/Transform4.java
+0
-84
未找到文件。
src/share/classes/sun/java2d/pisces/Dasher.java
浏览文件 @
90b4e7d3
...
...
@@ -36,117 +36,71 @@ package sun.java2d.pisces;
* semantics are unclear.
*
*/
public
class
Dasher
extends
LineSink
{
public
class
Dasher
implements
LineSink
{
private
final
LineSink
output
;
private
final
float
[]
dash
;
private
final
float
startPhase
;
private
final
boolean
startDashOn
;
private
final
int
startIdx
;
LineSink
output
;
int
[]
dash
;
int
startPhase
;
boolean
startDashOn
;
int
startIdx
;
private
final
float
m00
,
m10
,
m01
,
m11
;
private
final
float
det
;
int
idx
;
boolean
dashOn
;
int
phase
;
private
boolean
firstDashOn
;
private
boolean
starting
;
int
sx
,
sy
;
int
x0
,
y0
;
private
int
idx
;
private
boolean
dashOn
;
private
float
phase
;
int
m00
,
m01
;
int
m10
,
m11
;
private
float
sx
,
sy
;
private
float
x0
,
y0
;
private
float
sx1
,
sy1
;
Transform4
transform
;
boolean
symmetric
;
long
ldet
;
boolean
firstDashOn
;
boolean
starting
;
int
sx1
,
sy1
;
/**
* Empty constructor. <code>setOutput</code> and
* <code>setParameters</code> must be called prior to calling any
* other methods.
*/
public
Dasher
()
{}
/**
* Constructs a <code>Dasher</code>.
*
* @param output an output <code>LineSink</code>.
* @param dash an array of <code>int</code>s containing the dash
* pattern in S15.16 format.
* @param phase an <code>int</code> containing the dash phase in
* S15.16 format.
* @param dash an array of <code>int</code>s containing the dash pattern
* @param phase an <code>int</code> containing the dash phase
* @param transform a <code>Transform4</code> object indicating
* the transform that has been previously applied to all incoming
* coordinates. This is required in order to compute dash lengths
* properly.
*/
public
Dasher
(
LineSink
output
,
int
[]
dash
,
int
phase
,
Transform4
transform
)
{
setOutput
(
output
);
setParameters
(
dash
,
phase
,
transform
);
}
/**
* Sets the output <code>LineSink</code> of this
* <code>Dasher</code>.
*
* @param output an output <code>LineSink</code>.
*/
public
void
setOutput
(
LineSink
output
)
{
this
.
output
=
output
;
}
/**
* Sets the parameters of this <code>Dasher</code>.
*
* @param dash an array of <code>int</code>s containing the dash
* pattern in S15.16 format.
* @param phase an <code>int</code> containing the dash phase in
* S15.16 format.
* @param transform a <code>Transform4</code> object indicating
* the transform that has been previously applied to all incoming
* coordinates. This is required in order to compute dash lengths
* properly.
*/
public
void
setParameters
(
int
[]
dash
,
int
phase
,
Transform4
transform
)
{
float
[]
dash
,
float
phase
,
float
a00
,
float
a01
,
float
a10
,
float
a11
)
{
if
(
phase
<
0
)
{
throw
new
IllegalArgumentException
(
"phase < 0 !"
);
}
this
.
output
=
output
;
// Normalize so 0 <= phase < dash[0]
int
idx
=
0
;
dashOn
=
true
;
in
t
d
;
floa
t
d
;
while
(
phase
>=
(
d
=
dash
[
idx
]))
{
phase
-=
d
;
idx
=
(
idx
+
1
)
%
dash
.
length
;
dashOn
=
!
dashOn
;
}
this
.
dash
=
new
int
[
dash
.
length
];
for
(
int
i
=
0
;
i
<
dash
.
length
;
i
++)
{
this
.
dash
[
i
]
=
dash
[
i
];
}
this
.
dash
=
dash
;
this
.
startPhase
=
this
.
phase
=
phase
;
this
.
startDashOn
=
dashOn
;
this
.
startIdx
=
idx
;
this
.
transform
=
transform
;
this
.
m00
=
transform
.
m00
;
this
.
m01
=
transform
.
m01
;
this
.
m10
=
transform
.
m10
;
this
.
m11
=
transform
.
m11
;
this
.
ldet
=
((
long
)
m00
*
m11
-
(
long
)
m01
*
m10
)
>>
16
;
this
.
symmetric
=
(
m00
==
m11
&&
m10
==
-
m01
);
m00
=
a00
;
m01
=
a01
;
m10
=
a10
;
m11
=
a11
;
det
=
m00
*
m11
-
m01
*
m10
;
}
public
void
moveTo
(
int
x0
,
in
t
y0
)
{
public
void
moveTo
(
float
x0
,
floa
t
y0
)
{
output
.
moveTo
(
x0
,
y0
);
this
.
idx
=
startIdx
;
this
.
dashOn
=
this
.
startDashOn
;
...
...
@@ -160,7 +114,7 @@ public class Dasher extends LineSink {
output
.
lineJoin
();
}
private
void
goTo
(
int
x1
,
in
t
y1
)
{
private
void
goTo
(
float
x1
,
floa
t
y1
)
{
if
(
dashOn
)
{
if
(
starting
)
{
this
.
sx1
=
x1
;
...
...
@@ -180,52 +134,64 @@ public class Dasher extends LineSink {
this
.
y0
=
y1
;
}
public
void
lineTo
(
int
x1
,
int
y1
)
{
while
(
true
)
{
int
d
=
dash
[
idx
]
-
phase
;
int
lx
=
x1
-
x0
;
int
ly
=
y1
-
y0
;
// Compute segment length in the untransformed
// coordinate system
// IMPL NOTE - use fixed point
int
l
;
if
(
symmetric
)
{
l
=
(
int
)((
PiscesMath
.
hypot
(
lx
,
ly
)*
65536L
)/
ldet
);
}
else
{
long
la
=
((
long
)
ly
*
m00
-
(
long
)
lx
*
m10
)/
ldet
;
long
lb
=
((
long
)
ly
*
m01
-
(
long
)
lx
*
m11
)/
ldet
;
l
=
(
int
)
PiscesMath
.
hypot
(
la
,
lb
);
}
public
void
lineTo
(
float
x1
,
float
y1
)
{
// The widened line is squished to a 0 width one, so no drawing is done
if
(
det
==
0
)
{
goTo
(
x1
,
y1
);
return
;
}
float
dx
=
x1
-
x0
;
float
dy
=
y1
-
y0
;
// Compute segment length in the untransformed
// coordinate system
if
(
l
<
d
)
{
float
la
=
(
dy
*
m00
-
dx
*
m10
)/
det
;
float
lb
=
(
dy
*
m01
-
dx
*
m11
)/
det
;
float
origLen
=
(
float
)
Math
.
hypot
(
la
,
lb
);
if
(
origLen
==
0
)
{
// Let the output LineSink deal with cases where dx, dy are 0.
goTo
(
x1
,
y1
);
return
;
}
// The scaling factors needed to get the dx and dy of the
// transformed dash segments.
float
cx
=
dx
/
origLen
;
float
cy
=
dy
/
origLen
;
while
(
true
)
{
float
leftInThisDashSegment
=
dash
[
idx
]
-
phase
;
if
(
origLen
<
leftInThisDashSegment
)
{
goTo
(
x1
,
y1
);
// Advance phase within current dash segment
phase
+=
l
;
phase
+=
origLen
;
return
;
}
else
if
(
origLen
==
leftInThisDashSegment
)
{
goTo
(
x1
,
y1
);
phase
=
0
f
;
idx
=
(
idx
+
1
)
%
dash
.
length
;
dashOn
=
!
dashOn
;
return
;
}
long
t
;
int
xsplit
,
ysplit
;
// // For zero length dashses, SE appears to move 1/8 unit
// // in device space
// if (d == 0) {
// double dlx = lx/65536.0;
// double dly = ly/65536.0;
// len = PiscesMath.hypot(dlx, dly);
// double dt = 1.0/(8*len);
// double dxsplit = (x0/65536.0) + dt*dlx;
// double dysplit = (y0/65536.0) + dt*dly;
// xsplit = (int)(dxsplit*65536.0);
// ysplit = (int)(dysplit*65536.0);
// } else {
t
=
((
long
)
d
<<
16
)/
l
;
xsplit
=
x0
+
(
int
)(
t
*(
x1
-
x0
)
>>
16
);
ysplit
=
y0
+
(
int
)(
t
*(
y1
-
y0
)
>>
16
);
// }
goTo
(
xsplit
,
ysplit
);
float
dashx
,
dashy
;
float
dashdx
=
dash
[
idx
]
*
cx
;
float
dashdy
=
dash
[
idx
]
*
cy
;
if
(
phase
==
0
)
{
dashx
=
x0
+
dashdx
;
dashy
=
y0
+
dashdy
;
}
else
{
float
p
=
(
leftInThisDashSegment
)
/
dash
[
idx
];
dashx
=
x0
+
p
*
dashdx
;
dashy
=
y0
+
p
*
dashdy
;
}
goTo
(
dashx
,
dashy
);
origLen
-=
(
dash
[
idx
]
-
phase
);
// Advance to next dash segment
idx
=
(
idx
+
1
)
%
dash
.
length
;
dashOn
=
!
dashOn
;
...
...
@@ -233,6 +199,7 @@ public class Dasher extends LineSink {
}
}
public
void
close
()
{
lineTo
(
sx
,
sy
);
if
(
firstDashOn
)
{
...
...
src/share/classes/sun/java2d/pisces/LineSink.java
浏览文件 @
90b4e7d3
...
...
@@ -39,16 +39,16 @@ package sun.java2d.pisces;
* <code>LineSink</code> interface.
*
*/
public
abstract
class
LineSink
{
public
interface
LineSink
{
/**
* Moves the current drawing position to the point <code>(x0,
* y0)</code>.
*
* @param x0 the X coordinate
in S15.16 format
* @param y0 the Y coordinate
in S15.16 format
* @param x0 the X coordinate
* @param y0 the Y coordinate
*/
public
abstract
void
moveTo
(
int
x0
,
in
t
y0
);
public
void
moveTo
(
float
x0
,
floa
t
y0
);
/**
* Provides a hint that the current segment should be joined to
...
...
@@ -65,29 +65,29 @@ public abstract class LineSink {
* <p> Other <code>LineSink</code> classes should simply pass this
* hint to their output sink as needed.
*/
public
abstract
void
lineJoin
();
public
void
lineJoin
();
/**
* Draws a line from the current drawing position to the point
* <code>(x1, y1)</code> and sets the current drawing position to
* <code>(x1, y1)</code>.
*
* @param x1 the X coordinate
in S15.16 format
* @param y1 the Y coordinate
in S15.16 format
* @param x1 the X coordinate
* @param y1 the Y coordinate
*/
public
abstract
void
lineTo
(
int
x1
,
in
t
y1
);
public
void
lineTo
(
float
x1
,
floa
t
y1
);
/**
* Closes the current path by drawing a line from the current
* drawing position to the point specified by the moset recent
* <code>moveTo</code> command.
*/
public
abstract
void
close
();
public
void
close
();
/**
* Ends the current path. It may be necessary to end a path in
* order to allow end caps to be drawn.
*/
public
abstract
void
end
();
public
void
end
();
}
src/share/classes/sun/java2d/pisces/PiscesMath.java
已删除
100644 → 0
浏览文件 @
2c7696d6
/*
* Copyright (c) 2007, 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. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* 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.
*/
package
sun.java2d.pisces
;
public
class
PiscesMath
{
private
PiscesMath
()
{}
private
static
final
int
SINTAB_LG_ENTRIES
=
10
;
private
static
final
int
SINTAB_ENTRIES
=
1
<<
SINTAB_LG_ENTRIES
;
private
static
int
[]
sintab
;
public
static
final
int
PI
=
(
int
)(
Math
.
PI
*
65536.0
);
public
static
final
int
TWO_PI
=
(
int
)(
2.0
*
Math
.
PI
*
65536.0
);
public
static
final
int
PI_OVER_TWO
=
(
int
)((
Math
.
PI
/
2.0
)*
65536.0
);
public
static
final
int
SQRT_TWO
=
(
int
)(
Math
.
sqrt
(
2.0
)*
65536.0
);
static
{
sintab
=
new
int
[
SINTAB_ENTRIES
+
1
];
for
(
int
i
=
0
;
i
<
SINTAB_ENTRIES
+
1
;
i
++)
{
double
theta
=
i
*(
Math
.
PI
/
2.0
)/
SINTAB_ENTRIES
;
sintab
[
i
]
=
(
int
)(
Math
.
sin
(
theta
)*
65536.0
);
}
}
public
static
int
sin
(
int
theta
)
{
int
sign
=
1
;
if
(
theta
<
0
)
{
theta
=
-
theta
;
sign
=
-
1
;
}
// 0 <= theta
while
(
theta
>=
TWO_PI
)
{
theta
-=
TWO_PI
;
}
// 0 <= theta < 2*PI
if
(
theta
>=
PI
)
{
theta
=
TWO_PI
-
theta
;
sign
=
-
sign
;
}
// 0 <= theta < PI
if
(
theta
>
PI_OVER_TWO
)
{
theta
=
PI
-
theta
;
}
// 0 <= theta <= PI/2
int
itheta
=
(
int
)((
long
)
theta
*
SINTAB_ENTRIES
/(
PI_OVER_TWO
));
return
sign
*
sintab
[
itheta
];
}
public
static
int
cos
(
int
theta
)
{
return
sin
(
PI_OVER_TWO
-
theta
);
}
// public static double sqrt(double x) {
// double dsqrt = Math.sqrt(x);
// int ix = (int)(x*65536.0);
// Int Isqrt = Isqrt(Ix);
// Long Lx = (Long)(X*65536.0);
// Long Lsqrt = Lsqrt(Lx);
// System.Out.Println();
// System.Out.Println("X = " + X);
// System.Out.Println("Dsqrt = " + Dsqrt);
// System.Out.Println("Ix = " + Ix);
// System.Out.Println("Isqrt = " + Isqrt/65536.0);
// System.Out.Println("Lx = " + Lx);
// System.Out.Println("Lsqrt = " + Lsqrt/65536.0);
// Return Dsqrt;
// }
// From Ken Turkowski, _Fixed-Point Square Root_, In Graphics Gems V
public
static
int
isqrt
(
int
x
)
{
int
fracbits
=
16
;
int
root
=
0
;
int
remHi
=
0
;
int
remLo
=
x
;
int
count
=
15
+
fracbits
/
2
;
do
{
remHi
=
(
remHi
<<
2
)
|
(
remLo
>>>
30
);
// N.B. - unsigned shift R
remLo
<<=
2
;
root
<<=
1
;
int
testdiv
=
(
root
<<
1
)
+
1
;
if
(
remHi
>=
testdiv
)
{
remHi
-=
testdiv
;
root
++;
}
}
while
(
count
--
!=
0
);
return
root
;
}
public
static
long
lsqrt
(
long
x
)
{
int
fracbits
=
16
;
long
root
=
0
;
long
remHi
=
0
;
long
remLo
=
x
;
int
count
=
31
+
fracbits
/
2
;
do
{
remHi
=
(
remHi
<<
2
)
|
(
remLo
>>>
62
);
// N.B. - unsigned shift R
remLo
<<=
2
;
root
<<=
1
;
long
testDiv
=
(
root
<<
1
)
+
1
;
if
(
remHi
>=
testDiv
)
{
remHi
-=
testDiv
;
root
++;
}
}
while
(
count
--
!=
0
);
return
root
;
}
public
static
double
hypot
(
double
x
,
double
y
)
{
// new RuntimeException().printStackTrace();
return
Math
.
sqrt
(
x
*
x
+
y
*
y
);
}
public
static
int
hypot
(
int
x
,
int
y
)
{
return
(
int
)((
lsqrt
((
long
)
x
*
x
+
(
long
)
y
*
y
)
+
128
)
>>
8
);
}
public
static
long
hypot
(
long
x
,
long
y
)
{
return
(
lsqrt
(
x
*
x
+
y
*
y
)
+
128
)
>>
8
;
}
}
src/share/classes/sun/java2d/pisces/PiscesRenderingEngine.java
浏览文件 @
90b4e7d3
...
...
@@ -27,6 +27,7 @@ package sun.java2d.pisces;
import
java.awt.Shape
;
import
java.awt.BasicStroke
;
import
java.awt.geom.FlatteningPathIterator
;
import
java.awt.geom.Path2D
;
import
java.awt.geom.AffineTransform
;
import
java.awt.geom.PathIterator
;
...
...
@@ -37,23 +38,9 @@ import sun.java2d.pipe.RenderingEngine;
import
sun.java2d.pipe.AATileGenerator
;
public
class
PiscesRenderingEngine
extends
RenderingEngine
{
public
static
Transform4
IdentT4
=
new
Transform4
();
public
static
double
defaultFlat
=
0.1
;
static
int
FloatToS15_16
(
float
flt
)
{
flt
=
flt
*
65536
f
+
0.5f
;
if
(
flt
<=
-(
65536
f
*
65536
f
))
{
return
Integer
.
MIN_VALUE
;
}
else
if
(
flt
>=
(
65536
f
*
65536
f
))
{
return
Integer
.
MAX_VALUE
;
}
else
{
return
(
int
)
Math
.
floor
(
flt
);
}
}
static
float
S15_16ToFloat
(
int
fix
)
{
return
(
fix
/
65536
f
);
}
private
static
enum
NormMode
{
OFF
,
ON_NO_AA
,
ON_WITH_AA
}
/**
* Create a widened path as specified by the parameters.
...
...
@@ -85,18 +72,19 @@ public class PiscesRenderingEngine extends RenderingEngine {
strokeTo
(
src
,
null
,
width
,
NormMode
.
OFF
,
caps
,
join
,
miterlimit
,
dashes
,
dashphase
,
new
LineSink
()
{
public
void
moveTo
(
int
x0
,
in
t
y0
)
{
p2d
.
moveTo
(
S15_16ToFloat
(
x0
),
S15_16ToFloat
(
y0
)
);
public
void
moveTo
(
float
x0
,
floa
t
y0
)
{
p2d
.
moveTo
(
x0
,
y0
);
}
public
void
lineJoin
()
{}
public
void
lineTo
(
int
x1
,
in
t
y1
)
{
p2d
.
lineTo
(
S15_16ToFloat
(
x1
),
S15_16ToFloat
(
y1
)
);
public
void
lineTo
(
float
x1
,
floa
t
y1
)
{
p2d
.
lineTo
(
x1
,
y1
);
}
public
void
close
()
{
p2d
.
closePath
();
...
...
@@ -142,14 +130,17 @@ public class PiscesRenderingEngine extends RenderingEngine {
boolean
antialias
,
final
PathConsumer2D
consumer
)
{
strokeTo
(
src
,
at
,
bs
,
thin
,
normalize
,
antialias
,
NormMode
norm
=
(
normalize
)
?
((
antialias
)
?
NormMode
.
ON_WITH_AA
:
NormMode
.
ON_NO_AA
)
:
NormMode
.
OFF
;
strokeTo
(
src
,
at
,
bs
,
thin
,
norm
,
antialias
,
new
LineSink
()
{
public
void
moveTo
(
int
x0
,
in
t
y0
)
{
consumer
.
moveTo
(
S15_16ToFloat
(
x0
),
S15_16ToFloat
(
y0
)
);
public
void
moveTo
(
float
x0
,
floa
t
y0
)
{
consumer
.
moveTo
(
x0
,
y0
);
}
public
void
lineJoin
()
{}
public
void
lineTo
(
int
x1
,
in
t
y1
)
{
consumer
.
lineTo
(
S15_16ToFloat
(
x1
),
S15_16ToFloat
(
y1
)
);
public
void
lineTo
(
float
x1
,
floa
t
y1
)
{
consumer
.
lineTo
(
x1
,
y1
);
}
public
void
close
()
{
consumer
.
closePath
();
...
...
@@ -164,7 +155,7 @@ public class PiscesRenderingEngine extends RenderingEngine {
AffineTransform
at
,
BasicStroke
bs
,
boolean
thin
,
boolean
normalize
,
NormMode
normalize
,
boolean
antialias
,
LineSink
lsink
)
{
...
...
@@ -181,6 +172,7 @@ public class PiscesRenderingEngine extends RenderingEngine {
strokeTo
(
src
,
at
,
lw
,
normalize
,
bs
.
getEndCap
(),
bs
.
getLineJoin
(),
bs
.
getMiterLimit
(),
...
...
@@ -258,6 +250,7 @@ public class PiscesRenderingEngine extends RenderingEngine {
void
strokeTo
(
Shape
src
,
AffineTransform
at
,
float
width
,
NormMode
normalize
,
int
caps
,
int
join
,
float
miterlimit
,
...
...
@@ -265,36 +258,139 @@ public class PiscesRenderingEngine extends RenderingEngine {
float
dashphase
,
LineSink
lsink
)
{
Transform4
t4
;
if
(
at
==
null
||
at
.
isIdentity
())
{
t4
=
IdentT4
;
float
a00
=
1
f
,
a01
=
0
f
,
a10
=
0
f
,
a11
=
1
f
;
if
(
at
!=
null
&&
!
at
.
isIdentity
())
{
a00
=
(
float
)
at
.
getScaleX
();
a01
=
(
float
)
at
.
getShearX
();
a10
=
(
float
)
at
.
getShearY
();
a11
=
(
float
)
at
.
getScaleY
();
}
lsink
=
new
Stroker
(
lsink
,
width
,
caps
,
join
,
miterlimit
,
a00
,
a01
,
a10
,
a11
);
if
(
dashes
!=
null
)
{
lsink
=
new
Dasher
(
lsink
,
dashes
,
dashphase
,
a00
,
a01
,
a10
,
a11
);
}
PathIterator
pi
;
if
(
normalize
!=
NormMode
.
OFF
)
{
pi
=
new
FlatteningPathIterator
(
new
NormalizingPathIterator
(
src
.
getPathIterator
(
at
),
normalize
),
defaultFlat
);
}
else
{
t4
=
new
Transform4
(
FloatToS15_16
((
float
)
at
.
getScaleX
()),
FloatToS15_16
((
float
)
at
.
getShearX
()),
FloatToS15_16
((
float
)
at
.
getShearY
()),
FloatToS15_16
((
float
)
at
.
getScaleY
()));
pi
=
src
.
getPathIterator
(
at
,
defaultFlat
);
}
pathTo
(
pi
,
lsink
);
}
lsink
=
new
Stroker
(
lsink
,
FloatToS15_16
(
width
),
caps
,
join
,
FloatToS15_16
(
miterlimit
),
t4
);
if
(
dashes
!=
null
)
{
int
fdashes
[]
=
new
int
[
dashes
.
length
];
for
(
int
i
=
0
;
i
<
dashes
.
length
;
i
++)
{
fdashes
[
i
]
=
FloatToS15_16
(
dashes
[
i
]);
private
static
class
NormalizingPathIterator
implements
PathIterator
{
private
final
PathIterator
src
;
// the adjustment applied to the current position.
private
float
curx_adjust
,
cury_adjust
;
// the adjustment applied to the last moveTo position.
private
float
movx_adjust
,
movy_adjust
;
// constants used in normalization computations
private
final
float
lval
,
rval
;
NormalizingPathIterator
(
PathIterator
src
,
NormMode
mode
)
{
this
.
src
=
src
;
switch
(
mode
)
{
case
ON_NO_AA:
// round to nearest (0.25, 0.25) pixel
lval
=
rval
=
0.25f
;
break
;
case
ON_WITH_AA:
// round to nearest pixel center
lval
=
0
f
;
rval
=
0.5f
;
break
;
case
OFF:
throw
new
InternalError
(
"A NormalizingPathIterator should "
+
"not be created if no normalization is being done"
);
default
:
throw
new
InternalError
(
"Unrecognized normalization mode"
);
}
lsink
=
new
Dasher
(
lsink
,
fdashes
,
FloatToS15_16
(
dashphase
),
t4
);
}
PathIterator
pi
=
src
.
getPathIterator
(
at
,
defaultFlat
);
pathTo
(
pi
,
lsink
);
public
int
currentSegment
(
float
[]
coords
)
{
int
type
=
src
.
currentSegment
(
coords
);
int
lastCoord
;
switch
(
type
)
{
case
PathIterator
.
SEG_CUBICTO
:
lastCoord
=
4
;
break
;
case
PathIterator
.
SEG_QUADTO
:
lastCoord
=
2
;
break
;
case
PathIterator
.
SEG_LINETO
:
case
PathIterator
.
SEG_MOVETO
:
lastCoord
=
0
;
break
;
case
PathIterator
.
SEG_CLOSE
:
// we don't want to deal with this case later. We just exit now
curx_adjust
=
movx_adjust
;
cury_adjust
=
movy_adjust
;
return
type
;
default
:
throw
new
InternalError
(
"Unrecognized curve type"
);
}
// normalize endpoint
float
x_adjust
=
(
float
)
Math
.
floor
(
coords
[
lastCoord
]
+
lval
)
+
rval
-
coords
[
lastCoord
];
float
y_adjust
=
(
float
)
Math
.
floor
(
coords
[
lastCoord
+
1
]
+
lval
)
+
rval
-
coords
[
lastCoord
+
1
];
coords
[
lastCoord
]
+=
x_adjust
;
coords
[
lastCoord
+
1
]
+=
y_adjust
;
// now that the end points are done, normalize the control points
switch
(
type
)
{
case
PathIterator
.
SEG_CUBICTO
:
coords
[
0
]
+=
curx_adjust
;
coords
[
1
]
+=
cury_adjust
;
coords
[
2
]
+=
x_adjust
;
coords
[
3
]
+=
y_adjust
;
break
;
case
PathIterator
.
SEG_QUADTO
:
coords
[
0
]
+=
(
curx_adjust
+
x_adjust
)
/
2
;
coords
[
1
]
+=
(
cury_adjust
+
y_adjust
)
/
2
;
break
;
case
PathIterator
.
SEG_LINETO
:
break
;
case
PathIterator
.
SEG_MOVETO
:
movx_adjust
=
x_adjust
;
movy_adjust
=
y_adjust
;
break
;
case
PathIterator
.
SEG_CLOSE
:
throw
new
InternalError
(
"This should be handled earlier."
);
}
curx_adjust
=
x_adjust
;
cury_adjust
=
y_adjust
;
return
type
;
}
public
int
currentSegment
(
double
[]
coords
)
{
float
[]
tmp
=
new
float
[
6
];
int
type
=
this
.
currentSegment
(
tmp
);
for
(
int
i
=
0
;
i
<
6
;
i
++)
{
coords
[
i
]
=
(
float
)
tmp
[
i
];
}
return
type
;
}
public
int
getWindingRule
()
{
return
src
.
getWindingRule
();
}
public
boolean
isDone
()
{
return
src
.
isDone
();
}
public
void
next
()
{
src
.
next
();
}
}
void
pathTo
(
PathIterator
pi
,
LineSink
lsink
)
{
...
...
@@ -302,13 +398,11 @@ public class PiscesRenderingEngine extends RenderingEngine {
while
(!
pi
.
isDone
())
{
switch
(
pi
.
currentSegment
(
coords
))
{
case
PathIterator
.
SEG_MOVETO
:
lsink
.
moveTo
(
FloatToS15_16
(
coords
[
0
]),
FloatToS15_16
(
coords
[
1
]));
lsink
.
moveTo
(
coords
[
0
],
coords
[
1
]);
break
;
case
PathIterator
.
SEG_LINETO
:
lsink
.
lineJoin
();
lsink
.
lineTo
(
FloatToS15_16
(
coords
[
0
]),
FloatToS15_16
(
coords
[
1
]));
lsink
.
lineTo
(
coords
[
0
],
coords
[
1
]);
break
;
case
PathIterator
.
SEG_CLOSE
:
lsink
.
lineJoin
();
...
...
@@ -378,18 +472,28 @@ public class PiscesRenderingEngine extends RenderingEngine {
int
bbox
[])
{
PiscesCache
pc
=
PiscesCache
.
createInstance
();
Renderer
r
=
new
Renderer
();
r
.
setCache
(
pc
);
r
.
setAntialiasing
(
3
,
3
);
r
.
beginRendering
(
clip
.
getLoX
(),
clip
.
getLoY
(),
clip
.
getWidth
(),
clip
.
getHeight
());
Renderer
r
;
NormMode
norm
=
(
normalize
)
?
NormMode
.
ON_WITH_AA
:
NormMode
.
OFF
;
if
(
bs
==
null
)
{
PathIterator
pi
=
s
.
getPathIterator
(
at
,
defaultFlat
);
r
.
setWindingRule
(
pi
.
getWindingRule
());
PathIterator
pi
;
if
(
normalize
)
{
pi
=
new
FlatteningPathIterator
(
new
NormalizingPathIterator
(
s
.
getPathIterator
(
at
),
norm
),
defaultFlat
);
}
else
{
pi
=
s
.
getPathIterator
(
at
,
defaultFlat
);
}
r
=
new
Renderer
(
3
,
3
,
clip
.
getLoX
(),
clip
.
getLoY
(),
clip
.
getWidth
(),
clip
.
getHeight
(),
pi
.
getWindingRule
(),
pc
);
pathTo
(
pi
,
r
);
}
else
{
r
.
setWindingRule
(
PathIterator
.
WIND_NON_ZERO
);
strokeTo
(
s
,
at
,
bs
,
thin
,
normalize
,
true
,
r
);
r
=
new
Renderer
(
3
,
3
,
clip
.
getLoX
(),
clip
.
getLoY
(),
clip
.
getWidth
(),
clip
.
getHeight
(),
PathIterator
.
WIND_NON_ZERO
,
pc
);
strokeTo
(
s
,
at
,
bs
,
thin
,
norm
,
true
,
r
);
}
r
.
endRendering
();
PiscesTileGenerator
ptg
=
new
PiscesTileGenerator
(
pc
,
r
.
MAX_AA_ALPHA
);
...
...
@@ -420,3 +524,4 @@ public class PiscesRenderingEngine extends RenderingEngine {
}
}
}
src/share/classes/sun/java2d/pisces/Renderer.java
浏览文件 @
90b4e7d3
此差异已折叠。
点击以展开。
src/share/classes/sun/java2d/pisces/Stroker.java
浏览文件 @
90b4e7d3
此差异已折叠。
点击以展开。
src/share/classes/sun/java2d/pisces/Transform4.java
已删除
100644 → 0
浏览文件 @
2c7696d6
/*
* Copyright (c) 2007, 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. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* 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.
*/
package
sun.java2d.pisces
;
public
class
Transform4
{
public
int
m00
,
m01
,
m10
,
m11
;
// double det; // det*65536
public
Transform4
()
{
this
(
1
<<
16
,
0
,
0
,
1
<<
16
);
}
public
Transform4
(
int
m00
,
int
m01
,
int
m10
,
int
m11
)
{
this
.
m00
=
m00
;
this
.
m01
=
m01
;
this
.
m10
=
m10
;
this
.
m11
=
m11
;
// this.det = (double)m00*m11 - (double)m01*m10;
}
// public Transform4 createInverse() {
// double dm00 = m00/65536.0;
// double dm01 = m01/65536.0;
// double dm10 = m10/65536.0;
// double dm11 = m11/65536.0;
// double invdet = 65536.0/(dm00*dm11 - dm01*dm10);
// int im00 = (int)( dm11*invdet);
// int im01 = (int)(-dm01*invdet);
// int im10 = (int)(-dm10*invdet);
// int im11 = (int)( dm00*invdet);
// return new Transform4(im00, im01, im10, im11);
// }
// public void transform(int[] point) {
// }
// /**
// * Returns the length of the line segment obtained by inverse
// * transforming the points <code>(x0, y0)</code> and <code>(x1,
// * y1)</code>.
// */
// public int getTransformedLength(int x0, int x1, int y0, int y1) {
// int lx = x1 - x0;
// int ly = y1 - y0;
// double a = (double)m00*ly - (double)m10*lx;
// double b = (double)m01*ly - (double)m11*lx;
// double len = PiscesMath.sqrt((a*a + b*b)/(det*det));
// return (int)(len*65536.0);
// }
// public int getType() {
// }
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录