2
|
1 |
/*
|
5506
|
2 |
* Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved.
|
2
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
|
4 |
*
|
|
5 |
* This code is free software; you can redistribute it and/or modify it
|
|
6 |
* under the terms of the GNU General Public License version 2 only, as
|
5506
|
7 |
* published by the Free Software Foundation. Oracle designates this
|
2
|
8 |
* particular file as subject to the "Classpath" exception as provided
|
5506
|
9 |
* by Oracle in the LICENSE file that accompanied this code.
|
2
|
10 |
*
|
|
11 |
* This code is distributed in the hope that it will be useful, but WITHOUT
|
|
12 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
13 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
14 |
* version 2 for more details (a copy is included in the LICENSE file that
|
|
15 |
* accompanied this code).
|
|
16 |
*
|
|
17 |
* You should have received a copy of the GNU General Public License version
|
|
18 |
* 2 along with this work; if not, write to the Free Software Foundation,
|
|
19 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
20 |
*
|
5506
|
21 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
|
22 |
* or visit www.oracle.com if you need additional information or have any
|
|
23 |
* questions.
|
2
|
24 |
*/
|
|
25 |
|
|
26 |
package sun.java2d.loops;
|
|
27 |
|
|
28 |
import java.awt.Composite;
|
|
29 |
import java.awt.geom.AffineTransform;
|
|
30 |
import java.lang.ref.WeakReference;
|
|
31 |
import sun.java2d.SurfaceData;
|
|
32 |
import sun.java2d.loops.GraphicsPrimitive;
|
|
33 |
import sun.java2d.pipe.Region;
|
|
34 |
|
|
35 |
/**
|
|
36 |
* TransformHelper
|
|
37 |
* 1) applies an AffineTransform to a rectangle of pixels while copying
|
|
38 |
* from one surface to another
|
|
39 |
* 2) performs compositing of colors based upon a Composite
|
|
40 |
* parameter
|
|
41 |
*
|
|
42 |
* precise behavior is undefined if the source surface
|
|
43 |
* and the destination surface are the same surface
|
|
44 |
* with overlapping regions of pixels
|
|
45 |
*/
|
|
46 |
public class TransformHelper extends GraphicsPrimitive
|
|
47 |
{
|
|
48 |
public static final String methodSignature =
|
|
49 |
"TransformHelper(...)".toString();
|
|
50 |
|
|
51 |
public static final int primTypeID = makePrimTypeID();
|
|
52 |
|
|
53 |
private static RenderCache helpercache = new RenderCache(10);
|
|
54 |
|
|
55 |
public static TransformHelper locate(SurfaceType srctype) {
|
|
56 |
return (TransformHelper)
|
|
57 |
GraphicsPrimitiveMgr.locate(primTypeID,
|
|
58 |
srctype,
|
|
59 |
CompositeType.SrcNoEa,
|
|
60 |
SurfaceType.IntArgbPre);
|
|
61 |
}
|
|
62 |
|
|
63 |
public static synchronized TransformHelper getFromCache(SurfaceType src) {
|
|
64 |
Object o = helpercache.get(src, null, null);
|
|
65 |
if (o != null) {
|
|
66 |
return (TransformHelper) o;
|
|
67 |
}
|
|
68 |
TransformHelper helper = locate(src);
|
|
69 |
if (helper == null) {
|
|
70 |
/*
|
|
71 |
System.out.println("helper loop not found for:");
|
|
72 |
System.out.println("src: "+src);
|
|
73 |
*/
|
|
74 |
} else {
|
|
75 |
helpercache.put(src, null, null, helper);
|
|
76 |
}
|
|
77 |
return helper;
|
|
78 |
}
|
|
79 |
|
|
80 |
protected TransformHelper(SurfaceType srctype) {
|
|
81 |
super(methodSignature, primTypeID, srctype,
|
|
82 |
CompositeType.SrcNoEa,
|
|
83 |
SurfaceType.IntArgbPre);
|
|
84 |
}
|
|
85 |
|
|
86 |
public TransformHelper(long pNativePrim, SurfaceType srctype,
|
|
87 |
CompositeType comptype,
|
|
88 |
SurfaceType dsttype)
|
|
89 |
{
|
|
90 |
super(pNativePrim, methodSignature, primTypeID,
|
|
91 |
srctype, comptype, dsttype);
|
|
92 |
}
|
|
93 |
|
|
94 |
public native void Transform(MaskBlit output,
|
|
95 |
SurfaceData src, SurfaceData dst,
|
|
96 |
Composite comp, Region clip,
|
|
97 |
AffineTransform itx, int txtype,
|
|
98 |
int sx1, int sy1, int sx2, int sy2,
|
|
99 |
int dx1, int dy1, int dx2, int dy2,
|
|
100 |
int edges[], int dxoff, int dyoff);
|
|
101 |
|
|
102 |
public GraphicsPrimitive makePrimitive(SurfaceType srctype,
|
|
103 |
CompositeType comptype,
|
|
104 |
SurfaceType dsttype)
|
|
105 |
{
|
|
106 |
return null;
|
|
107 |
}
|
|
108 |
|
|
109 |
public GraphicsPrimitive traceWrap() {
|
|
110 |
return new TraceTransformHelper(this);
|
|
111 |
}
|
|
112 |
|
|
113 |
private static class TraceTransformHelper extends TransformHelper {
|
|
114 |
TransformHelper target;
|
|
115 |
|
|
116 |
public TraceTransformHelper(TransformHelper target) {
|
|
117 |
super(target.getSourceType());
|
|
118 |
this.target = target;
|
|
119 |
}
|
|
120 |
|
|
121 |
public GraphicsPrimitive traceWrap() {
|
|
122 |
return this;
|
|
123 |
}
|
|
124 |
|
|
125 |
public void Transform(MaskBlit output,
|
|
126 |
SurfaceData src, SurfaceData dst,
|
|
127 |
Composite comp, Region clip,
|
|
128 |
AffineTransform itx, int txtype,
|
|
129 |
int sx1, int sy1, int sx2, int sy2,
|
|
130 |
int dx1, int dy1, int dx2, int dy2,
|
|
131 |
int edges[], int dxoff, int dyoff)
|
|
132 |
{
|
|
133 |
tracePrimitive(target);
|
|
134 |
target.Transform(output, src, dst, comp, clip, itx, txtype,
|
|
135 |
sx1, sy1, sx2, sy2,
|
|
136 |
dx1, dy1, dx2, dy2,
|
|
137 |
edges, dxoff, dyoff);
|
|
138 |
}
|
|
139 |
}
|
|
140 |
}
|