Print this page
Added gradle and cmake project
Split |
Close |
Expand all |
Collapse all |
--- old/src/java.desktop/share/classes/sun/java2d/loops/MaskFill.java
+++ new/src/java.desktop/share/classes/sun/java2d/loops/MaskFill.java
1 1 /*
2 2 * Copyright (c) 1999, 2018, Oracle and/or its affiliates. All rights reserved.
3 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 4 *
5 5 * This code is free software; you can redistribute it and/or modify it
6 6 * under the terms of the GNU General Public License version 2 only, as
7 7 * published by the Free Software Foundation. Oracle designates this
8 8 * particular file as subject to the "Classpath" exception as provided
9 9 * by Oracle in the LICENSE file that accompanied this code.
10 10 *
11 11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 14 * version 2 for more details (a copy is included in the LICENSE file that
15 15 * accompanied this code).
16 16 *
17 17 * You should have received a copy of the GNU General Public License version
18 18 * 2 along with this work; if not, write to the Free Software Foundation,
19 19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 20 *
21 21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 22 * or visit www.oracle.com if you need additional information or have any
23 23 * questions.
24 24 */
25 25
26 26 package sun.java2d.loops;
27 27
28 28 import java.awt.Composite;
29 29 import java.awt.image.BufferedImage;
30 30 import sun.awt.image.BufImgSurfaceData;
31 31 import sun.java2d.loops.GraphicsPrimitive;
32 32 import sun.java2d.SunGraphics2D;
33 33 import sun.java2d.SurfaceData;
34 34 import sun.java2d.pipe.Region;
35 35
36 36 /**
37 37 * MaskFill
38 38 * 1) fills rectangles of pixels on a surface
39 39 * 2) performs compositing of colors based upon a Composite
40 40 * parameter
41 41 * 3) blends result of composite with destination using an
42 42 * alpha coverage mask
43 43 * 4) the mask may be null in which case it should be treated
44 44 * as if it were an array of all opaque values (0xff)
45 45 */
46 46 public class MaskFill extends GraphicsPrimitive
47 47 {
48 48 public static final String methodSignature = "MaskFill(...)".toString();
49 49 public static final String fillPgramSignature =
50 50 "FillAAPgram(...)".toString();
51 51 public static final String drawPgramSignature =
52 52 "DrawAAPgram(...)".toString();
53 53
54 54 public static final int primTypeID = makePrimTypeID();
55 55
56 56 private static RenderCache fillcache = new RenderCache(10);
57 57
58 58 public static MaskFill locate(SurfaceType srctype,
59 59 CompositeType comptype,
60 60 SurfaceType dsttype)
61 61 {
62 62 return (MaskFill)
63 63 GraphicsPrimitiveMgr.locate(primTypeID,
64 64 srctype, comptype, dsttype);
65 65 }
66 66
67 67 public static MaskFill locatePrim(SurfaceType srctype,
68 68 CompositeType comptype,
69 69 SurfaceType dsttype)
70 70 {
71 71 return (MaskFill)
72 72 GraphicsPrimitiveMgr.locatePrim(primTypeID,
73 73 srctype, comptype, dsttype);
74 74 }
75 75
76 76 /*
77 77 * Note that this uses locatePrim, not locate, so it can return
78 78 * null if there is no specific loop to handle this op...
79 79 */
80 80 public static MaskFill getFromCache(SurfaceType src,
81 81 CompositeType comp,
82 82 SurfaceType dst)
83 83 {
84 84 Object o = fillcache.get(src, comp, dst);
85 85 if (o != null) {
86 86 return (MaskFill) o;
87 87 }
88 88 MaskFill fill = locatePrim(src, comp, dst);
89 89 if (fill != null) {
90 90 fillcache.put(src, comp, dst, fill);
91 91 }
92 92 return fill;
93 93 }
94 94
95 95 protected MaskFill(String alternateSignature,
96 96 SurfaceType srctype,
97 97 CompositeType comptype,
98 98 SurfaceType dsttype)
99 99 {
100 100 super(alternateSignature, primTypeID, srctype, comptype, dsttype);
101 101 }
102 102
103 103 protected MaskFill(SurfaceType srctype,
104 104 CompositeType comptype,
105 105 SurfaceType dsttype)
106 106 {
107 107 super(methodSignature, primTypeID, srctype, comptype, dsttype);
108 108 }
109 109
110 110 public MaskFill(long pNativePrim,
111 111 SurfaceType srctype,
112 112 CompositeType comptype,
113 113 SurfaceType dsttype)
114 114 {
115 115 super(pNativePrim, methodSignature, primTypeID, srctype, comptype, dsttype);
116 116 }
117 117
118 118 /**
119 119 * All MaskFill implementors must have this invoker method
120 120 */
121 121 public native void MaskFill(SunGraphics2D sg2d, SurfaceData sData,
122 122 Composite comp,
123 123 int x, int y, int w, int h,
124 124 byte[] mask, int maskoff, int maskscan);
125 125
126 126 public native void FillAAPgram(SunGraphics2D sg2d, SurfaceData sData,
127 127 Composite comp,
128 128 double x, double y,
129 129 double dx1, double dy1,
130 130 double dx2, double dy2);
131 131
132 132 public native void DrawAAPgram(SunGraphics2D sg2d, SurfaceData sData,
133 133 Composite comp,
134 134 double x, double y,
135 135 double dx1, double dy1,
136 136 double dx2, double dy2,
137 137 double lw1, double lw2);
138 138
139 139 public boolean canDoParallelograms() {
140 140 return (getNativePrim() != 0);
141 141 }
142 142
143 143 static {
144 144 GraphicsPrimitiveMgr.registerGeneral(new MaskFill(null, null, null));
145 145 }
146 146
147 147 public GraphicsPrimitive makePrimitive(SurfaceType srctype,
148 148 CompositeType comptype,
149 149 SurfaceType dsttype)
150 150 {
151 151 if (SurfaceType.OpaqueColor.equals(srctype) ||
152 152 SurfaceType.AnyColor.equals(srctype))
153 153 {
154 154 if (CompositeType.Xor.equals(comptype)) {
155 155 throw new InternalError("Cannot construct MaskFill for " +
156 156 "XOR mode");
157 157 } else {
158 158 return new General(srctype, comptype, dsttype);
159 159 }
160 160 } else {
161 161 throw new InternalError("MaskFill can only fill with colors");
162 162 }
163 163 }
164 164
165 165 private static class General extends MaskFill {
166 166 FillRect fillop;
167 167 MaskBlit maskop;
168 168
169 169 public General(SurfaceType srctype,
170 170 CompositeType comptype,
171 171 SurfaceType dsttype)
172 172 {
173 173 super(srctype, comptype, dsttype);
174 174 fillop = FillRect.locate(srctype,
175 175 CompositeType.SrcNoEa,
176 176 SurfaceType.IntArgb);
177 177 maskop = MaskBlit.locate(SurfaceType.IntArgb, comptype, dsttype);
178 178 }
179 179
180 180 public void MaskFill(SunGraphics2D sg2d,
181 181 SurfaceData sData,
182 182 Composite comp,
183 183 int x, int y, int w, int h,
184 184 byte[] mask, int offset, int scan)
185 185 {
186 186 BufferedImage dstBI =
187 187 new BufferedImage(w, h, BufferedImage.TYPE_INT_ARGB);
188 188 SurfaceData tmpData = BufImgSurfaceData.createData(dstBI);
189 189
190 190 // REMIND: This is not pretty. It would be nicer if we
191 191 // passed a "FillData" object to the Pixel loops, instead
192 192 // of a SunGraphics2D parameter...
193 193 Region clip = sg2d.clipRegion;
194 194 sg2d.clipRegion = null;
195 195 int pixel = sg2d.pixel;
196 196 sg2d.pixel = tmpData.pixelFor(sg2d.getColor());
197 197 fillop.FillRect(sg2d, tmpData, 0, 0, w, h);
198 198 sg2d.pixel = pixel;
199 199 sg2d.clipRegion = clip;
200 200
201 201 maskop.MaskBlit(tmpData, sData, comp, null,
202 202 0, 0, x, y, w, h,
203 203 mask, offset, scan);
204 204 }
205 205 }
206 206
207 207 public GraphicsPrimitive traceWrap() {
208 208 return new TraceMaskFill(this);
209 209 }
210 210
211 211 private static class TraceMaskFill extends MaskFill {
212 212 MaskFill target;
213 213 MaskFill fillPgramTarget;
214 214 MaskFill drawPgramTarget;
215 215
216 216 public TraceMaskFill(MaskFill target) {
217 217 super(target.getSourceType(),
218 218 target.getCompositeType(),
219 219 target.getDestType());
220 220 this.target = target;
221 221 this.fillPgramTarget = new MaskFill(fillPgramSignature,
222 222 target.getSourceType(),
223 223 target.getCompositeType(),
224 224 target.getDestType());
225 225 this.drawPgramTarget = new MaskFill(drawPgramSignature,
226 226 target.getSourceType(),
227 227 target.getCompositeType(),
228 228 target.getDestType());
229 229 }
↓ open down ↓ |
229 lines elided |
↑ open up ↑ |
230 230
231 231 public GraphicsPrimitive traceWrap() {
232 232 return this;
233 233 }
234 234
235 235 public void MaskFill(SunGraphics2D sg2d, SurfaceData sData,
236 236 Composite comp,
237 237 int x, int y, int w, int h,
238 238 byte[] mask, int maskoff, int maskscan)
239 239 {
240 - tracePrimitive(target);
240 + if ((traceflags & TRACEPTIME) == 0) {
241 + tracePrimitive(target);
242 + }
243 + long time = System.nanoTime();
241 244 target.MaskFill(sg2d, sData, comp, x, y, w, h,
242 245 mask, maskoff, maskscan);
246 + tracePrimitiveTime(target, System.nanoTime() - time);
243 247 }
244 248
245 249 public void FillAAPgram(SunGraphics2D sg2d, SurfaceData sData,
246 250 Composite comp,
247 251 double x, double y,
248 252 double dx1, double dy1,
249 253 double dx2, double dy2)
250 254 {
251 - tracePrimitive(fillPgramTarget);
255 + if ((traceflags & TRACEPTIME) == 0) {
256 + tracePrimitive(fillPgramTarget);
257 + }
258 + long time = System.nanoTime();
252 259 target.FillAAPgram(sg2d, sData, comp,
253 260 x, y, dx1, dy1, dx2, dy2);
261 + tracePrimitiveTime(fillPgramTarget, System.nanoTime() - time);
254 262 }
255 263
256 264 public void DrawAAPgram(SunGraphics2D sg2d, SurfaceData sData,
257 265 Composite comp,
258 266 double x, double y,
259 267 double dx1, double dy1,
260 268 double dx2, double dy2,
261 269 double lw1, double lw2)
262 270 {
263 - tracePrimitive(drawPgramTarget);
271 + if ((traceflags & TRACEPTIME) == 0) {
272 + tracePrimitive(drawPgramTarget);
273 + }
274 + long time = System.nanoTime();
264 275 target.DrawAAPgram(sg2d, sData, comp,
265 276 x, y, dx1, dy1, dx2, dy2, lw1, lw2);
277 + tracePrimitiveTime(drawPgramTarget, System.nanoTime() - time);
266 278 }
267 279
268 280 public boolean canDoParallelograms() {
269 281 return target.canDoParallelograms();
270 282 }
271 283 }
272 284 }
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX