Showing the changes to java/pkg/sun/java2d/loops (136 of 18352 files). Show all
Unified · Split
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
| @@ -0,0 +1,332 @@ | |||
| 1 | /* | ||
| 2 | * Copyright (c) 1999, 2004, Oracle and/or its affiliates. All rights reserved. | ||
| 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 | ||
| 7 | * published by the Free Software Foundation. Oracle designates this | ||
| 8 | * particular file as subject to the "Classpath" exception as provided | ||
| 9 | * by Oracle in the LICENSE file that accompanied this code. | ||
| 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 | * | ||
| 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. | ||
| 24 | */ | ||
| 25 | |||
| 26 | package sun.java2d.loops; | ||
| 27 | |||
| 28 | import java.awt.Composite; | ||
| 29 | import java.awt.CompositeContext; | ||
| 30 | import java.awt.RenderingHints; | ||
| 31 | import java.awt.image.ColorModel; | ||
| 32 | import java.awt.image.Raster; | ||
| 33 | import java.awt.image.WritableRaster; | ||
| 34 | import java.lang.ref.WeakReference; | ||
| 35 | import sun.java2d.loops.GraphicsPrimitive; | ||
| 36 | import sun.java2d.SurfaceData; | ||
| 37 | import sun.java2d.pipe.Region; | ||
| 38 | import sun.java2d.pipe.SpanIterator; | ||
| 39 | |||
| 40 | /** | ||
| 41 | * Blit | ||
| 42 | * 1) copies rectangle of pixels from one surface to another | ||
| 43 | * 2) performs compositing of colors based upon a Composite | ||
| 44 | * parameter | ||
| 45 | * | ||
| 46 | * precise behavior is undefined if the source surface | ||
| 47 | * and the destination surface are the same surface | ||
| 48 | * with overlapping regions of pixels | ||
| 49 | */ | ||
| 50 | |||
| 51 | public class Blit extends GraphicsPrimitive | ||
| 52 | { | ||
| 53 | public static final String methodSignature = "Blit(...)".toString(); | ||
| 54 | |||
| 55 | public static final int primTypeID = makePrimTypeID(); | ||
| 56 | |||
| 57 | private static RenderCache blitcache = new RenderCache(20); | ||
| 58 | |||
| 59 | public static Blit locate(SurfaceType srctype, | ||
| 60 | CompositeType comptype, | ||
| 61 | SurfaceType dsttype) | ||
| 62 | { | ||
| 63 | return (Blit) | ||
| 64 | GraphicsPrimitiveMgr.locate(primTypeID, | ||
| 65 | srctype, comptype, dsttype); | ||
| 66 | } | ||
| 67 | |||
| 68 | public static Blit getFromCache(SurfaceType src, | ||
| 69 | CompositeType comp, | ||
| 70 | SurfaceType dst) | ||
| 71 | { | ||
| 72 | Object o = blitcache.get(src, comp, dst); | ||
| 73 | if (o != null) { | ||
| 74 | return (Blit) o; | ||
| 75 | } | ||
| 76 | |||
| 77 | Blit blit = locate(src, comp, dst); | ||
| 78 | if (blit == null) { | ||
| 79 | System.out.println("blit loop not found for:"); | ||
| 80 | System.out.println("src: "+src); | ||
| 81 | System.out.println("comp: "+comp); | ||
| 82 | System.out.println("dst: "+dst); | ||
| 83 | } else { | ||
| 84 | blitcache.put(src, comp, dst, blit); | ||
| 85 | } | ||
| 86 | return blit; | ||
| 87 | } | ||
| 88 | |||
| 89 | protected Blit(SurfaceType srctype, | ||
| 90 | CompositeType comptype, | ||
| 91 | SurfaceType dsttype) | ||
| 92 | { | ||
| 93 | super(methodSignature, primTypeID, srctype, comptype, dsttype); | ||
| 94 | } | ||
| 95 | |||
| 96 | public Blit(long pNativePrim, | ||
| 97 | SurfaceType srctype, | ||
| 98 | CompositeType comptype, | ||
| 99 | SurfaceType dsttype) | ||
| 100 | { | ||
| 101 | super(pNativePrim, methodSignature, primTypeID, srctype, comptype, dsttype); | ||
| 102 | } | ||
| 103 | |||
| 104 | /** | ||
| 105 | * All Blit implementors must have this invoker method | ||
| 106 | */ | ||
| 107 | public native void Blit(SurfaceData src, SurfaceData dst, | ||
| 108 | Composite comp, Region clip, | ||
| 109 | int srcx, int srcy, | ||
| 110 | int dstx, int dsty, | ||
| 111 | int width, int height); | ||
| 112 | |||
| 113 | static { | ||
| 114 | GraphicsPrimitiveMgr.registerGeneral(new Blit(null, null, null)); | ||
| 115 | } | ||
| 116 | |||
| 117 | public GraphicsPrimitive makePrimitive(SurfaceType srctype, | ||
| 118 | CompositeType comptype, | ||
| 119 | SurfaceType dsttype) | ||
| 120 | { | ||
| 121 | /* | ||
| 122 | System.out.println("Constructing general blit for:"); | ||
| 123 | System.out.println("src: "+srctype); | ||
| 124 | System.out.println("comp: "+comptype); | ||
| 125 | System.out.println("dst: "+dsttype); | ||
| 126 | */ | ||
| 127 | |||
| 128 | if (comptype.isDerivedFrom(CompositeType.Xor)) { | ||
| 129 | GeneralXorBlit gxb = new GeneralXorBlit(srctype, | ||
| 130 | comptype, | ||
| 131 | dsttype); | ||
| 132 | setupGeneralBinaryOp(gxb); | ||
| 133 | return gxb; | ||
| 134 | } else if (comptype.isDerivedFrom(CompositeType.AnyAlpha)) { | ||
| 135 | return new GeneralMaskBlit(srctype, comptype, dsttype); | ||
| 136 | } else { | ||
| 137 | return AnyBlit.instance; | ||
| 138 | } | ||
| 139 | } | ||
| 140 | |||
| 141 | private static class AnyBlit extends Blit { | ||
| 142 | public static AnyBlit instance = new AnyBlit(); | ||
| 143 | |||
| 144 | public AnyBlit() { | ||
| 145 | super(SurfaceType.Any, CompositeType.Any, SurfaceType.Any); | ||
| 146 | } | ||
| 147 | |||
| 148 | public void Blit(SurfaceData srcData, | ||
| 149 | SurfaceData dstData, | ||
| 150 | Composite comp, | ||
| 151 | Region clip, | ||
| 152 | int srcx, int srcy, | ||
| 153 | int dstx, int dsty, | ||
| 154 | int width, int height) | ||
| 155 | { | ||
| 156 | ColorModel srcCM = srcData.getColorModel(); | ||
| 157 | ColorModel dstCM = dstData.getColorModel(); | ||
| 158 | // REMIND: Should get RenderingHints from sg2d | ||
| 159 | CompositeContext ctx = comp.createContext(srcCM, dstCM, | ||
| 160 | new RenderingHints(null)); | ||
| 161 | Raster srcRas = srcData.getRaster(srcx, srcy, width, height); | ||
| 162 | WritableRaster dstRas = | ||
| 163 | (WritableRaster) dstData.getRaster(dstx, dsty, width, height); | ||
| 164 | |||
| 165 | if (clip == null) { | ||
| 166 | clip = Region.getInstanceXYWH(dstx, dsty, width, height); | ||
| 167 | } | ||
| 168 | int span[] = {dstx, dsty, dstx+width, dsty+height}; | ||
| 169 | SpanIterator si = clip.getSpanIterator(span); | ||
| 170 | srcx -= dstx; | ||
| 171 | srcy -= dsty; | ||
| 172 | while (si.nextSpan(span)) { | ||
| 173 | int w = span[2] - span[0]; | ||
| 174 | int h = span[3] - span[1]; | ||
| 175 | srcRas = srcRas.createChild(srcx + span[0], srcy + span[1], | ||
| 176 | w, h, 0, 0, null); | ||
| 177 | dstRas = dstRas.createWritableChild(span[0], span[1], | ||
| 178 | w, h, 0, 0, null); | ||
| 179 | ctx.compose(srcRas, dstRas, dstRas); | ||
| 180 | } | ||
| 181 | ctx.dispose(); | ||
| 182 | } | ||
| 183 | } | ||
| 184 | |||
| 185 | private static class GeneralMaskBlit extends Blit { | ||
| 186 | MaskBlit performop; | ||
| 187 | |||
| 188 | public GeneralMaskBlit(SurfaceType srctype, | ||
| 189 | CompositeType comptype, | ||
| 190 | SurfaceType dsttype) | ||
| 191 | { | ||
| 192 | super(srctype, comptype, dsttype); | ||
| 193 | performop = MaskBlit.locate(srctype, comptype, dsttype); | ||
| 194 | } | ||
| 195 | |||
| 196 | public void Blit(SurfaceData srcData, | ||
| 197 | SurfaceData dstData, | ||
| 198 | Composite comp, | ||
| 199 | Region clip, | ||
| 200 | int srcx, int srcy, | ||
| 201 | int dstx, int dsty, | ||
| 202 | int width, int height) | ||
| 203 | { | ||
| 204 | performop.MaskBlit(srcData, dstData, comp, clip, | ||
| 205 | srcx, srcy, dstx, dsty, | ||
| 206 | width, height, | ||
| 207 | null, 0, 0); | ||
| 208 | } | ||
| 209 | } | ||
| 210 | |||
| 211 | private static class GeneralXorBlit | ||
| 212 | extends Blit | ||
| 213 | implements GeneralBinaryOp | ||
| 214 | { | ||
| 215 | Blit convertsrc; | ||
| 216 | Blit convertdst; | ||
| 217 | Blit performop; | ||
| 218 | Blit convertresult; | ||
| 219 | |||
| 220 | WeakReference srcTmp; | ||
| 221 | WeakReference dstTmp; | ||
| 222 | |||
| 223 | public GeneralXorBlit(SurfaceType srctype, | ||
| 224 | CompositeType comptype, | ||
| 225 | SurfaceType dsttype) | ||
| 226 | { | ||
| 227 | super(srctype, comptype, dsttype); | ||
| 228 | } | ||
| 229 | |||
| 230 | public void setPrimitives(Blit srcconverter, | ||
| 231 | Blit dstconverter, | ||
| 232 | GraphicsPrimitive genericop, | ||
| 233 | Blit resconverter) | ||
| 234 | { | ||
| 235 | this.convertsrc = srcconverter; | ||
| 236 | this.convertdst = dstconverter; | ||
| 237 | this.performop = (Blit) genericop; | ||
| 238 | this.convertresult = resconverter; | ||
| 239 | } | ||
| 240 | |||
| 241 | public synchronized void Blit(SurfaceData srcData, | ||
| 242 | SurfaceData dstData, | ||
| 243 | Composite comp, | ||
| 244 | Region clip, | ||
| 245 | int srcx, int srcy, | ||
| 246 | int dstx, int dsty, | ||
| 247 | int width, int height) | ||
| 248 | { | ||
| 249 | SurfaceData src, dst; | ||
| 250 | Region opclip; | ||
| 251 | int sx, sy, dx, dy; | ||
| 252 | |||
| 253 | if (convertsrc == null) { | ||
| 254 | src = srcData; | ||
| 255 | sx = srcx; | ||
| 256 | sy = srcy; | ||
| 257 | } else { | ||
| 258 | SurfaceData cachedSrc = null; | ||
| 259 | if (srcTmp != null) { | ||
| 260 | cachedSrc = (SurfaceData) srcTmp.get(); | ||
| 261 | } | ||
| 262 | src = convertFrom(convertsrc, srcData, srcx, srcy, | ||
| 263 | width, height, cachedSrc); | ||
| 264 | sx = 0; | ||
| 265 | sy = 0; | ||
| 266 | if (src != cachedSrc) { | ||
| 267 | srcTmp = new WeakReference(src); | ||
| 268 | } | ||
| 269 | } | ||
| 270 | |||
| 271 | if (convertdst == null) { | ||
| 272 | dst = dstData; | ||
| 273 | dx = dstx; | ||
| 274 | dy = dsty; | ||
| 275 | opclip = clip; | ||
| 276 | } else { | ||
| 277 | // assert: convertresult != null | ||
| 278 | SurfaceData cachedDst = null; | ||
| 279 | if (dstTmp != null) { | ||
| 280 | cachedDst = (SurfaceData) dstTmp.get(); | ||
| 281 | } | ||
| 282 | dst = convertFrom(convertdst, dstData, dstx, dsty, | ||
| 283 | width, height, cachedDst); | ||
| 284 | dx = 0; | ||
| 285 | dy = 0; | ||
| 286 | opclip = null; | ||
| 287 | if (dst != cachedDst) { | ||
| 288 | dstTmp = new WeakReference(dst); | ||
| 289 | } | ||
| 290 | } | ||
| 291 | |||
| 292 | performop.Blit(src, dst, comp, opclip, | ||
| 293 | sx, sy, dx, dy, | ||
| 294 | width, height); | ||
| 295 | |||
| 296 | if (convertresult != null) { | ||
| 297 | // assert: convertdst != null | ||
| 298 | convertTo(convertresult, dst, dstData, clip, | ||
| 299 | dstx, dsty, width, height); | ||
| 300 | } | ||
| 301 | } | ||
| 302 | } | ||
| 303 | |||
| 304 | public GraphicsPrimitive traceWrap() { | ||
| 305 | return new TraceBlit(this); | ||
| 306 | } | ||
| 307 | |||
| 308 | private static class TraceBlit extends Blit { | ||
| 309 | Blit target; | ||
| 310 | |||
| 311 | public TraceBlit(Blit target) { | ||
| 312 | super(target.getSourceType(), | ||
| 313 | target.getCompositeType(), | ||
| 314 | target.getDestType()); | ||
| 315 | this.target = target; | ||
| 316 | } | ||
| 317 | |||
| 318 | public GraphicsPrimitive traceWrap() { | ||
| 319 | return this; | ||
| 320 | } | ||
| 321 | |||
| 322 | public void Blit(SurfaceData src, SurfaceData dst, | ||
| 323 | Composite comp, Region clip, | ||
| 324 | int srcx, int srcy, int dstx, int dsty, | ||
| 325 | int width, int height) | ||
| 326 | { | ||
| 327 | tracePrimitive(target); | ||
| 328 | target.Blit(src, dst, comp, clip, | ||
| 329 | srcx, srcy, dstx, dsty, width, height); | ||
| 330 | } | ||
| 331 | } | ||
| 332 | } | ||
Binary file not shown.
Binary file not shown.
Binary file not shown.
| @@ -0,0 +1,217 @@ | |||
| 1 | /* | ||
| 2 | * Copyright (c) 1999, 2008, Oracle and/or its affiliates. All rights reserved. | ||
| 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 | ||
| 7 | * published by the Free Software Foundation. Oracle designates this | ||
| 8 | * particular file as subject to the "Classpath" exception as provided | ||
| 9 | * by Oracle in the LICENSE file that accompanied this code. | ||
| 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 | * | ||
| 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. | ||
| 24 | */ | ||
| 25 | |||
| 26 | package sun.java2d.loops; | ||
| 27 | |||
| 28 | import java.awt.Font; | ||
| 29 | import java.awt.Color; | ||
| 30 | import java.awt.Composite; | ||
| 31 | import java.awt.AlphaComposite; | ||
| 32 | import java.awt.Transparency; | ||
| 33 | import java.awt.image.ColorModel; | ||
| 34 | import java.awt.image.WritableRaster; | ||
| 35 | import java.awt.image.BufferedImage; | ||
| 36 | import sun.awt.image.BufImgSurfaceData; | ||
| 37 | import sun.java2d.loops.GraphicsPrimitive; | ||
| 38 | import sun.java2d.SurfaceData; | ||
| 39 | import sun.java2d.SunGraphics2D; | ||
| 40 | import sun.java2d.pipe.Region; | ||
| 41 | |||
| 42 | /** | ||
| 43 | * BlitBg | ||
| 44 | * 1) copies rectangle of pixels from one surface to another | ||
| 45 | * 2) performs compositing of colors based upon a Composite | ||
| 46 | * parameter | ||
| 47 | * 3) assumes that non-opaque pixels are to be blended with | ||
| 48 | * the indicated Bg color before compositing with the | ||
| 49 | * destination | ||
| 50 | * | ||
| 51 | * precise behavior is undefined if the source surface | ||
| 52 | * and the destination surface are the same surface | ||
| 53 | * with overlapping regions of pixels | ||
| 54 | */ | ||
| 55 | public class BlitBg extends GraphicsPrimitive | ||
| 56 | { | ||
| 57 | public static final String methodSignature = "BlitBg(...)".toString(); | ||
| 58 | |||
| 59 | public static final int primTypeID = makePrimTypeID(); | ||
| 60 | |||
| 61 | private static RenderCache blitcache = new RenderCache(20); | ||
| 62 | |||
| 63 | public static BlitBg locate(SurfaceType srctype, | ||
| 64 | CompositeType comptype, | ||
| 65 | SurfaceType dsttype) | ||
| 66 | { | ||
| 67 | return (BlitBg) | ||
| 68 | GraphicsPrimitiveMgr.locate(primTypeID, | ||
| 69 | srctype, comptype, dsttype); | ||
| 70 | } | ||
| 71 | |||
| 72 | public static BlitBg getFromCache(SurfaceType src, | ||
| 73 | CompositeType comp, | ||
| 74 | SurfaceType dst) | ||
| 75 | { | ||
| 76 | Object o = blitcache.get(src, comp, dst); | ||
| 77 | if (o != null) { | ||
| 78 | return (BlitBg) o; | ||
| 79 | } | ||
| 80 | BlitBg blit = locate(src, comp, dst); | ||
| 81 | if (blit == null) { | ||
| 82 | System.out.println("blitbg loop not found for:"); | ||
| 83 | System.out.println("src: "+src); | ||
| 84 | System.out.println("comp: "+comp); | ||
| 85 | System.out.println("dst: "+dst); | ||
| 86 | } else { | ||
| 87 | blitcache.put(src, comp, dst, blit); | ||
| 88 | } | ||
| 89 | return blit; | ||
| 90 | } | ||
| 91 | |||
| 92 | protected BlitBg(SurfaceType srctype, | ||
| 93 | CompositeType comptype, | ||
| 94 | SurfaceType dsttype) | ||
| 95 | { | ||
| 96 | super(methodSignature, primTypeID, srctype, comptype, dsttype); | ||
| 97 | } | ||
| 98 | |||
| 99 | public BlitBg(long pNativePrim, | ||
| 100 | SurfaceType srctype, | ||
| 101 | CompositeType comptype, | ||
| 102 | SurfaceType dsttype) | ||
| 103 | { | ||
| 104 | super(pNativePrim, methodSignature, primTypeID, srctype, comptype, dsttype); | ||
| 105 | } | ||
| 106 | |||
| 107 | /** | ||
| 108 | * All BlitBg implementors must have this invoker method | ||
| 109 | */ | ||
| 110 | public native void BlitBg(SurfaceData src, SurfaceData dst, | ||
| 111 | Composite comp, Region clip, | ||
| 112 | int bgColor, | ||
| 113 | int srcx, int srcy, | ||
| 114 | int dstx, int dsty, | ||
| 115 | int width, int height); | ||
| 116 | |||
| 117 | static { | ||
| 118 | GraphicsPrimitiveMgr.registerGeneral(new BlitBg(null, null, null)); | ||
| 119 | } | ||
| 120 | |||
| 121 | public GraphicsPrimitive makePrimitive(SurfaceType srctype, | ||
| 122 | CompositeType comptype, | ||
| 123 | SurfaceType dsttype) | ||
| 124 | { | ||
| 125 | /* | ||
| 126 | System.out.println("Constructing general blitbg for:"); | ||
| 127 | System.out.println("src: "+srctype); | ||
| 128 | System.out.println("comp: "+comptype); | ||
| 129 | System.out.println("dst: "+dsttype); | ||
| 130 | */ | ||
| 131 | return new General(srctype, comptype, dsttype); | ||
| 132 | } | ||
| 133 | |||
| 134 | private static class General extends BlitBg { | ||
| 135 | CompositeType compositeType; | ||
| 136 | |||
| 137 | public General(SurfaceType srctype, | ||
| 138 | CompositeType comptype, | ||
| 139 | SurfaceType dsttype) | ||
| 140 | { | ||
| 141 | super(srctype, comptype, dsttype); | ||
| 142 | compositeType = comptype; | ||
| 143 | } | ||
| 144 | |||
| 145 | @Override | ||
| 146 | public void BlitBg(SurfaceData srcData, | ||
| 147 | SurfaceData dstData, | ||
| 148 | Composite comp, | ||
| 149 | Region clip, | ||
| 150 | int bgArgb, | ||
| 151 | int srcx, int srcy, | ||
| 152 | int dstx, int dsty, | ||
| 153 | int width, int height) | ||
| 154 | { | ||
| 155 | ColorModel dstModel = dstData.getColorModel(); | ||
| 156 | boolean bgHasAlpha = (bgArgb >>> 24) != 0xff; | ||
| 157 | if (!dstModel.hasAlpha() && bgHasAlpha) { | ||
| 158 | dstModel = ColorModel.getRGBdefault(); | ||
| 159 | } | ||
| 160 | WritableRaster wr = | ||
| 161 | dstModel.createCompatibleWritableRaster(width, height); | ||
| 162 | boolean isPremult = dstModel.isAlphaPremultiplied(); | ||
| 163 | BufferedImage bimg = | ||
| 164 | new BufferedImage(dstModel, wr, isPremult, null); | ||
| 165 | SurfaceData tmpData = BufImgSurfaceData.createData(bimg); | ||
| 166 | Color bgColor = new Color(bgArgb, bgHasAlpha); | ||
| 167 | SunGraphics2D sg2d = new SunGraphics2D(tmpData, bgColor, bgColor, | ||
| 168 | defaultFont); | ||
| 169 | FillRect fillop = FillRect.locate(SurfaceType.AnyColor, | ||
| 170 | CompositeType.SrcNoEa, | ||
| 171 | tmpData.getSurfaceType()); | ||
| 172 | Blit combineop = Blit.getFromCache(srcData.getSurfaceType(), | ||
| 173 | CompositeType.SrcOverNoEa, | ||
| 174 | tmpData.getSurfaceType()); | ||
| 175 | Blit blitop = Blit.getFromCache(tmpData.getSurfaceType(), compositeType, | ||
| 176 | dstData.getSurfaceType()); | ||
| 177 | fillop.FillRect(sg2d, tmpData, 0, 0, width, height); | ||
| 178 | combineop.Blit(srcData, tmpData, AlphaComposite.SrcOver, null, | ||
| 179 | srcx, srcy, 0, 0, width, height); | ||
| 180 | blitop.Blit(tmpData, dstData, comp, clip, | ||
| 181 | 0, 0, dstx, dsty, width, height); | ||
| 182 | } | ||
| 183 | |||
| 184 | private static Font defaultFont = new Font("Dialog", Font.PLAIN, 12); | ||
| 185 | } | ||
| 186 | |||
| 187 | public GraphicsPrimitive traceWrap() { | ||
| 188 | return new TraceBlitBg(this); | ||
| 189 | } | ||
| 190 | |||
| 191 | private static class TraceBlitBg extends BlitBg { | ||
| 192 | BlitBg target; | ||
| 193 | |||
| 194 | public TraceBlitBg(BlitBg target) { | ||
| 195 | super(target.getSourceType(), | ||
| 196 | target.getCompositeType(), | ||
| 197 | target.getDestType()); | ||
| 198 | this.target = target; | ||
| 199 | } | ||
| 200 | |||
| 201 | public GraphicsPrimitive traceWrap() { | ||
| 202 | return this; | ||
| 203 | } | ||
| 204 | |||
| 205 | @Override | ||
| 206 | public void BlitBg(SurfaceData src, SurfaceData dst, | ||
| 207 | Composite comp, Region clip, | ||
| 208 | int bgColor, | ||
| 209 | int srcx, int srcy, int dstx, int dsty, | ||
| 210 | int width, int height) | ||
| 211 | { | ||
| 212 | tracePrimitive(target); | ||
| 213 | target.BlitBg(src, dst, comp, clip, bgColor, | ||
| 214 | srcx, srcy, dstx, dsty, width, height); | ||
| 215 | } | ||
| 216 | } | ||
| 217 | } | ||
Binary file not shown.
| @@ -0,0 +1,295 @@ | |||
| 1 | /* | ||
| 2 | * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved. | ||
| 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 | ||
| 7 | * published by the Free Software Foundation. Oracle designates this | ||
| 8 | * particular file as subject to the "Classpath" exception as provided | ||
| 9 | * by Oracle in the LICENSE file that accompanied this code. | ||
| 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 | * | ||
| 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. | ||
| 24 | */ | ||
| 25 | |||
| 26 | package sun.java2d.loops; | ||
| 27 | |||
| 28 | import java.awt.image.BufferedImage; | ||
| 29 | import java.awt.AlphaComposite; | ||
| 30 | import java.util.HashMap; | ||
| 31 | |||
| 32 | /** | ||
| 33 | * A CompositeType object provides a chained description of a type of | ||
| 34 | * algorithm for color compositing. The object will provide a single | ||
| 35 | * String constant descriptor which is one way of describing a particular | ||
| 36 | * compositing algorithm as well as a pointer to another CompositeType | ||
| 37 | * which describes a more general algorithm for achieving the same result. | ||
| 38 | * <p> | ||
| 39 | * A description of a more specific algorithm is considered a "subtype" | ||
| 40 | * and a description of a more general algorithm is considered a "supertype". | ||
| 41 | * Thus, the deriveSubType method provides a way to create a new CompositeType | ||
| 42 | * that is related to but more specific than an existing CompositeType and | ||
| 43 | * the getSuperType method provides a way to ask a given CompositeType | ||
| 44 | * for a more general algorithm to achieve the same result. | ||
| 45 | * <p> | ||
| 46 | * Note that you cannot construct a brand new root for a chain since | ||
| 47 | * the constructor is private. Every chain of types must at some point | ||
| 48 | * derive from the Any node provided here using the deriveSubType() | ||
| 49 | * method. The presence of this common Any node on every chain | ||
| 50 | * ensures that all chains end with the DESC_ANY descriptor so that | ||
| 51 | * a suitable General GraphicsPrimitive object can be obtained for | ||
| 52 | * the indicated algorithm if all of the more specific searches fail. | ||
| 53 | */ | ||
| 54 | public final class CompositeType { | ||
| 55 | |||
| 56 | private static int unusedUID = 1; | ||
| 57 | private static final HashMap<String,Integer> compositeUIDMap = | ||
| 58 | new HashMap<String,Integer>(100); | ||
| 59 | |||
| 60 | /* | ||
| 61 | * CONSTANTS USED BY ALL PRIMITIVES TO DESCRIBE THE COMPOSITING | ||
| 62 | * ALGORITHMS THEY CAN PERFORM | ||
| 63 | */ | ||
| 64 | |||
| 65 | /** | ||
| 66 | * algorithm is a general algorithm that uses a CompositeContext | ||
| 67 | * to do the rendering. | ||
| 68 | */ | ||
| 69 | public static final String DESC_ANY = "Any CompositeContext"; | ||
| 70 | |||
| 71 | /** | ||
| 72 | * constant used to describe the Graphics.setXORMode() algorithm | ||
| 73 | */ | ||
| 74 | public static final String DESC_XOR = "XOR mode"; | ||
| 75 | |||
| 76 | /** | ||
| 77 | * constants used to describe the various AlphaComposite | ||
| 78 | * algorithms. | ||
| 79 | */ | ||
| 80 | public static final String DESC_CLEAR = "Porter-Duff Clear"; | ||
| 81 | public static final String DESC_SRC = "Porter-Duff Src"; | ||
| 82 | public static final String DESC_DST = "Porter-Duff Dst"; | ||
| 83 | public static final String DESC_SRC_OVER = "Porter-Duff Src Over Dst"; | ||
| 84 | public static final String DESC_DST_OVER = "Porter-Duff Dst Over Src"; | ||
| 85 | public static final String DESC_SRC_IN = "Porter-Duff Src In Dst"; | ||
| 86 | public static final String DESC_DST_IN = "Porter-Duff Dst In Src"; | ||
| 87 | public static final String DESC_SRC_OUT = "Porter-Duff Src HeldOutBy Dst"; | ||
| 88 | public static final String DESC_DST_OUT = "Porter-Duff Dst HeldOutBy Src"; | ||
| 89 | public static final String DESC_SRC_ATOP = "Porter-Duff Src Atop Dst"; | ||
| 90 | public static final String DESC_DST_ATOP = "Porter-Duff Dst Atop Src"; | ||
| 91 | public static final String DESC_ALPHA_XOR = "Porter-Duff Xor"; | ||
| 92 | |||
| 93 | /** | ||
| 94 | * constants used to describe the two common cases of | ||
| 95 | * AlphaComposite algorithms that are simpler if there | ||
| 96 | * is not extraAlpha. | ||
| 97 | */ | ||
| 98 | public static final String | ||
| 99 | DESC_SRC_NO_EA = "Porter-Duff Src, No Extra Alpha"; | ||
| 100 | public static final String | ||
| 101 | DESC_SRC_OVER_NO_EA = "Porter-Duff SrcOverDst, No Extra Alpha"; | ||
| 102 | |||
| 103 | /** | ||
| 104 | * constant used to describe an algorithm that implements all 8 of | ||
| 105 | * the Porter-Duff rules in one Primitive. | ||
| 106 | */ | ||
| 107 | public static final String DESC_ANY_ALPHA = "Any AlphaComposite Rule"; | ||
| 108 | |||
| 109 | /* | ||
| 110 | * END OF COMPOSITE ALGORITHM TYPE CONSTANTS | ||
| 111 | */ | ||
| 112 | |||
| 113 | /** | ||
| 114 | * The root CompositeType object for all chains of algorithm descriptions. | ||
| 115 | */ | ||
| 116 | public static final CompositeType | ||
| 117 | Any = new CompositeType(null, DESC_ANY); | ||
| 118 | |||
| 119 | /* | ||
| 120 | * START OF CompositeeType OBJECTS FOR THE VARIOUS CONSTANTS | ||
| 121 | */ | ||
| 122 | |||
| 123 | public static final CompositeType | ||
| 124 | General = Any; | ||
| 125 | |||
| 126 | public static final CompositeType | ||
| 127 | AnyAlpha = General.deriveSubType(DESC_ANY_ALPHA); | ||
| 128 | public static final CompositeType | ||
| 129 | Xor = General.deriveSubType(DESC_XOR); | ||
| 130 | |||
| 131 | public static final CompositeType | ||
| 132 | Clear = AnyAlpha.deriveSubType(DESC_CLEAR); | ||
| 133 | public static final CompositeType | ||
| 134 | Src = AnyAlpha.deriveSubType(DESC_SRC); | ||
| 135 | public static final CompositeType | ||
| 136 | Dst = AnyAlpha.deriveSubType(DESC_DST); | ||
| 137 | public static final CompositeType | ||
| 138 | SrcOver = AnyAlpha.deriveSubType(DESC_SRC_OVER); | ||
| 139 | public static final CompositeType | ||
| 140 | DstOver = AnyAlpha.deriveSubType(DESC_DST_OVER); | ||
| 141 | public static final CompositeType | ||
| 142 | SrcIn = AnyAlpha.deriveSubType(DESC_SRC_IN); | ||
| 143 | public static final CompositeType | ||
| 144 | DstIn = AnyAlpha.deriveSubType(DESC_DST_IN); | ||
| 145 | public static final CompositeType | ||
| 146 | SrcOut = AnyAlpha.deriveSubType(DESC_SRC_OUT); | ||
| 147 | public static final CompositeType | ||
| 148 | DstOut = AnyAlpha.deriveSubType(DESC_DST_OUT); | ||
| 149 | public static final CompositeType | ||
| 150 | SrcAtop = AnyAlpha.deriveSubType(DESC_SRC_ATOP); | ||
| 151 | public static final CompositeType | ||
| 152 | DstAtop = AnyAlpha.deriveSubType(DESC_DST_ATOP); | ||
| 153 | public static final CompositeType | ||
| 154 | AlphaXor = AnyAlpha.deriveSubType(DESC_ALPHA_XOR); | ||
| 155 | |||
| 156 | public static final CompositeType | ||
| 157 | SrcNoEa = Src.deriveSubType(DESC_SRC_NO_EA); | ||
| 158 | public static final CompositeType | ||
| 159 | SrcOverNoEa = SrcOver.deriveSubType(DESC_SRC_OVER_NO_EA); | ||
| 160 | |||
| 161 | /* | ||
| 162 | * A special CompositeType for the case where we are filling in | ||
| 163 | * SrcOverNoEa mode with an opaque color. In that case then the | ||
| 164 | * best loop for us to use would be a SrcNoEa loop, but what if | ||
| 165 | * there is no such loop? In that case then we would end up | ||
| 166 | * backing off to a Src loop (which should still be fine) or an | ||
| 167 | * AnyAlpha loop which would be slower than a SrcOver loop in | ||
| 168 | * most cases. | ||
| 169 | * The fix is to use the following chain which looks for loops | ||
| 170 | * in the following order: | ||
| 171 | * SrcNoEa, Src, SrcOverNoEa, SrcOver, AnyAlpha | ||
| 172 | */ | ||
| 173 | public static final CompositeType | ||
| 174 | OpaqueSrcOverNoEa = SrcOverNoEa.deriveSubType(DESC_SRC) | ||
| 175 | .deriveSubType(DESC_SRC_NO_EA); | ||
| 176 | |||
| 177 | /* | ||
| 178 | * END OF CompositeType OBJECTS FOR THE VARIOUS CONSTANTS | ||
| 179 | */ | ||
| 180 | |||
| 181 | /** | ||
| 182 | * Return a new CompositeType object which uses this object as its | ||
| 183 | * more general "supertype" descriptor. If no operation can be | ||
| 184 | * found that implements the algorithm described more exactly | ||
| 185 | * by desc, then this object will define the more general | ||
| 186 | * compositing algorithm that can be used instead. | ||
| 187 | */ | ||
| 188 | public CompositeType deriveSubType(String desc) { | ||
| 189 | return new CompositeType(this, desc); | ||
| 190 | } | ||
| 191 | |||
| 192 | /** | ||
| 193 | * Return a CompositeType object for the specified AlphaComposite | ||
| 194 | * rule. | ||
| 195 | */ | ||
| 196 | public static CompositeType forAlphaComposite(AlphaComposite ac) { | ||
| 197 | switch (ac.getRule()) { | ||
| 198 | case AlphaComposite.CLEAR: | ||
| 199 | return Clear; | ||
| 200 | case AlphaComposite.SRC: | ||
| 201 | if (ac.getAlpha() >= 1.0f) { | ||
| 202 | return SrcNoEa; | ||
| 203 | } else { | ||
| 204 | return Src; | ||
| 205 | } | ||
| 206 | case AlphaComposite.DST: | ||
| 207 | return Dst; | ||
| 208 | case AlphaComposite.SRC_OVER: | ||
| 209 | if (ac.getAlpha() >= 1.0f) { | ||
| 210 | return SrcOverNoEa; | ||
| 211 | } else { | ||
| 212 | return SrcOver; | ||
| 213 | } | ||
| 214 | case AlphaComposite.DST_OVER: | ||
| 215 | return DstOver; | ||
| 216 | case AlphaComposite.SRC_IN: | ||
| 217 | return SrcIn; | ||
| 218 | case AlphaComposite.DST_IN: | ||
| 219 | return DstIn; | ||
| 220 | case AlphaComposite.SRC_OUT: | ||
| 221 | return SrcOut; | ||
| 222 | case AlphaComposite.DST_OUT: | ||
| 223 | return DstOut; | ||
| 224 | case AlphaComposite.SRC_ATOP: | ||
| 225 | return SrcAtop; | ||
| 226 | case AlphaComposite.DST_ATOP: | ||
| 227 | return DstAtop; | ||
| 228 | case AlphaComposite.XOR: | ||
| 229 | return AlphaXor; | ||
| 230 | default: | ||
| 231 | throw new InternalError("Unrecognized alpha rule"); | ||
| 232 | } | ||
| 233 | } | ||
| 234 | |||
| 235 | private int uniqueID; | ||
| 236 | private String desc; | ||
| 237 | private CompositeType next; | ||
| 238 | |||
| 239 | private CompositeType(CompositeType parent, String desc) { | ||
| 240 | next = parent; | ||
| 241 | this.desc = desc; | ||
| 242 | this.uniqueID = makeUniqueID(desc); | ||
| 243 | } | ||
| 244 | |||
| 245 | public synchronized static final int makeUniqueID(String desc) { | ||
| 246 | Integer i = compositeUIDMap.get(desc); | ||
| 247 | |||
| 248 | if (i == null) { | ||
| 249 | if (unusedUID > 255) { | ||
| 250 | throw new InternalError("composite type id overflow"); | ||
| 251 | } | ||
| 252 | i = unusedUID++; | ||
| 253 | compositeUIDMap.put(desc, i); | ||
| 254 | } | ||
| 255 | return i; | ||
| 256 | } | ||
| 257 | |||
| 258 | public int getUniqueID() { | ||
| 259 | return uniqueID; | ||
| 260 | } | ||
| 261 | |||
| 262 | public String getDescriptor() { | ||
| 263 | return desc; | ||
| 264 | } | ||
| 265 | |||
| 266 | public CompositeType getSuperType() { | ||
| 267 | return next; | ||
| 268 | } | ||
| 269 | |||
| 270 | public int hashCode() { | ||
| 271 | return desc.hashCode(); | ||
| 272 | } | ||
| 273 | |||
| 274 | public boolean isDerivedFrom(CompositeType other) { | ||
| 275 | CompositeType comptype = this; | ||
| 276 | do { | ||
| 277 | if (comptype.desc == other.desc) { | ||
| 278 | return true; | ||
| 279 | } | ||
| 280 | comptype = comptype.next; | ||
| 281 | } while (comptype != null); | ||
| 282 | return false; | ||
| 283 | } | ||
| 284 | |||
| 285 | public boolean equals(Object o) { | ||
| 286 | if (o instanceof CompositeType) { | ||
| 287 | return (((CompositeType) o).uniqueID == this.uniqueID); | ||
| 288 | } | ||
| 289 | return false; | ||
| 290 | } | ||
| 291 | |||
| 292 | public String toString() { | ||
| 293 | return desc; | ||
| 294 | } | ||
| 295 | } | ||
Binary file not shown.
| @@ -0,0 +1,329 @@ | |||
| 1 | /* | ||
| 2 | * Copyright (c) 1997, 2007, Oracle and/or its affiliates. All rights reserved. | ||
| 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 | ||
| 7 | * published by the Free Software Foundation. Oracle designates this | ||
| 8 | * particular file as subject to the "Classpath" exception as provided | ||
| 9 | * by Oracle in the LICENSE file that accompanied this code. | ||
| 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 | * | ||
| 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. | ||
| 24 | */ | ||
| 25 | |||
| 26 | /* | ||
| 27 | * @author Charlton Innovations, Inc. | ||
| 28 | * @author Jim Graham | ||
| 29 | */ | ||
| 30 | |||
| 31 | package sun.java2d.loops; | ||
| 32 | |||
| 33 | import java.awt.Composite; | ||
| 34 | import java.awt.Rectangle; | ||
| 35 | import java.awt.image.ColorModel; | ||
| 36 | import java.awt.image.DataBuffer; | ||
| 37 | import java.awt.image.Raster; | ||
| 38 | import java.awt.image.WritableRaster; | ||
| 39 | import sun.awt.image.IntegerComponentRaster; | ||
| 40 | import sun.java2d.SurfaceData; | ||
| 41 | import sun.java2d.pipe.Region; | ||
| 42 | import sun.java2d.pipe.SpanIterator; | ||
| 43 | |||
| 44 | /** | ||
| 45 | * CustomComponent, collection of GraphicsPrimitive | ||
| 46 | * Basically, this collection of components performs conversion from | ||
| 47 | * ANY to ANY via opaque copy | ||
| 48 | */ | ||
| 49 | public final class CustomComponent { | ||
| 50 | public static void register() { | ||
| 51 | // REMIND: This does not work for all destinations yet since | ||
| 52 | // the screen SurfaceData objects do not implement getRaster | ||
| 53 | Class owner = CustomComponent.class; | ||
| 54 | GraphicsPrimitive[] primitives = { | ||
| 55 | new GraphicsPrimitiveProxy(owner, "OpaqueCopyAnyToArgb", | ||
| 56 | Blit.methodSignature, | ||
| 57 | Blit.primTypeID, | ||
| 58 | SurfaceType.Any, | ||
| 59 | CompositeType.SrcNoEa, | ||
| 60 | SurfaceType.IntArgb), | ||
| 61 | new GraphicsPrimitiveProxy(owner, "OpaqueCopyArgbToAny", | ||
| 62 | Blit.methodSignature, | ||
| 63 | Blit.primTypeID, | ||
| 64 | SurfaceType.IntArgb, | ||
| 65 | CompositeType.SrcNoEa, | ||
| 66 | SurfaceType.Any), | ||
| 67 | new GraphicsPrimitiveProxy(owner, "XorCopyArgbToAny", | ||
| 68 | Blit.methodSignature, | ||
| 69 | Blit.primTypeID, | ||
| 70 | SurfaceType.IntArgb, | ||
| 71 | CompositeType.Xor, | ||
| 72 | SurfaceType.Any), | ||
| 73 | }; | ||
| 74 | GraphicsPrimitiveMgr.register(primitives); | ||
| 75 | } | ||
| 76 | |||
| 77 | public static Region getRegionOfInterest(SurfaceData src, SurfaceData dst, | ||
| 78 | Region clip, | ||
| 79 | int srcx, int srcy, | ||
| 80 | int dstx, int dsty, | ||
| 81 | int w, int h) | ||
| 82 | { | ||
| 83 | /* | ||
| 84 | * Intersect all of: | ||
| 85 | * - operation area (dstx, dsty, w, h) | ||
| 86 | * - destination bounds | ||
| 87 | * - (translated) src bounds | ||
| 88 | * - supplied clip (may be non-rectangular) | ||
| 89 | * Intersect the rectangular regions first since those are | ||
| 90 | * simpler operations. | ||
| 91 | */ | ||
| 92 | Region ret = Region.getInstanceXYWH(dstx, dsty, w, h); | ||
| 93 | ret = ret.getIntersection(dst.getBounds()); | ||
| 94 | Rectangle r = src.getBounds(); | ||
| 95 | // srcxy in src space maps to dstxy in dst space | ||
| 96 | r.translate(dstx - srcx, dsty - srcy); | ||
| 97 | ret = ret.getIntersection(r); | ||
| 98 | if (clip != null) { | ||
| 99 | // Intersect with clip last since it may be non-rectangular | ||
| 100 | ret = ret.getIntersection(clip); | ||
| 101 | } | ||
| 102 | return ret; | ||
| 103 | } | ||
| 104 | } | ||
| 105 | |||
| 106 | /** | ||
| 107 | * ANY format to ARGB format Blit | ||
| 108 | */ | ||
| 109 | class OpaqueCopyAnyToArgb extends Blit { | ||
| 110 | OpaqueCopyAnyToArgb() { | ||
| 111 | super(SurfaceType.Any, | ||
| 112 | CompositeType.SrcNoEa, | ||
| 113 | SurfaceType.IntArgb); | ||
| 114 | } | ||
| 115 | |||
| 116 | public void Blit(SurfaceData src, SurfaceData dst, | ||
| 117 | Composite comp, Region clip, | ||
| 118 | int srcx, int srcy, int dstx, int dsty, int w, int h) | ||
| 119 | { | ||
| 120 | Raster srcRast = src.getRaster(srcx, srcy, w, h); | ||
| 121 | ColorModel srcCM = src.getColorModel(); | ||
| 122 | |||
| 123 | Raster dstRast = dst.getRaster(dstx, dsty, w, h); | ||
| 124 | IntegerComponentRaster icr = (IntegerComponentRaster) dstRast; | ||
| 125 | int[] dstPix = icr.getDataStorage(); | ||
| 126 | |||
| 127 | Region roi = CustomComponent.getRegionOfInterest(src, dst, clip, | ||
| 128 | srcx, srcy, | ||
| 129 | dstx, dsty, w, h); | ||
| 130 | SpanIterator si = roi.getSpanIterator(); | ||
| 131 | |||
| 132 | Object srcPix = null; | ||
| 133 | |||
| 134 | int dstScan = icr.getScanlineStride(); | ||
| 135 | // assert(icr.getPixelStride() == 1); | ||
| 136 | srcx -= dstx; | ||
| 137 | srcy -= dsty; | ||
| 138 | int span[] = new int[4]; | ||
| 139 | while (si.nextSpan(span)) { | ||
| 140 | int rowoff = icr.getDataOffset(0) + span[1] * dstScan + span[0]; | ||
| 141 | for (int y = span[1]; y < span[3]; y++) { | ||
| 142 | int off = rowoff; | ||
| 143 | for (int x = span[0]; x < span[2]; x++) { | ||
| 144 | srcPix = srcRast.getDataElements(x+srcx, y+srcy, srcPix); | ||
| 145 | dstPix[off++] = srcCM.getRGB(srcPix); | ||
| 146 | } | ||
| 147 | rowoff += dstScan; | ||
| 148 | } | ||
| 149 | } | ||
| 150 | // Pixels in the dest were modified directly, we must | ||
| 151 | // manually notify the raster that it was modified | ||
| 152 | icr.markDirty(); | ||
| 153 | // REMIND: We need to do something to make sure that dstRast | ||
| 154 | // is put back to the destination (as in the native Release | ||
| 155 | // function) | ||
| 156 | // src.releaseRaster(srcRast); // NOP? | ||
| 157 | // dst.releaseRaster(dstRast); | ||
| 158 | } | ||
| 159 | } | ||
| 160 | |||
| 161 | /** | ||
| 162 | * ARGB format to ANY format Blit | ||
| 163 | */ | ||
| 164 | class OpaqueCopyArgbToAny extends Blit { | ||
| 165 | OpaqueCopyArgbToAny() { | ||
| 166 | super(SurfaceType.IntArgb, | ||
| 167 | CompositeType.SrcNoEa, | ||
| 168 | SurfaceType.Any); | ||
| 169 | } | ||
| 170 | |||
| 171 | public void Blit(SurfaceData src, SurfaceData dst, | ||
| 172 | Composite comp, Region clip, | ||
| 173 | int srcx, int srcy, int dstx, int dsty, int w, int h) | ||
| 174 | { | ||
| 175 | Raster srcRast = src.getRaster(srcx, srcy, w, h); | ||
| 176 | IntegerComponentRaster icr = (IntegerComponentRaster) srcRast; | ||
| 177 | int[] srcPix = icr.getDataStorage(); | ||
| 178 | |||
| 179 | WritableRaster dstRast = | ||
| 180 | (WritableRaster) dst.getRaster(dstx, dsty, w, h); | ||
| 181 | ColorModel dstCM = dst.getColorModel(); | ||
| 182 | |||
| 183 | Region roi = CustomComponent.getRegionOfInterest(src, dst, clip, | ||
| 184 | srcx, srcy, | ||
| 185 | dstx, dsty, w, h); | ||
| 186 | SpanIterator si = roi.getSpanIterator(); | ||
| 187 | |||
| 188 | Object dstPix = null; | ||
| 189 | |||
| 190 | int srcScan = icr.getScanlineStride(); | ||
| 191 | // assert(icr.getPixelStride() == 1); | ||
| 192 | srcx -= dstx; | ||
| 193 | srcy -= dsty; | ||
| 194 | int span[] = new int[4]; | ||
| 195 | while (si.nextSpan(span)) { | ||
| 196 | int rowoff = (icr.getDataOffset(0) + | ||
| 197 | (srcy + span[1]) * srcScan + | ||
| 198 | (srcx + span[0])); | ||
| 199 | for (int y = span[1]; y < span[3]; y++) { | ||
| 200 | int off = rowoff; | ||
| 201 | for (int x = span[0]; x < span[2]; x++) { | ||
| 202 | dstPix = dstCM.getDataElements(srcPix[off++], dstPix); | ||
| 203 | dstRast.setDataElements(x, y, dstPix); | ||
| 204 | } | ||
| 205 | rowoff += srcScan; | ||
| 206 | } | ||
| 207 | } | ||
| 208 | // REMIND: We need to do something to make sure that dstRast | ||
| 209 | // is put back to the destination (as in the native Release | ||
| 210 | // function) | ||
| 211 | // src.releaseRaster(srcRast); // NOP? | ||
| 212 | // dst.releaseRaster(dstRast); | ||
| 213 | } | ||
| 214 | } | ||
| 215 | |||
| 216 | /** | ||
| 217 | * ARGB format to ANY format Blit (pixels are XORed together with XOR pixel) | ||
| 218 | */ | ||
| 219 | class XorCopyArgbToAny extends Blit { | ||
| 220 | XorCopyArgbToAny() { | ||
| 221 | super(SurfaceType.IntArgb, | ||
| 222 | CompositeType.Xor, | ||
| 223 | SurfaceType.Any); | ||
| 224 | } | ||
| 225 | |||
| 226 | public void Blit(SurfaceData src, SurfaceData dst, | ||
| 227 | Composite comp, Region clip, | ||
| 228 | int srcx, int srcy, int dstx, int dsty, int w, int h) | ||
| 229 | { | ||
| 230 | Raster srcRast = src.getRaster(srcx, srcy, w, h); | ||
| 231 | IntegerComponentRaster icr = (IntegerComponentRaster) srcRast; | ||
| 232 | int[] srcPix = icr.getDataStorage(); | ||
| 233 | |||
| 234 | WritableRaster dstRast = | ||
| 235 | (WritableRaster) dst.getRaster(dstx, dsty, w, h); | ||
| 236 | ColorModel dstCM = dst.getColorModel(); | ||
| 237 | |||
| 238 | Region roi = CustomComponent.getRegionOfInterest(src, dst, clip, | ||
| 239 | srcx, srcy, | ||
| 240 | dstx, dsty, w, h); | ||
| 241 | SpanIterator si = roi.getSpanIterator(); | ||
| 242 | |||
| 243 | int xorrgb = ((XORComposite)comp).getXorColor().getRGB(); | ||
| 244 | Object xorPixel = dstCM.getDataElements(xorrgb, null); | ||
| 245 | |||
| 246 | Object srcPixel = null; | ||
| 247 | Object dstPixel = null; | ||
| 248 | |||
| 249 | int srcScan = icr.getScanlineStride(); | ||
| 250 | // assert(icr.getPixelStride() == 1); | ||
| 251 | srcx -= dstx; | ||
| 252 | srcy -= dsty; | ||
| 253 | int span[] = new int[4]; | ||
| 254 | while (si.nextSpan(span)) { | ||
| 255 | int rowoff = (icr.getDataOffset(0) + | ||
| 256 | (srcy + span[1]) * srcScan + | ||
| 257 | (srcx + span[0])); | ||
| 258 | for (int y = span[1]; y < span[3]; y++) { | ||
| 259 | int off = rowoff; | ||
| 260 | for (int x = span[0]; x < span[2]; x++) { | ||
| 261 | // REMIND: alpha bits of the destination pixel are | ||
| 262 | // currently altered by the XOR operation, but | ||
| 263 | // should be left untouched | ||
| 264 | srcPixel = dstCM.getDataElements(srcPix[off++], srcPixel); | ||
| 265 | dstPixel = dstRast.getDataElements(x, y, dstPixel); | ||
| 266 | |||
| 267 | switch (dstCM.getTransferType()) { | ||
| 268 | case DataBuffer.TYPE_BYTE: | ||
| 269 | byte[] bytesrcarr = (byte[]) srcPixel; | ||
| 270 | byte[] bytedstarr = (byte[]) dstPixel; | ||
| 271 | byte[] bytexorarr = (byte[]) xorPixel; | ||
| 272 | for (int i = 0; i < bytedstarr.length; i++) { | ||
| 273 | bytedstarr[i] ^= bytesrcarr[i] ^ bytexorarr[i]; | ||
| 274 | } | ||
| 275 | break; | ||
| 276 | case DataBuffer.TYPE_SHORT: | ||
| 277 | case DataBuffer.TYPE_USHORT: | ||
| 278 | short[] shortsrcarr = (short[]) srcPixel; | ||
| 279 | short[] shortdstarr = (short[]) dstPixel; | ||
| 280 | short[] shortxorarr = (short[]) xorPixel; | ||
| 281 | for (int i = 0; i < shortdstarr.length; i++) { | ||
| 282 | shortdstarr[i] ^= shortsrcarr[i] ^ shortxorarr[i]; | ||
| 283 | } | ||
| 284 | break; | ||
| 285 | case DataBuffer.TYPE_INT: | ||
| 286 | int[] intsrcarr = (int[]) srcPixel; | ||
| 287 | int[] intdstarr = (int[]) dstPixel; | ||
| 288 | int[] intxorarr = (int[]) xorPixel; | ||
| 289 | for (int i = 0; i < intdstarr.length; i++) { | ||
| 290 | intdstarr[i] ^= intsrcarr[i] ^ intxorarr[i]; | ||
| 291 | } | ||
| 292 | break; | ||
| 293 | case DataBuffer.TYPE_FLOAT: | ||
| 294 | float[] floatsrcarr = (float[]) srcPixel; | ||
| 295 | float[] floatdstarr = (float[]) dstPixel; | ||
| 296 | float[] floatxorarr = (float[]) xorPixel; | ||
| 297 | for (int i = 0; i < floatdstarr.length; i++) { | ||
| 298 | int v = (Float.floatToIntBits(floatdstarr[i]) ^ | ||
| 299 | Float.floatToIntBits(floatsrcarr[i]) ^ | ||
| 300 | Float.floatToIntBits(floatxorarr[i])); | ||
| 301 | floatdstarr[i] = Float.intBitsToFloat(v); | ||
| 302 | } | ||
| 303 | break; | ||
| 304 | case DataBuffer.TYPE_DOUBLE: | ||
| 305 | double[] doublesrcarr = (double[]) srcPixel; | ||
| 306 | double[] doubledstarr = (double[]) dstPixel; | ||
| 307 | double[] doublexorarr = (double[]) xorPixel; | ||
| 308 | for (int i = 0; i < doubledstarr.length; i++) { | ||
| 309 | long v = (Double.doubleToLongBits(doubledstarr[i]) ^ | ||
| 310 | Double.doubleToLongBits(doublesrcarr[i]) ^ | ||
| 311 | Double.doubleToLongBits(doublexorarr[i])); | ||
| 312 | doubledstarr[i] = Double.longBitsToDouble(v); | ||
| 313 | } | ||
| 314 | break; | ||
| 315 | default: | ||
| 316 | throw new InternalError("Unsupported XOR pixel type"); | ||
| 317 | } | ||
| 318 | dstRast.setDataElements(x, y, dstPixel); | ||
| 319 | } | ||
| 320 | rowoff += srcScan; | ||
| 321 | } | ||
| 322 | } | ||
| 323 | // REMIND: We need to do something to make sure that dstRast | ||
| 324 | // is put back to the destination (as in the native Release | ||
| 325 | // function) | ||
| 326 | // src.releaseRaster(srcRast); // NOP? | ||
| 327 | // dst.releaseRaster(dstRast); | ||
| 328 | } | ||
| 329 | } | ||
Binary file not shown.
Binary file not shown.
Binary file not shown.
| @@ -0,0 +1,161 @@ | |||
| 1 | /* | ||
| 2 | * Copyright (c) 2000, 2003, Oracle and/or its affiliates. All rights reserved. | ||
| 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 | ||
| 7 | * published by the Free Software Foundation. Oracle designates this | ||
| 8 | * particular file as subject to the "Classpath" exception as provided | ||
| 9 | * by Oracle in the LICENSE file that accompanied this code. | ||
| 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 | * | ||
| 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. | ||
| 24 | */ | ||
| 25 | |||
| 26 | package sun.java2d.loops; | ||
| 27 | |||
| 28 | import sun.java2d.loops.GraphicsPrimitive; | ||
| 29 | import sun.java2d.pipe.Region; | ||
| 30 | import sun.java2d.SunGraphics2D; | ||
| 31 | import sun.java2d.SurfaceData; | ||
| 32 | import sun.font.GlyphList; | ||
| 33 | |||
| 34 | /** | ||
| 35 | * DrawGlyphList - loops for SolidTextRenderer pipe. | ||
| 36 | * 1) draw solid color text onto destination surface | ||
| 37 | * 2) must accept output area [x, y, dx, dy] | ||
| 38 | * from within the surface description data for clip rect | ||
| 39 | */ | ||
| 40 | public class DrawGlyphList extends GraphicsPrimitive { | ||
| 41 | |||
| 42 | public final static String methodSignature = "DrawGlyphList(...)".toString(); | ||
| 43 | |||
| 44 | public final static int primTypeID = makePrimTypeID(); | ||
| 45 | |||
| 46 | public static DrawGlyphList locate(SurfaceType srctype, | ||
| 47 | CompositeType comptype, | ||
| 48 | SurfaceType dsttype) | ||
| 49 | { | ||
| 50 | return (DrawGlyphList) | ||
| 51 | GraphicsPrimitiveMgr.locate(primTypeID, | ||
| 52 | srctype, comptype, dsttype); | ||
| 53 | } | ||
| 54 | |||
| 55 | protected DrawGlyphList(SurfaceType srctype, | ||
| 56 | CompositeType comptype, | ||
| 57 | SurfaceType dsttype) | ||
| 58 | { | ||
| 59 | super(methodSignature, primTypeID, srctype, comptype, dsttype); | ||
| 60 | } | ||
| 61 | |||
| 62 | public DrawGlyphList(long pNativePrim, | ||
| 63 | SurfaceType srctype, | ||
| 64 | CompositeType comptype, | ||
| 65 | SurfaceType dsttype) | ||
| 66 | { | ||
| 67 | super(pNativePrim, methodSignature, primTypeID, srctype, comptype, dsttype); | ||
| 68 | } | ||
| 69 | |||
| 70 | |||
| 71 | public native void DrawGlyphList(SunGraphics2D sg2d, SurfaceData dest, | ||
| 72 | GlyphList srcData); | ||
| 73 | |||
| 74 | // This instance is used only for lookup. | ||
| 75 | static { | ||
| 76 | GraphicsPrimitiveMgr.registerGeneral( | ||
| 77 | new DrawGlyphList(null, null, null)); | ||
| 78 | } | ||
| 79 | |||
| 80 | public GraphicsPrimitive makePrimitive(SurfaceType srctype, | ||
| 81 | CompositeType comptype, | ||
| 82 | SurfaceType dsttype) { | ||
| 83 | return new General(srctype, comptype, dsttype); | ||
| 84 | } | ||
| 85 | |||
| 86 | private static class General extends DrawGlyphList { | ||
| 87 | MaskFill maskop; | ||
| 88 | |||
| 89 | public General(SurfaceType srctype, | ||
| 90 | CompositeType comptype, | ||
| 91 | SurfaceType dsttype) | ||
| 92 | { | ||
| 93 | super(srctype, comptype, dsttype); | ||
| 94 | maskop = MaskFill.locate(srctype, comptype, dsttype); | ||
| 95 | } | ||
| 96 | |||
| 97 | public void DrawGlyphList(SunGraphics2D sg2d, SurfaceData dest, | ||
| 98 | GlyphList gl) { | ||
| 99 | |||
| 100 | int strbounds[] = gl.getBounds(); // Don't delete, bug 4895493 | ||
| 101 | int num = gl.getNumGlyphs(); | ||
| 102 | Region clip = sg2d.getCompClip(); | ||
| 103 | int cx1 = clip.getLoX(); | ||
| 104 | int cy1 = clip.getLoY(); | ||
| 105 | int cx2 = clip.getHiX(); | ||
| 106 | int cy2 = clip.getHiY(); | ||
| 107 | for (int i = 0; i < num; i++) { | ||
| 108 | gl.setGlyphIndex(i); | ||
| 109 | int metrics[] = gl.getMetrics(); | ||
| 110 | int gx1 = metrics[0]; | ||
| 111 | int gy1 = metrics[1]; | ||
| 112 | int w = metrics[2]; | ||
| 113 | int gx2 = gx1 + w; | ||
| 114 | int gy2 = gy1 + metrics[3]; | ||
| 115 | int off = 0; | ||
| 116 | if (gx1 < cx1) { | ||
| 117 | off = cx1 - gx1; | ||
| 118 | gx1 = cx1; | ||
| 119 | } | ||
| 120 | if (gy1 < cy1) { | ||
| 121 | off += (cy1 - gy1) * w; | ||
| 122 | gy1 = cy1; | ||
| 123 | } | ||
| 124 | if (gx2 > cx2) gx2 = cx2; | ||
| 125 | if (gy2 > cy2) gy2 = cy2; | ||
| 126 | if (gx2 > gx1 && gy2 > gy1) { | ||
| 127 | byte alpha[] = gl.getGrayBits(); | ||
| 128 | maskop.MaskFill(sg2d, dest, sg2d.composite, | ||
| 129 | gx1, gy1, gx2 - gx1, gy2 - gy1, | ||
| 130 | alpha, off, w); | ||
| 131 | } | ||
| 132 | } | ||
| 133 | } | ||
| 134 | } | ||
| 135 | |||
| 136 | public GraphicsPrimitive traceWrap() { | ||
| 137 | return new TraceDrawGlyphList(this); | ||
| 138 | } | ||
| 139 | |||
| 140 | private static class TraceDrawGlyphList extends DrawGlyphList { | ||
| 141 | DrawGlyphList target; | ||
| 142 | |||
| 143 | public TraceDrawGlyphList(DrawGlyphList target) { | ||
| 144 | super(target.getSourceType(), | ||
| 145 | target.getCompositeType(), | ||
| 146 | target.getDestType()); | ||
| 147 | this.target = target; | ||
| 148 | } | ||
| 149 | |||
| 150 | public GraphicsPrimitive traceWrap() { | ||
| 151 | return this; | ||
| 152 | } | ||
| 153 | |||
| 154 | public void DrawGlyphList(SunGraphics2D sg2d, SurfaceData dest, | ||
| 155 | GlyphList glyphs) | ||
| 156 | { | ||
| 157 | tracePrimitive(target); | ||
| 158 | target.DrawGlyphList(sg2d, dest, glyphs); | ||
| 159 | } | ||
| 160 | } | ||
| 161 | } | ||
Binary file not shown.
Binary file not shown.
Binary file not shown.
| @@ -0,0 +1,159 @@ | |||
| 1 | /* | ||
| 2 | * Copyright (c) 2000, 2004, Oracle and/or its affiliates. All rights reserved. | ||
| 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 | ||
| 7 | * published by the Free Software Foundation. Oracle designates this | ||
| 8 | * particular file as subject to the "Classpath" exception as provided | ||
| 9 | * by Oracle in the LICENSE file that accompanied this code. | ||
| 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 | * | ||
| 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. | ||
| 24 | */ | ||
| 25 | |||
| 26 | package sun.java2d.loops; | ||
| 27 | |||
| 28 | import sun.java2d.loops.GraphicsPrimitive; | ||
| 29 | import sun.java2d.pipe.Region; | ||
| 30 | import sun.java2d.SunGraphics2D; | ||
| 31 | import sun.java2d.SurfaceData; | ||
| 32 | import sun.font.GlyphList; | ||
| 33 | |||
| 34 | /** | ||
| 35 | * DrawGlyphListAA - loops for AATextRenderer pipe | ||
| 36 | * 1) draw anti-aliased text onto destination surface | ||
| 37 | * 2) must accept output area [x, y, dx, dy] | ||
| 38 | * from within the surface description data for clip rect | ||
| 39 | */ | ||
| 40 | public class DrawGlyphListAA extends GraphicsPrimitive { | ||
| 41 | |||
| 42 | public final static String methodSignature = "DrawGlyphListAA(...)".toString(); | ||
| 43 | |||
| 44 | public final static int primTypeID = makePrimTypeID(); | ||
| 45 | |||
| 46 | public static DrawGlyphListAA locate(SurfaceType srctype, | ||
| 47 | CompositeType comptype, | ||
| 48 | SurfaceType dsttype) | ||
| 49 | { | ||
| 50 | return (DrawGlyphListAA) | ||
| 51 | GraphicsPrimitiveMgr.locate(primTypeID, | ||
| 52 | srctype, comptype, dsttype); | ||
| 53 | } | ||
| 54 | |||
| 55 | protected DrawGlyphListAA(SurfaceType srctype, | ||
| 56 | CompositeType comptype, | ||
| 57 | SurfaceType dsttype) | ||
| 58 | { | ||
| 59 | super(methodSignature, primTypeID, srctype, comptype, dsttype); | ||
| 60 | } | ||
| 61 | |||
| 62 | public DrawGlyphListAA(long pNativePrim, | ||
| 63 | SurfaceType srctype, | ||
| 64 | CompositeType comptype, | ||
| 65 | SurfaceType dsttype) | ||
| 66 | { | ||
| 67 | super(pNativePrim, methodSignature, primTypeID, srctype, comptype, dsttype); | ||
| 68 | } | ||
| 69 | |||
| 70 | public native void DrawGlyphListAA(SunGraphics2D sg2d, SurfaceData dest, | ||
| 71 | GlyphList srcData); | ||
| 72 | |||
| 73 | static { | ||
| 74 | GraphicsPrimitiveMgr.registerGeneral( | ||
| 75 | new DrawGlyphListAA(null, null, null)); | ||
| 76 | } | ||
| 77 | |||
| 78 | public GraphicsPrimitive makePrimitive(SurfaceType srctype, | ||
| 79 | CompositeType comptype, | ||
| 80 | SurfaceType dsttype) { | ||
| 81 | return new General(srctype, comptype, dsttype); | ||
| 82 | } | ||
| 83 | |||
| 84 | public static class General extends DrawGlyphListAA { | ||
| 85 | MaskFill maskop; | ||
| 86 | |||
| 87 | public General(SurfaceType srctype, | ||
| 88 | CompositeType comptype, | ||
| 89 | SurfaceType dsttype) | ||
| 90 | { | ||
| 91 | super(srctype, comptype, dsttype); | ||
| 92 | maskop = MaskFill.locate(srctype, comptype, dsttype); | ||
| 93 | } | ||
| 94 | |||
| 95 | public void DrawGlyphListAA(SunGraphics2D sg2d, SurfaceData dest, | ||
| 96 | GlyphList gl) | ||
| 97 | { | ||
| 98 | gl.getBounds(); // Don't delete, bug 4895493 | ||
| 99 | int num = gl.getNumGlyphs(); | ||
| 100 | Region clip = sg2d.getCompClip(); | ||
| 101 | int cx1 = clip.getLoX(); | ||
| 102 | int cy1 = clip.getLoY(); | ||
| 103 | int cx2 = clip.getHiX(); | ||
| 104 | int cy2 = clip.getHiY(); | ||
| 105 | for (int i = 0; i < num; i++) { | ||
| 106 | gl.setGlyphIndex(i); | ||
| 107 | int metrics[] = gl.getMetrics(); | ||
| 108 | int gx1 = metrics[0]; | ||
| 109 | int gy1 = metrics[1]; | ||
| 110 | int w = metrics[2]; | ||
| 111 | int gx2 = gx1 + w; | ||
| 112 | int gy2 = gy1 + metrics[3]; | ||
| 113 | int off = 0; | ||
| 114 | if (gx1 < cx1) { | ||
| 115 | off = cx1 - gx1; | ||
| 116 | gx1 = cx1; | ||
| 117 | } | ||
| 118 | if (gy1 < cy1) { | ||
| 119 | off += (cy1 - gy1) * w; | ||
| 120 | gy1 = cy1; | ||
| 121 | } | ||
| 122 | if (gx2 > cx2) gx2 = cx2; | ||
| 123 | if (gy2 > cy2) gy2 = cy2; | ||
| 124 | if (gx2 > gx1 && gy2 > gy1) { | ||
| 125 | byte alpha[] = gl.getGrayBits(); | ||
| 126 | maskop.MaskFill(sg2d, dest, sg2d.composite, | ||
| 127 | gx1, gy1, gx2 - gx1, gy2 - gy1, | ||
| 128 | alpha, off, w); | ||
| 129 | } | ||
| 130 | } | ||
| 131 | } | ||
| 132 | } | ||
| 133 | |||
| 134 | public GraphicsPrimitive traceWrap() { | ||
| 135 | return new TraceDrawGlyphListAA(this); | ||
| 136 | } | ||
| 137 | |||
| 138 | private static class TraceDrawGlyphListAA extends DrawGlyphListAA { | ||
| 139 | DrawGlyphListAA target; | ||
| 140 | |||
| 141 | public TraceDrawGlyphListAA(DrawGlyphListAA target) { | ||
| 142 | super(target.getSourceType(), | ||
| 143 | target.getCompositeType(), | ||
| 144 | target.getDestType()); | ||
| 145 | this.target = target; | ||
| 146 | } | ||
| 147 | |||
| 148 | public GraphicsPrimitive traceWrap() { | ||
| 149 | return this; | ||
| 150 | } | ||
| 151 | |||
| 152 | public void DrawGlyphListAA(SunGraphics2D sg2d, SurfaceData dest, | ||
| 153 | GlyphList glyphs) | ||
| 154 | { | ||
| 155 | tracePrimitive(target); | ||
| 156 | target.DrawGlyphListAA(sg2d, dest, glyphs); | ||
| 157 | } | ||
| 158 | } | ||
| 159 | } | ||
Binary file not shown.
Binary file not shown.
| @@ -0,0 +1,117 @@ | |||
| 1 | /* | ||
| 2 | * Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved. | ||
| 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 | ||
| 7 | * published by the Free Software Foundation. Oracle designates this | ||
| 8 | * particular file as subject to the "Classpath" exception as provided | ||
| 9 | * by Oracle in the LICENSE file that accompanied this code. | ||
| 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 | * | ||
| 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. | ||
| 24 | */ | ||
| 25 | |||
| 26 | package sun.java2d.loops; | ||
| 27 | |||
| 28 | import sun.java2d.loops.GraphicsPrimitive; | ||
| 29 | import sun.java2d.pipe.Region; | ||
| 30 | import sun.java2d.SunGraphics2D; | ||
| 31 | import sun.java2d.SurfaceData; | ||
| 32 | import sun.font.GlyphList; | ||
| 33 | |||
| 34 | /** | ||
| 35 | * DrawGlyphListLCD- loops for LCDTextRenderer pipe | ||
| 36 | * 1) draw LCD anti-aliased text onto destination surface | ||
| 37 | * 2) must accept output area [x, y, dx, dy] | ||
| 38 | * from within the surface description data for clip rect | ||
| 39 | */ | ||
| 40 | public class DrawGlyphListLCD extends GraphicsPrimitive { | ||
| 41 | |||
| 42 | public final static String | ||
| 43 | methodSignature = "DrawGlyphListLCD(...)".toString(); | ||
| 44 | |||
| 45 | public final static int primTypeID = makePrimTypeID(); | ||
| 46 | |||
| 47 | public static DrawGlyphListLCD locate(SurfaceType srctype, | ||
| 48 | CompositeType comptype, | ||
| 49 | SurfaceType dsttype) | ||
| 50 | { | ||
| 51 | return (DrawGlyphListLCD) | ||
| 52 | GraphicsPrimitiveMgr.locate(primTypeID, | ||
| 53 | srctype, comptype, dsttype); | ||
| 54 | } | ||
| 55 | |||
| 56 | protected DrawGlyphListLCD(SurfaceType srctype, | ||
| 57 | CompositeType comptype, | ||
| 58 | SurfaceType dsttype) | ||
| 59 | { | ||
| 60 | super(methodSignature, primTypeID, srctype, comptype, dsttype); | ||
| 61 | } | ||
| 62 | |||
| 63 | public DrawGlyphListLCD(long pNativePrim, | ||
| 64 | SurfaceType srctype, | ||
| 65 | CompositeType comptype, | ||
| 66 | SurfaceType dsttype) | ||
| 67 | { | ||
| 68 | super(pNativePrim, methodSignature, primTypeID, | ||
| 69 | srctype, comptype, dsttype); | ||
| 70 | } | ||
| 71 | |||
| 72 | public native void DrawGlyphListLCD(SunGraphics2D sg2d, SurfaceData dest, | ||
| 73 | GlyphList srcData); | ||
| 74 | |||
| 75 | static { | ||
| 76 | GraphicsPrimitiveMgr.registerGeneral( | ||
| 77 | new DrawGlyphListLCD(null, null, null)); | ||
| 78 | } | ||
| 79 | |||
| 80 | public GraphicsPrimitive makePrimitive(SurfaceType srctype, | ||
| 81 | CompositeType comptype, | ||
| 82 | SurfaceType dsttype) { | ||
| 83 | /* Do not return a General loop. SunGraphics2D determines whether | ||
| 84 | * to use LCD or standard AA text based on whether there is an | ||
| 85 | * installed loop. | ||
| 86 | * This can be uncommented once there is a General loop which can | ||
| 87 | * handle one byte per colour component masks properly. | ||
| 88 | */ | ||
| 89 | return null; | ||
| 90 | } | ||
| 91 | |||
| 92 | public GraphicsPrimitive traceWrap() { | ||
| 93 | return new TraceDrawGlyphListLCD(this); | ||
| 94 | } | ||
| 95 | |||
| 96 | private static class TraceDrawGlyphListLCD extends DrawGlyphListLCD { | ||
| 97 | DrawGlyphListLCD target; | ||
| 98 | |||
| 99 | public TraceDrawGlyphListLCD(DrawGlyphListLCD target) { | ||
| 100 | super(target.getSourceType(), | ||
| 101 | target.getCompositeType(), | ||
| 102 | target.getDestType()); | ||
| 103 | this.target = target; | ||
| 104 | } | ||
| 105 | |||
| 106 | public GraphicsPrimitive traceWrap() { | ||
| 107 | return this; | ||
| 108 | } | ||
| 109 | |||
| 110 | public void DrawGlyphListLCD(SunGraphics2D sg2d, SurfaceData dest, | ||
| 111 | GlyphList glyphs) | ||
| 112 | { | ||
| 113 | tracePrimitive(target); | ||
| 114 | target.DrawGlyphListLCD(sg2d, dest, glyphs); | ||
| 115 | } | ||
| 116 | } | ||
| 117 | } | ||
Binary file not shown.
Binary file not shown.
| @@ -0,0 +1,114 @@ | |||
| 1 | /* | ||
| 2 | * Copyright (c) 1997, 2002, Oracle and/or its affiliates. All rights reserved. | ||
| 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 | ||
| 7 | * published by the Free Software Foundation. Oracle designates this | ||
| 8 | * particular file as subject to the "Classpath" exception as provided | ||
| 9 | * by Oracle in the LICENSE file that accompanied this code. | ||
| 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 | * | ||
| 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. | ||
| 24 | */ | ||
| 25 | |||
| 26 | /* | ||
| 27 | * @author Charlton Innovations, Inc. | ||
| 28 | */ | ||
| 29 | |||
| 30 | package sun.java2d.loops; | ||
| 31 | |||
| 32 | import sun.java2d.loops.GraphicsPrimitive; | ||
| 33 | import java.awt.Color; | ||
| 34 | import java.awt.image.ColorModel; | ||
| 35 | import java.awt.image.Raster; | ||
| 36 | import sun.java2d.SunGraphics2D; | ||
| 37 | import sun.java2d.SurfaceData; | ||
| 38 | |||
| 39 | /** | ||
| 40 | * DrawLine | ||
| 41 | * 1) draw solid color single width line onto destination surface | ||
| 42 | * 2) must accept output area [x, y, dx, dy] | ||
| 43 | * from within the surface description data for clip rect | ||
| 44 | */ | ||
| 45 | public class DrawLine extends GraphicsPrimitive | ||
| 46 | { | ||
| 47 | public final static String methodSignature = "DrawLine(...)".toString(); | ||
| 48 | |||
| 49 | public final static int primTypeID = makePrimTypeID(); | ||
| 50 | |||
| 51 | public static DrawLine locate(SurfaceType srctype, | ||
| 52 | CompositeType comptype, | ||
| 53 | SurfaceType dsttype) | ||
| 54 | { | ||
| 55 | return (DrawLine) GraphicsPrimitiveMgr.locate(primTypeID, | ||
| 56 | srctype, comptype, dsttype); | ||
| 57 | } | ||
| 58 | |||
| 59 | protected DrawLine(SurfaceType srctype, | ||
| 60 | CompositeType comptype, | ||
| 61 | SurfaceType dsttype) | ||
| 62 | { | ||
| 63 | super(methodSignature, primTypeID, srctype, comptype, dsttype); | ||
| 64 | } | ||
| 65 | |||
| 66 | public DrawLine(long pNativePrim, | ||
| 67 | SurfaceType srctype, | ||
| 68 | CompositeType comptype, | ||
| 69 | SurfaceType dsttype) | ||
| 70 | { | ||
| 71 | super(pNativePrim, methodSignature, primTypeID, srctype, comptype, dsttype); | ||
| 72 | } | ||
| 73 | |||
| 74 | /** | ||
| 75 | * All DrawLine implementors must have this invoker method | ||
| 76 | */ | ||
| 77 | public native void DrawLine(SunGraphics2D sg2d, SurfaceData dest, | ||
| 78 | int x1, int y1, int x2, int y2); | ||
| 79 | |||
| 80 | public GraphicsPrimitive makePrimitive(SurfaceType srctype, | ||
| 81 | CompositeType comptype, | ||
| 82 | SurfaceType dsttype) | ||
| 83 | { | ||
| 84 | // REMIND: use FillSpans or converter object? | ||
| 85 | throw new InternalError("DrawLine not implemented for "+ | ||
| 86 | srctype+" with "+comptype); | ||
| 87 | } | ||
| 88 | |||
| 89 | public GraphicsPrimitive traceWrap() { | ||
| 90 | return new TraceDrawLine(this); | ||
| 91 | } | ||
| 92 | |||
| 93 | private static class TraceDrawLine extends DrawLine { | ||
| 94 | DrawLine target; | ||
| 95 | |||
| 96 | public TraceDrawLine(DrawLine target) { | ||
| 97 | super(target.getSourceType(), | ||
| 98 | target.getCompositeType(), | ||
| 99 | target.getDestType()); | ||
| 100 | this.target = target; | ||
| 101 | } | ||
| 102 | |||
| 103 | public GraphicsPrimitive traceWrap() { | ||
| 104 | return this; | ||
| 105 | } | ||
| 106 | |||
| 107 | public void DrawLine(SunGraphics2D sg2d, SurfaceData dest, | ||
| 108 | int x1, int y1, int x2, int y2) | ||
| 109 | { | ||
| 110 | tracePrimitive(target); | ||
| 111 | target.DrawLine(sg2d, dest, x1, y1, x2, y2); | ||
| 112 | } | ||
| 113 | } | ||
| 114 | } | ||
Binary file not shown.
Binary file not shown.
| @@ -0,0 +1,123 @@ | |||
| 1 | /* | ||
| 2 | * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved. | ||
| 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 | ||
| 7 | * published by the Free Software Foundation. Oracle designates this | ||
| 8 | * particular file as subject to the "Classpath" exception as provided | ||
| 9 | * by Oracle in the LICENSE file that accompanied this code. | ||
| 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 | * | ||
| 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. | ||
| 24 | */ | ||
| 25 | |||
| 26 | /* | ||
| 27 | * @author Jim Graham | ||
| 28 | */ | ||
| 29 | |||
| 30 | package sun.java2d.loops; | ||
| 31 | |||
| 32 | import sun.java2d.loops.GraphicsPrimitive; | ||
| 33 | import sun.java2d.SunGraphics2D; | ||
| 34 | import sun.java2d.SurfaceData; | ||
| 35 | |||
| 36 | /** | ||
| 37 | * DrawParallelogram | ||
| 38 | * 1) fill the area between the 4 edges of an outer parallelogram | ||
| 39 | * (as specified by an origin and 2 delta vectors) | ||
| 40 | * but also outside the 4 edges of an inner parallelogram | ||
| 41 | * (as specified by proportional amounts of the outer delta vectors) | ||
| 42 | */ | ||
| 43 | public class DrawParallelogram extends GraphicsPrimitive | ||
| 44 | { | ||
| 45 | public final static String methodSignature = | ||
| 46 | "DrawParallelogram(...)".toString(); | ||
| 47 | |||
| 48 | public final static int primTypeID = makePrimTypeID(); | ||
| 49 | |||
| 50 | public static DrawParallelogram locate(SurfaceType srctype, | ||
| 51 | CompositeType comptype, | ||
| 52 | SurfaceType dsttype) | ||
| 53 | { | ||
| 54 | return (DrawParallelogram) | ||
| 55 | GraphicsPrimitiveMgr.locate(primTypeID, | ||
| 56 | srctype, comptype, dsttype); | ||
| 57 | } | ||
| 58 | |||
| 59 | protected DrawParallelogram(SurfaceType srctype, | ||
| 60 | CompositeType comptype, | ||
| 61 | SurfaceType dsttype) | ||
| 62 | { | ||
| 63 | super(methodSignature, primTypeID, | ||
| 64 | srctype, comptype, dsttype); | ||
| 65 | } | ||
| 66 | |||
| 67 | public DrawParallelogram(long pNativePrim, | ||
| 68 | SurfaceType srctype, | ||
| 69 | CompositeType comptype, | ||
| 70 | SurfaceType dsttype) | ||
| 71 | { | ||
| 72 | super(pNativePrim, methodSignature, primTypeID, | ||
| 73 | srctype, comptype, dsttype); | ||
| 74 | } | ||
| 75 | |||
| 76 | /** | ||
| 77 | * All DrawParallelogram implementors must have this invoker method | ||
| 78 | */ | ||
| 79 | public native void DrawParallelogram(SunGraphics2D sg, SurfaceData dest, | ||
| 80 | double x, double y, | ||
| 81 | double dx1, double dy1, | ||
| 82 | double dx2, double dy2, | ||
| 83 | double lw1, double lw2); | ||
| 84 | |||
| 85 | public GraphicsPrimitive makePrimitive(SurfaceType srctype, | ||
| 86 | CompositeType comptype, | ||
| 87 | SurfaceType dsttype) | ||
| 88 | { | ||
| 89 | // REMIND: iterate with a FillRect primitive? | ||
| 90 | throw new InternalError("DrawParallelogram not implemented for "+ | ||
| 91 | srctype+" with "+comptype); | ||
| 92 | } | ||
| 93 | |||
| 94 | public GraphicsPrimitive traceWrap() { | ||
| 95 | return new TraceDrawParallelogram(this); | ||
| 96 | } | ||
| 97 | |||
| 98 | private static class TraceDrawParallelogram extends DrawParallelogram { | ||
| 99 | DrawParallelogram target; | ||
| 100 | |||
| 101 | public TraceDrawParallelogram(DrawParallelogram target) { | ||
| 102 | super(target.getSourceType(), | ||
| 103 | target.getCompositeType(), | ||
| 104 | target.getDestType()); | ||
| 105 | this.target = target; | ||
| 106 | } | ||
| 107 | |||
| 108 | public GraphicsPrimitive traceWrap() { | ||
| 109 | return this; | ||
| 110 | } | ||
| 111 | |||
| 112 | public void DrawParallelogram(SunGraphics2D sg2d, SurfaceData dest, | ||
| 113 | double x, double y, | ||
| 114 | double dx1, double dy1, | ||
| 115 | double dx2, double dy2, | ||
| 116 | double lw1, double lw2) | ||
| 117 | { | ||
| 118 | tracePrimitive(target); | ||
| 119 | target.DrawParallelogram(sg2d, dest, | ||
| 120 | x, y, dx1, dy1, dx2, dy2, lw1, lw2); | ||
| 121 | } | ||
| 122 | } | ||
| 123 | } | ||
Binary file not shown.
Binary file not shown.
| @@ -0,0 +1,114 @@ | |||
| 1 | /* | ||
| 2 | * Copyright (c) 2005, 2006, Oracle and/or its affiliates. All rights reserved. | ||
| 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 | ||
| 7 | * published by the Free Software Foundation. Oracle designates this | ||
| 8 | * particular file as subject to the "Classpath" exception as provided | ||
| 9 | * by Oracle in the LICENSE file that accompanied this code. | ||
| 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 | * | ||
| 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. | ||
| 24 | */ | ||
| 25 | |||
| 26 | package sun.java2d.loops; | ||
| 27 | |||
| 28 | import sun.java2d.loops.GraphicsPrimitive; | ||
| 29 | import sun.java2d.SunGraphics2D; | ||
| 30 | import sun.java2d.SurfaceData; | ||
| 31 | import java.awt.geom.Path2D; | ||
| 32 | |||
| 33 | /** | ||
| 34 | * DrawPath | ||
| 35 | * 1. draw single-width line path onto destination surface | ||
| 36 | * 2. must accept output area [x, y, dx, dy] | ||
| 37 | * from within the surface description data for clip rect | ||
| 38 | */ | ||
| 39 | public class DrawPath extends GraphicsPrimitive { | ||
| 40 | |||
| 41 | public final static String methodSignature = | ||
| 42 | "DrawPath(...)".toString(); | ||
| 43 | |||
| 44 | public final static int primTypeID = makePrimTypeID(); | ||
| 45 | |||
| 46 | public static DrawPath locate(SurfaceType srctype, | ||
| 47 | CompositeType comptype, | ||
| 48 | SurfaceType dsttype) | ||
| 49 | { | ||
| 50 | return (DrawPath) | ||
| 51 | GraphicsPrimitiveMgr.locate(primTypeID, | ||
| 52 | srctype, comptype, dsttype); | ||
| 53 | } | ||
| 54 | |||
| 55 | protected DrawPath(SurfaceType srctype, | ||
| 56 | CompositeType comptype, | ||
| 57 | SurfaceType dsttype) | ||
| 58 | { | ||
| 59 | super(methodSignature, primTypeID, | ||
| 60 | srctype, comptype, dsttype); | ||
| 61 | } | ||
| 62 | |||
| 63 | public DrawPath(long pNativePrim, | ||
| 64 | SurfaceType srctype, | ||
| 65 | CompositeType comptype, | ||
| 66 | SurfaceType dsttype) | ||
| 67 | { | ||
| 68 | super(pNativePrim, methodSignature, primTypeID, | ||
| 69 | srctype, comptype, dsttype); | ||
| 70 | } | ||
| 71 | |||
| 72 | |||
| 73 | /** | ||
| 74 | * All DrawPath implementors must have this invoker method | ||
| 75 | */ | ||
| 76 | public native void DrawPath(SunGraphics2D sg2d, SurfaceData sData, | ||
| 77 | int transX, int transY, | ||
| 78 | Path2D.Float p2df); | ||
| 79 | |||
| 80 | public GraphicsPrimitive makePrimitive(SurfaceType srctype, | ||
| 81 | CompositeType comptype, | ||
| 82 | SurfaceType dsttype) | ||
| 83 | { | ||
| 84 | throw new InternalError("DrawPath not implemented for "+ | ||
| 85 | srctype+" with "+comptype); | ||
| 86 | } | ||
| 87 | |||
| 88 | public GraphicsPrimitive traceWrap() { | ||
| 89 | return new TraceDrawPath(this); | ||
| 90 | } | ||
| 91 | |||
| 92 | private static class TraceDrawPath extends DrawPath { | ||
| 93 | DrawPath target; | ||
| 94 | |||
| 95 | public TraceDrawPath(DrawPath target) { | ||
| 96 | super(target.getSourceType(), | ||
| 97 | target.getCompositeType(), | ||
| 98 | target.getDestType()); | ||
| 99 | this.target = target; | ||
| 100 | } | ||
| 101 | |||
| 102 | public GraphicsPrimitive traceWrap() { | ||
| 103 | return this; | ||
| 104 | } | ||
| 105 | |||
| 106 | public void DrawPath(SunGraphics2D sg2d, SurfaceData sData, | ||
| 107 | int transX, int transY, | ||
| 108 | Path2D.Float p2df) | ||
| 109 | { | ||
| 110 | tracePrimitive(target); | ||
| 111 | target.DrawPath(sg2d, sData, transX, transY, p2df); | ||
| 112 | } | ||
| 113 | } | ||
| 114 | } | ||
Binary file not shown.
Binary file not shown.
| @@ -0,0 +1,120 @@ | |||
| 1 | /* | ||
| 2 | * Copyright (c) 1997, 2002, Oracle and/or its affiliates. All rights reserved. | ||
| 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 | ||
| 7 | * published by the Free Software Foundation. Oracle designates this | ||
| 8 | * particular file as subject to the "Classpath" exception as provided | ||
| 9 | * by Oracle in the LICENSE file that accompanied this code. | ||
| 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 | * | ||
| 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. | ||
| 24 | */ | ||
| 25 | |||
| 26 | /* | ||
| 27 | * @author Charlton Innovations, Inc. | ||
| 28 | */ | ||
| 29 | |||
| 30 | package sun.java2d.loops; | ||
| 31 | |||
| 32 | import sun.java2d.loops.GraphicsPrimitive; | ||
| 33 | import sun.java2d.SunGraphics2D; | ||
| 34 | import sun.java2d.SurfaceData; | ||
| 35 | |||
| 36 | /** | ||
| 37 | * DrawPolygons | ||
| 38 | * 1) draw single-width line polygons onto destination surface | ||
| 39 | * 2) must accept output area [x, y, dx, dy] | ||
| 40 | * from within the surface description data for clip rect | ||
| 41 | */ | ||
| 42 | public class DrawPolygons extends GraphicsPrimitive | ||
| 43 | { | ||
| 44 | public final static String methodSignature = "DrawPolygons(...)".toString(); | ||
| 45 | |||
| 46 | public final static int primTypeID = makePrimTypeID(); | ||
| 47 | |||
| 48 | public static DrawPolygons locate(SurfaceType srctype, | ||
| 49 | CompositeType comptype, | ||
| 50 | SurfaceType dsttype) | ||
| 51 | { | ||
| 52 | return (DrawPolygons) | ||
| 53 | GraphicsPrimitiveMgr.locate(primTypeID, | ||
| 54 | srctype, comptype, dsttype); | ||
| 55 | } | ||
| 56 | |||
| 57 | protected DrawPolygons(SurfaceType srctype, | ||
| 58 | CompositeType comptype, | ||
| 59 | SurfaceType dsttype) | ||
| 60 | { | ||
| 61 | super(methodSignature, primTypeID, srctype, comptype, dsttype); | ||
| 62 | } | ||
| 63 | |||
| 64 | public DrawPolygons(long pNativePrim, | ||
| 65 | SurfaceType srctype, | ||
| 66 | CompositeType comptype, | ||
| 67 | SurfaceType dsttype) | ||
| 68 | { | ||
| 69 | super(pNativePrim, methodSignature, primTypeID, srctype, comptype, dsttype); | ||
| 70 | } | ||
| 71 | |||
| 72 | /** | ||
| 73 | * All DrawPolygon implementors must have this invoker method | ||
| 74 | */ | ||
| 75 | public native void DrawPolygons(SunGraphics2D sg2d, SurfaceData sData, | ||
| 76 | int xPoints[], int yPoints[], | ||
| 77 | int nPoints[], int numPolys, | ||
| 78 | int transX, int transY, | ||
| 79 | boolean close); | ||
| 80 | |||
| 81 | public GraphicsPrimitive makePrimitive(SurfaceType srctype, | ||
| 82 | CompositeType comptype, | ||
| 83 | SurfaceType dsttype) | ||
| 84 | { | ||
| 85 | // REMIND: use FillSpans or converter object? | ||
| 86 | throw new InternalError("DrawPolygons not implemented for "+ | ||
| 87 | srctype+" with "+comptype); | ||
| 88 | } | ||
| 89 | |||
| 90 | public GraphicsPrimitive traceWrap() { | ||
| 91 | return new TraceDrawPolygons(this); | ||
| 92 | } | ||
| 93 | |||
| 94 | private static class TraceDrawPolygons extends DrawPolygons { | ||
| 95 | DrawPolygons target; | ||
| 96 | |||
| 97 | public TraceDrawPolygons(DrawPolygons target) { | ||
| 98 | super(target.getSourceType(), | ||
| 99 | target.getCompositeType(), | ||
| 100 | target.getDestType()); | ||
| 101 | this.target = target; | ||
| 102 | } | ||
| 103 | |||
| 104 | public GraphicsPrimitive traceWrap() { | ||
| 105 | return this; | ||
| 106 | } | ||
| 107 | |||
| 108 | public void DrawPolygons(SunGraphics2D sg2d, SurfaceData sData, | ||
| 109 | int xPoints[], int yPoints[], | ||
| 110 | int nPoints[], int numPolys, | ||
| 111 | int transX, int transY, | ||
| 112 | boolean close) | ||
| 113 | { | ||
| 114 | tracePrimitive(target); | ||
| 115 | target.DrawPolygons(sg2d, sData, | ||
| 116 | xPoints, yPoints, nPoints, numPolys, | ||
| 117 | transX, transY, close); | ||
| 118 | } | ||
| 119 | } | ||
| 120 | } | ||
Binary file not shown.
Binary file not shown.
| @@ -0,0 +1,115 @@ | |||
| 1 | /* | ||
| 2 | * Copyright (c) 1997, 2002, Oracle and/or its affiliates. All rights reserved. | ||
| 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 | ||
| 7 | * published by the Free Software Foundation. Oracle designates this | ||
| 8 | * particular file as subject to the "Classpath" exception as provided | ||
| 9 | * by Oracle in the LICENSE file that accompanied this code. | ||
| 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 | * | ||
| 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. | ||
| 24 | */ | ||
| 25 | |||
| 26 | /* | ||
| 27 | * @author Charlton Innovations, Inc. | ||
| 28 | */ | ||
| 29 | |||
| 30 | package sun.java2d.loops; | ||
| 31 | |||
| 32 | import sun.java2d.loops.GraphicsPrimitive; | ||
| 33 | import java.awt.Color; | ||
| 34 | import java.awt.image.ColorModel; | ||
| 35 | import java.awt.image.Raster; | ||
| 36 | import sun.java2d.SunGraphics2D; | ||
| 37 | import sun.java2d.SurfaceData; | ||
| 38 | |||
| 39 | /** | ||
| 40 | * DrawRect | ||
| 41 | * 1) draw single-width line rectangle onto destination surface | ||
| 42 | * 2) must accept output area [x, y, dx, dy] | ||
| 43 | * from within the surface description data for clip rect | ||
| 44 | */ | ||
| 45 | public class DrawRect extends GraphicsPrimitive | ||
| 46 | { | ||
| 47 | public final static String methodSignature = "DrawRect(...)".toString(); | ||
| 48 | |||
| 49 | public final static int primTypeID = makePrimTypeID(); | ||
| 50 | |||
| 51 | public static DrawRect locate(SurfaceType srctype, | ||
| 52 | CompositeType comptype, | ||
| 53 | SurfaceType dsttype) | ||
| 54 | { | ||
| 55 | return (DrawRect) | ||
| 56 | GraphicsPrimitiveMgr.locate(primTypeID, | ||
| 57 | srctype, comptype, dsttype); | ||
| 58 | } | ||
| 59 | |||
| 60 | protected DrawRect(SurfaceType srctype, | ||
| 61 | CompositeType comptype, | ||
| 62 | SurfaceType dsttype) | ||
| 63 | { | ||
| 64 | super(methodSignature, primTypeID, srctype, comptype, dsttype); | ||
| 65 | } | ||
| 66 | |||
| 67 | public DrawRect(long pNativePrim, | ||
| 68 | SurfaceType srctype, | ||
| 69 | CompositeType comptype, | ||
| 70 | SurfaceType dsttype) | ||
| 71 | { | ||
| 72 | super(pNativePrim, methodSignature, primTypeID, srctype, comptype, dsttype); | ||
| 73 | } | ||
| 74 | |||
| 75 | /** | ||
| 76 | * All DrawRect implementors must have this invoker method | ||
| 77 | */ | ||
| 78 | public native void DrawRect(SunGraphics2D sg2d, SurfaceData dest, | ||
| 79 | int x1, int y1, int w, int h); | ||
| 80 | |||
| 81 | public GraphicsPrimitive makePrimitive(SurfaceType srctype, | ||
| 82 | CompositeType comptype, | ||
| 83 | SurfaceType dsttype) | ||
| 84 | { | ||
| 85 | // REMIND: use FillSpans or converter object? | ||
| 86 | throw new InternalError("DrawRect not implemented for "+ | ||
| 87 | srctype+" with "+comptype); | ||
| 88 | } | ||
| 89 | |||
| 90 | public GraphicsPrimitive traceWrap() { | ||
| 91 | return new TraceDrawRect(this); | ||
| 92 | } | ||
| 93 | |||
| 94 | private static class TraceDrawRect extends DrawRect { | ||
| 95 | DrawRect target; | ||
| 96 | |||
| 97 | public TraceDrawRect(DrawRect target) { | ||
| 98 | super(target.getSourceType(), | ||
| 99 | target.getCompositeType(), | ||
| 100 | target.getDestType()); | ||
| 101 | this.target = target; | ||
| 102 | } | ||
| 103 | |||
| 104 | public GraphicsPrimitive traceWrap() { | ||
| 105 | return this; | ||
| 106 | } | ||
| 107 | |||
| 108 | public void DrawRect(SunGraphics2D sg2d, SurfaceData dest, | ||
| 109 | int x1, int y1, int w, int h) | ||
| 110 | { | ||
| 111 | tracePrimitive(target); | ||
| 112 | target.DrawRect(sg2d, dest, x1, y1, w, h); | ||
| 113 | } | ||
| 114 | } | ||
| 115 | } | ||
Binary file not shown.
Binary file not shown.
| @@ -0,0 +1,118 @@ | |||
| 1 | /* | ||
| 2 | * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved. | ||
| 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 | ||
| 7 | * published by the Free Software Foundation. Oracle designates this | ||
| 8 | * particular file as subject to the "Classpath" exception as provided | ||
| 9 | * by Oracle in the LICENSE file that accompanied this code. | ||
| 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 | * | ||
| 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. | ||
| 24 | */ | ||
| 25 | |||
| 26 | /* | ||
| 27 | * @author Jim Graham | ||
| 28 | */ | ||
| 29 | |||
| 30 | package sun.java2d.loops; | ||
| 31 | |||
| 32 | import sun.java2d.loops.GraphicsPrimitive; | ||
| 33 | import sun.java2d.SunGraphics2D; | ||
| 34 | import sun.java2d.SurfaceData; | ||
| 35 | |||
| 36 | /** | ||
| 37 | * FillParallelogram | ||
| 38 | * 1) fill the area between the 4 edges of a parallelogram | ||
| 39 | * (as specified by an origin and 2 delta vectors) | ||
| 40 | */ | ||
| 41 | public class FillParallelogram extends GraphicsPrimitive | ||
| 42 | { | ||
| 43 | public final static String methodSignature = | ||
| 44 | "FillParallelogram(...)".toString(); | ||
| 45 | |||
| 46 | public final static int primTypeID = makePrimTypeID(); | ||
| 47 | |||
| 48 | public static FillParallelogram locate(SurfaceType srctype, | ||
| 49 | CompositeType comptype, | ||
| 50 | SurfaceType dsttype) | ||
| 51 | { | ||
| 52 | return (FillParallelogram) | ||
| 53 | GraphicsPrimitiveMgr.locate(primTypeID, | ||
| 54 | srctype, comptype, dsttype); | ||
| 55 | } | ||
| 56 | |||
| 57 | protected FillParallelogram(SurfaceType srctype, | ||
| 58 | CompositeType comptype, | ||
| 59 | SurfaceType dsttype) | ||
| 60 | { | ||
| 61 | super(methodSignature, primTypeID, | ||
| 62 | srctype, comptype, dsttype); | ||
| 63 | } | ||
| 64 | |||
| 65 | public FillParallelogram(long pNativePrim, | ||
| 66 | SurfaceType srctype, | ||
| 67 | CompositeType comptype, | ||
| 68 | SurfaceType dsttype) | ||
| 69 | { | ||
| 70 | super(pNativePrim, methodSignature, primTypeID, | ||
| 71 | srctype, comptype, dsttype); | ||
| 72 | } | ||
| 73 | |||
| 74 | /** | ||
| 75 | * All FillParallelogram implementors must have this invoker method | ||
| 76 | */ | ||
| 77 | public native void FillParallelogram(SunGraphics2D sg2d, SurfaceData dest, | ||
| 78 | double x0, double y0, | ||
| 79 | double dx1, double dy1, | ||
| 80 | double dx2, double dy2); | ||
| 81 | |||
| 82 | public GraphicsPrimitive makePrimitive(SurfaceType srctype, | ||
| 83 | CompositeType comptype, | ||
| 84 | SurfaceType dsttype) | ||
| 85 | { | ||
| 86 | // REMIND: iterate with a FillRect primitive? | ||
| 87 | throw new InternalError("FillParallelogram not implemented for "+ | ||
| 88 | srctype+" with "+comptype); | ||
| 89 | } | ||
| 90 | |||
| 91 | public GraphicsPrimitive traceWrap() { | ||
| 92 | return new TraceFillParallelogram(this); | ||
| 93 | } | ||
| 94 | |||
| 95 | private static class TraceFillParallelogram extends FillParallelogram { | ||
| 96 | FillParallelogram target; | ||
| 97 | |||
| 98 | public TraceFillParallelogram(FillParallelogram target) { | ||
| 99 | super(target.getSourceType(), | ||
| 100 | target.getCompositeType(), | ||
| 101 | target.getDestType()); | ||
| 102 | this.target = target; | ||
| 103 | } | ||
| 104 | |||
| 105 | public GraphicsPrimitive traceWrap() { | ||
| 106 | return this; | ||
| 107 | } | ||
| 108 | |||
| 109 | public void FillParallelogram(SunGraphics2D sg2d, SurfaceData dest, | ||
| 110 | double x0, double y0, | ||
| 111 | double dx1, double dy1, | ||
| 112 | double dx2, double dy2) | ||
| 113 | { | ||
| 114 | tracePrimitive(target); | ||
| 115 | target.FillParallelogram(sg2d, dest, x0, y0, dx1, dy1, dx2, dy2); | ||
| 116 | } | ||
| 117 | } | ||
| 118 | } | ||
Binary file not shown.
Binary file not shown.
| @@ -0,0 +1,114 @@ | |||
| 1 | /* | ||
| 2 | * Copyright (c) 2005, 2006, Oracle and/or its affiliates. All rights reserved. | ||
| 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 | ||
| 7 | * published by the Free Software Foundation. Oracle designates this | ||
| 8 | * particular file as subject to the "Classpath" exception as provided | ||
| 9 | * by Oracle in the LICENSE file that accompanied this code. | ||
| 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 | * | ||
| 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. | ||
| 24 | */ | ||
| 25 | |||
| 26 | package sun.java2d.loops; | ||
| 27 | |||
| 28 | import sun.java2d.loops.GraphicsPrimitive; | ||
| 29 | import sun.java2d.SunGraphics2D; | ||
| 30 | import sun.java2d.SurfaceData; | ||
| 31 | import java.awt.geom.Path2D; | ||
| 32 | |||
| 33 | /** | ||
| 34 | * FillPath | ||
| 35 | * 1. fill path onto destination surface | ||
| 36 | * 2. must accept output area [x, y, dx, dy] | ||
| 37 | * from within the surface description data for clip rect | ||
| 38 | */ | ||
| 39 | public class FillPath extends GraphicsPrimitive { | ||
| 40 | |||
| 41 | public final static String methodSignature = | ||
| 42 | "FillPath(...)".toString(); | ||
| 43 | |||
| 44 | public final static int primTypeID = makePrimTypeID(); | ||
| 45 | |||
| 46 | public static FillPath locate(SurfaceType srctype, | ||
| 47 | CompositeType comptype, | ||
| 48 | SurfaceType dsttype) | ||
| 49 | { | ||
| 50 | return (FillPath) | ||
| 51 | GraphicsPrimitiveMgr.locate(primTypeID, | ||
| 52 | srctype, comptype, dsttype); | ||
| 53 | } | ||
| 54 | |||
| 55 | protected FillPath(SurfaceType srctype, | ||
| 56 | CompositeType comptype, | ||
| 57 | SurfaceType dsttype) | ||
| 58 | { | ||
| 59 | super(methodSignature, primTypeID, | ||
| 60 | srctype, comptype, dsttype); | ||
| 61 | } | ||
| 62 | |||
| 63 | public FillPath(long pNativePrim, | ||
| 64 | SurfaceType srctype, | ||
| 65 | CompositeType comptype, | ||
| 66 | SurfaceType dsttype) | ||
| 67 | { | ||
| 68 | super(pNativePrim, methodSignature, primTypeID, | ||
| 69 | srctype, comptype, dsttype); | ||
| 70 | } | ||
| 71 | |||
| 72 | |||
| 73 | /** | ||
| 74 | * All FillPath implementors must have this invoker method | ||
| 75 | */ | ||
| 76 | public native void FillPath(SunGraphics2D sg2d, SurfaceData sData, | ||
| 77 | int transX, int transY, | ||
| 78 | Path2D.Float p2df); | ||
| 79 | |||
| 80 | public GraphicsPrimitive makePrimitive(SurfaceType srctype, | ||
| 81 | CompositeType comptype, | ||
| 82 | SurfaceType dsttype) | ||
| 83 | { | ||
| 84 | throw new InternalError("FillPath not implemented for "+ | ||
| 85 | srctype+" with "+comptype); | ||
| 86 | } | ||
| 87 | |||
| 88 | public GraphicsPrimitive traceWrap() { | ||
| 89 | return new TraceFillPath(this); | ||
| 90 | } | ||
| 91 | |||
| 92 | private static class TraceFillPath extends FillPath { | ||
| 93 | FillPath target; | ||
| 94 | |||
| 95 | public TraceFillPath(FillPath target) { | ||
| 96 | super(target.getSourceType(), | ||
| 97 | target.getCompositeType(), | ||
| 98 | target.getDestType()); | ||
| 99 | this.target = target; | ||
| 100 | } | ||
| 101 | |||
| 102 | public GraphicsPrimitive traceWrap() { | ||
| 103 | return this; | ||
| 104 | } | ||
| 105 | |||
| 106 | public void FillPath(SunGraphics2D sg2d, SurfaceData sData, | ||
| 107 | int transX, int transY, | ||
| 108 | Path2D.Float p2df) | ||
| 109 | { | ||
| 110 | tracePrimitive(target); | ||
| 111 | target.FillPath(sg2d, sData, transX, transY, p2df); | ||
| 112 | } | ||
| 113 | } | ||
| 114 | } | ||
Binary file not shown.
Binary file not shown.
Binary file not shown.
| @@ -0,0 +1,135 @@ | |||
| 1 | /* | ||
| 2 | * Copyright (c) 1997, 2002, Oracle and/or its affiliates. All rights reserved. | ||
| 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 | ||
| 7 | * published by the Free Software Foundation. Oracle designates this | ||
| 8 | * particular file as subject to the "Classpath" exception as provided | ||
| 9 | * by Oracle in the LICENSE file that accompanied this code. | ||
| 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 | * | ||
| 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. | ||
| 24 | */ | ||
| 25 | |||
| 26 | /* | ||
| 27 | * @author Charlton Innovations, Inc. | ||
| 28 | */ | ||
| 29 | |||
| 30 | package sun.java2d.loops; | ||
| 31 | |||
| 32 | import sun.java2d.loops.GraphicsPrimitive; | ||
| 33 | import java.awt.Color; | ||
| 34 | import java.awt.image.ColorModel; | ||
| 35 | import java.awt.image.Raster; | ||
| 36 | import sun.java2d.SunGraphics2D; | ||
| 37 | import sun.java2d.SurfaceData; | ||
| 38 | |||
| 39 | /** | ||
| 40 | * FillRect | ||
| 41 | * 1) draw solid color rectangle onto destination surface | ||
| 42 | * 2) must accept output area [x, y, dx, dy] | ||
| 43 | * from within the surface description data for clip rect | ||
| 44 | */ | ||
| 45 | public class FillRect extends GraphicsPrimitive | ||
| 46 | { | ||
| 47 | public final static String methodSignature = "FillRect(...)".toString(); | ||
| 48 | |||
| 49 | public final static int primTypeID = makePrimTypeID(); | ||
| 50 | |||
| 51 | public static FillRect locate(SurfaceType srctype, | ||
| 52 | CompositeType comptype, | ||
| 53 | SurfaceType dsttype) | ||
| 54 | { | ||
| 55 | return (FillRect) | ||
| 56 | GraphicsPrimitiveMgr.locate(primTypeID, | ||
| 57 | srctype, comptype, dsttype); | ||
| 58 | } | ||
| 59 | |||
| 60 | protected FillRect(SurfaceType srctype, | ||
| 61 | CompositeType comptype, | ||
| 62 | SurfaceType dsttype) | ||
| 63 | { | ||
| 64 | super(methodSignature, primTypeID, srctype, comptype, dsttype); | ||
| 65 | } | ||
| 66 | |||
| 67 | public FillRect(long pNativePrim, | ||
| 68 | SurfaceType srctype, | ||
| 69 | CompositeType comptype, | ||
| 70 | SurfaceType dsttype) | ||
| 71 | { | ||
| 72 | super(pNativePrim, methodSignature, primTypeID, srctype, comptype, dsttype); | ||
| 73 | } | ||
| 74 | |||
| 75 | /** | ||
| 76 | * All FillRect implementors must have this invoker method | ||
| 77 | */ | ||
| 78 | public native void FillRect(SunGraphics2D sg2d, SurfaceData dest, | ||
| 79 | int x, int y, int w, int h); | ||
| 80 | |||
| 81 | static { | ||
| 82 | GraphicsPrimitiveMgr.registerGeneral(new FillRect(null, null, null)); | ||
| 83 | } | ||
| 84 | |||
| 85 | public GraphicsPrimitive makePrimitive(SurfaceType srctype, | ||
| 86 | CompositeType comptype, | ||
| 87 | SurfaceType dsttype) | ||
| 88 | { | ||
| 89 | return new General(srctype, comptype, dsttype); | ||
| 90 | } | ||
| 91 | |||
| 92 | public static class General extends FillRect { | ||
| 93 | public MaskFill fillop; | ||
| 94 | |||
| 95 | public General(SurfaceType srctype, | ||
| 96 | CompositeType comptype, | ||
| 97 | SurfaceType dsttype) | ||
| 98 | { | ||
| 99 | super(srctype, comptype, dsttype); | ||
| 100 | fillop = MaskFill.locate(srctype, comptype, dsttype); | ||
| 101 | } | ||
| 102 | |||
| 103 | public void FillRect(SunGraphics2D sg2d, SurfaceData dest, | ||
| 104 | int x, int y, int w, int h) | ||
| 105 | { | ||
| 106 | fillop.MaskFill(sg2d, dest, sg2d.composite, x, y, w, h, null, 0, 0); | ||
| 107 | } | ||
| 108 | } | ||
| 109 | |||
| 110 | public GraphicsPrimitive traceWrap() { | ||
| 111 | return new TraceFillRect(this); | ||
| 112 | } | ||
| 113 | |||
| 114 | private static class TraceFillRect extends FillRect { | ||
| 115 | FillRect target; | ||
| 116 | |||
| 117 | public TraceFillRect(FillRect target) { | ||
| 118 | super(target.getSourceType(), | ||
| 119 | target.getCompositeType(), | ||
| 120 | target.getDestType()); | ||
| 121 | this.target = target; | ||
| 122 | } | ||
| 123 | |||
| 124 | public GraphicsPrimitive traceWrap() { | ||
| 125 | return this; | ||
| 126 | } | ||
| 127 | |||
| 128 | public void FillRect(SunGraphics2D sg2d, SurfaceData dest, | ||
| 129 | int x, int y, int w, int h) | ||
| 130 | { | ||
| 131 | tracePrimitive(target); | ||
| 132 | target.FillRect(sg2d, dest, x, y, w, h); | ||
| 133 | } | ||
| 134 | } | ||
| 135 | } | ||
Binary file not shown.
Binary file not shown.
| @@ -0,0 +1,122 @@ | |||
| 1 | /* | ||
| 2 | * Copyright (c) 1998, 2002, Oracle and/or its affiliates. All rights reserved. | ||
| 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 | ||
| 7 | * published by the Free Software Foundation. Oracle designates this | ||
| 8 | * particular file as subject to the "Classpath" exception as provided | ||
| 9 | * by Oracle in the LICENSE file that accompanied this code. | ||
| 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 | * | ||
| 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. | ||
| 24 | */ | ||
| 25 | |||
| 26 | /* | ||
| 27 | * @author Jim Graham | ||
| 28 | * @author Charlton Innovations, Inc. | ||
| 29 | */ | ||
| 30 | |||
| 31 | package sun.java2d.loops; | ||
| 32 | |||
| 33 | import sun.java2d.loops.GraphicsPrimitive; | ||
| 34 | import sun.java2d.pipe.SpanIterator; | ||
| 35 | import java.awt.Color; | ||
| 36 | import java.awt.image.ColorModel; | ||
| 37 | import java.awt.image.Raster; | ||
| 38 | import sun.java2d.SunGraphics2D; | ||
| 39 | import sun.java2d.SurfaceData; | ||
| 40 | |||
| 41 | /** | ||
| 42 | * FillSpans | ||
| 43 | * 1) draw solid color onto destination surface | ||
| 44 | * 2) rectangular areas to fill come from SpanIterator | ||
| 45 | */ | ||
| 46 | public class FillSpans extends GraphicsPrimitive | ||
| 47 | { | ||
| 48 | public final static String methodSignature = "FillSpans(...)".toString(); | ||
| 49 | |||
| 50 | public final static int primTypeID = makePrimTypeID(); | ||
| 51 | |||
| 52 | public static FillSpans locate(SurfaceType srctype, | ||
| 53 | CompositeType comptype, | ||
| 54 | SurfaceType dsttype) | ||
| 55 | { | ||
| 56 | return (FillSpans) | ||
| 57 | GraphicsPrimitiveMgr.locate(primTypeID, | ||
| 58 | srctype, comptype, dsttype); | ||
| 59 | } | ||
| 60 | |||
| 61 | protected FillSpans(SurfaceType srctype, | ||
| 62 | CompositeType comptype, | ||
| 63 | SurfaceType dsttype) | ||
| 64 | { | ||
| 65 | super(methodSignature, primTypeID, srctype, comptype, dsttype); | ||
| 66 | } | ||
| 67 | |||
| 68 | public FillSpans(long pNativePrim, | ||
| 69 | SurfaceType srctype, | ||
| 70 | CompositeType comptype, | ||
| 71 | SurfaceType dsttype) | ||
| 72 | { | ||
| 73 | super(pNativePrim, methodSignature, primTypeID, srctype, comptype, dsttype); | ||
| 74 | } | ||
| 75 | |||
| 76 | private native void FillSpans(SunGraphics2D sg2d, SurfaceData dest, | ||
| 77 | int pixel, long pIterator, SpanIterator si); | ||
| 78 | |||
| 79 | /** | ||
| 80 | * All FillSpan implementors must have this invoker method | ||
| 81 | */ | ||
| 82 | public void FillSpans(SunGraphics2D sg2d, SurfaceData dest, | ||
| 83 | SpanIterator si) | ||
| 84 | { | ||
| 85 | FillSpans(sg2d, dest, sg2d.pixel, si.getNativeIterator(), si); | ||
| 86 | } | ||
| 87 | |||
| 88 | public GraphicsPrimitive makePrimitive(SurfaceType srctype, | ||
| 89 | CompositeType comptype, | ||
| 90 | SurfaceType dsttype) | ||
| 91 | { | ||
| 92 | // REMIND: iterate with a FillRect primitive? | ||
| 93 | throw new InternalError("FillSpans not implemented for "+ | ||
| 94 | srctype+" with "+comptype); | ||
| 95 | } | ||
| 96 | |||
| 97 | public GraphicsPrimitive traceWrap() { | ||
| 98 | return new TraceFillSpans(this); | ||
| 99 | } | ||
| 100 | |||
| 101 | private static class TraceFillSpans extends FillSpans { | ||
| 102 | FillSpans target; | ||
| 103 | |||
| 104 | public TraceFillSpans(FillSpans target) { | ||
| 105 | super(target.getSourceType(), | ||
| 106 | target.getCompositeType(), | ||
| 107 | target.getDestType()); | ||
| 108 | this.target = target; | ||
| 109 | } | ||
| 110 | |||
| 111 | public GraphicsPrimitive traceWrap() { | ||
| 112 | return this; | ||
| 113 | } | ||
| 114 | |||
| 115 | public void FillSpans(SunGraphics2D sg2d, SurfaceData dest, | ||
| 116 | SpanIterator si) | ||
| 117 | { | ||
| 118 | tracePrimitive(target); | ||
| 119 | target.FillSpans(sg2d, dest, si); | ||
| 120 | } | ||
| 121 | } | ||
| 122 | } | ||
Binary file not shown.
| @@ -0,0 +1,89 @@ | |||
| 1 | /* | ||
| 2 | * Copyright (c) 1999, 2005, Oracle and/or its affiliates. All rights reserved. | ||
| 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 | ||
| 7 | * published by the Free Software Foundation. Oracle designates this | ||
| 8 | * particular file as subject to the "Classpath" exception as provided | ||
| 9 | * by Oracle in the LICENSE file that accompanied this code. | ||
| 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 | * | ||
| 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. | ||
| 24 | */ | ||
| 25 | |||
| 26 | package sun.java2d.loops; | ||
| 27 | |||
| 28 | import java.awt.Font; | ||
| 29 | import java.awt.geom.AffineTransform; | ||
| 30 | |||
| 31 | import sun.font.Font2D; | ||
| 32 | import sun.font.FontStrike; | ||
| 33 | import sun.font.FontStrikeDesc; | ||
| 34 | |||
| 35 | /* | ||
| 36 | * A FontInfo object holds all calculated or derived data needed | ||
| 37 | * to handle rendering operations based on a particular set of | ||
| 38 | * Graphics2D rendering attributes. | ||
| 39 | * Note that this does not use a Font2DHandle, and also has a reference | ||
| 40 | * to the strike which also references the Font2D. | ||
| 41 | * So presently, until SG2D objects no longer reference this FontInfo, | ||
| 42 | * there is still some potential for a bad Font2D to be used for a short | ||
| 43 | * time. I am reluctant to add the overhead of that machinery here without | ||
| 44 | * a proven benefit. | ||
| 45 | */ | ||
| 46 | public class FontInfo implements Cloneable { | ||
| 47 | public Font font; | ||
| 48 | public Font2D font2D; | ||
| 49 | public FontStrike fontStrike; | ||
| 50 | public double[] devTx; | ||
| 51 | public double[] glyphTx; | ||
| 52 | public int pixelHeight; | ||
| 53 | public float originX; | ||
| 54 | public float originY; | ||
| 55 | public int aaHint; | ||
| 56 | public boolean lcdRGBOrder; | ||
| 57 | /* lcdSubPixPos is used if FM is ON for HRGB/HBGR LCD text mode */ | ||
| 58 | public boolean lcdSubPixPos; | ||
| 59 | |||
| 60 | public String mtx(double[] matrix) { | ||
| 61 | return ("["+ | ||
| 62 | matrix[0]+", "+ | ||
| 63 | matrix[1]+", "+ | ||
| 64 | matrix[2]+", "+ | ||
| 65 | matrix[3]+ | ||
| 66 | "]"); | ||
| 67 | } | ||
| 68 | |||
| 69 | public Object clone() { | ||
| 70 | try { | ||
| 71 | return super.clone(); | ||
| 72 | } catch (CloneNotSupportedException e) { | ||
| 73 | return null; | ||
| 74 | } | ||
| 75 | } | ||
| 76 | |||
| 77 | public String toString() { | ||
| 78 | return ("FontInfo["+ | ||
| 79 | "font="+font+", "+ | ||
| 80 | "devTx="+mtx(devTx)+", "+ | ||
| 81 | "glyphTx="+mtx(glyphTx)+", "+ | ||
| 82 | "pixelHeight="+pixelHeight+", "+ | ||
| 83 | "origin=("+originX+","+originY+"), "+ | ||
| 84 | "aaHint="+aaHint+", "+ | ||
| 85 | "lcdRGBOrder="+(lcdRGBOrder ? "RGB" : "BGR")+ | ||
| 86 | "lcdSubPixPos="+lcdSubPixPos+ | ||
| 87 | "]"); | ||
| 88 | } | ||
| 89 | } | ||
Binary file not shown.
| @@ -0,0 +1,1125 @@ | |||
| 1 | /* | ||
| 2 | * Copyright (c) 1998, 2008, Oracle and/or its affiliates. All rights reserved. | ||
| 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 | ||
| 7 | * published by the Free Software Foundation. Oracle designates this | ||
| 8 | * particular file as subject to the "Classpath" exception as provided | ||
| 9 | * by Oracle in the LICENSE file that accompanied this code. | ||
| 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 | * | ||
| 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. | ||
| 24 | */ | ||
| 25 | |||
| 26 | /* | ||
| 27 | * @author Charlton Innovations, Inc. | ||
| 28 | */ | ||
| 29 | |||
| 30 | package sun.java2d.loops; | ||
| 31 | |||
| 32 | import java.awt.image.WritableRaster; | ||
| 33 | import java.awt.image.DataBuffer; | ||
| 34 | import java.awt.image.ColorModel; | ||
| 35 | import java.awt.geom.Path2D; | ||
| 36 | import java.awt.geom.PathIterator; | ||
| 37 | import java.awt.geom.AffineTransform; | ||
| 38 | import sun.java2d.pipe.Region; | ||
| 39 | import sun.java2d.pipe.SpanIterator; | ||
| 40 | import sun.java2d.SunGraphics2D; | ||
| 41 | import sun.java2d.SurfaceData; | ||
| 42 | import sun.java2d.loops.ProcessPath; | ||
| 43 | import sun.font.GlyphList; | ||
| 44 | |||
| 45 | /** | ||
| 46 | * GeneralRenderer collection | ||
| 47 | * Basically, a collection of components which permit basic | ||
| 48 | * rendering to occur on rasters of any format | ||
| 49 | */ | ||
| 50 | |||
| 51 | public final class GeneralRenderer { | ||
| 52 | public static void register() { | ||
| 53 | Class owner = GeneralRenderer.class; | ||
| 54 | GraphicsPrimitive[] primitives = { | ||
| 55 | new GraphicsPrimitiveProxy(owner, "SetFillRectANY", | ||
| 56 | FillRect.methodSignature, | ||
| 57 | FillRect.primTypeID, | ||
| 58 | SurfaceType.AnyColor, | ||
| 59 | CompositeType.SrcNoEa, | ||
| 60 | SurfaceType.Any), | ||
| 61 | new GraphicsPrimitiveProxy(owner, "SetFillPathANY", | ||
| 62 | FillPath.methodSignature, | ||
| 63 | FillPath.primTypeID, | ||
| 64 | SurfaceType.AnyColor, | ||
| 65 | CompositeType.SrcNoEa, | ||
| 66 | SurfaceType.Any), | ||
| 67 | new GraphicsPrimitiveProxy(owner, "SetFillSpansANY", | ||
| 68 | FillSpans.methodSignature, | ||
| 69 | FillSpans.primTypeID, | ||
| 70 | SurfaceType.AnyColor, | ||
| 71 | CompositeType.SrcNoEa, | ||
| 72 | SurfaceType.Any), | ||
| 73 | new GraphicsPrimitiveProxy(owner, "SetDrawLineANY", | ||
| 74 | DrawLine.methodSignature, | ||
| 75 | DrawLine.primTypeID, | ||
| 76 | SurfaceType.AnyColor, | ||
| 77 | CompositeType.SrcNoEa, | ||
| 78 | SurfaceType.Any), | ||
| 79 | new GraphicsPrimitiveProxy(owner, "SetDrawPolygonsANY", | ||
| 80 | DrawPolygons.methodSignature, | ||
| 81 | DrawPolygons.primTypeID, | ||
| 82 | SurfaceType.AnyColor, | ||
| 83 | CompositeType.SrcNoEa, | ||
| 84 | SurfaceType.Any), | ||
| 85 | new GraphicsPrimitiveProxy(owner, "SetDrawPathANY", | ||
| 86 | DrawPath.methodSignature, | ||
| 87 | DrawPath.primTypeID, | ||
| 88 | SurfaceType.AnyColor, | ||
| 89 | CompositeType.SrcNoEa, | ||
| 90 | SurfaceType.Any), | ||
| 91 | new GraphicsPrimitiveProxy(owner, "SetDrawRectANY", | ||
| 92 | DrawRect.methodSignature, | ||
| 93 | DrawRect.primTypeID, | ||
| 94 | SurfaceType.AnyColor, | ||
| 95 | CompositeType.SrcNoEa, | ||
| 96 | SurfaceType.Any), | ||
| 97 | |||
| 98 | new GraphicsPrimitiveProxy(owner, "XorFillRectANY", | ||
| 99 | FillRect.methodSignature, | ||
| 100 | FillRect.primTypeID, | ||
| 101 | SurfaceType.AnyColor, | ||
| 102 | CompositeType.Xor, | ||
| 103 | SurfaceType.Any), | ||
| 104 | new GraphicsPrimitiveProxy(owner, "XorFillPathANY", | ||
| 105 | FillPath.methodSignature, | ||
| 106 | FillPath.primTypeID, | ||
| 107 | SurfaceType.AnyColor, | ||
| 108 | CompositeType.Xor, | ||
| 109 | SurfaceType.Any), | ||
| 110 | new GraphicsPrimitiveProxy(owner, "XorFillSpansANY", | ||
| 111 | FillSpans.methodSignature, | ||
| 112 | FillSpans.primTypeID, | ||
| 113 | SurfaceType.AnyColor, | ||
| 114 | CompositeType.Xor, | ||
| 115 | SurfaceType.Any), | ||
| 116 | new GraphicsPrimitiveProxy(owner, "XorDrawLineANY", | ||
| 117 | DrawLine.methodSignature, | ||
| 118 | DrawLine.primTypeID, | ||
| 119 | SurfaceType.AnyColor, | ||
| 120 | CompositeType.Xor, | ||
| 121 | SurfaceType.Any), | ||
| 122 | new GraphicsPrimitiveProxy(owner, "XorDrawPolygonsANY", | ||
| 123 | DrawPolygons.methodSignature, | ||
| 124 | DrawPolygons.primTypeID, | ||
| 125 | SurfaceType.AnyColor, | ||
| 126 | CompositeType.Xor, | ||
| 127 | SurfaceType.Any), | ||
| 128 | new GraphicsPrimitiveProxy(owner, "XorDrawPathANY", | ||
| 129 | DrawPath.methodSignature, | ||
| 130 | DrawPath.primTypeID, | ||
| 131 | SurfaceType.AnyColor, | ||
| 132 | CompositeType.Xor, | ||
| 133 | SurfaceType.Any), | ||
| 134 | new GraphicsPrimitiveProxy(owner, "XorDrawRectANY", | ||
| 135 | DrawRect.methodSignature, | ||
| 136 | DrawRect.primTypeID, | ||
| 137 | SurfaceType.AnyColor, | ||
| 138 | CompositeType.Xor, | ||
| 139 | SurfaceType.Any), | ||
| 140 | new GraphicsPrimitiveProxy(owner, "XorDrawGlyphListANY", | ||
| 141 | DrawGlyphList.methodSignature, | ||
| 142 | DrawGlyphList.primTypeID, | ||
| 143 | SurfaceType.AnyColor, | ||
| 144 | CompositeType.Xor, | ||
| 145 | SurfaceType.Any), | ||
| 146 | new GraphicsPrimitiveProxy(owner, "XorDrawGlyphListAAANY", | ||
| 147 | DrawGlyphListAA.methodSignature, | ||
| 148 | DrawGlyphListAA.primTypeID, | ||
| 149 | SurfaceType.AnyColor, | ||
| 150 | CompositeType.Xor, | ||
| 151 | SurfaceType.Any), | ||
| 152 | }; | ||
| 153 | GraphicsPrimitiveMgr.register(primitives); | ||
| 154 | } | ||
| 155 | |||
| 156 | static void doDrawPoly(SurfaceData sData, PixelWriter pw, | ||
| 157 | int xPoints[], int yPoints[], int off, int nPoints, | ||
| 158 | Region clip, int transx, int transy, boolean close) | ||
| 159 | { | ||
| 160 | int mx, my, x1, y1; | ||
| 161 | int[] tmp = null; | ||
| 162 | |||
| 163 | if (nPoints <= 0) { | ||
| 164 | return; | ||
| 165 | } | ||
| 166 | mx = x1 = xPoints[off] + transx; | ||
| 167 | my = y1 = yPoints[off] + transy; | ||
| 168 | while (--nPoints > 0) { | ||
| 169 | ++off; | ||
| 170 | int x2 = xPoints[off] + transx; | ||
| 171 | int y2 = yPoints[off] + transy; | ||
| 172 | tmp = GeneralRenderer.doDrawLine(sData, pw, tmp, clip, | ||
| 173 | x1, y1, x2, y2); | ||
| 174 | x1 = x2; | ||
| 175 | y1 = y2; | ||
| 176 | } | ||
| 177 | if (close && (x1 != mx || y1 != my)) { | ||
| 178 | tmp = GeneralRenderer.doDrawLine(sData, pw, tmp, clip, | ||
| 179 | x1, y1, mx, my); | ||
| 180 | } | ||
| 181 | } | ||
| 182 | |||
| 183 | static void doSetRect(SurfaceData sData, PixelWriter pw, | ||
| 184 | int x1, int y1, int x2, int y2) { | ||
| 185 | WritableRaster dstRast = | ||
| 186 | (WritableRaster) sData.getRaster(x1, y1, x2-x1, y2-y1); | ||
| 187 | pw.setRaster(dstRast); | ||
| 188 | |||
| 189 | while (y1 < y2) { | ||
| 190 | for (int x = x1; x < x2; x++) { | ||
| 191 | pw.writePixel(x, y1); | ||
| 192 | } | ||
| 193 | y1++; | ||
| 194 | } | ||
| 195 | } | ||
| 196 | |||
| 197 | static int[] doDrawLine(SurfaceData sData, PixelWriter pw, int[] boundPts, | ||
| 198 | Region clip, | ||
| 199 | int origx1, int origy1, int origx2, int origy2) | ||
| 200 | { | ||
| 201 | if (boundPts == null) { | ||
| 202 | boundPts = new int[8]; | ||
| 203 | } | ||
| 204 | boundPts[0] = origx1; | ||
| 205 | boundPts[1] = origy1; | ||
| 206 | boundPts[2] = origx2; | ||
| 207 | boundPts[3] = origy2; | ||
| 208 | if (!adjustLine(boundPts, | ||
| 209 | clip.getLoX(), clip.getLoY(), | ||
| 210 | clip.getHiX(), clip.getHiY())) | ||
| 211 | { | ||
| 212 | return boundPts; | ||
| 213 | } | ||
| 214 | int x1 = boundPts[0]; | ||
| 215 | int y1 = boundPts[1]; | ||
| 216 | int x2 = boundPts[2]; | ||
| 217 | int y2 = boundPts[3]; | ||
| 218 | |||
| 219 | WritableRaster dstRast = (WritableRaster) | ||
| 220 | sData.getRaster(Math.min(x1, x2), Math.min(y1, y2), | ||
| 221 | Math.abs(x1 - x2) + 1, Math.abs(y1 - y2) + 1); | ||
| 222 | pw.setRaster(dstRast); | ||
| 223 | |||
| 224 | /* this could be made smaller, more elegant, more traditional. */ | ||
| 225 | if (x1 == x2) { | ||
| 226 | if (y1 > y2) { | ||
| 227 | do { | ||
| 228 | pw.writePixel(x1, y1); | ||
| 229 | y1--; | ||
| 230 | } while (y1 >= y2); | ||
| 231 | } else { | ||
| 232 | do { | ||
| 233 | pw.writePixel(x1, y1); | ||
| 234 | y1++; | ||
| 235 | } while (y1 <= y2); | ||
| 236 | } | ||
| 237 | } else if (y1 == y2) { | ||
| 238 | if (x1 > x2) { | ||
| 239 | do { | ||
| 240 | pw.writePixel(x1, y1); | ||
| 241 | x1--; | ||
| 242 | } while (x1 >= x2); | ||
| 243 | } else { | ||
| 244 | do { | ||
| 245 | pw.writePixel(x1, y1); | ||
| 246 | x1++; | ||
| 247 | } while (x1 <= x2); | ||
| 248 | } | ||
| 249 | } else { | ||
| 250 | int dx = boundPts[4]; | ||
| 251 | int dy = boundPts[5]; | ||
| 252 | int ax = boundPts[6]; | ||
| 253 | int ay = boundPts[7]; | ||
| 254 | int steps; | ||
| 255 | int bumpmajor; | ||
| 256 | int bumpminor; | ||
| 257 | int errminor; | ||
| 258 | int errmajor; | ||
| 259 | int error; | ||
| 260 | boolean xmajor; | ||
| 261 | |||
| 262 | if (ax >= ay) { | ||
| 263 | /* x is dominant */ | ||
| 264 | xmajor = true; | ||
| 265 | errmajor = ay * 2; | ||
| 266 | errminor = ax * 2; | ||
| 267 | bumpmajor = (dx < 0) ? -1 : 1; | ||
| 268 | bumpminor = (dy < 0) ? -1 : 1; | ||
| 269 | ax = -ax; /* For clipping adjustment below */ | ||
| 270 | steps = x2 - x1; | ||
| 271 | } else { | ||
| 272 | /* y is dominant */ | ||
| 273 | xmajor = false; | ||
| 274 | errmajor = ax * 2; | ||
| 275 | errminor = ay * 2; | ||
| 276 | bumpmajor = (dy < 0) ? -1 : 1; | ||
| 277 | bumpminor = (dx < 0) ? -1 : 1; | ||
| 278 | ay = -ay; /* For clipping adjustment below */ | ||
| 279 | steps = y2 - y1; | ||
| 280 | } | ||
| 281 | error = - (errminor / 2); | ||
| 282 | if (y1 != origy1) { | ||
| 283 | int ysteps = y1 - origy1; | ||
| 284 | if (ysteps < 0) { | ||
| 285 | ysteps = -ysteps; | ||
| 286 | } | ||
| 287 | error += ysteps * ax * 2; | ||
| 288 | } | ||
| 289 | if (x1 != origx1) { | ||
| 290 | int xsteps = x1 - origx1; | ||
| 291 | if (xsteps < 0) { | ||
| 292 | xsteps = -xsteps; | ||
| 293 | } | ||
| 294 | error += xsteps * ay * 2; | ||
| 295 | } | ||
| 296 | if (steps < 0) { | ||
| 297 | steps = -steps; | ||
| 298 | } | ||
| 299 | if (xmajor) { | ||
| 300 | do { | ||
| 301 | pw.writePixel(x1, y1); | ||
| 302 | x1 += bumpmajor; | ||
| 303 | error += errmajor; | ||
| 304 | if (error >= 0) { | ||
| 305 | y1 += bumpminor; | ||
| 306 | error -= errminor; | ||
| 307 | } | ||
| 308 | } while (--steps >= 0); | ||
| 309 | } else { | ||
| 310 | do { | ||
| 311 | pw.writePixel(x1, y1); | ||
| 312 | y1 += bumpmajor; | ||
| 313 | error += errmajor; | ||
| 314 | if (error >= 0) { | ||
| 315 | x1 += bumpminor; | ||
| 316 | error -= errminor; | ||
| 317 | } | ||
| 318 | } while (--steps >= 0); | ||
| 319 | } | ||
| 320 | } | ||
| 321 | return boundPts; | ||
| 322 | } | ||
| 323 | |||
| 324 | public static void doDrawRect(PixelWriter pw, | ||
| 325 | SunGraphics2D sg2d, SurfaceData sData, | ||
| 326 | int x, int y, int w, int h) | ||
| 327 | { | ||
| 328 | if (w < 0 || h < 0) { | ||
| 329 | return; | ||
| 330 | } | ||
| 331 | int x2 = Region.dimAdd(Region.dimAdd(x, w), 1); | ||
| 332 | int y2 = Region.dimAdd(Region.dimAdd(y, h), 1); | ||
| 333 | Region r = sg2d.getCompClip().getBoundsIntersectionXYXY(x, y, x2, y2); | ||
| 334 | if (r.isEmpty()) { | ||
| 335 | return; | ||
| 336 | } | ||
| 337 | int cx1 = r.getLoX(); | ||
| 338 | int cy1 = r.getLoY(); | ||
| 339 | int cx2 = r.getHiX(); | ||
| 340 | int cy2 = r.getHiY(); | ||
| 341 | |||
| 342 | if (w < 2 || h < 2) { | ||
| 343 | doSetRect(sData, pw, cx1, cy1, cx2, cy2); | ||
| 344 | return; | ||
| 345 | } | ||
| 346 | |||
| 347 | |||
| 348 | if (cy1 == y) { | ||
| 349 | doSetRect(sData, pw, cx1, cy1, cx2, cy1+1); | ||
| 350 | } | ||
| 351 | if (cx1 == x) { | ||
| 352 | doSetRect(sData, pw, cx1, cy1+1, cx1+1, cy2-1); | ||
| 353 | } | ||
| 354 | if (cx2 == x2) { | ||
| 355 | doSetRect(sData, pw, cx2-1, cy1+1, cx2, cy2-1); | ||
| 356 | } | ||
| 357 | if (cy2 == y2) { | ||
| 358 | doSetRect(sData, pw, cx1, cy2-1, cx2, cy2); | ||
| 359 | } | ||
| 360 | } | ||
| 361 | |||
| 362 | /* | ||
| 363 | * REMIND: For now this will field both AA and non-AA requests and | ||
| 364 | * use a simple threshold to choose pixels if the supplied grey | ||
| 365 | * bits are antialiased. We should really find a way to disable | ||
| 366 | * AA text at a higher level or to have the GlyphList be able to | ||
| 367 | * reset the glyphs to non-AA after construction. | ||
| 368 | */ | ||
| 369 | static void doDrawGlyphList(SurfaceData sData, PixelWriter pw, | ||
| 370 | GlyphList gl, Region clip) | ||
| 371 | { | ||
| 372 | int[] bounds = gl.getBounds(); | ||
| 373 | clip.clipBoxToBounds(bounds); | ||
| 374 | int cx1 = bounds[0]; | ||
| 375 | int cy1 = bounds[1]; | ||
| 376 | int cx2 = bounds[2]; | ||
| 377 | int cy2 = bounds[3]; | ||
| 378 | |||
| 379 | WritableRaster dstRast = | ||
| 380 | (WritableRaster) sData.getRaster(cx1, cy1, cx2 - cx1, cy2 - cy1); | ||
| 381 | pw.setRaster(dstRast); | ||
| 382 | |||
| 383 | int num = gl.getNumGlyphs(); | ||
| 384 | for (int i = 0; i < num; i++) { | ||
| 385 | gl.setGlyphIndex(i); | ||
| 386 | int metrics[] = gl.getMetrics(); | ||
| 387 | int gx1 = metrics[0]; | ||
| 388 | int gy1 = metrics[1]; | ||
| 389 | int w = metrics[2]; | ||
| 390 | int gx2 = gx1 + w; | ||
| 391 | int gy2 = gy1 + metrics[3]; | ||
| 392 | int off = 0; | ||
| 393 | if (gx1 < cx1) { | ||
| 394 | off = cx1 - gx1; | ||
| 395 | gx1 = cx1; | ||
| 396 | } | ||
| 397 | if (gy1 < cy1) { | ||
| 398 | off += (cy1 - gy1) * w; | ||
| 399 | gy1 = cy1; | ||
| 400 | } | ||
| 401 | if (gx2 > cx2) gx2 = cx2; | ||
| 402 | if (gy2 > cy2) gy2 = cy2; | ||
| 403 | if (gx2 > gx1 && gy2 > gy1) { | ||
| 404 | byte alpha[] = gl.getGrayBits(); | ||
| 405 | w -= (gx2 - gx1); | ||
| 406 | for (int y = gy1; y < gy2; y++) { | ||
| 407 | for (int x = gx1; x < gx2; x++) { | ||
| 408 | if (alpha[off++] < 0) { | ||
| 409 | pw.writePixel(x, y); | ||
| 410 | } | ||
| 411 | } | ||
| 412 | off += w; | ||
| 413 | } | ||
| 414 | } | ||
| 415 | } | ||
| 416 | } | ||
| 417 | |||
| 418 | static final int OUTCODE_TOP = 1; | ||
| 419 | static final int OUTCODE_BOTTOM = 2; | ||
| 420 | static final int OUTCODE_LEFT = 4; | ||
| 421 | static final int OUTCODE_RIGHT = 8; | ||
| 422 | |||
| 423 | static int outcode(int x, int y, int xmin, int ymin, int xmax, int ymax) { | ||
| 424 | int code; | ||
| 425 | if (y < ymin) { | ||
| 426 | code = OUTCODE_TOP; | ||
| 427 | } else if (y > ymax) { | ||
| 428 | code = OUTCODE_BOTTOM; | ||
| 429 | } else { | ||
| 430 | code = 0; | ||
| 431 | } | ||
| 432 | if (x < xmin) { | ||
| 433 | code |= OUTCODE_LEFT; | ||
| 434 | } else if (x > xmax) { | ||
| 435 | code |= OUTCODE_RIGHT; | ||
| 436 | } | ||
| 437 | return code; | ||
| 438 | } | ||
| 439 | |||
| 440 | public static boolean adjustLine(int [] boundPts, | ||
| 441 | int cxmin, int cymin, int cx2, int cy2) | ||
| 442 | { | ||
| 443 | int cxmax = cx2 - 1; | ||
| 444 | int cymax = cy2 - 1; | ||
| 445 | int x1 = boundPts[0]; | ||
| 446 | int y1 = boundPts[1]; | ||
| 447 | int x2 = boundPts[2]; | ||
| 448 | int y2 = boundPts[3]; | ||
| 449 | |||
| 450 | if ((cxmax < cxmin) || (cymax < cymin)) { | ||
| 451 | return false; | ||
| 452 | } | ||
| 453 | |||
| 454 | if (x1 == x2) { | ||
| 455 | if (x1 < cxmin || x1 > cxmax) { | ||
| 456 | return false; | ||
| 457 | } | ||
| 458 | if (y1 > y2) { | ||
| 459 | int t = y1; | ||
| 460 | y1 = y2; | ||
| 461 | y2 = t; | ||
| 462 | } | ||
| 463 | if (y1 < cymin) { | ||
| 464 | y1 = cymin; | ||
| 465 | } | ||
| 466 | if (y2 > cymax) { | ||
| 467 | y2 = cymax; | ||
| 468 | } | ||
| 469 | if (y1 > y2) { | ||
| 470 | return false; | ||
| 471 | } | ||
| 472 | boundPts[1] = y1; | ||
| 473 | boundPts[3] = y2; | ||
| 474 | } else if (y1 == y2) { | ||
| 475 | if (y1 < cymin || y1 > cymax) { | ||
| 476 | return false; | ||
| 477 | } | ||
| 478 | if (x1 > x2) { | ||
| 479 | int t = x1; | ||
| 480 | x1 = x2; | ||
| 481 | x2 = t; | ||
| 482 | } | ||
| 483 | if (x1 < cxmin) { | ||
| 484 | x1 = cxmin; | ||
| 485 | } | ||
| 486 | if (x2 > cxmax) { | ||
| 487 | x2 = cxmax; | ||
| 488 | } | ||
| 489 | if (x1 > x2) { | ||
| 490 | return false; | ||
| 491 | } | ||
| 492 | boundPts[0] = x1; | ||
| 493 | boundPts[2] = x2; | ||
| 494 | } else { | ||
| 495 | /* REMIND: This could overflow... */ | ||
| 496 | int outcode1, outcode2; | ||
| 497 | int dx = x2 - x1; | ||
| 498 | int dy = y2 - y1; | ||
| 499 | int ax = (dx < 0) ? -dx : dx; | ||
| 500 | int ay = (dy < 0) ? -dy : dy; | ||
| 501 | boolean xmajor = (ax >= ay); | ||
| 502 | |||
| 503 | outcode1 = outcode(x1, y1, cxmin, cymin, cxmax, cymax); | ||
| 504 | outcode2 = outcode(x2, y2, cxmin, cymin, cxmax, cymax); | ||
| 505 | while ((outcode1 | outcode2) != 0) { | ||
| 506 | int xsteps, ysteps; | ||
| 507 | if ((outcode1 & outcode2) != 0) { | ||
| 508 | return false; | ||
| 509 | } | ||
| 510 | if (outcode1 != 0) { | ||
| 511 | if (0 != (outcode1 & (OUTCODE_TOP | OUTCODE_BOTTOM))) { | ||
| 512 | if (0 != (outcode1 & OUTCODE_TOP)) { | ||
| 513 | y1 = cymin; | ||
| 514 | } else { | ||
| 515 | y1 = cymax; | ||
| 516 | } | ||
| 517 | ysteps = y1 - boundPts[1]; | ||
| 518 | if (ysteps < 0) { | ||
| 519 | ysteps = -ysteps; | ||
| 520 | } | ||
| 521 | xsteps = 2 * ysteps * ax + ay; | ||
| 522 | if (xmajor) { | ||
| 523 | xsteps += ay - ax - 1; | ||
| 524 | } | ||
| 525 | xsteps = xsteps / (2 * ay); | ||
| 526 | if (dx < 0) { | ||
| 527 | xsteps = -xsteps; | ||
| 528 | } | ||
| 529 | x1 = boundPts[0] + xsteps; | ||
| 530 | } else if (0 != | ||
| 531 | (outcode1 & (OUTCODE_LEFT | OUTCODE_RIGHT))) { | ||
| 532 | if (0 != (outcode1 & OUTCODE_LEFT)) { | ||
| 533 | x1 = cxmin; | ||
| 534 | } else { | ||
| 535 | x1 = cxmax; | ||
| 536 | } | ||
| 537 | xsteps = x1 - boundPts[0]; | ||
| 538 | if (xsteps < 0) { | ||
| 539 | xsteps = -xsteps; | ||
| 540 | } | ||
| 541 | ysteps = 2 * xsteps * ay + ax; | ||
| 542 | if (!xmajor) { | ||
| 543 | ysteps += ax - ay - 1; | ||
| 544 | } | ||
| 545 | ysteps = ysteps / (2 * ax); | ||
| 546 | if (dy < 0) { | ||
| 547 | ysteps = -ysteps; | ||
| 548 | } | ||
| 549 | y1 = boundPts[1] + ysteps; | ||
| 550 | } | ||
| 551 | outcode1 = outcode(x1, y1, cxmin, cymin, cxmax, cymax); | ||
| 552 | } else { | ||
| 553 | if (0 != (outcode2 & (OUTCODE_TOP | OUTCODE_BOTTOM))) { | ||
| 554 | if (0 != (outcode2 & OUTCODE_TOP)) { | ||
| 555 | y2 = cymin; | ||
| 556 | } else { | ||
| 557 | y2 = cymax; | ||
| 558 | } | ||
| 559 | ysteps = y2 - boundPts[3]; | ||
| 560 | if (ysteps < 0) { | ||
| 561 | ysteps = -ysteps; | ||
| 562 | } | ||
| 563 | xsteps = 2 * ysteps * ax + ay; | ||
| 564 | if (xmajor) { | ||
| 565 | xsteps += ay - ax; | ||
| 566 | } else { | ||
| 567 | xsteps -= 1; | ||
| 568 | } | ||
| 569 | xsteps = xsteps / (2 * ay); | ||
| 570 | if (dx > 0) { | ||
| 571 | xsteps = -xsteps; | ||
| 572 | } | ||
| 573 | x2 = boundPts[2] + xsteps; | ||
| 574 | } else if (0 != | ||
| 575 | (outcode2 & (OUTCODE_LEFT | OUTCODE_RIGHT))) { | ||
| 576 | if (0 != (outcode2 & OUTCODE_LEFT)) { | ||
| 577 | x2 = cxmin; | ||
| 578 | } else { | ||
| 579 | x2 = cxmax; | ||
| 580 | } | ||
| 581 | xsteps = x2 - boundPts[2]; | ||
| 582 | if (xsteps < 0) { | ||
| 583 | xsteps = -xsteps; | ||
| 584 | } | ||
| 585 | ysteps = 2 * xsteps * ay + ax; | ||
| 586 | if (xmajor) { | ||
| 587 | ysteps -= 1; | ||
| 588 | } else { | ||
| 589 | ysteps += ax - ay; | ||
| 590 | } | ||
| 591 | ysteps = ysteps / (2 * ax); | ||
| 592 | if (dy > 0) { | ||
| 593 | ysteps = -ysteps; | ||
| 594 | } | ||
| 595 | y2 = boundPts[3] + ysteps; | ||
| 596 | } | ||
| 597 | outcode2 = outcode(x2, y2, cxmin, cymin, cxmax, cymax); | ||
| 598 | } | ||
| 599 | } | ||
| 600 | boundPts[0] = x1; | ||
| 601 | boundPts[1] = y1; | ||
| 602 | boundPts[2] = x2; | ||
| 603 | boundPts[3] = y2; | ||
| 604 | boundPts[4] = dx; | ||
| 605 | boundPts[5] = dy; | ||
| 606 | boundPts[6] = ax; | ||
| 607 | boundPts[7] = ay; | ||
| 608 | } | ||
| 609 | return true; | ||
| 610 | } | ||
| 611 | |||
| 612 | static PixelWriter createSolidPixelWriter(SunGraphics2D sg2d, | ||
| 613 | SurfaceData sData) | ||
| 614 | { | ||
| 615 | ColorModel dstCM = sData.getColorModel(); | ||
| 616 | Object srcPixel = dstCM.getDataElements(sg2d.eargb, null); | ||
| 617 | |||
| 618 | return new SolidPixelWriter(srcPixel); | ||
| 619 | } | ||
| 620 | |||
| 621 | static PixelWriter createXorPixelWriter(SunGraphics2D sg2d, | ||
| 622 | SurfaceData sData) | ||
| 623 | { | ||
| 624 | ColorModel dstCM = sData.getColorModel(); | ||
| 625 | |||
| 626 | Object srcPixel = dstCM.getDataElements(sg2d.eargb, null); | ||
| 627 | |||
| 628 | XORComposite comp = (XORComposite)sg2d.getComposite(); | ||
| 629 | int xorrgb = comp.getXorColor().getRGB(); | ||
| 630 | Object xorPixel = dstCM.getDataElements(xorrgb, null); | ||
| 631 | |||
| 632 | switch (dstCM.getTransferType()) { | ||
| 633 | case DataBuffer.TYPE_BYTE: | ||
| 634 | return new XorPixelWriter.ByteData(srcPixel, xorPixel); | ||
| 635 | case DataBuffer.TYPE_SHORT: | ||
| 636 | case DataBuffer.TYPE_USHORT: | ||
| 637 | return new XorPixelWriter.ShortData(srcPixel, xorPixel); | ||
| 638 | case DataBuffer.TYPE_INT: | ||
| 639 | return new XorPixelWriter.IntData(srcPixel, xorPixel); | ||
| 640 | case DataBuffer.TYPE_FLOAT: | ||
| 641 | return new XorPixelWriter.FloatData(srcPixel, xorPixel); | ||
| 642 | case DataBuffer.TYPE_DOUBLE: | ||
| 643 | return new XorPixelWriter.DoubleData(srcPixel, xorPixel); | ||
| 644 | default: | ||
| 645 | throw new InternalError("Unsupported XOR pixel type"); | ||
| 646 | } | ||
| 647 | } | ||
| 648 | } | ||
| 649 | |||
| 650 | class SetFillRectANY extends FillRect { | ||
| 651 | SetFillRectANY() { | ||
| 652 | super(SurfaceType.AnyColor, | ||
| 653 | CompositeType.SrcNoEa, | ||
| 654 | SurfaceType.Any); | ||
| 655 | } | ||
| 656 | |||
| 657 | public void FillRect(SunGraphics2D sg2d, SurfaceData sData, | ||
| 658 | int x, int y, int w, int h) | ||
| 659 | { | ||
| 660 | PixelWriter pw = GeneralRenderer.createSolidPixelWriter(sg2d, sData); | ||
| 661 | |||
| 662 | Region r = sg2d.getCompClip().getBoundsIntersectionXYWH(x, y, w, h); | ||
| 663 | |||
| 664 | GeneralRenderer.doSetRect(sData, pw, | ||
| 665 | r.getLoX(), r.getLoY(), | ||
| 666 | r.getHiX(), r.getHiY()); | ||
| 667 | } | ||
| 668 | } | ||
| 669 | |||
| 670 | class PixelWriterDrawHandler extends ProcessPath.DrawHandler { | ||
| 671 | PixelWriter pw; | ||
| 672 | SurfaceData sData; | ||
| 673 | Region clip; | ||
| 674 | |||
| 675 | public PixelWriterDrawHandler(SurfaceData sData, PixelWriter pw, | ||
| 676 | Region clip, int strokeHint) { | ||
| 677 | super(clip.getLoX(), clip.getLoY(), | ||
| 678 | clip.getHiX(), clip.getHiY(), | ||
| 679 | strokeHint); | ||
| 680 | this.sData = sData; | ||
| 681 | this.pw = pw; | ||
| 682 | this.clip = clip; | ||
| 683 | } | ||
| 684 | |||
| 685 | public void drawLine(int x0, int y0, int x1, int y1) { | ||
| 686 | GeneralRenderer.doDrawLine(sData, pw, null, clip, | ||
| 687 | x0, y0, x1, y1); | ||
| 688 | } | ||
| 689 | |||
| 690 | public void drawPixel(int x0, int y0) { | ||
| 691 | GeneralRenderer.doSetRect(sData, pw, x0, y0, x0 + 1, y0 + 1); | ||
| 692 | } | ||
| 693 | |||
| 694 | public void drawScanline(int x0, int x1, int y0) { | ||
| 695 | GeneralRenderer.doSetRect(sData, pw, x0, y0, x1 + 1, y0 + 1); | ||
| 696 | } | ||
| 697 | } | ||
| 698 | |||
| 699 | class SetFillPathANY extends FillPath { | ||
| 700 | SetFillPathANY() { | ||
| 701 | super(SurfaceType.AnyColor, CompositeType.SrcNoEa, | ||
| 702 | SurfaceType.Any); | ||
| 703 | } | ||
| 704 | |||
| 705 | public void FillPath(SunGraphics2D sg2d, SurfaceData sData, | ||
| 706 | int transx, int transy, | ||
| 707 | Path2D.Float p2df) | ||
| 708 | { | ||
| 709 | PixelWriter pw = GeneralRenderer.createSolidPixelWriter(sg2d, sData); | ||
| 710 | ProcessPath.fillPath( | ||
| 711 | new PixelWriterDrawHandler(sData, pw, sg2d.getCompClip(), | ||
| 712 | sg2d.strokeHint), | ||
| 713 | p2df, transx, transy); | ||
| 714 | } | ||
| 715 | } | ||
| 716 | |||
| 717 | class SetFillSpansANY extends FillSpans { | ||
| 718 | SetFillSpansANY() { | ||
| 719 | super(SurfaceType.AnyColor, | ||
| 720 | CompositeType.SrcNoEa, | ||
| 721 | SurfaceType.Any); | ||
| 722 | } | ||
| 723 | |||
| 724 | public void FillSpans(SunGraphics2D sg2d, SurfaceData sData, | ||
| 725 | SpanIterator si) | ||
| 726 | { | ||
| 727 | PixelWriter pw = GeneralRenderer.createSolidPixelWriter(sg2d, sData); | ||
| 728 | |||
| 729 | int span[] = new int[4]; | ||
| 730 | while (si.nextSpan(span)) { | ||
| 731 | GeneralRenderer.doSetRect(sData, pw, | ||
| 732 | span[0], span[1], span[2], span[3]); | ||
| 733 | } | ||
| 734 | } | ||
| 735 | } | ||
| 736 | |||
| 737 | class SetDrawLineANY extends DrawLine { | ||
| 738 | SetDrawLineANY() { | ||
| 739 | super(SurfaceType.AnyColor, | ||
| 740 | CompositeType.SrcNoEa, | ||
| 741 | SurfaceType.Any); | ||
| 742 | } | ||
| 743 | |||
| 744 | public void DrawLine(SunGraphics2D sg2d, SurfaceData sData, | ||
| 745 | int x1, int y1, int x2, int y2) | ||
| 746 | { | ||
| 747 | PixelWriter pw = GeneralRenderer.createSolidPixelWriter(sg2d, sData); | ||
| 748 | |||
| 749 | if (y1 >= y2) { | ||
| 750 | GeneralRenderer.doDrawLine(sData, pw, null, | ||
| 751 | sg2d.getCompClip(), | ||
| 752 | x2, y2, x1, y1); | ||
| 753 | } else { | ||
| 754 | GeneralRenderer.doDrawLine(sData, pw, null, | ||
| 755 | sg2d.getCompClip(), | ||
| 756 | x1, y1, x2, y2); | ||
| 757 | } | ||
| 758 | } | ||
| 759 | } | ||
| 760 | |||
| 761 | class SetDrawPolygonsANY extends DrawPolygons { | ||
| 762 | SetDrawPolygonsANY() { | ||
| 763 | super(SurfaceType.AnyColor, | ||
| 764 | CompositeType.SrcNoEa, | ||
| 765 | SurfaceType.Any); | ||
| 766 | } | ||
| 767 | |||
| 768 | public void DrawPolygons(SunGraphics2D sg2d, SurfaceData sData, | ||
| 769 | int xPoints[], int yPoints[], | ||
| 770 | int nPoints[], int numPolys, | ||
| 771 | int transx, int transy, | ||
| 772 | boolean close) | ||
| 773 | { | ||
| 774 | PixelWriter pw = GeneralRenderer.createSolidPixelWriter(sg2d, sData); | ||
| 775 | |||
| 776 | int off = 0; | ||
| 777 | Region clip = sg2d.getCompClip(); | ||
| 778 | for (int i = 0; i < numPolys; i++) { | ||
| 779 | int numpts = nPoints[i]; | ||
| 780 | GeneralRenderer.doDrawPoly(sData, pw, | ||
| 781 | xPoints, yPoints, off, numpts, | ||
| 782 | clip, transx, transy, close); | ||
| 783 | off += numpts; | ||
| 784 | } | ||
| 785 | } | ||
| 786 | } | ||
| 787 | |||
| 788 | class SetDrawPathANY extends DrawPath { | ||
| 789 | SetDrawPathANY() { | ||
| 790 | super(SurfaceType.AnyColor, | ||
| 791 | CompositeType.SrcNoEa, | ||
| 792 | SurfaceType.Any); | ||
| 793 | } | ||
| 794 | |||
| 795 | public void DrawPath(SunGraphics2D sg2d, SurfaceData sData, | ||
| 796 | int transx, int transy, | ||
| 797 | Path2D.Float p2df) | ||
| 798 | { | ||
| 799 | PixelWriter pw = GeneralRenderer.createSolidPixelWriter(sg2d, sData); | ||
| 800 | ProcessPath.drawPath( | ||
| 801 | new PixelWriterDrawHandler(sData, pw, sg2d.getCompClip(), | ||
| 802 | sg2d.strokeHint), | ||
| 803 | p2df, transx, transy | ||
| 804 | ); | ||
| 805 | } | ||
| 806 | } | ||
| 807 | |||
| 808 | class SetDrawRectANY extends DrawRect { | ||
| 809 | SetDrawRectANY() { | ||
| 810 | super(SurfaceType.AnyColor, | ||
| 811 | CompositeType.SrcNoEa, | ||
| 812 | SurfaceType.Any); | ||
| 813 | } | ||
| 814 | |||
| 815 | public void DrawRect(SunGraphics2D sg2d, SurfaceData sData, | ||
| 816 | int x, int y, int w, int h) | ||
| 817 | { | ||
| 818 | PixelWriter pw = GeneralRenderer.createSolidPixelWriter(sg2d, sData); | ||
| 819 | |||
| 820 | GeneralRenderer.doDrawRect(pw, sg2d, sData, x, y, w, h); | ||
| 821 | } | ||
| 822 | } | ||
| 823 | |||
| 824 | class XorFillRectANY extends FillRect { | ||
| 825 | XorFillRectANY() { | ||
| 826 | super(SurfaceType.AnyColor, | ||
| 827 | CompositeType.Xor, | ||
| 828 | SurfaceType.Any); | ||
| 829 | } | ||
| 830 | |||
| 831 | public void FillRect(SunGraphics2D sg2d, SurfaceData sData, | ||
| 832 | int x, int y, int w, int h) | ||
| 833 | { | ||
| 834 | PixelWriter pw = GeneralRenderer.createXorPixelWriter(sg2d, sData); | ||
| 835 | |||
| 836 | Region r = sg2d.getCompClip().getBoundsIntersectionXYWH(x, y, w, h); | ||
| 837 | |||
| 838 | GeneralRenderer.doSetRect(sData, pw, | ||
| 839 | r.getLoX(), r.getLoY(), | ||
| 840 | r.getHiX(), r.getHiY()); | ||
| 841 | } | ||
| 842 | } | ||
| 843 | |||
| 844 | class XorFillPathANY extends FillPath { | ||
| 845 | XorFillPathANY() { | ||
| 846 | super(SurfaceType.AnyColor, CompositeType.Xor, | ||
| 847 | SurfaceType.Any); | ||
| 848 | } | ||
| 849 | |||
| 850 | public void FillPath(SunGraphics2D sg2d, SurfaceData sData, | ||
| 851 | int transx, int transy, | ||
| 852 | Path2D.Float p2df) | ||
| 853 | { | ||
| 854 | PixelWriter pw = GeneralRenderer.createXorPixelWriter(sg2d, sData); | ||
| 855 | ProcessPath.fillPath( | ||
| 856 | new PixelWriterDrawHandler(sData, pw, sg2d.getCompClip(), | ||
| 857 | sg2d.strokeHint), | ||
| 858 | p2df, transx, transy); | ||
| 859 | } | ||
| 860 | } | ||
| 861 | |||
| 862 | class XorFillSpansANY extends FillSpans { | ||
| 863 | XorFillSpansANY() { | ||
| 864 | super(SurfaceType.AnyColor, | ||
| 865 | CompositeType.Xor, | ||
| 866 | SurfaceType.Any); | ||
| 867 | } | ||
| 868 | |||
| 869 | public void FillSpans(SunGraphics2D sg2d, SurfaceData sData, | ||
| 870 | SpanIterator si) | ||
| 871 | { | ||
| 872 | PixelWriter pw = GeneralRenderer.createXorPixelWriter(sg2d, sData); | ||
| 873 | |||
| 874 | int span[] = new int[4]; | ||
| 875 | while (si.nextSpan(span)) { | ||
| 876 | GeneralRenderer.doSetRect(sData, pw, | ||
| 877 | span[0], span[1], span[2], span[3]); | ||
| 878 | } | ||
| 879 | } | ||
| 880 | } | ||
| 881 | |||
| 882 | class XorDrawLineANY extends DrawLine { | ||
| 883 | XorDrawLineANY() { | ||
| 884 | super(SurfaceType.AnyColor, | ||
| 885 | CompositeType.Xor, | ||
| 886 | SurfaceType.Any); | ||
| 887 | } | ||
| 888 | |||
| 889 | public void DrawLine(SunGraphics2D sg2d, SurfaceData sData, | ||
| 890 | int x1, int y1, int x2, int y2) | ||
| 891 | { | ||
| 892 | PixelWriter pw = GeneralRenderer.createXorPixelWriter(sg2d, sData); | ||
| 893 | |||
| 894 | if (y1 >= y2) { | ||
| 895 | GeneralRenderer.doDrawLine(sData, pw, null, | ||
| 896 | sg2d.getCompClip(), | ||
| 897 | x2, y2, x1, y1); | ||
| 898 | } else { | ||
| 899 | GeneralRenderer.doDrawLine(sData, pw, null, | ||
| 900 | sg2d.getCompClip(), | ||
| 901 | x1, y1, x2, y2); | ||
| 902 | } | ||
| 903 | } | ||
| 904 | } | ||
| 905 | |||
| 906 | class XorDrawPolygonsANY extends DrawPolygons { | ||
| 907 | XorDrawPolygonsANY() { | ||
| 908 | super(SurfaceType.AnyColor, | ||
| 909 | CompositeType.Xor, | ||
| 910 | SurfaceType.Any); | ||
| 911 | } | ||
| 912 | |||
| 913 | public void DrawPolygons(SunGraphics2D sg2d, SurfaceData sData, | ||
| 914 | int xPoints[], int yPoints[], | ||
| 915 | int nPoints[], int numPolys, | ||
| 916 | int transx, int transy, | ||
| 917 | boolean close) | ||
| 918 | { | ||
| 919 | PixelWriter pw = GeneralRenderer.createXorPixelWriter(sg2d, sData); | ||
| 920 | |||
| 921 | int off = 0; | ||
| 922 | Region clip = sg2d.getCompClip(); | ||
| 923 | for (int i = 0; i < numPolys; i++) { | ||
| 924 | int numpts = nPoints[i]; | ||
| 925 | GeneralRenderer.doDrawPoly(sData, pw, | ||
| 926 | xPoints, yPoints, off, numpts, | ||
| 927 | clip, transx, transy, close); | ||
| 928 | off += numpts; | ||
| 929 | } | ||
| 930 | } | ||
| 931 | } | ||
| 932 | |||
| 933 | class XorDrawPathANY extends DrawPath { | ||
| 934 | XorDrawPathANY() { | ||
| 935 | super(SurfaceType.AnyColor, | ||
| 936 | CompositeType.Xor, | ||
| 937 | SurfaceType.Any); | ||
| 938 | } | ||
| 939 | |||
| 940 | public void DrawPath(SunGraphics2D sg2d, SurfaceData sData, | ||
| 941 | int transx, int transy, Path2D.Float p2df) | ||
| 942 | { | ||
| 943 | PixelWriter pw = GeneralRenderer.createXorPixelWriter(sg2d, sData); | ||
| 944 | ProcessPath.drawPath( | ||
| 945 | new PixelWriterDrawHandler(sData, pw, sg2d.getCompClip(), | ||
| 946 | sg2d.strokeHint), | ||
| 947 | p2df, transx, transy | ||
| 948 | ); | ||
| 949 | } | ||
| 950 | } | ||
| 951 | |||
| 952 | class XorDrawRectANY extends DrawRect { | ||
| 953 | XorDrawRectANY() { | ||
| 954 | super(SurfaceType.AnyColor, | ||
| 955 | CompositeType.Xor, | ||
| 956 | SurfaceType.Any); | ||
| 957 | } | ||
| 958 | |||
| 959 | public void DrawRect(SunGraphics2D sg2d, SurfaceData sData, | ||
| 960 | int x, int y, int w, int h) | ||
| 961 | { | ||
| 962 | PixelWriter pw = GeneralRenderer.createXorPixelWriter(sg2d, sData); | ||
| 963 | |||
| 964 | GeneralRenderer.doDrawRect(pw, sg2d, sData, x, y, w, h); | ||
| 965 | } | ||
| 966 | } | ||
| 967 | |||
| 968 | class XorDrawGlyphListANY extends DrawGlyphList { | ||
| 969 | XorDrawGlyphListANY() { | ||
| 970 | super(SurfaceType.AnyColor, | ||
| 971 | CompositeType.Xor, | ||
| 972 | SurfaceType.Any); | ||
| 973 | } | ||
| 974 | |||
| 975 | public void DrawGlyphList(SunGraphics2D sg2d, SurfaceData sData, | ||
| 976 | GlyphList gl) | ||
| 977 | { | ||
| 978 | PixelWriter pw = GeneralRenderer.createXorPixelWriter(sg2d, sData); | ||
| 979 | GeneralRenderer.doDrawGlyphList(sData, pw, gl, sg2d.getCompClip()); | ||
| 980 | } | ||
| 981 | } | ||
| 982 | |||
| 983 | class XorDrawGlyphListAAANY extends DrawGlyphListAA { | ||
| 984 | XorDrawGlyphListAAANY() { | ||
| 985 | super(SurfaceType.AnyColor, | ||
| 986 | CompositeType.Xor, | ||
| 987 | SurfaceType.Any); | ||
| 988 | } | ||
| 989 | |||
| 990 | public void DrawGlyphListAA(SunGraphics2D sg2d, SurfaceData sData, | ||
| 991 | GlyphList gl) | ||
| 992 | { | ||
| 993 | PixelWriter pw = GeneralRenderer.createXorPixelWriter(sg2d, sData); | ||
| 994 | GeneralRenderer.doDrawGlyphList(sData, pw, gl, sg2d.getCompClip()); | ||
| 995 | } | ||
| 996 | } | ||
| 997 | |||
| 998 | abstract class PixelWriter { | ||
| 999 | protected WritableRaster dstRast; | ||
| 1000 | |||
| 1001 | public void setRaster(WritableRaster dstRast) { | ||
| 1002 | this.dstRast = dstRast; | ||
| 1003 | } | ||
| 1004 | |||
| 1005 | public abstract void writePixel(int x, int y); | ||
| 1006 | } | ||
| 1007 | |||
| 1008 | class SolidPixelWriter extends PixelWriter { | ||
| 1009 | protected Object srcData; | ||
| 1010 | |||
| 1011 | SolidPixelWriter(Object srcPixel) { | ||
| 1012 | this.srcData = srcPixel; | ||
| 1013 | } | ||
| 1014 | |||
| 1015 | public void writePixel(int x, int y) { | ||
| 1016 | dstRast.setDataElements(x, y, srcData); | ||
| 1017 | } | ||
| 1018 | } | ||
| 1019 | |||
| 1020 | abstract class XorPixelWriter extends PixelWriter { | ||
| 1021 | protected ColorModel dstCM; | ||
| 1022 | |||
| 1023 | public void writePixel(int x, int y) { | ||
| 1024 | Object dstPixel = dstRast.getDataElements(x, y, null); | ||
| 1025 | xorPixel(dstPixel); | ||
| 1026 | dstRast.setDataElements(x, y, dstPixel); | ||
| 1027 | } | ||
| 1028 | |||
| 1029 | protected abstract void xorPixel(Object pixData); | ||
| 1030 | |||
| 1031 | public static class ByteData extends XorPixelWriter { | ||
| 1032 | byte[] xorData; | ||
| 1033 | |||
| 1034 | ByteData(Object srcPixel, Object xorPixel) { | ||
| 1035 | this.xorData = (byte[]) srcPixel; | ||
| 1036 | xorPixel(xorPixel); | ||
| 1037 | this.xorData = (byte[]) xorPixel; | ||
| 1038 | } | ||
| 1039 | |||
| 1040 | protected void xorPixel(Object pixData) { | ||
| 1041 | byte[] dstData = (byte[]) pixData; | ||
| 1042 | for (int i = 0; i < dstData.length; i++) { | ||
| 1043 | dstData[i] ^= xorData[i]; | ||
| 1044 | } | ||
| 1045 | } | ||
| 1046 | } | ||
| 1047 | |||
| 1048 | public static class ShortData extends XorPixelWriter { | ||
| 1049 | short[] xorData; | ||
| 1050 | |||
| 1051 | ShortData(Object srcPixel, Object xorPixel) { | ||
| 1052 | this.xorData = (short[]) srcPixel; | ||
| 1053 | xorPixel(xorPixel); | ||
| 1054 | this.xorData = (short[]) xorPixel; | ||
| 1055 | } | ||
| 1056 | |||
| 1057 | protected void xorPixel(Object pixData) { | ||
| 1058 | short[] dstData = (short[]) pixData; | ||
| 1059 | for (int i = 0; i < dstData.length; i++) { | ||
| 1060 | dstData[i] ^= xorData[i]; | ||
| 1061 | } | ||
| 1062 | } | ||
| 1063 | } | ||
| 1064 | |||
| 1065 | public static class IntData extends XorPixelWriter { | ||
| 1066 | int[] xorData; | ||
| 1067 | |||
| 1068 | IntData(Object srcPixel, Object xorPixel) { | ||
| 1069 | this.xorData = (int[]) srcPixel; | ||
| 1070 | xorPixel(xorPixel); | ||
| 1071 | this.xorData = (int[]) xorPixel; | ||
| 1072 | } | ||
| 1073 | |||
| 1074 | protected void xorPixel(Object pixData) { | ||
| 1075 | int[] dstData = (int[]) pixData; | ||
| 1076 | for (int i = 0; i < dstData.length; i++) { | ||
| 1077 | dstData[i] ^= xorData[i]; | ||
| 1078 | } | ||
| 1079 | } | ||
| 1080 | } | ||
| 1081 | |||
| 1082 | public static class FloatData extends XorPixelWriter { | ||
| 1083 | int[] xorData; | ||
| 1084 | |||
| 1085 | FloatData(Object srcPixel, Object xorPixel) { | ||
| 1086 | float[] srcData = (float[]) srcPixel; | ||
| 1087 | float[] xorData = (float[]) xorPixel; | ||
| 1088 | this.xorData = new int[srcData.length]; | ||
| 1089 | for (int i = 0; i < srcData.length; i++) { | ||
| 1090 | this.xorData[i] = (Float.floatToIntBits(srcData[i]) ^ | ||
| 1091 | Float.floatToIntBits(xorData[i])); | ||
| 1092 | } | ||
| 1093 | } | ||
| 1094 | |||
| 1095 | protected void xorPixel(Object pixData) { | ||
| 1096 | float[] dstData = (float[]) pixData; | ||
| 1097 | for (int i = 0; i < dstData.length; i++) { | ||
| 1098 | int v = Float.floatToIntBits(dstData[i]) ^ xorData[i]; | ||
| 1099 | dstData[i] = Float.intBitsToFloat(v); | ||
| 1100 | } | ||
| 1101 | } | ||
| 1102 | } | ||
| 1103 | |||
| 1104 | public static class DoubleData extends XorPixelWriter { | ||
| 1105 | long[] xorData; | ||
| 1106 | |||
| 1107 | DoubleData(Object srcPixel, Object xorPixel) { | ||
| 1108 | double[] srcData = (double[]) srcPixel; | ||
| 1109 | double[] xorData = (double[]) xorPixel; | ||
| 1110 | this.xorData = new long[srcData.length]; | ||
| 1111 | for (int i = 0; i < srcData.length; i++) { | ||
| 1112 | this.xorData[i] = (Double.doubleToLongBits(srcData[i]) ^ | ||
| 1113 | Double.doubleToLongBits(xorData[i])); | ||
| 1114 | } | ||
| 1115 | } | ||
| 1116 | |||
| 1117 | protected void xorPixel(Object pixData) { | ||
| 1118 | double[] dstData = (double[]) pixData; | ||
| 1119 | for (int i = 0; i < dstData.length; i++) { | ||
| 1120 | long v = Double.doubleToLongBits(dstData[i]) ^ xorData[i]; | ||
| 1121 | dstData[i] = Double.longBitsToDouble(v); | ||
| 1122 | } | ||
| 1123 | } | ||
| 1124 | } | ||
| 1125 | } | ||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
| @@ -0,0 +1,623 @@ | |||
| 1 | /* | ||
| 2 | * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved. | ||
| 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 | ||
| 7 | * published by the Free Software Foundation. Oracle designates this | ||
| 8 | * particular file as subject to the "Classpath" exception as provided | ||
| 9 | * by Oracle in the LICENSE file that accompanied this code. | ||
| 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 | * | ||
| 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. | ||
| 24 | */ | ||
| 25 | |||
| 26 | /* | ||
| 27 | * @author Charlton Innovations, Inc. | ||
| 28 | */ | ||
| 29 | |||
| 30 | package sun.java2d.loops; | ||
| 31 | |||
| 32 | import java.awt.image.BufferedImage; | ||
| 33 | import java.awt.AlphaComposite; | ||
| 34 | import java.awt.Rectangle; | ||
| 35 | import sun.awt.image.BufImgSurfaceData; | ||
| 36 | import sun.java2d.SurfaceData; | ||
| 37 | import sun.java2d.pipe.Region; | ||
| 38 | import java.lang.reflect.Field; | ||
| 39 | import java.util.StringTokenizer; | ||
| 40 | import java.util.Iterator; | ||
| 41 | import java.util.HashMap; | ||
| 42 | import java.util.Map; | ||
| 43 | import java.io.PrintStream; | ||
| 44 | import java.io.OutputStream; | ||
| 45 | import java.io.FileOutputStream; | ||
| 46 | import java.io.FileNotFoundException; | ||
| 47 | import java.security.AccessController; | ||
| 48 | import java.security.PrivilegedAction; | ||
| 49 | import sun.security.action.GetPropertyAction; | ||
| 50 | |||
| 51 | /** | ||
| 52 | * defines interface for primitives which can be placed into | ||
| 53 | * the graphic component manager framework | ||
| 54 | */ | ||
| 55 | public abstract class GraphicsPrimitive { | ||
| 56 | |||
| 57 | protected static interface GeneralBinaryOp { | ||
| 58 | /** | ||
| 59 | * This method allows the setupGeneralBinaryOp method to set | ||
| 60 | * the converters into the General version of the Primitive. | ||
| 61 | */ | ||
| 62 | public void setPrimitives(Blit srcconverter, | ||
| 63 | Blit dstconverter, | ||
| 64 | GraphicsPrimitive genericop, | ||
| 65 | Blit resconverter); | ||
| 66 | |||
| 67 | /** | ||
| 68 | * These 4 methods are implemented automatically for any | ||
| 69 | * GraphicsPrimitive. They are used by setupGeneralBinaryOp | ||
| 70 | * to retrieve the information needed to find the right | ||
| 71 | * converter primitives. | ||
| 72 | */ | ||
| 73 | public SurfaceType getSourceType(); | ||
| 74 | public CompositeType getCompositeType(); | ||
| 75 | public SurfaceType getDestType(); | ||
| 76 | public String getSignature(); | ||
| 77 | public int getPrimTypeID(); | ||
| 78 | } | ||
| 79 | |||
| 80 | protected static interface GeneralUnaryOp { | ||
| 81 | /** | ||
| 82 | * This method allows the setupGeneralUnaryOp method to set | ||
| 83 | * the converters into the General version of the Primitive. | ||
| 84 | */ | ||
| 85 | public void setPrimitives(Blit dstconverter, | ||
| 86 | GraphicsPrimitive genericop, | ||
| 87 | Blit resconverter); | ||
| 88 | |||
| 89 | /** | ||
| 90 | * These 3 methods are implemented automatically for any | ||
| 91 | * GraphicsPrimitive. They are used by setupGeneralUnaryOp | ||
| 92 | * to retrieve the information needed to find the right | ||
| 93 | * converter primitives. | ||
| 94 | */ | ||
| 95 | public CompositeType getCompositeType(); | ||
| 96 | public SurfaceType getDestType(); | ||
| 97 | public String getSignature(); | ||
| 98 | public int getPrimTypeID(); | ||
| 99 | } | ||
| 100 | |||
| 101 | /** | ||
| 102 | * INSTANCE DATA MEMBERS DESCRIBING CHARACTERISTICS OF THIS PRIMITIVE | ||
| 103 | **/ | ||
| 104 | |||
| 105 | // Making these be instance data members (instead of virtual methods | ||
| 106 | // overridden by subclasses) is actually cheaper, since each class | ||
| 107 | // is a singleton. As instance data members with final accessors, | ||
| 108 | // accesses can be inlined. | ||
| 109 | private String methodSignature; | ||
| 110 | private int uniqueID; | ||
| 111 | private static int unusedPrimID = 1; | ||
| 112 | |||
| 113 | private SurfaceType sourceType; | ||
| 114 | private CompositeType compositeType; | ||
| 115 | private SurfaceType destType; | ||
| 116 | |||
| 117 | private long pNativePrim; // Native blit loop info | ||
| 118 | |||
| 119 | public synchronized static final int makePrimTypeID() { | ||
| 120 | if (unusedPrimID > 255) { | ||
| 121 | throw new InternalError("primitive id overflow"); | ||
| 122 | } | ||
| 123 | return unusedPrimID++; | ||
| 124 | } | ||
| 125 | |||
| 126 | public synchronized static final int makeUniqueID(int primTypeID, | ||
| 127 | SurfaceType src, | ||
| 128 | CompositeType cmp, | ||
| 129 | SurfaceType dst) | ||
| 130 | { | ||
| 131 | return (primTypeID << 24) | | ||
| 132 | (dst.getUniqueID() << 16) | | ||
| 133 | (cmp.getUniqueID() << 8) | | ||
| 134 | (src.getUniqueID()); | ||
| 135 | } | ||
| 136 | |||
| 137 | /** | ||
| 138 | * Create a new GraphicsPrimitive with all of the required | ||
| 139 | * descriptive information. | ||
| 140 | */ | ||
| 141 | protected GraphicsPrimitive(String methodSignature, | ||
| 142 | int primTypeID, | ||
| 143 | SurfaceType sourceType, | ||
| 144 | CompositeType compositeType, | ||
| 145 | SurfaceType destType) | ||
| 146 | { | ||
| 147 | this.methodSignature = methodSignature; | ||
| 148 | this.sourceType = sourceType; | ||
| 149 | this.compositeType = compositeType; | ||
| 150 | this.destType = destType; | ||
| 151 | |||
| 152 | if(sourceType == null || compositeType == null || destType == null) { | ||
| 153 | this.uniqueID = primTypeID << 24; | ||
| 154 | } else { | ||
| 155 | this.uniqueID = GraphicsPrimitive.makeUniqueID(primTypeID, | ||
| 156 | sourceType, | ||
| 157 | compositeType, | ||
| 158 | destType); | ||
| 159 | } | ||
| 160 | } | ||
| 161 | |||
| 162 | /** | ||
| 163 | * Create a new GraphicsPrimitive for native invocation | ||
| 164 | * with all of the required descriptive information. | ||
| 165 | */ | ||
| 166 | protected GraphicsPrimitive(long pNativePrim, | ||
| 167 | String methodSignature, | ||
| 168 | int primTypeID, | ||
| 169 | SurfaceType sourceType, | ||
| 170 | CompositeType compositeType, | ||
| 171 | SurfaceType destType) | ||
| 172 | { | ||
| 173 | this.pNativePrim = pNativePrim; | ||
| 174 | this.methodSignature = methodSignature; | ||
| 175 | this.sourceType = sourceType; | ||
| 176 | this.compositeType = compositeType; | ||
| 177 | this.destType = destType; | ||
| 178 | |||
| 179 | if(sourceType == null || compositeType == null || destType == null) { | ||
| 180 | this.uniqueID = primTypeID << 24; | ||
| 181 | } else { | ||
| 182 | this.uniqueID = GraphicsPrimitive.makeUniqueID(primTypeID, | ||
| 183 | sourceType, | ||
| 184 | compositeType, | ||
| 185 | destType); | ||
| 186 | } | ||
| 187 | } | ||
| 188 | |||
| 189 | /** | ||
| 190 | * METHODS TO DESCRIBE THE SURFACES PRIMITIVES | ||
| 191 | * CAN OPERATE ON AND THE FUNCTIONALITY THEY IMPLEMENT | ||
| 192 | **/ | ||
| 193 | |||
| 194 | /** | ||
| 195 | * Gets instance ID of this graphics primitive. | ||
| 196 | * | ||
| 197 | * Instance ID is comprised of four distinct ids (ORed together) | ||
| 198 | * that uniquely identify each instance of a GraphicsPrimitive | ||
| 199 | * object. The four ids making up instance ID are: | ||
| 200 | * 1. primitive id - identifier shared by all primitives of the | ||
| 201 | * same type (eg. all Blits have the same primitive id) | ||
| 202 | * 2. sourcetype id - identifies source surface type | ||
| 203 | * 3. desttype id - identifies destination surface type | ||
| 204 | * 4. compositetype id - identifies composite used | ||
| 205 | * | ||
| 206 | * @return instance ID | ||
| 207 | */ | ||
| 208 | public final int getUniqueID() { | ||
| 209 | return uniqueID; | ||
| 210 | } | ||
| 211 | |||
| 212 | /** | ||
| 213 | */ | ||
| 214 | public final String getSignature() { | ||
| 215 | return methodSignature; | ||
| 216 | } | ||
| 217 | |||
| 218 | /** | ||
| 219 | * Gets unique id for this GraphicsPrimitive type. | ||
| 220 | * | ||
| 221 | * This id is used to identify the TYPE of primitive (Blit vs. BlitBg) | ||
| 222 | * as opposed to INSTANCE of primitive. | ||
| 223 | * | ||
| 224 | * @return primitive ID | ||
| 225 | */ | ||
| 226 | public final int getPrimTypeID() { | ||
| 227 | return uniqueID >>> 24; | ||
| 228 | } | ||
| 229 | |||
| 230 | /** | ||
| 231 | */ | ||
| 232 | public final long getNativePrim() { | ||
| 233 | return pNativePrim; | ||
| 234 | } | ||
| 235 | |||
| 236 | /** | ||
| 237 | */ | ||
| 238 | public final SurfaceType getSourceType() { | ||
| 239 | return sourceType; | ||
| 240 | } | ||
| 241 | |||
| 242 | /** | ||
| 243 | */ | ||
| 244 | public final CompositeType getCompositeType() { | ||
| 245 | return compositeType; | ||
| 246 | } | ||
| 247 | |||
| 248 | /** | ||
| 249 | */ | ||
| 250 | public final SurfaceType getDestType() { | ||
| 251 | return destType; | ||
| 252 | } | ||
| 253 | |||
| 254 | /** | ||
| 255 | * Return true if this primitive can be used for the given signature | ||
| 256 | * surfaces, and composite. | ||
| 257 | * | ||
| 258 | * @param signature The signature of the given operation. Must be | ||
| 259 | * == (not just .equals) the signature string given by the | ||
| 260 | * abstract class that declares the operation. | ||
| 261 | * @param srctype The surface type for the source of the operation | ||
| 262 | * @param comptype The composite type for the operation | ||
| 263 | * @param dsttype The surface type for the destination of the operation | ||
| 264 | */ | ||
| 265 | public final boolean satisfies(String signature, | ||
| 266 | SurfaceType srctype, | ||
| 267 | CompositeType comptype, | ||
| 268 | SurfaceType dsttype) | ||
| 269 | { | ||
| 270 | if (signature != methodSignature) { | ||
| 271 | return false; | ||
| 272 | } | ||
| 273 | while (true) { | ||
| 274 | if (srctype == null) { | ||
| 275 | return false; | ||
| 276 | } | ||
| 277 | if (srctype.equals(sourceType)) { | ||
| 278 | break; | ||
| 279 | } | ||
| 280 | srctype = srctype.getSuperType(); | ||
| 281 | } | ||
| 282 | while (true) { | ||
| 283 | if (comptype == null) { | ||
| 284 | return false; | ||
| 285 | } | ||
| 286 | if (comptype.equals(compositeType)) { | ||
| 287 | break; | ||
| 288 | } | ||
| 289 | comptype = comptype.getSuperType(); | ||
| 290 | } | ||
| 291 | while (true) { | ||
| 292 | if (dsttype == null) { | ||
| 293 | return false; | ||
| 294 | } | ||
| 295 | if (dsttype.equals(destType)) { | ||
| 296 | break; | ||
| 297 | } | ||
| 298 | dsttype = dsttype.getSuperType(); | ||
| 299 | } | ||
| 300 | return true; | ||
| 301 | } | ||
| 302 | |||
| 303 | // | ||
| 304 | // A version of satisfies used for regression testing | ||
| 305 | // | ||
| 306 | final boolean satisfiesSameAs(GraphicsPrimitive other) { | ||
| 307 | return (methodSignature == other.methodSignature && | ||
| 308 | sourceType.equals(other.sourceType) && | ||
| 309 | compositeType.equals(other.compositeType) && | ||
| 310 | destType.equals(other.destType)); | ||
| 311 | } | ||
| 312 | |||
| 313 | public abstract GraphicsPrimitive makePrimitive(SurfaceType srctype, | ||
| 314 | CompositeType comptype, | ||
| 315 | SurfaceType dsttype); | ||
| 316 | |||
| 317 | public abstract GraphicsPrimitive traceWrap(); | ||
| 318 | |||
| 319 | static HashMap traceMap; | ||
| 320 | |||
| 321 | public static int traceflags; | ||
| 322 | public static String tracefile; | ||
| 323 | public static PrintStream traceout; | ||
| 324 | |||
| 325 | public static final int TRACELOG = 1; | ||
| 326 | public static final int TRACETIMESTAMP = 2; | ||
| 327 | public static final int TRACECOUNTS = 4; | ||
| 328 | |||
| 329 | static { | ||
| 330 | GetPropertyAction gpa = new GetPropertyAction("sun.java2d.trace"); | ||
| 331 | String trace = (String)AccessController.doPrivileged(gpa); | ||
| 332 | if (trace != null) { | ||
| 333 | boolean verbose = false; | ||
| 334 | int traceflags = 0; | ||
| 335 | StringTokenizer st = new StringTokenizer(trace, ","); | ||
| 336 | while (st.hasMoreTokens()) { | ||
| 337 | String tok = st.nextToken(); | ||
| 338 | if (tok.equalsIgnoreCase("count")) { | ||
| 339 | traceflags |= GraphicsPrimitive.TRACECOUNTS; | ||
| 340 | } else if (tok.equalsIgnoreCase("log")) { | ||
| 341 | traceflags |= GraphicsPrimitive.TRACELOG; | ||
| 342 | } else if (tok.equalsIgnoreCase("timestamp")) { | ||
| 343 | traceflags |= GraphicsPrimitive.TRACETIMESTAMP; | ||
| 344 | } else if (tok.equalsIgnoreCase("verbose")) { | ||
| 345 | verbose = true; | ||
| 346 | } else if (tok.regionMatches(true, 0, "out:", 0, 4)) { | ||
| 347 | tracefile = tok.substring(4); | ||
| 348 | } else { | ||
| 349 | if (!tok.equalsIgnoreCase("help")) { | ||
| 350 | System.err.println("unrecognized token: "+tok); | ||
| 351 | } | ||
| 352 | System.err.println("usage: -Dsun.java2d.trace="+ | ||
| 353 | "[log[,timestamp]],[count],"+ | ||
| 354 | "[out:<filename>],[help],[verbose]"); | ||
| 355 | } | ||
| 356 | } | ||
| 357 | if (verbose) { | ||
| 358 | System.err.print("GraphicsPrimitive logging "); | ||
| 359 | if ((traceflags & GraphicsPrimitive.TRACELOG) != 0) { | ||
| 360 | System.err.println("enabled"); | ||
| 361 | System.err.print("GraphicsPrimitive timetamps "); | ||
| 362 | if ((traceflags & GraphicsPrimitive.TRACETIMESTAMP) != 0) { | ||
| 363 | System.err.println("enabled"); | ||
| 364 | } else { | ||
| 365 | System.err.println("disabled"); | ||
| 366 | } | ||
| 367 | } else { | ||
| 368 | System.err.println("[and timestamps] disabled"); | ||
| 369 | } | ||
| 370 | System.err.print("GraphicsPrimitive invocation counts "); | ||
| 371 | if ((traceflags & GraphicsPrimitive.TRACECOUNTS) != 0) { | ||
| 372 | System.err.println("enabled"); | ||
| 373 | } else { | ||
| 374 | System.err.println("disabled"); | ||
| 375 | } | ||
| 376 | System.err.print("GraphicsPrimitive trace output to "); | ||
| 377 | if (tracefile == null) { | ||
| 378 | System.err.println("System.err"); | ||
| 379 | } else { | ||
| 380 | System.err.println("file '"+tracefile+"'"); | ||
| 381 | } | ||
| 382 | } | ||
| 383 | GraphicsPrimitive.traceflags = traceflags; | ||
| 384 | } | ||
| 385 | } | ||
| 386 | |||
| 387 | public static boolean tracingEnabled() { | ||
| 388 | return (traceflags != 0); | ||
| 389 | } | ||
| 390 | |||
| 391 | private static PrintStream getTraceOutputFile() { | ||
| 392 | if (traceout == null) { | ||
| 393 | if (tracefile != null) { | ||
| 394 | Object o = | ||
| 395 | AccessController.doPrivileged(new PrivilegedAction() { | ||
| 396 | public Object run() { | ||
| 397 | try { | ||
| 398 | return new FileOutputStream(tracefile); | ||
| 399 | } catch (FileNotFoundException e) { | ||
| 400 | return null; | ||
| 401 | } | ||
| 402 | } | ||
| 403 | }); | ||
| 404 | if (o != null) { | ||
| 405 | traceout = new PrintStream((OutputStream) o); | ||
| 406 | } else { | ||
| 407 | traceout = System.err; | ||
| 408 | } | ||
| 409 | } else { | ||
| 410 | traceout = System.err; | ||
| 411 | } | ||
| 412 | } | ||
| 413 | return traceout; | ||
| 414 | } | ||
| 415 | |||
| 416 | public static class TraceReporter extends Thread { | ||
| 417 | public static void setShutdownHook() { | ||
| 418 | AccessController.doPrivileged(new PrivilegedAction() { | ||
| 419 | public Object run() { | ||
| 420 | TraceReporter t = new TraceReporter(); | ||
| 421 | t.setContextClassLoader(null); | ||
| 422 | Runtime.getRuntime().addShutdownHook(t); | ||
| 423 | return null; | ||
| 424 | } | ||
| 425 | }); | ||
| 426 | } | ||
| 427 | |||
| 428 | public void run() { | ||
| 429 | PrintStream ps = getTraceOutputFile(); | ||
| 430 | Iterator iterator = traceMap.entrySet().iterator(); | ||
| 431 | long total = 0; | ||
| 432 | int numprims = 0; | ||
| 433 | while (iterator.hasNext()) { | ||
| 434 | Map.Entry me = (Map.Entry) iterator.next(); | ||
| 435 | Object prim = me.getKey(); | ||
| 436 | int[] count = (int[]) me.getValue(); | ||
| 437 | if (count[0] == 1) { | ||
| 438 | ps.print("1 call to "); | ||
| 439 | } else { | ||
| 440 | ps.print(count[0]+" calls to "); | ||
| 441 | } | ||
| 442 | ps.println(prim); | ||
| 443 | numprims++; | ||
| 444 | total += count[0]; | ||
| 445 | } | ||
| 446 | if (numprims == 0) { | ||
| 447 | ps.println("No graphics primitives executed"); | ||
| 448 | } else if (numprims > 1) { | ||
| 449 | ps.println(total+" total calls to "+ | ||
| 450 | numprims+" different primitives"); | ||
| 451 | } | ||
| 452 | } | ||
| 453 | } | ||
| 454 | |||
| 455 | public synchronized static void tracePrimitive(Object prim) { | ||
| 456 | if ((traceflags & TRACECOUNTS) != 0) { | ||
| 457 | if (traceMap == null) { | ||
| 458 | traceMap = new HashMap(); | ||
| 459 | TraceReporter.setShutdownHook(); | ||
| 460 | } | ||
| 461 | Object o = traceMap.get(prim); | ||
| 462 | if (o == null) { | ||
| 463 | o = new int[1]; | ||
| 464 | traceMap.put(prim, o); | ||
| 465 | } | ||
| 466 | ((int[]) o)[0]++; | ||
| 467 | } | ||
| 468 | if ((traceflags & TRACELOG) != 0) { | ||
| 469 | PrintStream ps = getTraceOutputFile(); | ||
| 470 | if ((traceflags & TRACETIMESTAMP) != 0) { | ||
| 471 | ps.print(System.currentTimeMillis()+": "); | ||
| 472 | } | ||
| 473 | ps.println(prim); | ||
| 474 | } | ||
| 475 | } | ||
| 476 | |||
| 477 | protected void setupGeneralBinaryOp(GeneralBinaryOp gbo) { | ||
| 478 | int primID = gbo.getPrimTypeID(); | ||
| 479 | String methodSignature = gbo.getSignature(); | ||
| 480 | SurfaceType srctype = gbo.getSourceType(); | ||
| 481 | CompositeType comptype = gbo.getCompositeType(); | ||
| 482 | SurfaceType dsttype = gbo.getDestType(); | ||
| 483 | Blit convertsrc, convertdst, convertres; | ||
| 484 | GraphicsPrimitive performop; | ||
| 485 | |||
| 486 | convertsrc = createConverter(srctype, SurfaceType.IntArgb); | ||
| 487 | performop = GraphicsPrimitiveMgr.locatePrim(primID, | ||
| 488 | SurfaceType.IntArgb, | ||
| 489 | comptype, dsttype); | ||
| 490 | if (performop != null) { | ||
| 491 | convertdst = null; | ||
| 492 | convertres = null; | ||
| 493 | } else { | ||
| 494 | performop = getGeneralOp(primID, comptype); | ||
| 495 | if (performop == null) { | ||
| 496 | throw new InternalError("Cannot construct general op for "+ | ||
| 497 | methodSignature+" "+comptype); | ||
| 498 | } | ||
| 499 | convertdst = createConverter(dsttype, SurfaceType.IntArgb); | ||
| 500 | convertres = createConverter(SurfaceType.IntArgb, dsttype); | ||
| 501 | } | ||
| 502 | |||
| 503 | gbo.setPrimitives(convertsrc, convertdst, performop, convertres); | ||
| 504 | } | ||
| 505 | |||
| 506 | protected void setupGeneralUnaryOp(GeneralUnaryOp guo) { | ||
| 507 | int primID = guo.getPrimTypeID(); | ||
| 508 | String methodSignature = guo.getSignature(); | ||
| 509 | CompositeType comptype = guo.getCompositeType(); | ||
| 510 | SurfaceType dsttype = guo.getDestType(); | ||
| 511 | |||
| 512 | Blit convertdst = createConverter(dsttype, SurfaceType.IntArgb); | ||
| 513 | GraphicsPrimitive performop = getGeneralOp(primID, comptype); | ||
| 514 | Blit convertres = createConverter(SurfaceType.IntArgb, dsttype); | ||
| 515 | if (convertdst == null || performop == null || convertres == null) { | ||
| 516 | throw new InternalError("Cannot construct binary op for "+ | ||
| 517 | comptype+" "+dsttype); | ||
| 518 | } | ||
| 519 | |||
| 520 | guo.setPrimitives(convertdst, performop, convertres); | ||
| 521 | } | ||
| 522 | |||
| 523 | protected static Blit createConverter(SurfaceType srctype, | ||
| 524 | SurfaceType dsttype) | ||
| 525 | { | ||
| 526 | if (srctype.equals(dsttype)) { | ||
| 527 | return null; | ||
| 528 | } | ||
| 529 | Blit cv = Blit.getFromCache(srctype, CompositeType.SrcNoEa, dsttype); | ||
| 530 | if (cv == null) { | ||
| 531 | throw new InternalError("Cannot construct converter for "+ | ||
| 532 | srctype+"=>"+dsttype); | ||
| 533 | } | ||
| 534 | return cv; | ||
| 535 | } | ||
| 536 | |||
| 537 | protected static SurfaceData convertFrom(Blit ob, SurfaceData srcData, | ||
| 538 | int srcX, int srcY, int w, int h, | ||
| 539 | SurfaceData dstData) | ||
| 540 | { | ||
| 541 | return convertFrom(ob, srcData, | ||
| 542 | srcX, srcY, w, h, dstData, | ||
| 543 | BufferedImage.TYPE_INT_ARGB); | ||
| 544 | } | ||
| 545 | |||
| 546 | protected static SurfaceData convertFrom(Blit ob, SurfaceData srcData, | ||
| 547 | int srcX, int srcY, int w, int h, | ||
| 548 | SurfaceData dstData, int type) | ||
| 549 | { | ||
| 550 | if (dstData != null) { | ||
| 551 | Rectangle r = dstData.getBounds(); | ||
| 552 | if (w > r.width || h > r.height) { | ||
| 553 | dstData = null; | ||
| 554 | } | ||
| 555 | } | ||
| 556 | if (dstData == null) { | ||
| 557 | BufferedImage dstBI = new BufferedImage(w, h, type); | ||
| 558 | dstData = BufImgSurfaceData.createData(dstBI); | ||
| 559 | } | ||
| 560 | ob.Blit(srcData, dstData, AlphaComposite.Src, null, | ||
| 561 | srcX, srcY, 0, 0, w, h); | ||
| 562 | return dstData; | ||
| 563 | } | ||
| 564 | |||
| 565 | protected static void convertTo(Blit ob, | ||
| 566 | SurfaceData srcImg, SurfaceData dstImg, | ||
| 567 | Region clip, | ||
| 568 | int dstX, int dstY, int w, int h) | ||
| 569 | { | ||
| 570 | if (ob != null) { | ||
| 571 | ob.Blit(srcImg, dstImg, AlphaComposite.Src, clip, | ||
| 572 | 0, 0, dstX, dstY, w, h); | ||
| 573 | } | ||
| 574 | } | ||
| 575 | |||
| 576 | protected static GraphicsPrimitive getGeneralOp(int primID, | ||
| 577 | CompositeType comptype) | ||
| 578 | { | ||
| 579 | return GraphicsPrimitiveMgr.locatePrim(primID, | ||
| 580 | SurfaceType.IntArgb, | ||
| 581 | comptype, | ||
| 582 | SurfaceType.IntArgb); | ||
| 583 | } | ||
| 584 | |||
| 585 | public static String simplename(Field[] fields, Object o) { | ||
| 586 | for (int i = 0; i < fields.length; i++) { | ||
| 587 | Field f = fields[i]; | ||
| 588 | try { | ||
| 589 | if (o == f.get(null)) { | ||
| 590 | return f.getName(); | ||
| 591 | } | ||
| 592 | } catch (Exception e) { | ||
| 593 | } | ||
| 594 | } | ||
| 595 | return "\""+o.toString()+"\""; | ||
| 596 | } | ||
| 597 | |||
| 598 | public static String simplename(SurfaceType st) { | ||
| 599 | return simplename(SurfaceType.class.getDeclaredFields(), st); | ||
| 600 | } | ||
| 601 | |||
| 602 | public static String simplename(CompositeType ct) { | ||
| 603 | return simplename(CompositeType.class.getDeclaredFields(), ct); | ||
| 604 | } | ||
| 605 | |||
| 606 | private String cachedname; | ||
| 607 | |||
| 608 | public String toString() { | ||
| 609 | if (cachedname == null) { | ||
| 610 | String sig = methodSignature; | ||
| 611 | int index = sig.indexOf('('); | ||
| 612 | if (index >= 0) { | ||
| 613 | sig = sig.substring(0, index); | ||
| 614 | } | ||
| 615 | cachedname = (getClass().getName()+"::"+ | ||
| 616 | sig+"("+ | ||
| 617 | simplename(sourceType)+", "+ | ||
| 618 | simplename(compositeType)+", "+ | ||
| 619 | simplename(destType)+")"); | ||
| 620 | } | ||
| 621 | return cachedname; | ||
| 622 | } | ||
| 623 | } | ||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
| @@ -0,0 +1,330 @@ | |||
| 1 | /* | ||
| 2 | * Copyright (c) 1997, 2006, Oracle and/or its affiliates. All rights reserved. | ||
| 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 | ||
| 7 | * published by the Free Software Foundation. Oracle designates this | ||
| 8 | * particular file as subject to the "Classpath" exception as provided | ||
| 9 | * by Oracle in the LICENSE file that accompanied this code. | ||
| 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 | * | ||
| 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. | ||
| 24 | */ | ||
| 25 | |||
| 26 | /* | ||
| 27 | * @author Charlton Innovations, Inc. | ||
| 28 | */ | ||
| 29 | |||
| 30 | package sun.java2d.loops; | ||
| 31 | |||
| 32 | import java.util.Comparator; | ||
| 33 | import java.util.Arrays; | ||
| 34 | import sun.java2d.SunGraphics2D; | ||
| 35 | |||
| 36 | /** | ||
| 37 | * GraphicsComponentMgr provides services to | ||
| 38 | * 1. register primitives for later use | ||
| 39 | * 2. locate an instance of a primitve based on characteristics | ||
| 40 | */ | ||
| 41 | public final class GraphicsPrimitiveMgr { | ||
| 42 | |||
| 43 | private static final boolean debugTrace = false; | ||
| 44 | private static GraphicsPrimitive primitives[]; | ||
| 45 | private static GraphicsPrimitive generalPrimitives[]; | ||
| 46 | private static boolean needssort = true; | ||
| 47 | |||
| 48 | private static native void initIDs(Class GP, Class ST, Class CT, | ||
| 49 | Class SG2D, Class Color, Class AT, | ||
| 50 | Class XORComp, Class AlphaComp, | ||
| 51 | Class Path2D, Class Path2DFloat, | ||
| 52 | Class SHints); | ||
| 53 | private static native void registerNativeLoops(); | ||
| 54 | |||
| 55 | static { | ||
| 56 | initIDs(GraphicsPrimitive.class, | ||
| 57 | SurfaceType.class, | ||
| 58 | CompositeType.class, | ||
| 59 | SunGraphics2D.class, | ||
| 60 | java.awt.Color.class, | ||
| 61 | java.awt.geom.AffineTransform.class, | ||
| 62 | XORComposite.class, | ||
| 63 | java.awt.AlphaComposite.class, | ||
| 64 | java.awt.geom.Path2D.class, | ||
| 65 | java.awt.geom.Path2D.Float.class, | ||
| 66 | sun.awt.SunHints.class); | ||
| 67 | CustomComponent.register(); | ||
| 68 | GeneralRenderer.register(); | ||
| 69 | registerNativeLoops(); | ||
| 70 | } | ||
| 71 | |||
| 72 | private static class PrimitiveSpec { | ||
| 73 | public int uniqueID; | ||
| 74 | } | ||
| 75 | |||
| 76 | private static Comparator primSorter = new Comparator() { | ||
| 77 | public int compare(Object o1, Object o2) { | ||
| 78 | int id1 = ((GraphicsPrimitive) o1).getUniqueID(); | ||
| 79 | int id2 = ((GraphicsPrimitive) o2).getUniqueID(); | ||
| 80 | |||
| 81 | return (id1 == id2 ? 0 : (id1 < id2 ? -1 : 1)); | ||
| 82 | } | ||
| 83 | }; | ||
| 84 | |||
| 85 | private static Comparator primFinder = new Comparator() { | ||
| 86 | public int compare(Object o1, Object o2) { | ||
| 87 | int id1 = ((GraphicsPrimitive) o1).getUniqueID(); | ||
| 88 | int id2 = ((PrimitiveSpec) o2).uniqueID; | ||
| 89 | |||
| 90 | return (id1 == id2 ? 0 : (id1 < id2 ? -1 : 1)); | ||
| 91 | } | ||
| 92 | }; | ||
| 93 | |||
| 94 | /** | ||
| 95 | * Ensure that noone can instantiate this class. | ||
| 96 | */ | ||
| 97 | private GraphicsPrimitiveMgr() { | ||
| 98 | } | ||
| 99 | |||
| 100 | public synchronized static void register(GraphicsPrimitive[] newPrimitives) | ||
| 101 | { | ||
| 102 | GraphicsPrimitive[] devCollection = primitives; | ||
| 103 | int oldSize = 0; | ||
| 104 | int newSize = newPrimitives.length; | ||
| 105 | if (debugTrace) { | ||
| 106 | writeLog("Registering " + newSize + " primitives"); | ||
| 107 | for (int i = 0; i < newSize; i++) { | ||
| 108 | writeLog(newPrimitives[i].toString()); | ||
| 109 | } | ||
| 110 | } | ||
| 111 | if (devCollection != null) { | ||
| 112 | oldSize = devCollection.length; | ||
| 113 | } | ||
| 114 | GraphicsPrimitive[] temp = new GraphicsPrimitive[oldSize + newSize]; | ||
| 115 | if (devCollection != null) { | ||
| 116 | System.arraycopy(devCollection, 0, temp, 0, oldSize); | ||
| 117 | } | ||
| 118 | System.arraycopy(newPrimitives, 0, temp, oldSize, newSize); | ||
| 119 | needssort = true; | ||
| 120 | primitives = temp; | ||
| 121 | } | ||
| 122 | |||
| 123 | public synchronized static void registerGeneral(GraphicsPrimitive gen) { | ||
| 124 | if (generalPrimitives == null) { | ||
| 125 | generalPrimitives = new GraphicsPrimitive[] {gen}; | ||
| 126 | return; | ||
| 127 | } | ||
| 128 | int len = generalPrimitives.length; | ||
| 129 | GraphicsPrimitive[] newGen = new GraphicsPrimitive[len + 1]; | ||
| 130 | System.arraycopy(generalPrimitives, 0, newGen, 0, len); | ||
| 131 | newGen[len] = gen; | ||
| 132 | generalPrimitives = newGen; | ||
| 133 | } | ||
| 134 | |||
| 135 | public synchronized static GraphicsPrimitive locate(int primTypeID, | ||
| 136 | SurfaceType dsttype) | ||
| 137 | { | ||
| 138 | return locate(primTypeID, | ||
| 139 | SurfaceType.OpaqueColor, | ||
| 140 | CompositeType.Src, | ||
| 141 | dsttype); | ||
| 142 | } | ||
| 143 | |||
| 144 | public synchronized static GraphicsPrimitive locate(int primTypeID, | ||
| 145 | SurfaceType srctype, | ||
| 146 | CompositeType comptype, | ||
| 147 | SurfaceType dsttype) | ||
| 148 | { | ||
| 149 | /* | ||
| 150 | System.out.println("Looking for:"); | ||
| 151 | System.out.println(" method: "+signature); | ||
| 152 | System.out.println(" from: "+srctype); | ||
| 153 | System.out.println(" by: "+comptype); | ||
| 154 | System.out.println(" to: "+dsttype); | ||
| 155 | */ | ||
| 156 | GraphicsPrimitive prim = locatePrim(primTypeID, | ||
| 157 | srctype, comptype, dsttype); | ||
| 158 | |||
| 159 | if (prim == null) { | ||
| 160 | //System.out.println("Trying general loop"); | ||
| 161 | prim = locateGeneral(primTypeID); | ||
| 162 | if (prim != null) { | ||
| 163 | prim = prim.makePrimitive(srctype, comptype, dsttype); | ||
| 164 | if (prim != null && GraphicsPrimitive.traceflags != 0) { | ||
| 165 | prim = prim.traceWrap(); | ||
| 166 | } | ||
| 167 | } | ||
| 168 | } | ||
| 169 | return prim; | ||
| 170 | } | ||
| 171 | |||
| 172 | public synchronized static GraphicsPrimitive | ||
| 173 | locatePrim(int primTypeID, | ||
| 174 | SurfaceType srctype, | ||
| 175 | CompositeType comptype, | ||
| 176 | SurfaceType dsttype) | ||
| 177 | { | ||
| 178 | /* | ||
| 179 | System.out.println("Looking for:"); | ||
| 180 | System.out.println(" method: "+signature); | ||
| 181 | System.out.println(" from: "+srctype); | ||
| 182 | System.out.println(" by: "+comptype); | ||
| 183 | System.out.println(" to: "+dsttype); | ||
| 184 | */ | ||
| 185 | SurfaceType src, dst; | ||
| 186 | CompositeType cmp; | ||
| 187 | GraphicsPrimitive prim; | ||
| 188 | PrimitiveSpec spec = new PrimitiveSpec(); | ||
| 189 | |||
| 190 | for (dst = dsttype; dst != null; dst = dst.getSuperType()) { | ||
| 191 | for (src = srctype; src != null; src = src.getSuperType()) { | ||
| 192 | for (cmp = comptype; cmp != null; cmp = cmp.getSuperType()) { | ||
| 193 | /* | ||
| 194 | System.out.println("Trying:"); | ||
| 195 | System.out.println(" method: "+spec.methodSignature); | ||
| 196 | System.out.println(" from: "+spec.sourceType); | ||
| 197 | System.out.println(" by: "+spec.compType); | ||
| 198 | System.out.println(" to: "+spec.destType); | ||
| 199 | */ | ||
| 200 | |||
| 201 | spec.uniqueID = | ||
| 202 | GraphicsPrimitive.makeUniqueID(primTypeID, src, cmp, dst); | ||
| 203 | prim = locate(spec); | ||
| 204 | if (prim != null) { | ||
| 205 | //System.out.println("<GPMgr> Found: " + prim + " in " + i + " steps"); | ||
| 206 | return prim; | ||
| 207 | } | ||
| 208 | } | ||
| 209 | } | ||
| 210 | } | ||
| 211 | return null; | ||
| 212 | } | ||
| 213 | |||
| 214 | private static GraphicsPrimitive locateGeneral(int primTypeID) { | ||
| 215 | if (generalPrimitives == null) { | ||
| 216 | return null; | ||
| 217 | } | ||
| 218 | for (int i = 0; i < generalPrimitives.length; i++) { | ||
| 219 | GraphicsPrimitive prim = generalPrimitives[i]; | ||
| 220 | if (prim.getPrimTypeID() == primTypeID) { | ||
| 221 | return prim; | ||
| 222 | } | ||
| 223 | } | ||
| 224 | return null; | ||
| 225 | //throw new InternalError("No general handler registered for"+signature); | ||
| 226 | } | ||
| 227 | |||
| 228 | private static GraphicsPrimitive locate(PrimitiveSpec spec) { | ||
| 229 | if (needssort) { | ||
| 230 | if (GraphicsPrimitive.traceflags != 0) { | ||
| 231 | for (int i = 0; i < primitives.length; i++) { | ||
| 232 | primitives[i] = primitives[i].traceWrap(); | ||
| 233 | } | ||
| 234 | } | ||
| 235 | Arrays.sort(primitives, primSorter); | ||
| 236 | needssort = false; | ||
| 237 | } | ||
| 238 | GraphicsPrimitive[] devCollection = primitives; | ||
| 239 | if (devCollection == null) { | ||
| 240 | return null; | ||
| 241 | } | ||
| 242 | int index = Arrays.binarySearch(devCollection, spec, primFinder); | ||
| 243 | if (index >= 0) { | ||
| 244 | GraphicsPrimitive prim = devCollection[index]; | ||
| 245 | if (prim instanceof GraphicsPrimitiveProxy) { | ||
| 246 | prim = ((GraphicsPrimitiveProxy) prim).instantiate(); | ||
| 247 | devCollection[index] = prim; | ||
| 248 | if (debugTrace) { | ||
| 249 | writeLog("Instantiated graphics primitive " + prim); | ||
| 250 | } | ||
| 251 | } | ||
| 252 | if (debugTrace) { | ||
| 253 | writeLog("Lookup found[" + index + "]["+ prim + "]"); | ||
| 254 | } | ||
| 255 | return prim; | ||
| 256 | } | ||
| 257 | if (debugTrace) { | ||
| 258 | writeLog("Lookup found nothing for:"); | ||
| 259 | writeLog(" " + spec.uniqueID); | ||
| 260 | } | ||
| 261 | return null; | ||
| 262 | } | ||
| 263 | |||
| 264 | private static void writeLog(String str) { | ||
| 265 | if (debugTrace) { | ||
| 266 | System.err.println(str); | ||
| 267 | } | ||
| 268 | } | ||
| 269 | |||
| 270 | /** | ||
| 271 | * Test that all of the GraphicsPrimitiveProxy objects actually | ||
| 272 | * resolve to something. Throws a RuntimeException if anything | ||
| 273 | * is wrong, an has no effect if all is well. | ||
| 274 | */ | ||
| 275 | // This is only really meant to be called from GraphicsPrimitiveProxyTest | ||
| 276 | // in the regression tests directory, but it has to be here because | ||
| 277 | // it needs access to a private data structure. It is not very | ||
| 278 | // big, though. | ||
| 279 | public static void testPrimitiveInstantiation() { | ||
| 280 | testPrimitiveInstantiation(false); | ||
| 281 | } | ||
| 282 | |||
| 283 | public static void testPrimitiveInstantiation(boolean verbose) { | ||
| 284 | int resolved = 0; | ||
| 285 | int unresolved = 0; | ||
| 286 | GraphicsPrimitive[] prims = primitives; | ||
| 287 | for (int j = 0; j < prims.length; j++) { | ||
| 288 | GraphicsPrimitive p = prims[j]; | ||
| 289 | if (p instanceof GraphicsPrimitiveProxy) { | ||
| 290 | GraphicsPrimitive r = ((GraphicsPrimitiveProxy) p).instantiate(); | ||
| 291 | if (!r.getSignature().equals(p.getSignature()) || | ||
| 292 | r.getUniqueID() != p.getUniqueID()) { | ||
| 293 | System.out.println("r.getSignature == "+r.getSignature()); | ||
| 294 | System.out.println("r.getUniqueID == " + r.getUniqueID()); | ||
| 295 | System.out.println("p.getSignature == "+p.getSignature()); | ||
| 296 | System.out.println("p.getUniqueID == " + p.getUniqueID()); | ||
| 297 | throw new RuntimeException("Primitive " + p | ||
| 298 | + " returns wrong signature for " | ||
| 299 | + r.getClass()); | ||
| 300 | } | ||
| 301 | // instantiate checks that p.satisfiesSameAs(r) | ||
| 302 | unresolved++; | ||
| 303 | p = r; | ||
| 304 | if (verbose) { | ||
| 305 | System.out.println(p); | ||
| 306 | } | ||
| 307 | } else { | ||
| 308 | if (verbose) { | ||
| 309 | System.out.println(p + " (not proxied)."); | ||
| 310 | } | ||
| 311 | resolved++; | ||
| 312 | } | ||
| 313 | } | ||
| 314 | System.out.println(resolved+ | ||
| 315 | " graphics primitives were not proxied."); | ||
| 316 | System.out.println(unresolved+ | ||
| 317 | " proxied graphics primitives resolved correctly."); | ||
| 318 | System.out.println(resolved+unresolved+ | ||
| 319 | " total graphics primitives"); | ||
| 320 | } | ||
| 321 | |||
| 322 | public static void main(String argv[]) { | ||
| 323 | // REMIND: Should trigger loading of platform primitives somehow... | ||
| 324 | if (needssort) { | ||
| 325 | Arrays.sort(primitives, primSorter); | ||
| 326 | needssort = false; | ||
| 327 | } | ||
| 328 | testPrimitiveInstantiation(argv.length > 0); | ||
| 329 | } | ||
| 330 | } | ||
Binary file not shown.
| @@ -0,0 +1,114 @@ | |||
| 1 | /* | ||
| 2 | * Copyright (c) 1998, 2003, Oracle and/or its affiliates. All rights reserved. | ||
| 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 | ||
| 7 | * published by the Free Software Foundation. Oracle designates this | ||
| 8 | * particular file as subject to the "Classpath" exception as provided | ||
| 9 | * by Oracle in the LICENSE file that accompanied this code. | ||
| 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 | * | ||
| 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. | ||
| 24 | */ | ||
| 25 | |||
| 26 | package sun.java2d.loops; | ||
| 27 | |||
| 28 | /** | ||
| 29 | * GraphicsPrimitiveProxy | ||
| 30 | * | ||
| 31 | * Acts as a proxy for instances of GraphicsPrimitive, enabling lazy | ||
| 32 | * classloading of these primitives. This leads to a substantial | ||
| 33 | * savings in start-up time and footprint. In the typical case, | ||
| 34 | * it has been found that a small number of GraphicsPrimitive instance | ||
| 35 | * actually end up getting instantiated. | ||
| 36 | * <p> | ||
| 37 | * Note that the makePrimitive method should never be invoked on | ||
| 38 | * a GraphicsPrimitiveProxy object since they are instantiated as | ||
| 39 | * soon as they are found in the primitive list and never returned | ||
| 40 | * to the caller. | ||
| 41 | */ | ||
| 42 | public class GraphicsPrimitiveProxy extends GraphicsPrimitive { | ||
| 43 | |||
| 44 | private Class owner; | ||
| 45 | private String relativeClassName; | ||
| 46 | |||
| 47 | /** | ||
| 48 | * Create a GraphicsPrimitiveProxy for a primitive with a no-argument | ||
| 49 | * constructor. | ||
| 50 | * | ||
| 51 | * @param owner The owner class for this primitive. The primitive | ||
| 52 | * must be in the same package as this owner. | ||
| 53 | * @param relativeClassName The name of the class this is a proxy for. | ||
| 54 | * This should not include the package. | ||
| 55 | */ | ||
| 56 | public GraphicsPrimitiveProxy(Class owner, String relativeClassName, | ||
| 57 | String methodSignature, | ||
| 58 | int primID, | ||
| 59 | SurfaceType srctype, | ||
| 60 | CompositeType comptype, | ||
| 61 | SurfaceType dsttype) | ||
| 62 | { | ||
| 63 | super(methodSignature, primID, srctype, comptype, dsttype); | ||
| 64 | this.owner = owner; | ||
| 65 | this.relativeClassName = relativeClassName; | ||
| 66 | } | ||
| 67 | |||
| 68 | public GraphicsPrimitive makePrimitive(SurfaceType srctype, | ||
| 69 | CompositeType comptype, | ||
| 70 | SurfaceType dsttype) { | ||
| 71 | // This should never happen. | ||
| 72 | throw new InternalError("makePrimitive called on a Proxy!"); | ||
| 73 | } | ||
| 74 | |||
| 75 | // | ||
| 76 | // Come up with the real instance. Called from | ||
| 77 | // GraphicsPrimitiveMgr.locate() | ||
| 78 | // | ||
| 79 | GraphicsPrimitive instantiate() { | ||
| 80 | String name = getPackageName(owner.getName()) + "." | ||
| 81 | + relativeClassName; | ||
| 82 | try { | ||
| 83 | Class clazz = Class.forName(name); | ||
| 84 | GraphicsPrimitive p = (GraphicsPrimitive) clazz.newInstance(); | ||
| 85 | if (!satisfiesSameAs(p)) { | ||
| 86 | throw new RuntimeException("Primitive " + p | ||
| 87 | + " incompatible with proxy for " | ||
| 88 | + name); | ||
| 89 | } | ||
| 90 | return p; | ||
| 91 | } catch (ClassNotFoundException ex) { | ||
| 92 | throw new RuntimeException(ex.toString()); | ||
| 93 | } catch (InstantiationException ex) { | ||
| 94 | throw new RuntimeException(ex.toString()); | ||
| 95 | } catch (IllegalAccessException ex) { | ||
| 96 | throw new RuntimeException(ex.toString()); | ||
| 97 | } | ||
| 98 | // A RuntimeException should never happen in a deployed JDK, because | ||
| 99 | // the regression test GraphicsPrimitiveProxyTest will catch any | ||
| 100 | // of these errors. | ||
| 101 | } | ||
| 102 | |||
| 103 | private static String getPackageName(String className) { | ||
| 104 | int lastDotIdx = className.lastIndexOf('.'); | ||
| 105 | if (lastDotIdx < 0) { | ||
| 106 | return className; | ||
| 107 | } | ||
| 108 | return className.substring(0, lastDotIdx); | ||
| 109 | } | ||
| 110 | |||
| 111 | public GraphicsPrimitive traceWrap() { | ||
| 112 | return instantiate().traceWrap(); | ||
| 113 | } | ||
| 114 | } | ||
Binary file not shown.
Binary file not shown.
Binary file not shown.
| @@ -0,0 +1,264 @@ | |||
| 1 | /* | ||
| 2 | * Copyright (c) 1999, 2004, Oracle and/or its affiliates. All rights reserved. | ||
| 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 | ||
| 7 | * published by the Free Software Foundation. Oracle designates this | ||
| 8 | * particular file as subject to the "Classpath" exception as provided | ||
| 9 | * by Oracle in the LICENSE file that accompanied this code. | ||
| 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 | * | ||
| 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. | ||
| 24 | */ | ||
| 25 | |||
| 26 | package sun.java2d.loops; | ||
| 27 | |||
| 28 | import java.awt.Composite; | ||
| 29 | import java.lang.ref.WeakReference; | ||
| 30 | import sun.java2d.loops.GraphicsPrimitive; | ||
| 31 | import sun.java2d.SurfaceData; | ||
| 32 | import sun.java2d.pipe.Region; | ||
| 33 | |||
| 34 | /** | ||
| 35 | * MaskBlit | ||
| 36 | * 1) copies rectangle of pixels from one surface to another | ||
| 37 | * 2) performs compositing of colors based upon a Composite | ||
| 38 | * parameter | ||
| 39 | * 3) blends result of composite with destination using an | ||
| 40 | * alpha coverage mask | ||
| 41 | * 4) the mask may be null in which case it should be treated | ||
| 42 | * as if it were an array of all opaque values (0xff) | ||
| 43 | * | ||
| 44 | * precise behavior is undefined if the source surface | ||
| 45 | * and the destination surface are the same surface | ||
| 46 | * with overlapping regions of pixels | ||
| 47 | */ | ||
| 48 | |||
| 49 | public class MaskBlit extends GraphicsPrimitive | ||
| 50 | { | ||
| 51 | public static final String methodSignature = "MaskBlit(...)".toString(); | ||
| 52 | |||
| 53 | public static final int primTypeID = makePrimTypeID(); | ||
| 54 | |||
| 55 | private static RenderCache blitcache = new RenderCache(20); | ||
| 56 | |||
| 57 | public static MaskBlit locate(SurfaceType srctype, | ||
| 58 | CompositeType comptype, | ||
| 59 | SurfaceType dsttype) | ||
| 60 | { | ||
| 61 | return (MaskBlit) | ||
| 62 | GraphicsPrimitiveMgr.locate(primTypeID, | ||
| 63 | srctype, comptype, dsttype); | ||
| 64 | } | ||
| 65 | |||
| 66 | public static MaskBlit getFromCache(SurfaceType src, | ||
| 67 | CompositeType comp, | ||
| 68 | SurfaceType dst) | ||
| 69 | { | ||
| 70 | Object o = blitcache.get(src, comp, dst); | ||
| 71 | if (o != null) { | ||
| 72 | return (MaskBlit) o; | ||
| 73 | } | ||
| 74 | MaskBlit blit = locate(src, comp, dst); | ||
| 75 | if (blit == null) { | ||
| 76 | System.out.println("mask blit loop not found for:"); | ||
| 77 | System.out.println("src: "+src); | ||
| 78 | System.out.println("comp: "+comp); | ||
| 79 | System.out.println("dst: "+dst); | ||
| 80 | } else { | ||
| 81 | blitcache.put(src, comp, dst, blit); | ||
| 82 | } | ||
| 83 | return blit; | ||
| 84 | } | ||
| 85 | |||
| 86 | protected MaskBlit(SurfaceType srctype, | ||
| 87 | CompositeType comptype, | ||
| 88 | SurfaceType dsttype) | ||
| 89 | { | ||
| 90 | super(methodSignature, primTypeID, srctype, comptype, dsttype); | ||
| 91 | } | ||
| 92 | |||
| 93 | public MaskBlit(long pNativePrim, | ||
| 94 | SurfaceType srctype, | ||
| 95 | CompositeType comptype, | ||
| 96 | SurfaceType dsttype) | ||
| 97 | { | ||
| 98 | super(pNativePrim, methodSignature, primTypeID, srctype, comptype, dsttype); | ||
| 99 | } | ||
| 100 | |||
| 101 | /** | ||
| 102 | * All MaskBlit implementors must have this invoker method | ||
| 103 | */ | ||
| 104 | public native void MaskBlit(SurfaceData src, SurfaceData dst, | ||
| 105 | Composite comp, Region clip, | ||
| 106 | int srcx, int srcy, | ||
| 107 | int dstx, int dsty, | ||
| 108 | int width, int height, | ||
| 109 | byte[] mask, int maskoff, int maskscan); | ||
| 110 | |||
| 111 | static { | ||
| 112 | GraphicsPrimitiveMgr.registerGeneral(new MaskBlit(null, null, null)); | ||
| 113 | } | ||
| 114 | |||
| 115 | public GraphicsPrimitive makePrimitive(SurfaceType srctype, | ||
| 116 | CompositeType comptype, | ||
| 117 | SurfaceType dsttype) | ||
| 118 | { | ||
| 119 | /* | ||
| 120 | new Throwable().printStackTrace(); | ||
| 121 | System.out.println("Constructing general maskblit for:"); | ||
| 122 | System.out.println("src: "+srctype); | ||
| 123 | System.out.println("comp: "+comptype); | ||
| 124 | System.out.println("dst: "+dsttype); | ||
| 125 | */ | ||
| 126 | |||
| 127 | if (CompositeType.Xor.equals(comptype)) { | ||
| 128 | throw new InternalError("Cannot construct MaskBlit for " + | ||
| 129 | "XOR mode"); | ||
| 130 | } | ||
| 131 | |||
| 132 | General ob = new General(srctype, comptype, dsttype); | ||
| 133 | setupGeneralBinaryOp(ob); | ||
| 134 | return ob; | ||
| 135 | } | ||
| 136 | |||
| 137 | private static class General | ||
| 138 | extends MaskBlit | ||
| 139 | implements GeneralBinaryOp | ||
| 140 | { | ||
| 141 | Blit convertsrc; | ||
| 142 | Blit convertdst; | ||
| 143 | MaskBlit performop; | ||
| 144 | Blit convertresult; | ||
| 145 | |||
| 146 | WeakReference srcTmp; | ||
| 147 | WeakReference dstTmp; | ||
| 148 | |||
| 149 | public General(SurfaceType srctype, | ||
| 150 | CompositeType comptype, | ||
| 151 | SurfaceType dsttype) | ||
| 152 | { | ||
| 153 | super(srctype, comptype, dsttype); | ||
| 154 | } | ||
| 155 | |||
| 156 | public void setPrimitives(Blit srcconverter, | ||
| 157 | Blit dstconverter, | ||
| 158 | GraphicsPrimitive genericop, | ||
| 159 | Blit resconverter) | ||
| 160 | { | ||
| 161 | this.convertsrc = srcconverter; | ||
| 162 | this.convertdst = dstconverter; | ||
| 163 | this.performop = (MaskBlit) genericop; | ||
| 164 | this.convertresult = resconverter; | ||
| 165 | } | ||
| 166 | |||
| 167 | public synchronized void MaskBlit(SurfaceData srcData, | ||
| 168 | SurfaceData dstData, | ||
| 169 | Composite comp, | ||
| 170 | Region clip, | ||
| 171 | int srcx, int srcy, | ||
| 172 | int dstx, int dsty, | ||
| 173 | int width, int height, | ||
| 174 | byte mask[], int offset, int scan) | ||
| 175 | { | ||
| 176 | SurfaceData src, dst; | ||
| 177 | Region opclip; | ||
| 178 | int sx, sy, dx, dy; | ||
| 179 | |||
| 180 | if (convertsrc == null) { | ||
| 181 | src = srcData; | ||
| 182 | sx = srcx; | ||
| 183 | sy = srcy; | ||
| 184 | } else { | ||
| 185 | SurfaceData cachedSrc = null; | ||
| 186 | if (srcTmp != null) { | ||
| 187 | cachedSrc = (SurfaceData) srcTmp.get(); | ||
| 188 | } | ||
| 189 | src = convertFrom(convertsrc, srcData, srcx, srcy, | ||
| 190 | width, height, cachedSrc); | ||
| 191 | sx = 0; | ||
| 192 | sy = 0; | ||
| 193 | if (src != cachedSrc) { | ||
| 194 | srcTmp = new WeakReference(src); | ||
| 195 | } | ||
| 196 | } | ||
| 197 | |||
| 198 | if (convertdst == null) { | ||
| 199 | dst = dstData; | ||
| 200 | dx = dstx; | ||
| 201 | dy = dsty; | ||
| 202 | opclip = clip; | ||
| 203 | } else { | ||
| 204 | // assert: convertresult != null | ||
| 205 | SurfaceData cachedDst = null; | ||
| 206 | if (dstTmp != null) { | ||
| 207 | cachedDst = (SurfaceData) dstTmp.get(); | ||
| 208 | } | ||
| 209 | dst = convertFrom(convertdst, dstData, dstx, dsty, | ||
| 210 | width, height, cachedDst); | ||
| 211 | dx = 0; | ||
| 212 | dy = 0; | ||
| 213 | opclip = null; | ||
| 214 | if (dst != cachedDst) { | ||
| 215 | dstTmp = new WeakReference(dst); | ||
| 216 | } | ||
| 217 | } | ||
| 218 | |||
| 219 | performop.MaskBlit(src, dst, comp, opclip, | ||
| 220 | sx, sy, dx, dy, width, height, | ||
| 221 | mask, offset, scan); | ||
| 222 | |||
| 223 | if (convertresult != null) { | ||
| 224 | // assert: convertdst != null | ||
| 225 | convertTo(convertresult, dst, dstData, clip, | ||
| 226 | dstx, dsty, width, height); | ||
| 227 | } | ||
| 228 | } | ||
| 229 | } | ||
| 230 | |||
| 231 | public GraphicsPrimitive traceWrap() { | ||
| 232 | return new TraceMaskBlit(this); | ||
| 233 | } | ||
| 234 | |||
| 235 | private static class TraceMaskBlit extends MaskBlit { | ||
| 236 | MaskBlit target; | ||
| 237 | |||
| 238 | public TraceMaskBlit(MaskBlit target) { | ||
| 239 | // We need to have the same NativePrim as our | ||
| 240 | // target in case we are used with a TransformHelper | ||
| 241 | super(target.getNativePrim(), | ||
| 242 | target.getSourceType(), | ||
| 243 | target.getCompositeType(), | ||
| 244 | target.getDestType()); | ||
| 245 | this.target = target; | ||
| 246 | } | ||
| 247 | |||
| 248 | public GraphicsPrimitive traceWrap() { | ||
| 249 | return this; | ||
| 250 | } | ||
| 251 | |||
| 252 | public void MaskBlit(SurfaceData src, SurfaceData dst, | ||
| 253 | Composite comp, Region clip, | ||
| 254 | int srcx, int srcy, int dstx, int dsty, | ||
| 255 | int width, int height, | ||
| 256 | byte[] mask, int maskoff, int maskscan) | ||
| 257 | { | ||
| 258 | tracePrimitive(target); | ||
| 259 | target.MaskBlit(src, dst, comp, clip, | ||
| 260 | srcx, srcy, dstx, dsty, width, height, | ||
| 261 | mask, maskoff, maskscan); | ||
| 262 | } | ||
| 263 | } | ||
| 264 | } | ||
Binary file not shown.
Binary file not shown.
Binary file not shown.
| @@ -0,0 +1,273 @@ | |||
| 1 | /* | ||
| 2 | * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved. | ||
| 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 | ||
| 7 | * published by the Free Software Foundation. Oracle designates this | ||
| 8 | * particular file as subject to the "Classpath" exception as provided | ||
| 9 | * by Oracle in the LICENSE file that accompanied this code. | ||
| 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 | * | ||
| 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. | ||
| 24 | */ | ||
| 25 | |||
| 26 | package sun.java2d.loops; | ||
| 27 | |||
| 28 | import java.awt.Paint; | ||
| 29 | import java.awt.PaintContext; | ||
| 30 | import java.awt.Composite; | ||
| 31 | import java.awt.Rectangle; | ||
| 32 | import java.awt.image.ColorModel; | ||
| 33 | import java.awt.image.BufferedImage; | ||
| 34 | import java.awt.image.WritableRaster; | ||
| 35 | import sun.awt.image.BufImgSurfaceData; | ||
| 36 | import sun.java2d.loops.GraphicsPrimitive; | ||
| 37 | import sun.java2d.SunGraphics2D; | ||
| 38 | import sun.java2d.SurfaceData; | ||
| 39 | |||
| 40 | /** | ||
| 41 | * MaskFill | ||
| 42 | * 1) fills rectangles of pixels on a surface | ||
| 43 | * 2) performs compositing of colors based upon a Composite | ||
| 44 | * parameter | ||
| 45 | * 3) blends result of composite with destination using an | ||
| 46 | * alpha coverage mask | ||
| 47 | * 4) the mask may be null in which case it should be treated | ||
| 48 | * as if it were an array of all opaque values (0xff) | ||
| 49 | */ | ||
| 50 | public class MaskFill extends GraphicsPrimitive | ||
| 51 | { | ||
| 52 | public static final String methodSignature = "MaskFill(...)".toString(); | ||
| 53 | public static final String fillPgramSignature = | ||
| 54 | "FillAAPgram(...)".toString(); | ||
| 55 | public static final String drawPgramSignature = | ||
| 56 | "DrawAAPgram(...)".toString(); | ||
| 57 | |||
| 58 | public static final int primTypeID = makePrimTypeID(); | ||
| 59 | |||
| 60 | private static RenderCache fillcache = new RenderCache(10); | ||
| 61 | |||
| 62 | public static MaskFill locate(SurfaceType srctype, | ||
| 63 | CompositeType comptype, | ||
| 64 | SurfaceType dsttype) | ||
| 65 | { | ||
| 66 | return (MaskFill) | ||
| 67 | GraphicsPrimitiveMgr.locate(primTypeID, | ||
| 68 | srctype, comptype, dsttype); | ||
| 69 | } | ||
| 70 | |||
| 71 | public static MaskFill locatePrim(SurfaceType srctype, | ||
| 72 | CompositeType comptype, | ||
| 73 | SurfaceType dsttype) | ||
| 74 | { | ||
| 75 | return (MaskFill) | ||
| 76 | GraphicsPrimitiveMgr.locatePrim(primTypeID, | ||
| 77 | srctype, comptype, dsttype); | ||
| 78 | } | ||
| 79 | |||
| 80 | /* | ||
| 81 | * Note that this uses locatePrim, not locate, so it can return | ||
| 82 | * null if there is no specific loop to handle this op... | ||
| 83 | */ | ||
| 84 | public static MaskFill getFromCache(SurfaceType src, | ||
| 85 | CompositeType comp, | ||
| 86 | SurfaceType dst) | ||
| 87 | { | ||
| 88 | Object o = fillcache.get(src, comp, dst); | ||
| 89 | if (o != null) { | ||
| 90 | return (MaskFill) o; | ||
| 91 | } | ||
| 92 | MaskFill fill = locatePrim(src, comp, dst); | ||
| 93 | if (fill != null) { | ||
| 94 | fillcache.put(src, comp, dst, fill); | ||
| 95 | } | ||
| 96 | return fill; | ||
| 97 | } | ||
| 98 | |||
| 99 | protected MaskFill(String alternateSignature, | ||
| 100 | SurfaceType srctype, | ||
| 101 | CompositeType comptype, | ||
| 102 | SurfaceType dsttype) | ||
| 103 | { | ||
| 104 | super(alternateSignature, primTypeID, srctype, comptype, dsttype); | ||
| 105 | } | ||
| 106 | |||
| 107 | protected MaskFill(SurfaceType srctype, | ||
| 108 | CompositeType comptype, | ||
| 109 | SurfaceType dsttype) | ||
| 110 | { | ||
| 111 | super(methodSignature, primTypeID, srctype, comptype, dsttype); | ||
| 112 | } | ||
| 113 | |||
| 114 | public MaskFill(long pNativePrim, | ||
| 115 | SurfaceType srctype, | ||
| 116 | CompositeType comptype, | ||
| 117 | SurfaceType dsttype) | ||
| 118 | { | ||
| 119 | super(pNativePrim, methodSignature, primTypeID, srctype, comptype, dsttype); | ||
| 120 | } | ||
| 121 | |||
| 122 | /** | ||
| 123 | * All MaskFill implementors must have this invoker method | ||
| 124 | */ | ||
| 125 | public native void MaskFill(SunGraphics2D sg2d, SurfaceData sData, | ||
| 126 | Composite comp, | ||
| 127 | int x, int y, int w, int h, | ||
| 128 | byte[] mask, int maskoff, int maskscan); | ||
| 129 | |||
| 130 | public native void FillAAPgram(SunGraphics2D sg2d, SurfaceData sData, | ||
| 131 | Composite comp, | ||
| 132 | double x, double y, | ||
| 133 | double dx1, double dy1, | ||
| 134 | double dx2, double dy2); | ||
| 135 | |||
| 136 | public native void DrawAAPgram(SunGraphics2D sg2d, SurfaceData sData, | ||
| 137 | Composite comp, | ||
| 138 | double x, double y, | ||
| 139 | double dx1, double dy1, | ||
| 140 | double dx2, double dy2, | ||
| 141 | double lw1, double lw2); | ||
| 142 | |||
| 143 | public boolean canDoParallelograms() { | ||
| 144 | return (getNativePrim() != 0); | ||
| 145 | } | ||
| 146 | |||
| 147 | static { | ||
| 148 | GraphicsPrimitiveMgr.registerGeneral(new MaskFill(null, null, null)); | ||
| 149 | } | ||
| 150 | |||
| 151 | public GraphicsPrimitive makePrimitive(SurfaceType srctype, | ||
| 152 | CompositeType comptype, | ||
| 153 | SurfaceType dsttype) | ||
| 154 | { | ||
| 155 | if (SurfaceType.OpaqueColor.equals(srctype) || | ||
| 156 | SurfaceType.AnyColor.equals(srctype)) | ||
| 157 | { | ||
| 158 | if (CompositeType.Xor.equals(comptype)) { | ||
| 159 | throw new InternalError("Cannot construct MaskFill for " + | ||
| 160 | "XOR mode"); | ||
| 161 | } else { | ||
| 162 | return new General(srctype, comptype, dsttype); | ||
| 163 | } | ||
| 164 | } else { | ||
| 165 | throw new InternalError("MaskFill can only fill with colors"); | ||
| 166 | } | ||
| 167 | } | ||
| 168 | |||
| 169 | private static class General extends MaskFill { | ||
| 170 | FillRect fillop; | ||
| 171 | MaskBlit maskop; | ||
| 172 | |||
| 173 | public General(SurfaceType srctype, | ||
| 174 | CompositeType comptype, | ||
| 175 | SurfaceType dsttype) | ||
| 176 | { | ||
| 177 | super(srctype, comptype, dsttype); | ||
| 178 | fillop = FillRect.locate(srctype, | ||
| 179 | CompositeType.SrcNoEa, | ||
| 180 | SurfaceType.IntArgb); | ||
| 181 | maskop = MaskBlit.locate(SurfaceType.IntArgb, comptype, dsttype); | ||
| 182 | } | ||
| 183 | |||
| 184 | public void MaskFill(SunGraphics2D sg2d, | ||
| 185 | SurfaceData sData, | ||
| 186 | Composite comp, | ||
| 187 | int x, int y, int w, int h, | ||
| 188 | byte mask[], int offset, int scan) | ||
| 189 | { | ||
| 190 | BufferedImage dstBI = | ||
| 191 | new BufferedImage(w, h, BufferedImage.TYPE_INT_ARGB); | ||
| 192 | SurfaceData tmpData = BufImgSurfaceData.createData(dstBI); | ||
| 193 | |||
| 194 | // REMIND: This is not pretty. It would be nicer if we | ||
| 195 | // passed a "FillData" object to the Pixel loops, instead | ||
| 196 | // of a SunGraphics2D parameter... | ||
| 197 | int pixel = sg2d.pixel; | ||
| 198 | sg2d.pixel = tmpData.pixelFor(sg2d.getColor()); | ||
| 199 | fillop.FillRect(sg2d, tmpData, 0, 0, w, h); | ||
| 200 | sg2d.pixel = pixel; | ||
| 201 | |||
| 202 | maskop.MaskBlit(tmpData, sData, comp, null, | ||
| 203 | 0, 0, x, y, w, h, | ||
| 204 | mask, offset, scan); | ||
| 205 | } | ||
| 206 | } | ||
| 207 | |||
| 208 | public GraphicsPrimitive traceWrap() { | ||
| 209 | return new TraceMaskFill(this); | ||
| 210 | } | ||
| 211 | |||
| 212 | private static class TraceMaskFill extends MaskFill { | ||
| 213 | MaskFill target; | ||
| 214 | MaskFill fillPgramTarget; | ||
| 215 | MaskFill drawPgramTarget; | ||
| 216 | |||
| 217 | public TraceMaskFill(MaskFill target) { | ||
| 218 | super(target.getSourceType(), | ||
| 219 | target.getCompositeType(), | ||
| 220 | target.getDestType()); | ||
| 221 | this.target = target; | ||
| 222 | this.fillPgramTarget = new MaskFill(fillPgramSignature, | ||
| 223 | target.getSourceType(), | ||
| 224 | target.getCompositeType(), | ||
| 225 | target.getDestType()); | ||
| 226 | this.drawPgramTarget = new MaskFill(drawPgramSignature, | ||
| 227 | target.getSourceType(), | ||
| 228 | target.getCompositeType(), | ||
| 229 | target.getDestType()); | ||
| 230 | } | ||
| 231 | |||
| 232 | public GraphicsPrimitive traceWrap() { | ||
| 233 | return this; | ||
| 234 | } | ||
| 235 | |||
| 236 | public void MaskFill(SunGraphics2D sg2d, SurfaceData sData, | ||
| 237 | Composite comp, | ||
| 238 | int x, int y, int w, int h, | ||
| 239 | byte[] mask, int maskoff, int maskscan) | ||
| 240 | { | ||
| 241 | tracePrimitive(target); | ||
| 242 | target.MaskFill(sg2d, sData, comp, x, y, w, h, | ||
| 243 | mask, maskoff, maskscan); | ||
| 244 | } | ||
| 245 | |||
| 246 | public void FillAAPgram(SunGraphics2D sg2d, SurfaceData sData, | ||
| 247 | Composite comp, | ||
| 248 | double x, double y, | ||
| 249 | double dx1, double dy1, | ||
| 250 | double dx2, double dy2) | ||
| 251 | { | ||
| 252 | tracePrimitive(fillPgramTarget); | ||
| 253 | target.FillAAPgram(sg2d, sData, comp, | ||
| 254 | x, y, dx1, dy1, dx2, dy2); | ||
| 255 | } | ||
| 256 | |||
| 257 | public void DrawAAPgram(SunGraphics2D sg2d, SurfaceData sData, | ||
| 258 | Composite comp, | ||
| 259 | double x, double y, | ||
| 260 | double dx1, double dy1, | ||
| 261 | double dx2, double dy2, | ||
| 262 | double lw1, double lw2) | ||
| 263 | { | ||
| 264 | tracePrimitive(drawPgramTarget); | ||
| 265 | target.DrawAAPgram(sg2d, sData, comp, | ||
| 266 | x, y, dx1, dy1, dx2, dy2, lw1, lw2); | ||
| 267 | } | ||
| 268 | |||
| 269 | public boolean canDoParallelograms() { | ||
| 270 | return target.canDoParallelograms(); | ||
| 271 | } | ||
| 272 | } | ||
| 273 | } | ||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
| @@ -0,0 +1,2128 @@ | |||
| 1 | /* | ||
| 2 | * Copyright (c) 2005, 2006, Oracle and/or its affiliates. All rights reserved. | ||
| 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 | ||
| 7 | * published by the Free Software Foundation. Oracle designates this | ||
| 8 | * particular file as subject to the "Classpath" exception as provided | ||
| 9 | * by Oracle in the LICENSE file that accompanied this code. | ||
| 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 | * | ||
| 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. | ||
| 24 | */ | ||
| 25 | |||
| 26 | package sun.java2d.loops; | ||
| 27 | |||
| 28 | import java.awt.geom.Path2D; | ||
| 29 | import java.awt.geom.PathIterator; | ||
| 30 | import java.awt.geom.QuadCurve2D; | ||
| 31 | import sun.awt.SunHints; | ||
| 32 | import java.util.*; | ||
| 33 | |||
| 34 | /* This is the java implementation of the native code from | ||
| 35 | * src/share/native/sun/java2d/loops/ProcessPath.[c,h] | ||
| 36 | * This code is written to be as much similar to the native | ||
| 37 | * as it possible. So, it sometimes does not follow java naming conventions. | ||
| 38 | * | ||
| 39 | * It's important to keep this code synchronized with native one. See more | ||
| 40 | * comments, description and high level scheme of the rendering process in the | ||
| 41 | * ProcessPath.c | ||
| 42 | */ | ||
| 43 | |||
| 44 | public class ProcessPath { | ||
| 45 | |||
| 46 | /* Public interfaces and methods for drawing and filling general paths */ | ||
| 47 | |||
| 48 | public static abstract class DrawHandler { | ||
| 49 | public int xMin; | ||
| 50 | public int yMin; | ||
| 51 | public int xMax; | ||
| 52 | public int yMax; | ||
| 53 | public float xMinf; | ||
| 54 | public float yMinf; | ||
| 55 | public float xMaxf; | ||
| 56 | public float yMaxf; | ||
| 57 | |||
| 58 | public int strokeControl; | ||
| 59 | |||
| 60 | public DrawHandler(int xMin, int yMin, int xMax, int yMax, | ||
| 61 | int strokeControl) | ||
| 62 | { | ||
| 63 | setBounds(xMin, yMin, xMax, yMax, strokeControl); | ||
| 64 | } | ||
| 65 | |||
| 66 | public void setBounds(int xMin, int yMin, int xMax, int yMax) | ||
| 67 | { | ||
| 68 | this.xMin = xMin; | ||
| 69 | this.yMin = yMin; | ||
| 70 | this.xMax = xMax; | ||
| 71 | this.yMax = yMax; | ||
| 72 | |||
| 73 | /* Setting up fractional clipping box | ||
| 74 | * | ||
| 75 | * We are using following float -> int mapping: | ||
| 76 | * | ||
| 77 | * xi = floor(xf + 0.5) | ||
| 78 | * | ||
| 79 | * So, fractional values that hit the [xmin, xmax) integer interval | ||
| 80 | * will be situated inside the [xmin-0.5, xmax - 0.5) fractional | ||
| 81 | * interval. We are using EPSF constant to provide that upper | ||
| 82 | * boundary is not included. | ||
| 83 | */ | ||
| 84 | xMinf = xMin - 0.5f; | ||
| 85 | yMinf = yMin - 0.5f; | ||
| 86 | xMaxf = xMax - 0.5f - EPSF; | ||
| 87 | yMaxf = yMax - 0.5f - EPSF; | ||
| 88 | } | ||
| 89 | |||
| 90 | public void setBounds(int xMin, int yMin, int xMax, int yMax, | ||
| 91 | int strokeControl) | ||
| 92 | { | ||
| 93 | this.strokeControl = strokeControl; | ||
| 94 | setBounds(xMin, yMin, xMax, yMax); | ||
| 95 | } | ||
| 96 | |||
| 97 | public void adjustBounds(int bxMin, int byMin, int bxMax, int byMax) | ||
| 98 | { | ||
| 99 | if (xMin > bxMin) bxMin = xMin; | ||
| 100 | if (xMax < bxMax) bxMax = xMax; | ||
| 101 | if (yMin > byMin) byMin = yMin; | ||
| 102 | if (yMax < byMax) byMax = yMax; | ||
| 103 | setBounds(bxMin, byMin, bxMax, byMax); | ||
| 104 | } | ||
| 105 | |||
| 106 | public DrawHandler(int xMin, int yMin, int xMax, int yMax) { | ||
| 107 | this(xMin, yMin, xMax, yMax, SunHints.INTVAL_STROKE_DEFAULT); | ||
| 108 | } | ||
| 109 | |||
| 110 | public abstract void drawLine(int x0, int y0, int x1, int y1); | ||
| 111 | |||
| 112 | public abstract void drawPixel(int x0, int y0); | ||
| 113 | |||
| 114 | public abstract void drawScanline(int x0, int x1, int y0); | ||
| 115 | } | ||
| 116 | |||
| 117 | public interface EndSubPathHandler { | ||
| 118 | public void processEndSubPath(); | ||
| 119 | } | ||
| 120 | |||
| 121 | public static final int PH_MODE_DRAW_CLIP = 0; | ||
| 122 | public static final int PH_MODE_FILL_CLIP = 1; | ||
| 123 | |||
| 124 | public static abstract class ProcessHandler implements EndSubPathHandler { | ||
| 125 | DrawHandler dhnd; | ||
| 126 | int clipMode; | ||
| 127 | |||
| 128 | public ProcessHandler(DrawHandler dhnd, | ||
| 129 | int clipMode) { | ||
| 130 | this.dhnd = dhnd; | ||
| 131 | this.clipMode = clipMode; | ||
| 132 | } | ||
| 133 | |||
| 134 | public abstract void processFixedLine(int x1, int y1, | ||
| 135 | int x2, int y2, int [] pixelInfo, | ||
| 136 | boolean checkBounds, | ||
| 137 | boolean endSubPath); | ||
| 138 | } | ||
| 139 | |||
| 140 | public static EndSubPathHandler noopEndSubPathHandler = | ||
| 141 | new EndSubPathHandler() { | ||
| 142 | public void processEndSubPath() { } | ||
| 143 | }; | ||
| 144 | |||
| 145 | public static boolean fillPath(DrawHandler dhnd, Path2D.Float p2df, | ||
| 146 | int transX, int transY) | ||
| 147 | { | ||
| 148 | FillProcessHandler fhnd = new FillProcessHandler(dhnd); | ||
| 149 | if (!doProcessPath(fhnd, p2df, transX, transY)) { | ||
| 150 | return false; | ||
| 151 | } | ||
| 152 | FillPolygon(fhnd, p2df.getWindingRule()); | ||
| 153 | return true; | ||
| 154 | } | ||
| 155 | |||
| 156 | public static boolean drawPath(DrawHandler dhnd, | ||
| 157 | EndSubPathHandler endSubPath, | ||
| 158 | Path2D.Float p2df, | ||
| 159 | int transX, int transY) | ||
| 160 | { | ||
| 161 | return doProcessPath(new DrawProcessHandler(dhnd, endSubPath), | ||
| 162 | p2df, transX, transY); | ||
| 163 | } | ||
| 164 | |||
| 165 | public static boolean drawPath(DrawHandler dhnd, | ||
| 166 | Path2D.Float p2df, | ||
| 167 | int transX, int transY) | ||
| 168 | { | ||
| 169 | return doProcessPath(new DrawProcessHandler(dhnd, | ||
| 170 | noopEndSubPathHandler), | ||
| 171 | p2df, transX, transY); | ||
| 172 | } | ||
| 173 | |||
| 174 | /* Private implementation of the rendering process */ | ||
| 175 | |||
| 176 | /* Boundaries used for skipping huge path segments */ | ||
| 177 | private static final float UPPER_BND = Float.MAX_VALUE/4.0f; | ||
| 178 | private static final float LOWER_BND = -UPPER_BND; | ||
| 179 | |||
| 180 | /* Precision (in bits) used in forward differencing */ | ||
| 181 | private static final int FWD_PREC = 7; | ||
| 182 | |||
| 183 | /* Precision (in bits) used for the rounding in the midpoint test */ | ||
| 184 | private static final int MDP_PREC = 10; | ||
| 185 | |||
| 186 | private static final int MDP_MULT = 1 << MDP_PREC; | ||
| 187 | private static final int MDP_HALF_MULT = MDP_MULT >> 1; | ||
| 188 | |||
| 189 | /* Boundaries used for clipping large path segments (those are inside | ||
| 190 | * [UPPER/LOWER]_BND boundaries) | ||
| 191 | */ | ||
| 192 | private static final int UPPER_OUT_BND = 1 << (30 - MDP_PREC); | ||
| 193 | private static final int LOWER_OUT_BND = -UPPER_OUT_BND; | ||
| 194 | |||
| 195 | |||
| 196 | /* Calculation boundaries. They are used for switching to the more slow but | ||
| 197 | * allowing larger input values method of calculation of the initial values | ||
| 198 | * of the scan converted line segments inside the FillPolygon | ||
| 199 | */ | ||
| 200 | private static final float CALC_UBND = 1 << (30 - MDP_PREC); | ||
| 201 | private static final float CALC_LBND = -CALC_UBND; | ||
| 202 | |||
| 203 | |||
| 204 | /* Following constants are used for providing open boundaries of the | ||
| 205 | * intervals | ||
| 206 | */ | ||
| 207 | public static final int EPSFX = 1; | ||
| 208 | public static final float EPSF = ((float)EPSFX)/MDP_MULT; | ||
| 209 | |||
| 210 | /* Bit mask used to separate whole part from the fraction part of the | ||
| 211 | * number | ||
| 212 | */ | ||
| 213 | private static final int MDP_W_MASK = -MDP_MULT; | ||
| 214 | |||
| 215 | /* Bit mask used to separate fractional part from the whole part of the | ||
| 216 | * number | ||
| 217 | */ | ||
| 218 | private static final int MDP_F_MASK = MDP_MULT - 1; | ||
| 219 | |||
| 220 | /* | ||
| 221 | * Constants for the forward differencing | ||
| 222 | * of the cubic and quad curves | ||
| 223 | */ | ||
| 224 | |||
| 225 | /* Maximum size of the cubic curve (calculated as the size of the bounding | ||
| 226 | * box of the control points) which could be rendered without splitting | ||
| 227 | */ | ||
| 228 | private static final int MAX_CUB_SIZE = 256; | ||
| 229 | |||
| 230 | /* Maximum size of the quad curve (calculated as the size of the bounding | ||
| 231 | * box of the control points) which could be rendered without splitting | ||
| 232 | */ | ||
| 233 | private static final int MAX_QUAD_SIZE = 1024; | ||
| 234 | |||
| 235 | /* Default power of 2 steps used in the forward differencing. Here DF prefix | ||
| 236 | * stands for DeFault. Constants below are used as initial values for the | ||
| 237 | * adaptive forward differencing algorithm. | ||
| 238 | */ | ||
| 239 | private static final int DF_CUB_STEPS = 3; | ||
| 240 | private static final int DF_QUAD_STEPS = 2; | ||
| 241 | |||
| 242 | /* Shift of the current point of the curve for preparing to the midpoint | ||
| 243 | * rounding | ||
| 244 | */ | ||
| 245 | private static final int DF_CUB_SHIFT = FWD_PREC + DF_CUB_STEPS*3 - | ||
| 246 | MDP_PREC; | ||
| 247 | private static final int DF_QUAD_SHIFT = FWD_PREC + DF_QUAD_STEPS*2 - | ||
| 248 | MDP_PREC; | ||
| 249 | |||
| 250 | /* Default amount of steps of the forward differencing */ | ||
| 251 | private static final int DF_CUB_COUNT = (1<<DF_CUB_STEPS); | ||
| 252 | private static final int DF_QUAD_COUNT = (1<<DF_QUAD_STEPS); | ||
| 253 | |||
| 254 | /* Default boundary constants used to check the necessity of the restepping | ||
| 255 | */ | ||
| 256 | private static final int DF_CUB_DEC_BND = 1<<DF_CUB_STEPS*3 + FWD_PREC + 2; | ||
| 257 | private static final int DF_CUB_INC_BND = 1<<DF_CUB_STEPS*3 + FWD_PREC - 1; | ||
| 258 | private static final int DF_QUAD_DEC_BND = 1<<DF_QUAD_STEPS*2 + | ||
| 259 | FWD_PREC + 2; | ||
| 260 | private static final int DF_QUAD_INC_BND = 1<<DF_QUAD_STEPS*2 + | ||
| 261 | FWD_PREC - 1; | ||
| 262 | |||
| 263 | /* Multipliers for the coefficients of the polynomial form of the cubic and | ||
| 264 | * quad curves representation | ||
| 265 | */ | ||
| 266 | private static final int CUB_A_SHIFT = FWD_PREC; | ||
| 267 | private static final int CUB_B_SHIFT = (DF_CUB_STEPS + FWD_PREC + 1); | ||
| 268 | private static final int CUB_C_SHIFT = (DF_CUB_STEPS*2 + FWD_PREC); | ||
| 269 | |||
| 270 | private static final int CUB_A_MDP_MULT = (1<<CUB_A_SHIFT); | ||
| 271 | private static final int CUB_B_MDP_MULT = (1<<CUB_B_SHIFT); | ||
| 272 | private static final int CUB_C_MDP_MULT = (1<<CUB_C_SHIFT); | ||
| 273 | |||
| 274 | private static final int QUAD_A_SHIFT = FWD_PREC; | ||
| 275 | private static final int QUAD_B_SHIFT = (DF_QUAD_STEPS + FWD_PREC); | ||
| 276 | |||
| 277 | private static final int QUAD_A_MDP_MULT = (1<<QUAD_A_SHIFT); | ||
| 278 | private static final int QUAD_B_MDP_MULT = (1<<QUAD_B_SHIFT); | ||
| 279 | |||
| 280 | /* Clipping macros for drawing and filling algorithms */ | ||
| 281 | private static float CLIP(float a1, float b1, float a2, float b2, | ||
| 282 | double t) { | ||
| 283 | return (float)(b1 + (double)(t - a1)*(b2 - b1) / (a2 - a1)); | ||
| 284 | } | ||
| 285 | |||
| 286 | private static int CLIP(int a1, int b1, int a2, int b2, double t) { | ||
| 287 | return (int)(b1 + (double)(t - a1)*(b2 - b1) / (a2 - a1)); | ||
| 288 | } | ||
| 289 | |||
| 290 | |||
| 291 | private static final int CRES_MIN_CLIPPED = 0; | ||
| 292 | private static final int CRES_MAX_CLIPPED = 1; | ||
| 293 | private static final int CRES_NOT_CLIPPED = 3; | ||
| 294 | private static final int CRES_INVISIBLE = 4; | ||
| 295 | |||
| 296 | private static boolean IS_CLIPPED(int res) { | ||
| 297 | return res == CRES_MIN_CLIPPED || res == CRES_MAX_CLIPPED; | ||
| 298 | } | ||
| 299 | |||
| 300 | /* This is java implementation of the macro from ProcessGeneralPath.c. | ||
| 301 | * To keep the logic of the java code similar to the native one | ||
| 302 | * array and set of indexes are used to point out the data. | ||
| 303 | */ | ||
| 304 | private static int TESTANDCLIP(float LINE_MIN, float LINE_MAX, float[] c, | ||
| 305 | int a1, int b1, int a2, int b2) { | ||
| 306 | double t; | ||
| 307 | int res = CRES_NOT_CLIPPED; | ||
| 308 | if (c[a1] < (LINE_MIN) || c[a1] > (LINE_MAX)) { | ||
| 309 | if (c[a1] < (LINE_MIN)) { | ||
| 310 | if (c[a2] < (LINE_MIN)) { | ||
| 311 | return CRES_INVISIBLE; | ||
| 312 | }; | ||
| 313 | res = CRES_MIN_CLIPPED; | ||
| 314 | t = (LINE_MIN); | ||
| 315 | } else { | ||
| 316 | if (c[a2] > (LINE_MAX)) { | ||
| 317 | return CRES_INVISIBLE; | ||
| 318 | }; | ||
| 319 | res = CRES_MAX_CLIPPED; | ||
| 320 | t = (LINE_MAX); | ||
| 321 | } | ||
| 322 | c[b1] = CLIP(c[a1], c[b1], c[a2], c[b2], t); | ||
| 323 | c[a1] = (float)t; | ||
| 324 | } | ||
| 325 | return res; | ||
| 326 | } | ||
| 327 | |||
| 328 | /* Integer version of the method above */ | ||
| 329 | private static int TESTANDCLIP(int LINE_MIN, int LINE_MAX, int[] c, | ||
| 330 | int a1, int b1, int a2, int b2) { | ||
| 331 | double t; | ||
| 332 | int res = CRES_NOT_CLIPPED; | ||
| 333 | if (c[a1] < (LINE_MIN) || c[a1] > (LINE_MAX)) { | ||
| 334 | if (c[a1] < (LINE_MIN)) { | ||
| 335 | if (c[a2] < (LINE_MIN)) { | ||
| 336 | return CRES_INVISIBLE; | ||
| 337 | }; | ||
| 338 | res = CRES_MIN_CLIPPED; | ||
| 339 | t = (LINE_MIN); | ||
| 340 | } else { | ||
| 341 | if (c[a2] > (LINE_MAX)) { | ||
| 342 | return CRES_INVISIBLE; | ||
| 343 | }; | ||
| 344 | res = CRES_MAX_CLIPPED; | ||
| 345 | t = (LINE_MAX); | ||
| 346 | } | ||
| 347 | c[b1] = CLIP(c[a1], c[b1], c[a2], c[b2], t); | ||
| 348 | c[a1] = (int)t; | ||
| 349 | } | ||
| 350 | return res; | ||
| 351 | } | ||
| 352 | |||
| 353 | |||
| 354 | |||
| 355 | /* Following method is used for clipping and clumping filled shapes. | ||
| 356 | * An example of this process is shown on the picture below: | ||
| 357 | * ----+ ----+ | ||
| 358 | * |/ | |/ | | ||
| 359 | * + | + | | ||
| 360 | * /| | I | | ||
| 361 | * / | | I | | ||
| 362 | * | | | ===> I | | ||
| 363 | * \ | | I | | ||
| 364 | * \| | I | | ||
| 365 | * + | + | | ||
| 366 | * |\ | |\ | | ||
| 367 | * | ----+ | ----+ | ||
| 368 | * boundary boundary | ||
| 369 | * | ||
| 370 | * We can only perform clipping in case of right side of the output area | ||
| 371 | * because all segments passed out the right boundary don't influence on the | ||
| 372 | * result of scan conversion algorithm (it correctly handles half open | ||
| 373 | * contours). | ||
| 374 | * | ||
| 375 | * This is java implementation of the macro from ProcessGeneralPath.c. | ||
| 376 | * To keep the logic of the java code similar to the native one | ||
| 377 | * array and set of indexes are used to point out the data. | ||
| 378 | * | ||
| 379 | */ | ||
| 380 | private static int CLIPCLAMP(float LINE_MIN, float LINE_MAX, float[] c, | ||
| 381 | int a1, int b1, int a2, int b2, | ||
| 382 | int a3, int b3) { | ||
| 383 | c[a3] = c[a1]; | ||
| 384 | c[b3] = c[b1]; | ||
| 385 | int res = TESTANDCLIP(LINE_MIN, LINE_MAX, c, a1, b1, a2, b2); | ||
| 386 | if (res == CRES_MIN_CLIPPED) { | ||
| 387 | c[a3] = c[a1]; | ||
| 388 | } else if (res == CRES_MAX_CLIPPED) { | ||
| 389 | c[a3] = c[a1]; | ||
| 390 | res = CRES_MAX_CLIPPED; | ||
| 391 | } else if (res == CRES_INVISIBLE) { | ||
| 392 | if (c[a1] > LINE_MAX) { | ||
| 393 | res = CRES_INVISIBLE; | ||
| 394 | } else { | ||
| 395 | c[a1] = LINE_MIN; | ||
| 396 | c[a2] = LINE_MIN; | ||
| 397 | res = CRES_NOT_CLIPPED; | ||
| 398 | } | ||
| 399 | } | ||
| 400 | return res; | ||
| 401 | } | ||
| 402 | |||
| 403 | /* Integer version of the method above */ | ||
| 404 | private static int CLIPCLAMP(int LINE_MIN, int LINE_MAX, int[] c, | ||
| 405 | int a1, int b1, int a2, int b2, | ||
| 406 | int a3, int b3) { | ||
| 407 | c[a3] = c[a1]; | ||
| 408 | c[b3] = c[b1]; | ||
| 409 | int res = TESTANDCLIP(LINE_MIN, LINE_MAX, c, a1, b1, a2, b2); | ||
| 410 | if (res == CRES_MIN_CLIPPED) { | ||
| 411 | c[a3] = c[a1]; | ||
| 412 | } else if (res == CRES_MAX_CLIPPED) { | ||
| 413 | c[a3] = c[a1]; | ||
| 414 | res = CRES_MAX_CLIPPED; | ||
| 415 | } else if (res == CRES_INVISIBLE) { | ||
| 416 | if (c[a1] > LINE_MAX) { | ||
| 417 | res = CRES_INVISIBLE; | ||
| 418 | } else { | ||
| 419 | c[a1] = LINE_MIN; | ||
| 420 | c[a2] = LINE_MIN; | ||
| 421 | res = CRES_NOT_CLIPPED; | ||
| 422 | } | ||
| 423 | } | ||
| 424 | return res; | ||
| 425 | } | ||
| 426 | |||
| 427 | private static class DrawProcessHandler extends ProcessHandler { | ||
| 428 | |||
| 429 | EndSubPathHandler processESP; | ||
| 430 | |||
| 431 | public DrawProcessHandler(DrawHandler dhnd, | ||
| 432 | EndSubPathHandler processESP) { | ||
| 433 | super(dhnd, PH_MODE_DRAW_CLIP); | ||
| 434 | this.dhnd = dhnd; | ||
| 435 | this.processESP = processESP; | ||
| 436 | } | ||
| 437 | |||
| 438 | public void processEndSubPath() { | ||
| 439 | processESP.processEndSubPath(); | ||
| 440 | } | ||
| 441 | |||
| 442 | void PROCESS_LINE(int fX0, int fY0, int fX1, int fY1, | ||
| 443 | boolean checkBounds, int[] pixelInfo) { | ||
| 444 | int X0 = fX0 >> MDP_PREC; | ||
| 445 | int Y0 = fY0 >> MDP_PREC; | ||
| 446 | int X1 = fX1 >> MDP_PREC; | ||
| 447 | int Y1 = fY1 >> MDP_PREC; | ||
| 448 | |||
| 449 | /* Handling lines having just one pixel */ | ||
| 450 | if (((X0^X1) | (Y0^Y1)) == 0) { | ||
| 451 | if (checkBounds && | ||
| 452 | (dhnd.yMin > Y0 || | ||
| 453 | dhnd.yMax <= Y0 || | ||
| 454 | dhnd.xMin > X0 || | ||
| 455 | dhnd.xMax <= X0)) return; | ||
| 456 | |||
| 457 | if (pixelInfo[0] == 0) { | ||
| 458 | pixelInfo[0] = 1; | ||
| 459 | pixelInfo[1] = X0; | ||
| 460 | pixelInfo[2] = Y0; | ||
| 461 | pixelInfo[3] = X0; | ||
| 462 | pixelInfo[4] = Y0; | ||
| 463 | dhnd.drawPixel(X0, Y0); | ||
| 464 | } else if ((X0 != pixelInfo[3] || Y0 != pixelInfo[4]) && | ||
| 465 | (X0 != pixelInfo[1] || Y0 != pixelInfo[2])) { | ||
| 466 | dhnd.drawPixel(X0, Y0); | ||
| 467 | pixelInfo[3] = X0; | ||
| 468 | pixelInfo[4] = Y0; | ||
| 469 | } | ||
| 470 | return; | ||
| 471 | } | ||
| 472 | |||
| 473 | if (!checkBounds || | ||
| 474 | (dhnd.yMin <= Y0 && | ||
| 475 | dhnd.yMax > Y0 && | ||
| 476 | dhnd.xMin <= X0 && | ||
| 477 | dhnd.xMax > X0)) | ||
| 478 | { | ||
| 479 | /* Switch off first pixel of the line before drawing */ | ||
| 480 | if (pixelInfo[0] == 1 && | ||
| 481 | ((pixelInfo[1] == X0 && pixelInfo[2] == Y0) || | ||
| 482 | (pixelInfo[3] == X0 && pixelInfo[4] == Y0))) | ||
| 483 | { | ||
| 484 | dhnd.drawPixel(X0, Y0); | ||
| 485 | } | ||
| 486 | } | ||
| 487 | |||
| 488 | dhnd.drawLine(X0, Y0, X1, Y1); | ||
| 489 | |||
| 490 | if (pixelInfo[0] == 0) { | ||
| 491 | pixelInfo[0] = 1; | ||
| 492 | pixelInfo[1] = X0; | ||
| 493 | pixelInfo[2] = Y0; | ||
| 494 | pixelInfo[3] = X0; | ||
| 495 | pixelInfo[4] = Y0; | ||
| 496 | } | ||
| 497 | |||
| 498 | /* Switch on last pixel of the line if it was already | ||
| 499 | * drawn during rendering of the previous segments | ||
| 500 | */ | ||
| 501 | if ((pixelInfo[1] == X1 && pixelInfo[2] == Y1) || | ||
| 502 | (pixelInfo[3] == X1 && pixelInfo[4] == Y1)) | ||
| 503 | { | ||
| 504 | if (checkBounds && | ||
| 505 | (dhnd.yMin > Y1 || | ||
| 506 | dhnd.yMax <= Y1 || | ||
| 507 | dhnd.xMin > X1 || | ||
| 508 | dhnd.xMax <= X1)) { | ||
| 509 | return; | ||
| 510 | } | ||
| 511 | |||
| 512 | dhnd.drawPixel(X1, Y1); | ||
| 513 | } | ||
| 514 | pixelInfo[3] = X1; | ||
| 515 | pixelInfo[4] = Y1; | ||
| 516 | } | ||
| 517 | |||
| 518 | void PROCESS_POINT(int fX, int fY, boolean checkBounds, | ||
| 519 | int[] pixelInfo) { | ||
| 520 | int _X = fX>> MDP_PREC; | ||
| 521 | int _Y = fY>> MDP_PREC; | ||
| 522 | if (checkBounds && | ||
| 523 | (dhnd.yMin > _Y || | ||
| 524 | dhnd.yMax <= _Y || | ||
| 525 | dhnd.xMin > _X || | ||
| 526 | dhnd.xMax <= _X)) return; | ||
| 527 | /* | ||
| 528 | * (_X,_Y) should be inside boundaries | ||
| 529 | * | ||
| 530 | * assert(dhnd.yMin <= _Y && | ||
| 531 | * dhnd.yMax > _Y && | ||
| 532 | * dhnd.xMin <= _X && | ||
| 533 | * dhnd.xMax > _X); | ||
| 534 | * | ||
| 535 | */ | ||
| 536 | if (pixelInfo[0] == 0) { | ||
| 537 | pixelInfo[0] = 1; | ||
| 538 | pixelInfo[1] = _X; | ||
| 539 | pixelInfo[2] = _Y; | ||
| 540 | pixelInfo[3] = _X; | ||
| 541 | pixelInfo[4] = _Y; | ||
| 542 | dhnd.drawPixel(_X, _Y); | ||
| 543 | } else if ((_X != pixelInfo[3] || _Y != pixelInfo[4]) && | ||
| 544 | (_X != pixelInfo[1] || _Y != pixelInfo[2])) { | ||
| 545 | dhnd.drawPixel(_X, _Y); | ||
| 546 | pixelInfo[3] = _X; | ||
| 547 | pixelInfo[4] = _Y; | ||
| 548 | } | ||
| 549 | } | ||
| 550 | |||
| 551 | /* Drawing line with subpixel endpoints | ||
| 552 | * | ||
| 553 | * (x1, y1), (x2, y2) - fixed point coordinates of the endpoints | ||
| 554 | * with MDP_PREC bits for the fractional part | ||
| 555 | * | ||
| 556 | * pixelInfo - structure which keeps drawing info for avoiding | ||
| 557 | * multiple drawing at the same position on the | ||
| 558 | * screen (required for the XOR mode of drawing) | ||
| 559 | * | ||
| 560 | * pixelInfo[0] - state of the drawing | ||
| 561 | * 0 - no pixel drawn between | ||
| 562 | * moveTo/close of the path | ||
| 563 | * 1 - there are drawn pixels | ||
| 564 | * | ||
| 565 | * pixelInfo[1,2] - first pixel of the path | ||
| 566 | * between moveTo/close of the | ||
| 567 | * path | ||
| 568 | * | ||
| 569 | * pixelInfo[3,4] - last drawn pixel between | ||
| 570 | * moveTo/close of the path | ||
| 571 | * | ||
| 572 | * checkBounds - flag showing necessity of checking the clip | ||
| 573 | * | ||
| 574 | */ | ||
| 575 | public void processFixedLine(int x1, int y1, int x2, int y2, | ||
| 576 | int[] pixelInfo, boolean checkBounds, | ||
| 577 | boolean endSubPath) { | ||
| 578 | |||
| 579 | /* Checking if line is inside a (X,Y),(X+MDP_MULT,Y+MDP_MULT) box */ | ||
| 580 | int c = ((x1 ^ x2) | (y1 ^ y2)); | ||
| 581 | int rx1, ry1, rx2, ry2; | ||
| 582 | if ((c & MDP_W_MASK) == 0) { | ||
| 583 | /* Checking for the segments with integer coordinates having | ||
| 584 | * the same start and end points | ||
| 585 | */ | ||
| 586 | if (c == 0) { | ||
| 587 | PROCESS_POINT(x1 + MDP_HALF_MULT, y1 + MDP_HALF_MULT, | ||
| 588 | checkBounds, pixelInfo); | ||
| 589 | } | ||
| 590 | return; | ||
| 591 | } | ||
| 592 | |||
| 593 | if (x1 == x2 || y1 == y2) { | ||
| 594 | rx1 = x1 + MDP_HALF_MULT; | ||
| 595 | rx2 = x2 + MDP_HALF_MULT; | ||
| 596 | ry1 = y1 + MDP_HALF_MULT; | ||
| 597 | ry2 = y2 + MDP_HALF_MULT; | ||
| 598 | } else { | ||
| 599 | /* Neither dx nor dy can be zero because of the check above */ | ||
| 600 | int dx = x2 - x1; | ||
| 601 | int dy = y2 - y1; | ||
| 602 | |||
| 603 | /* Floor of x1, y1, x2, y2 */ | ||
| 604 | int fx1 = x1 & MDP_W_MASK; | ||
| 605 | int fy1 = y1 & MDP_W_MASK; | ||
| 606 | int fx2 = x2 & MDP_W_MASK; | ||
| 607 | int fy2 = y2 & MDP_W_MASK; | ||
| 608 | |||
| 609 | /* Processing first endpoint */ | ||
| 610 | if (fx1 == x1 || fy1 == y1) { | ||
| 611 | /* Adding MDP_HALF_MULT to the [xy]1 if f[xy]1 == [xy]1 | ||
| 612 | * will not affect the result | ||
| 613 | */ | ||
| 614 | rx1 = x1 + MDP_HALF_MULT; | ||
| 615 | ry1 = y1 + MDP_HALF_MULT; | ||
| 616 | } else { | ||
| 617 | /* Boundary at the direction from (x1,y1) to (x2,y2) */ | ||
| 618 | int bx1 = (x1 < x2) ? fx1 + MDP_MULT : fx1; | ||
| 619 | int by1 = (y1 < y2) ? fy1 + MDP_MULT : fy1; | ||
| 620 | |||
| 621 | /* intersection with column bx1 */ | ||
| 622 | int cross = y1 + ((bx1 - x1)*dy)/dx; | ||
| 623 | if (cross >= fy1 && cross <= fy1 + MDP_MULT) { | ||
| 624 | rx1 = bx1; | ||
| 625 | ry1 = cross + MDP_HALF_MULT; | ||
| 626 | } else { | ||
| 627 | /* intersection with row by1 */ | ||
| 628 | cross = x1 + ((by1 - y1)*dx)/dy; | ||
| 629 | rx1 = cross + MDP_HALF_MULT; | ||
| 630 | ry1 = by1; | ||
| 631 | } | ||
| 632 | } | ||
| 633 | |||
| 634 | /* Processing second endpoint */ | ||
| 635 | if (fx2 == x2 || fy2 == y2) { | ||
| 636 | /* Adding MDP_HALF_MULT to the [xy]2 if f[xy]2 == [xy]2 | ||
| 637 | * will not affect the result | ||
| 638 | */ | ||
| 639 | rx2 = x2 + MDP_HALF_MULT; | ||
| 640 | ry2 = y2 + MDP_HALF_MULT; | ||
| 641 | } else { | ||
| 642 | /* Boundary at the direction from (x2,y2) to (x1,y1) */ | ||
| 643 | int bx2 = (x1 > x2) ? fx2 + MDP_MULT : fx2; | ||
| 644 | int by2 = (y1 > y2) ? fy2 + MDP_MULT : fy2; | ||
| 645 | |||
| 646 | /* intersection with column bx2 */ | ||
| 647 | int cross = y2 + ((bx2 - x2)*dy)/dx; | ||
| 648 | if (cross >= fy2 && cross <= fy2 + MDP_MULT) { | ||
| 649 | rx2 = bx2; | ||
| 650 | ry2 = cross + MDP_HALF_MULT; | ||
| 651 | } else { | ||
| 652 | /* intersection with row by2 */ | ||
| 653 | cross = x2 + ((by2 - y2)*dx)/dy; | ||
| 654 | rx2 = cross + MDP_HALF_MULT; | ||
| 655 | ry2 = by2; | ||
| 656 | } | ||
| 657 | } | ||
| 658 | } | ||
| 659 | PROCESS_LINE(rx1, ry1, rx2, ry2, checkBounds, pixelInfo); | ||
| 660 | } | ||
| 661 | } | ||
| 662 | |||
| 663 | /* Performing drawing of the monotonic in X and Y quadratic curves with | ||
| 664 | * sizes less than MAX_QUAD_SIZE by using forward differencing method of | ||
| 665 | * calculation. See comments to the DrawMonotonicQuad in the | ||
| 666 | * ProcessGeneralPath.c | ||
| 667 | */ | ||
| 668 | private static void DrawMonotonicQuad(ProcessHandler hnd, | ||
| 669 | float[] coords, | ||
| 670 | boolean checkBounds, | ||
| 671 | int[] pixelInfo) { | ||
| 672 | |||
| 673 | int x0 = (int)(coords[0]*MDP_MULT); | ||
| 674 | int y0 = (int)(coords[1]*MDP_MULT); | ||
| 675 | |||
| 676 | int xe = (int)(coords[4]*MDP_MULT); | ||
| 677 | int ye = (int)(coords[5]*MDP_MULT); | ||
| 678 | |||
| 679 | /* Extracting fractional part of coordinates of first control point */ | ||
| 680 | int px = (x0 & (~MDP_W_MASK)) << DF_QUAD_SHIFT; | ||
| 681 | int py = (y0 & (~MDP_W_MASK)) << DF_QUAD_SHIFT; | ||
| 682 | |||
| 683 | /* Setting default amount of steps */ | ||
| 684 | int count = DF_QUAD_COUNT; | ||
| 685 | |||
| 686 | /* Setting default shift for preparing to the midpoint rounding */ | ||
| 687 | int shift = DF_QUAD_SHIFT; | ||
| 688 | |||
| 689 | int ax = (int)((coords[0] - 2*coords[2] + | ||
| 690 | coords[4])*QUAD_A_MDP_MULT); | ||
| 691 | int ay = (int)((coords[1] - 2*coords[3] + | ||
| 692 | coords[5])*QUAD_A_MDP_MULT); | ||
| 693 | |||
| 694 | int bx = (int)((-2*coords[0] + 2*coords[2])*QUAD_B_MDP_MULT); | ||
| 695 | int by = (int)((-2*coords[1] + 2*coords[3])*QUAD_B_MDP_MULT); | ||
| 696 | |||
| 697 | int ddpx = 2*ax; | ||
| 698 | int ddpy = 2*ay; | ||
| 699 | |||
| 700 | int dpx = ax + bx; | ||
| 701 | int dpy = ay + by; | ||
| 702 | |||
| 703 | int x1, y1; | ||
| 704 | |||
| 705 | int x2 = x0; | ||
| 706 | int y2 = y0; | ||
| 707 | |||
| 708 | int maxDD = Math.max(Math.abs(ddpx),Math.abs(ddpy)); | ||
| 709 | |||
| 710 | int dx = xe - x0; | ||
| 711 | int dy = ye - y0; | ||
| 712 | |||
| 713 | int x0w = x0 & MDP_W_MASK; | ||
| 714 | int y0w = y0 & MDP_W_MASK; | ||
| 715 | |||
| 716 | /* Perform decreasing step in 2 times if slope of the first forward | ||
| 717 | * difference changes too quickly (more than a pixel per step in X or Y | ||
| 718 | * direction). We can perform adjusting of the step size before the | ||
| 719 | * rendering loop because the curvature of the quad curve remains the | ||
| 720 | * same along all the curve | ||
| 721 | */ | ||
| 722 | while (maxDD > DF_QUAD_DEC_BND) { | ||
| 723 | dpx = (dpx<<1) - ax; | ||
| 724 | dpy = (dpy<<1) - ay; | ||
| 725 | count <<= 1; | ||
| 726 | maxDD >>= 2; | ||
| 727 | px <<=2; | ||
| 728 | py <<=2; | ||
| 729 | shift += 2; | ||
| 730 | } | ||
| 731 | |||
| 732 | while(count-- > 1) { | ||
| 733 | px += dpx; | ||
| 734 | py += dpy; | ||
| 735 | |||
| 736 | dpx += ddpx; | ||
| 737 | dpy += ddpy; | ||
| 738 | |||
| 739 | x1 = x2; | ||
| 740 | y1 = y2; | ||
| 741 | |||
| 742 | x2 = x0w + (px >> shift); | ||
| 743 | y2 = y0w + (py >> shift); | ||
| 744 | |||
| 745 | /* Checking that we are not running out of the endpoint and bounding | ||
| 746 | * violating coordinate. The check is pretty simple because the | ||
| 747 | * curve passed to the DrawCubic already splitted into the | ||
| 748 | * monotonic in X and Y pieces | ||
| 749 | */ | ||
| 750 | |||
| 751 | /* Bounding x2 by xe */ | ||
| 752 | if (((xe-x2)^dx) < 0) { | ||
| 753 | x2 = xe; | ||
| 754 | } | ||
| 755 | |||
| 756 | /* Bounding y2 by ye */ | ||
| 757 | if (((ye-y2)^dy) < 0) { | ||
| 758 | y2 = ye; | ||
| 759 | } | ||
| 760 | |||
| 761 | hnd.processFixedLine(x1, y1, x2, y2, pixelInfo, checkBounds, false); | ||
| 762 | } | ||
| 763 | |||
| 764 | /* We are performing one step less than necessary and use actual | ||
| 765 | * (xe,ye) endpoint of the curve instead of calculated. This prevent us | ||
| 766 | * from running above the curve endpoint due to the accumulated errors | ||
| 767 | * during the iterations. | ||
| 768 | */ | ||
| 769 | |||
| 770 | hnd.processFixedLine(x2, y2, xe, ye, pixelInfo, checkBounds, false); | ||
| 771 | } | ||
| 772 | |||
| 773 | /* | ||
| 774 | * Checking size of the quad curves and split them if necessary. | ||
| 775 | * Calling DrawMonotonicQuad for the curves of the appropriate size. | ||
| 776 | * Note: coords array could be changed | ||
| 777 | */ | ||
| 778 | private static void ProcessMonotonicQuad(ProcessHandler hnd, | ||
| 779 | float[] coords, | ||
| 780 | int[] pixelInfo) { | ||
| 781 | |||
| 782 | float[] coords1 = new float[6]; | ||
| 783 | float tx, ty; | ||
| 784 | float xMin, yMin, xMax, yMax; | ||
| 785 | |||
| 786 | xMin = xMax = coords[0]; | ||
| 787 | yMin = yMax = coords[1]; | ||
| 788 | for (int i = 2; i < 6; i += 2) { | ||
| 789 | xMin = (xMin > coords[i])? coords[i] : xMin; | ||
| 790 | xMax = (xMax < coords[i])? coords[i] : xMax; | ||
| 791 | yMin = (yMin > coords[i + 1])? coords[i + 1] : yMin; | ||
| 792 | yMax = (yMax < coords[i + 1])? coords[i + 1] : yMax; | ||
| 793 | } | ||
| 794 | |||
| 795 | if (hnd.clipMode == PH_MODE_DRAW_CLIP) { | ||
| 796 | |||
| 797 | /* In case of drawing we could just skip curves which are | ||
| 798 | * completely out of bounds | ||
| 799 | */ | ||
| 800 | if (hnd.dhnd.xMaxf < xMin || hnd.dhnd.xMinf > xMax || | ||
| 801 | hnd.dhnd.yMaxf < yMin || hnd.dhnd.yMinf > yMax) { | ||
| 802 | return; | ||
| 803 | } | ||
| 804 | } else { | ||
| 805 | |||
| 806 | /* In case of filling we could skip curves which are above, | ||
| 807 | * below and behind the right boundary of the visible area | ||
| 808 | */ | ||
| 809 | |||
| 810 | if (hnd.dhnd.yMaxf < yMin || hnd.dhnd.yMinf > yMax || | ||
| 811 | hnd.dhnd.xMaxf < xMin) | ||
| 812 | { | ||
| 813 | return; | ||
| 814 | } | ||
| 815 | |||
| 816 | /* We could clamp x coordinates to the corresponding boundary | ||
| 817 | * if the curve is completely behind the left one | ||
| 818 | */ | ||
| 819 | |||
| 820 | if (hnd.dhnd.xMinf > xMax) { | ||
| 821 | coords[0] = coords[2] = coords[4] = hnd.dhnd.xMinf; | ||
| 822 | } | ||
| 823 | } | ||
| 824 | |||
| 825 | if (xMax - xMin > MAX_QUAD_SIZE || yMax - yMin > MAX_QUAD_SIZE) { | ||
| 826 | coords1[4] = coords[4]; | ||
| 827 | coords1[5] = coords[5]; | ||
| 828 | coords1[2] = (coords[2] + coords[4])/2.0f; | ||
| 829 | coords1[3] = (coords[3] + coords[5])/2.0f; | ||
| 830 | coords[2] = (coords[0] + coords[2])/2.0f; | ||
| 831 | coords[3] = (coords[1] + coords[3])/2.0f; | ||
| 832 | coords[4] = coords1[0] = (coords[2] + coords1[2])/2.0f; | ||
| 833 | coords[5] = coords1[1] = (coords[3] + coords1[3])/2.0f; | ||
| 834 | |||
| 835 | ProcessMonotonicQuad(hnd, coords, pixelInfo); | ||
| 836 | |||
| 837 | ProcessMonotonicQuad(hnd, coords1, pixelInfo); | ||
| 838 | } else { | ||
| 839 | DrawMonotonicQuad(hnd, coords, | ||
| 840 | /* Set checkBounds parameter if curve intersects | ||
| 841 | * boundary of the visible area. We know that the | ||
| 842 | * curve is visible, so the check is pretty | ||
| 843 | * simple | ||
| 844 | */ | ||
| 845 | hnd.dhnd.xMinf >= xMin || | ||
| 846 | hnd.dhnd.xMaxf <= xMax || | ||
| 847 | hnd.dhnd.yMinf >= yMin || | ||
| 848 | hnd.dhnd.yMaxf <= yMax, | ||
| 849 | pixelInfo); | ||
| 850 | } | ||
| 851 | } | ||
| 852 | |||
| 853 | /* | ||
| 854 | * Split quadratic curve into monotonic in X and Y parts. Calling | ||
| 855 | * ProcessMonotonicQuad for each monotonic piece of the curve. | ||
| 856 | * Note: coords array could be changed | ||
| 857 | */ | ||
| 858 | private static void ProcessQuad(ProcessHandler hnd, float[] coords, | ||
| 859 | int[] pixelInfo) { | ||
| 860 | /* Temporary array for holding parameters corresponding to the extreme | ||
| 861 | * in X and Y points | ||
| 862 | */ | ||
| 863 | double params[] = new double[2]; | ||
| 864 | int cnt = 0; | ||
| 865 | double param; | ||
| 866 | |||
| 867 | /* Simple check for monotonicity in X before searching for the extreme | ||
| 868 | * points of the X(t) function. We first check if the curve is | ||
| 869 | * monotonic in X by seeing if all of the X coordinates are strongly | ||
| 870 | * ordered. | ||
| 871 | */ | ||
| 872 | if ((coords[0] > coords[2] || coords[2] > coords[4]) && | ||
| 873 | (coords[0] < coords[2] || coords[2] < coords[4])) | ||
| 874 | { | ||
| 875 | /* Searching for extreme points of the X(t) function by solving | ||
| 876 | * dX(t) | ||
| 877 | * ---- = 0 equation | ||
| 878 | * dt | ||
| 879 | */ | ||
| 880 | double ax = coords[0] - 2*coords[2] + coords[4]; | ||
| 881 | if (ax != 0) { | ||
| 882 | /* Calculating root of the following equation | ||
| 883 | * ax*t + bx = 0 | ||
| 884 | */ | ||
| 885 | double bx = coords[0] - coords[2]; | ||
| 886 | |||
| 887 | param = bx/ax; | ||
| 888 | if (param < 1.0 && param > 0.0) { | ||
| 889 | params[cnt++] = param; | ||
| 890 | } | ||
| 891 | } | ||
| 892 | } | ||
| 893 | |||
| 894 | /* Simple check for monotonicity in Y before searching for the extreme | ||
| 895 | * points of the Y(t) function. We first check if the curve is | ||
| 896 | * monotonic in Y by seeing if all of the Y coordinates are strongly | ||
| 897 | * ordered. | ||
| 898 | */ | ||
| 899 | if ((coords[1] > coords[3] || coords[3] > coords[5]) && | ||
| 900 | (coords[1] < coords[3] || coords[3] < coords[5])) | ||
| 901 | { | ||
| 902 | /* Searching for extreme points of the Y(t) function by solving | ||
| 903 | * dY(t) | ||
| 904 | * ----- = 0 equation | ||
| 905 | * dt | ||
| 906 | */ | ||
| 907 | double ay = coords[1] - 2*coords[3] + coords[5]; | ||
| 908 | |||
| 909 | if (ay != 0) { | ||
| 910 | /* Calculating root of the following equation | ||
| 911 | * ay*t + by = 0 | ||
| 912 | */ | ||
| 913 | double by = coords[1] - coords[3]; | ||
| 914 | |||
| 915 | param = by/ay; | ||
| 916 | if (param < 1.0 && param > 0.0) { | ||
| 917 | if (cnt > 0) { | ||
| 918 | /* Inserting parameter only if it differs from | ||
| 919 | * already stored | ||
| 920 | */ | ||
| 921 | if (params[0] > param) { | ||
| 922 | params[cnt++] = params[0]; | ||
| 923 | params[0] = param; | ||
| 924 | } else if (params[0] < param) { | ||
| 925 | params[cnt++] = param; | ||
| 926 | } | ||
| 927 | } else { | ||
| 928 | params[cnt++] = param; | ||
| 929 | } | ||
| 930 | } | ||
| 931 | } | ||
| 932 | } | ||
| 933 | |||
| 934 | /* Processing obtained monotonic parts */ | ||
| 935 | switch(cnt) { | ||
| 936 | case 0: | ||
| 937 | break; | ||
| 938 | case 1: | ||
| 939 | ProcessFirstMonotonicPartOfQuad(hnd, coords, pixelInfo, | ||
| 940 | (float)params[0]); | ||
| 941 | break; | ||
| 942 | case 2: | ||
| 943 | ProcessFirstMonotonicPartOfQuad(hnd, coords, pixelInfo, | ||
| 944 | (float)params[0]); | ||
| 945 | param = params[1] - params[0]; | ||
| 946 | if (param > 0) { | ||
| 947 | ProcessFirstMonotonicPartOfQuad(hnd, coords, pixelInfo, | ||
| 948 | /* Scale parameter to match with | ||
| 949 | * rest of the curve | ||
| 950 | */ | ||
| 951 | (float)(param/(1.0 - params[0]))); | ||
| 952 | } | ||
| 953 | break; | ||
| 954 | } | ||
| 955 | |||
| 956 | ProcessMonotonicQuad(hnd,coords,pixelInfo); | ||
| 957 | } | ||
| 958 | |||
| 959 | /* | ||
| 960 | * Bite the piece of the quadratic curve from start point till the point | ||
| 961 | * corresponding to the specified parameter then call ProcessQuad for the | ||
| 962 | * bitten part. | ||
| 963 | * Note: coords array will be changed | ||
| 964 | */ | ||
| 965 | private static void ProcessFirstMonotonicPartOfQuad(ProcessHandler hnd, | ||
| 966 | float[] coords, | ||
| 967 | int[] pixelInfo, | ||
| 968 | float t) { | ||
| 969 | float[] coords1 = new float[6]; | ||
| 970 | |||
| 971 | coords1[0] = coords[0]; | ||
| 972 | coords1[1] = coords[1]; | ||
| 973 | coords1[2] = coords[0] + t*(coords[2] - coords[0]); | ||
| 974 | coords1[3] = coords[1] + t*(coords[3] - coords[1]); | ||
| 975 | coords[2] = coords[2] + t*(coords[4] - coords[2]); | ||
| 976 | coords[3] = coords[3] + t*(coords[5] - coords[3]); | ||
| 977 | coords[0] = coords1[4] = coords1[2] + t*(coords[2] - coords1[2]); | ||
| 978 | coords[1] = coords1[5] = coords1[3] + t*(coords[3] - coords1[3]); | ||
| 979 | |||
| 980 | ProcessMonotonicQuad(hnd, coords1, pixelInfo); | ||
| 981 | } | ||
| 982 | |||
| 983 | /* Performing drawing of the monotonic in X and Y cubic curves with sizes | ||
| 984 | * less than MAX_CUB_SIZE by using forward differencing method of | ||
| 985 | * calculation. See comments to the DrawMonotonicCubic in the | ||
| 986 | * ProcessGeneralPath.c | ||
| 987 | */ | ||
| 988 | private static void DrawMonotonicCubic(ProcessHandler hnd, | ||
| 989 | float[] coords, | ||
| 990 | boolean checkBounds, | ||
| 991 | int[] pixelInfo) { | ||
| 992 | int x0 = (int)(coords[0]*MDP_MULT); | ||
| 993 | int y0 = (int)(coords[1]*MDP_MULT); | ||
| 994 | |||
| 995 | int xe = (int)(coords[6]*MDP_MULT); | ||
| 996 | int ye = (int)(coords[7]*MDP_MULT); | ||
| 997 | |||
| 998 | /* Extracting fractional part of coordinates of first control point */ | ||
| 999 | int px = (x0 & (~MDP_W_MASK)) << DF_CUB_SHIFT; | ||
| 1000 | int py = (y0 & (~MDP_W_MASK)) << DF_CUB_SHIFT; | ||
| 1001 | |||
| 1002 | /* Setting default boundary values for checking first and second forward | ||
| 1003 | * difference for the necessity of the restepping. See comments to the | ||
| 1004 | * boundary values in ProcessQuad for more info. | ||
| 1005 | */ | ||
| 1006 | int incStepBnd = DF_CUB_INC_BND; | ||
| 1007 | int decStepBnd = DF_CUB_DEC_BND; | ||
| 1008 | |||
| 1009 | /* Setting default amount of steps */ | ||
| 1010 | int count = DF_CUB_COUNT; | ||
| 1011 | |||
| 1012 | /* Setting default shift for preparing to the midpoint rounding */ | ||
| 1013 | int shift = DF_CUB_SHIFT; | ||
| 1014 | |||
| 1015 | int ax = (int)((-coords[0] + 3*coords[2] - 3*coords[4] + | ||
| 1016 | coords[6])*CUB_A_MDP_MULT); | ||
| 1017 | int ay = (int)((-coords[1] + 3*coords[3] - 3*coords[5] + | ||
| 1018 | coords[7])*CUB_A_MDP_MULT); | ||
| 1019 | |||
| 1020 | int bx = (int)((3*coords[0] - 6*coords[2] + | ||
| 1021 | 3*coords[4])*CUB_B_MDP_MULT); | ||
| 1022 | int by = (int)((3*coords[1] - 6*coords[3] + | ||
| 1023 | 3*coords[5])*CUB_B_MDP_MULT); | ||
| 1024 | |||
| 1025 | int cx = (int)((-3*coords[0] + 3*coords[2])*(CUB_C_MDP_MULT)); | ||
| 1026 | int cy = (int)((-3*coords[1] + 3*coords[3])*(CUB_C_MDP_MULT)); | ||
| 1027 | |||
| 1028 | int dddpx = 6*ax; | ||
| 1029 | int dddpy = 6*ay; | ||
| 1030 | |||
| 1031 | int ddpx = dddpx + bx; | ||
| 1032 | int ddpy = dddpy + by; | ||
| 1033 | |||
| 1034 | int dpx = ax + (bx>>1) + cx; | ||
| 1035 | int dpy = ay + (by>>1) + cy; | ||
| 1036 | |||
| 1037 | int x1, y1; | ||
| 1038 | |||
| 1039 | int x2 = x0; | ||
| 1040 | int y2 = y0; | ||
| 1041 | |||
| 1042 | /* Calculating whole part of the first point of the curve */ | ||
| 1043 | int x0w = x0 & MDP_W_MASK; | ||
| 1044 | int y0w = y0 & MDP_W_MASK; | ||
| 1045 | |||
| 1046 | int dx = xe - x0; | ||
| 1047 | int dy = ye - y0; | ||
| 1048 | |||
| 1049 | while (count > 0) { | ||
| 1050 | /* Perform decreasing step in 2 times if necessary */ | ||
| 1051 | while (Math.abs(ddpx) > decStepBnd || | ||
| 1052 | Math.abs(ddpy) > decStepBnd) { | ||
| 1053 | ddpx = (ddpx<<1) - dddpx; | ||
| 1054 | ddpy = (ddpy<<1) - dddpy; | ||
| 1055 | dpx = (dpx<<2) - (ddpx>>1); | ||
| 1056 | dpy = (dpy<<2) - (ddpy>>1); | ||
| 1057 | count <<=1; | ||
| 1058 | decStepBnd <<=3; | ||
| 1059 | incStepBnd <<=3; | ||
| 1060 | px <<=3; | ||
| 1061 | py <<=3; | ||
| 1062 | shift += 3; | ||
| 1063 | } | ||
| 1064 | |||
| 1065 | /* Perform increasing step in 2 times if necessary. | ||
| 1066 | * Note: we could do it only in even steps | ||
| 1067 | */ | ||
| 1068 | |||
| 1069 | while ((count & 1) == 0 && shift > DF_CUB_SHIFT && | ||
| 1070 | Math.abs(dpx) <= incStepBnd && | ||
| 1071 | Math.abs(dpy) <= incStepBnd) { | ||
| 1072 | dpx = (dpx>>2) + (ddpx>>3); | ||
| 1073 | dpy = (dpy>>2) + (ddpy>>3); | ||
| 1074 | ddpx = (ddpx + dddpx)>>1; | ||
| 1075 | ddpy = (ddpy + dddpy)>>1; | ||
| 1076 | count >>=1; | ||
| 1077 | decStepBnd >>=3; | ||
| 1078 | incStepBnd >>=3; | ||
| 1079 | px >>=3; | ||
| 1080 | py >>=3; | ||
| 1081 | shift -= 3; | ||
| 1082 | } | ||
| 1083 | |||
| 1084 | count--; | ||
| 1085 | |||
| 1086 | /* Performing one step less than necessary and use actual (xe,ye) | ||
| 1087 | * curve's endpoint instead of calculated. This prevent us from | ||
| 1088 | * running above the curve endpoint due to the accumulated errors | ||
| 1089 | * during the iterations. | ||
| 1090 | */ | ||
| 1091 | if (count > 0) { | ||
| 1092 | px += dpx; | ||
| 1093 | py += dpy; | ||
| 1094 | |||
| 1095 | dpx += ddpx; | ||
| 1096 | dpy += ddpy; | ||
| 1097 | ddpx += dddpx; | ||
| 1098 | ddpy += dddpy; | ||
| 1099 | |||
| 1100 | x1 = x2; | ||
| 1101 | y1 = y2; | ||
| 1102 | |||
| 1103 | x2 = x0w + (px >> shift); | ||
| 1104 | y2 = y0w + (py >> shift); | ||
| 1105 | |||
| 1106 | /* Checking that we are not running out of the endpoint and | ||
| 1107 | * bounding violating coordinate. The check is pretty simple | ||
| 1108 | * because the curve passed to the DrawCubic already splitted | ||
| 1109 | * into the monotonic in X and Y pieces | ||
| 1110 | */ | ||
| 1111 | |||
| 1112 | /* Bounding x2 by xe */ | ||
| 1113 | if (((xe-x2)^dx) < 0) { | ||
| 1114 | x2 = xe; | ||
| 1115 | } | ||
| 1116 | |||
| 1117 | /* Bounding y2 by ye */ | ||
| 1118 | if (((ye-y2)^dy) < 0) { | ||
| 1119 | y2 = ye; | ||
| 1120 | } | ||
| 1121 | |||
| 1122 | hnd.processFixedLine(x1, y1, x2, y2, pixelInfo, checkBounds, | ||
| 1123 | false); | ||
| 1124 | } else { | ||
| 1125 | hnd.processFixedLine(x2, y2, xe, ye, pixelInfo, checkBounds, | ||
| 1126 | false); | ||
| 1127 | } | ||
| 1128 | } | ||
| 1129 | } | ||
| 1130 | |||
| 1131 | /* | ||
| 1132 | * Checking size of the cubic curves and split them if necessary. | ||
| 1133 | * Calling DrawMonotonicCubic for the curves of the appropriate size. | ||
| 1134 | * Note: coords array could be changed | ||
| 1135 | */ | ||
| 1136 | private static void ProcessMonotonicCubic(ProcessHandler hnd, | ||
| 1137 | float[] coords, | ||
| 1138 | int[] pixelInfo) { | ||
| 1139 | |||
| 1140 | float[] coords1 = new float[8]; | ||
| 1141 | float tx, ty; | ||
| 1142 | float xMin, xMax; | ||
| 1143 | float yMin, yMax; | ||
| 1144 | |||
| 1145 | xMin = xMax = coords[0]; | ||
| 1146 | yMin = yMax = coords[1]; | ||
| 1147 | |||
| 1148 | for (int i = 2; i < 8; i += 2) { | ||
| 1149 | xMin = (xMin > coords[i])? coords[i] : xMin; | ||
| 1150 | xMax = (xMax < coords[i])? coords[i] : xMax; | ||
| 1151 | yMin = (yMin > coords[i + 1])? coords[i + 1] : yMin; | ||
| 1152 | yMax = (yMax < coords[i + 1])? coords[i + 1] : yMax; | ||
| 1153 | } | ||
| 1154 | |||
| 1155 | if (hnd.clipMode == PH_MODE_DRAW_CLIP) { | ||
| 1156 | /* In case of drawing we could just skip curves which are | ||
| 1157 | * completely out of bounds | ||
| 1158 | */ | ||
| 1159 | if (hnd.dhnd.xMaxf < xMin || hnd.dhnd.xMinf > xMax || | ||
| 1160 | hnd.dhnd.yMaxf < yMin || hnd.dhnd.yMinf > yMax) { | ||
| 1161 | return; | ||
| 1162 | } | ||
| 1163 | } else { | ||
| 1164 | |||
| 1165 | /* In case of filling we could skip curves which are above, | ||
| 1166 | * below and behind the right boundary of the visible area | ||
| 1167 | */ | ||
| 1168 | |||
| 1169 | if (hnd.dhnd.yMaxf < yMin || hnd.dhnd.yMinf > yMax || | ||
| 1170 | hnd.dhnd.xMaxf < xMin) | ||
| 1171 | { | ||
| 1172 | return; | ||
| 1173 | } | ||
| 1174 | |||
| 1175 | /* We could clamp x coordinates to the corresponding boundary | ||
| 1176 | * if the curve is completely behind the left one | ||
| 1177 | */ | ||
| 1178 | |||
| 1179 | if (hnd.dhnd.xMinf > xMax) { | ||
| 1180 | coords[0] = coords[2] = coords[4] = coords[6] = | ||
| 1181 | hnd.dhnd.xMinf; | ||
| 1182 | } | ||
| 1183 | } | ||
| 1184 | |||
| 1185 | if (xMax - xMin > MAX_CUB_SIZE || yMax - yMin > MAX_CUB_SIZE) { | ||
| 1186 | coords1[6] = coords[6]; | ||
| 1187 | coords1[7] = coords[7]; | ||
| 1188 | coords1[4] = (coords[4] + coords[6])/2.0f; | ||
| 1189 | coords1[5] = (coords[5] + coords[7])/2.0f; | ||
| 1190 | tx = (coords[2] + coords[4])/2.0f; | ||
| 1191 | ty = (coords[3] + coords[5])/2.0f; | ||
| 1192 | coords1[2] = (tx + coords1[4])/2.0f; | ||
| 1193 | coords1[3] = (ty + coords1[5])/2.0f; | ||
| 1194 | coords[2] = (coords[0] + coords[2])/2.0f; | ||
| 1195 | coords[3] = (coords[1] + coords[3])/2.0f; | ||
| 1196 | coords[4] = (coords[2] + tx)/2.0f; | ||
| 1197 | coords[5] = (coords[3] + ty)/2.0f; | ||
| 1198 | coords[6]=coords1[0]=(coords[4] + coords1[2])/2.0f; | ||
| 1199 | coords[7]=coords1[1]=(coords[5] + coords1[3])/2.0f; | ||
| 1200 | |||
| 1201 | ProcessMonotonicCubic(hnd, coords, pixelInfo); | ||
| 1202 | |||
| 1203 | ProcessMonotonicCubic(hnd, coords1, pixelInfo); | ||
| 1204 | } else { | ||
| 1205 | DrawMonotonicCubic(hnd, coords, | ||
| 1206 | /* Set checkBounds parameter if curve intersects | ||
| 1207 | * boundary of the visible area. We know that | ||
| 1208 | * the curve is visible, so the check is pretty | ||
| 1209 | * simple | ||
| 1210 | */ | ||
| 1211 | hnd.dhnd.xMinf > xMin || | ||
| 1212 | hnd.dhnd.xMaxf < xMax || | ||
| 1213 | hnd.dhnd.yMinf > yMin || | ||
| 1214 | hnd.dhnd.yMaxf < yMax, | ||
| 1215 | pixelInfo); | ||
| 1216 | } | ||
| 1217 | } | ||
| 1218 | |||
| 1219 | /* | ||
| 1220 | * Split cubic curve into monotonic in X and Y parts. Calling | ||
| 1221 | * ProcessMonotonicCubic for each monotonic piece of the curve. | ||
| 1222 | * | ||
| 1223 | * Note: coords array could be changed | ||
| 1224 | */ | ||
| 1225 | private static void ProcessCubic(ProcessHandler hnd, | ||
| 1226 | float[] coords, | ||
| 1227 | int[] pixelInfo) { | ||
| 1228 | /* Temporary array for holding parameters corresponding to the extreme | ||
| 1229 | * in X and Y points | ||
| 1230 | */ | ||
| 1231 | double params[] = new double[4]; | ||
| 1232 | double eqn[] = new double[3]; | ||
| 1233 | double res[] = new double[2]; | ||
| 1234 | int cnt = 0; | ||
| 1235 | |||
| 1236 | /* Simple check for monotonicity in X before searching for the extreme | ||
| 1237 | * points of the X(t) function. We first check if the curve is | ||
| 1238 | * monotonic in X by seeing if all of the X coordinates are strongly | ||
| 1239 | * ordered. | ||
| 1240 | */ | ||
| 1241 | if ((coords[0] > coords[2] || coords[2] > coords[4] || | ||
| 1242 | coords[4] > coords[6]) && | ||
| 1243 | (coords[0] < coords[2] || coords[2] < coords[4] || | ||
| 1244 | coords[4] < coords[6])) | ||
| 1245 | { | ||
| 1246 | /* Searching for extreme points of the X(t) function by solving | ||
| 1247 | * dX(t) | ||
| 1248 | * ---- = 0 equation | ||
| 1249 | * dt | ||
| 1250 | */ | ||
| 1251 | eqn[2] = -coords[0] + 3*coords[2] - 3*coords[4] + coords[6]; | ||
| 1252 | eqn[1] = 2*(coords[0] - 2*coords[2] + coords[4]); | ||
| 1253 | eqn[0] = -coords[0] + coords[2]; | ||
| 1254 | |||
| 1255 | int nr = QuadCurve2D.solveQuadratic(eqn, res); | ||
| 1256 | |||
| 1257 | /* Following code also correctly works in degenerate case of | ||
| 1258 | * the quadratic equation (nr = -1) because we do not need | ||
| 1259 | * splitting in this case. | ||
| 1260 | */ | ||
| 1261 | for (int i = 0; i < nr; i++) { | ||
| 1262 | if (res[i] > 0 && res[i] < 1) { | ||
| 1263 | params[cnt++] = res[i]; | ||
| 1264 | } | ||
| 1265 | } | ||
| 1266 | } | ||
| 1267 | |||
| 1268 | /* Simple check for monotonicity in Y before searching for the extreme | ||
| 1269 | * points of the Y(t) function. We first check if the curve is | ||
| 1270 | * monotonic in Y by seeing if all of the Y coordinates are strongly | ||
| 1271 | * ordered. | ||
| 1272 | */ | ||
| 1273 | if ((coords[1] > coords[3] || coords[3] > coords[5] || | ||
| 1274 | coords[5] > coords[7]) && | ||
| 1275 | (coords[1] < coords[3] || coords[3] < coords[5] || | ||
| 1276 | coords[5] < coords[7])) | ||
| 1277 | { | ||
| 1278 | /* Searching for extreme points of the Y(t) function by solving | ||
| 1279 | * dY(t) | ||
| 1280 | * ----- = 0 equation | ||
| 1281 | * dt | ||
| 1282 | */ | ||
| 1283 | eqn[2] = -coords[1] + 3*coords[3] - 3*coords[5] + coords[7]; | ||
| 1284 | eqn[1] = 2*(coords[1] - 2*coords[3] + coords[5]); | ||
| 1285 | eqn[0] = -coords[1] + coords[3]; | ||
| 1286 | |||
| 1287 | int nr = QuadCurve2D.solveQuadratic(eqn, res); | ||
| 1288 | |||
| 1289 | /* Following code also correctly works in degenerate case of | ||
| 1290 | * the quadratic equation (nr = -1) because we do not need | ||
| 1291 | * splitting in this case. | ||
| 1292 | */ | ||
| 1293 | for (int i = 0; i < nr; i++) { | ||
| 1294 | if (res[i] > 0 && res[i] < 1) { | ||
| 1295 | params[cnt++] = res[i]; | ||
| 1296 | } | ||
| 1297 | } | ||
| 1298 | } | ||
| 1299 | |||
| 1300 | if (cnt > 0) { | ||
| 1301 | /* Sorting parameter values corresponding to the extreme points | ||
| 1302 | * of the curve | ||
| 1303 | */ | ||
| 1304 | Arrays.sort(params, 0, cnt); | ||
| 1305 | |||
| 1306 | /* Processing obtained monotonic parts */ | ||
| 1307 | ProcessFirstMonotonicPartOfCubic(hnd, coords, pixelInfo, | ||
| 1308 | (float)params[0]); | ||
| 1309 | for (int i = 1; i < cnt; i++) { | ||
| 1310 | double param = params[i] - params[i-1]; | ||
| 1311 | if (param > 0) { | ||
| 1312 | ProcessFirstMonotonicPartOfCubic(hnd, coords, pixelInfo, | ||
| 1313 | /* Scale parameter to match with rest of the curve */ | ||
| 1314 | (float)(param/(1.0 - params[i - 1]))); | ||
| 1315 | } | ||
| 1316 | } | ||
| 1317 | } | ||
| 1318 | |||
| 1319 | ProcessMonotonicCubic(hnd,coords,pixelInfo); | ||
| 1320 | } | ||
| 1321 | |||
| 1322 | /* | ||
| 1323 | * Bite the piece of the cubic curve from start point till the point | ||
| 1324 | * corresponding to the specified parameter then call ProcessCubic for the | ||
| 1325 | * bitten part. | ||
| 1326 | * Note: coords array will be changed | ||
| 1327 | */ | ||
| 1328 | private static void ProcessFirstMonotonicPartOfCubic(ProcessHandler hnd, | ||
| 1329 | float[] coords, | ||
| 1330 | int[] pixelInfo, | ||
| 1331 | float t) | ||
| 1332 | { | ||
| 1333 | float[] coords1 = new float[8]; | ||
| 1334 | float tx, ty; | ||
| 1335 | |||
| 1336 | coords1[0] = coords[0]; | ||
| 1337 | coords1[1] = coords[1]; | ||
| 1338 | tx = coords[2] + t*(coords[4] - coords[2]); | ||
| 1339 | ty = coords[3] + t*(coords[5] - coords[3]); | ||
| 1340 | coords1[2] = coords[0] + t*(coords[2] - coords[0]); | ||
| 1341 | coords1[3] = coords[1] + t*(coords[3] - coords[1]); | ||
| 1342 | coords1[4] = coords1[2] + t*(tx - coords1[2]); | ||
| 1343 | coords1[5] = coords1[3] + t*(ty - coords1[3]); | ||
| 1344 | coords[4] = coords[4] + t*(coords[6] - coords[4]); | ||
| 1345 | coords[5] = coords[5] + t*(coords[7] - coords[5]); | ||
| 1346 | coords[2] = tx + t*(coords[4] - tx); | ||
| 1347 | coords[3] = ty + t*(coords[5] - ty); | ||
| 1348 | coords[0]=coords1[6]=coords1[4] + t*(coords[2] - coords1[4]); | ||
| 1349 | coords[1]=coords1[7]=coords1[5] + t*(coords[3] - coords1[5]); | ||
| 1350 | |||
| 1351 | ProcessMonotonicCubic(hnd, coords1, pixelInfo); | ||
| 1352 | } | ||
| 1353 | |||
| 1354 | /* Note: | ||
| 1355 | * For more easy reading of the code below each java version of the macros | ||
| 1356 | * from the ProcessPath.c preceded by the commented origin call | ||
| 1357 | * containing verbose names of the parameters | ||
| 1358 | */ | ||
| 1359 | private static void ProcessLine(ProcessHandler hnd, float x1, float y1, | ||
| 1360 | float x2, float y2, int[] pixelInfo) { | ||
| 1361 | float xMin, yMin, xMax, yMax; | ||
| 1362 | int X1, Y1, X2, Y2, X3, Y3, res; | ||
| 1363 | boolean clipped = false; | ||
| 1364 | float x3,y3; | ||
| 1365 | float c[] = new float[]{x1, y1, x2, y2, 0, 0}; | ||
| 1366 | |||
| 1367 | boolean lastClipped; | ||
| 1368 | |||
| 1369 | xMin = hnd.dhnd.xMinf; | ||
| 1370 | yMin = hnd.dhnd.yMinf; | ||
| 1371 | xMax = hnd.dhnd.xMaxf; | ||
| 1372 | yMax = hnd.dhnd.yMaxf; | ||
| 1373 | |||
| 1374 | // | ||
| 1375 | // TESTANDCLIP(yMin, yMax, y1, x1, y2, x2, res); | ||
| 1376 | // | ||
| 1377 | res = TESTANDCLIP(yMin, yMax, c, 1, 0, 3, 2); | ||
| 1378 | if (res == CRES_INVISIBLE) return; | ||
| 1379 | clipped = IS_CLIPPED(res); | ||
| 1380 | // | ||
| 1381 | // TESTANDCLIP(yMin, yMax, y2, x2, y1, x1, res); | ||
| 1382 | // | ||
| 1383 | res = TESTANDCLIP(yMin, yMax, c, 3, 2, 1, 0); | ||
| 1384 | if (res == CRES_INVISIBLE) return; | ||
| 1385 | lastClipped = IS_CLIPPED(res); | ||
| 1386 | clipped = clipped || lastClipped; | ||
| 1387 | |||
| 1388 | if (hnd.clipMode == PH_MODE_DRAW_CLIP) { | ||
| 1389 | // | ||
| 1390 | // TESTANDCLIP(xMin, xMax, x1, y1, x2, y2, res); | ||
| 1391 | // | ||
| 1392 | res = TESTANDCLIP(xMin, xMax, c, 0, 1, 2, 3); | ||
| 1393 | if (res == CRES_INVISIBLE) return; | ||
| 1394 | clipped = clipped || IS_CLIPPED(res); | ||
| 1395 | // | ||
| 1396 | // TESTANDCLIP(xMin, xMax, x2, y2, x1, y1, res); | ||
| 1397 | // | ||
| 1398 | res = TESTANDCLIP(xMin, xMax, c, 2, 3, 0, 1); | ||
| 1399 | if (res == CRES_INVISIBLE) return; | ||
| 1400 | lastClipped = lastClipped || IS_CLIPPED(res); | ||
| 1401 | clipped = clipped || lastClipped; | ||
| 1402 | X1 = (int)(c[0]*MDP_MULT); | ||
| 1403 | Y1 = (int)(c[1]*MDP_MULT); | ||
| 1404 | X2 = (int)(c[2]*MDP_MULT); | ||
| 1405 | Y2 = (int)(c[3]*MDP_MULT); | ||
| 1406 | |||
| 1407 | hnd.processFixedLine(X1, Y1, X2, Y2, pixelInfo, | ||
| 1408 | clipped, /* enable boundary checking in | ||
| 1409 | case of clipping to avoid | ||
| 1410 | entering out of bounds which | ||
| 1411 | could happens during rounding | ||
| 1412 | */ | ||
| 1413 | lastClipped /* Notify pProcessFixedLine | ||
| 1414 | that | ||
| 1415 | this is the end of the | ||
| 1416 | subpath (because of exiting | ||
| 1417 | out of boundaries) | ||
| 1418 | */ | ||
| 1419 | ); | ||
| 1420 | } else { | ||
| 1421 | /* Clamping starting from first vertex of the the processed | ||
| 1422 | * segment | ||
| 1423 | * | ||
| 1424 | * CLIPCLAMP(xMin, xMax, x1, y1, x2, y2, x3, y3, res); | ||
| 1425 | */ | ||
| 1426 | res = CLIPCLAMP(xMin, xMax, c, 0, 1, 2, 3, 4, 5); | ||
| 1427 | X1 = (int)(c[0]*MDP_MULT); | ||
| 1428 | Y1 = (int)(c[1]*MDP_MULT); | ||
| 1429 | |||
| 1430 | /* Clamping only by left boundary */ | ||
| 1431 | if (res == CRES_MIN_CLIPPED) { | ||
| 1432 | X3 = (int)(c[4]*MDP_MULT); | ||
| 1433 | Y3 = (int)(c[5]*MDP_MULT); | ||
| 1434 | hnd.processFixedLine(X3, Y3, X1, Y1, pixelInfo, | ||
| 1435 | false, lastClipped); | ||
| 1436 | |||
| 1437 | } else if (res == CRES_INVISIBLE) { | ||
| 1438 | return; | ||
| 1439 | } | ||
| 1440 | |||
| 1441 | /* Clamping starting from last vertex of the the processed | ||
| 1442 | * segment | ||
| 1443 | * | ||
| 1444 | * CLIPCLAMP(xMin, xMax, x2, y2, x1, y1, x3, y3, res); | ||
| 1445 | */ | ||
| 1446 | res = CLIPCLAMP(xMin, xMax, c, 2, 3, 0, 1, 4, 5); | ||
| 1447 | |||
| 1448 | /* Checking if there was a clip by right boundary */ | ||
| 1449 | lastClipped = lastClipped || (res == CRES_MAX_CLIPPED); | ||
| 1450 | |||
| 1451 | X2 = (int)(c[2]*MDP_MULT); | ||
| 1452 | Y2 = (int)(c[3]*MDP_MULT); | ||
| 1453 | hnd.processFixedLine(X1, Y1, X2, Y2, pixelInfo, | ||
| 1454 | false, lastClipped); | ||
| 1455 | |||
| 1456 | /* Clamping only by left boundary */ | ||
| 1457 | if (res == CRES_MIN_CLIPPED) { | ||
| 1458 | X3 = (int)(c[4]*MDP_MULT); | ||
| 1459 | Y3 = (int)(c[5]*MDP_MULT); | ||
| 1460 | hnd.processFixedLine(X2, Y2, X3, Y3, pixelInfo, | ||
| 1461 | false, lastClipped); | ||
| 1462 | } | ||
| 1463 | } | ||
| 1464 | } | ||
| 1465 | |||
| 1466 | private static boolean doProcessPath(ProcessHandler hnd, | ||
| 1467 | Path2D.Float p2df, | ||
| 1468 | float transXf, float transYf) { | ||
| 1469 | float coords[] = new float[8]; | ||
| 1470 | float tCoords[] = new float[8]; | ||
| 1471 | float closeCoord[] = new float[] {0.0f, 0.0f}; | ||
| 1472 | float firstCoord[] = new float[2]; | ||
| 1473 | int pixelInfo[] = new int[5]; | ||
| 1474 | boolean subpathStarted = false; | ||
| 1475 | boolean skip = false; | ||
| 1476 | float lastX, lastY; | ||
| 1477 | pixelInfo[0] = 0; | ||
| 1478 | |||
| 1479 | /* Adjusting boundaries to the capabilities of the | ||
| 1480 | * ProcessPath code | ||
| 1481 | */ | ||
| 1482 | hnd.dhnd.adjustBounds(LOWER_OUT_BND, LOWER_OUT_BND, | ||
| 1483 | UPPER_OUT_BND, UPPER_OUT_BND); | ||
| 1484 | |||
| 1485 | /* Adding support of the KEY_STROKE_CONTROL rendering hint. | ||
| 1486 | * Now we are supporting two modes: "pixels at centers" and | ||
| 1487 | * "pixels at corners". | ||
| 1488 | * First one is disabled by default but could be enabled by setting | ||
| 1489 | * VALUE_STROKE_PURE to the rendering hint. It means that pixel at the | ||
| 1490 | * screen (x,y) has (x + 0.5, y + 0.5) float coordinates. | ||
| 1491 | * | ||
| 1492 | * Second one is enabled by default and means straightforward mapping | ||
| 1493 | * (x,y) --> (x,y) | ||
| 1494 | */ | ||
| 1495 | if (hnd.dhnd.strokeControl == SunHints.INTVAL_STROKE_PURE) { | ||
| 1496 | closeCoord[0] = -0.5f; | ||
| 1497 | closeCoord[1] = -0.5f; | ||
| 1498 | transXf -= 0.5; | ||
| 1499 | transYf -= 0.5; | ||
| 1500 | } | ||
| 1501 | |||
| 1502 | PathIterator pi = p2df.getPathIterator(null); | ||
| 1503 | |||
| 1504 | while (!pi.isDone()) { | ||
| 1505 | switch (pi.currentSegment(coords)) { | ||
| 1506 | case PathIterator.SEG_MOVETO: | ||
| 1507 | /* Performing closing of the unclosed segments */ | ||
| 1508 | if (subpathStarted && !skip) { | ||
| 1509 | if (hnd.clipMode == PH_MODE_FILL_CLIP) { | ||
| 1510 | if (tCoords[0] != closeCoord[0] || | ||
| 1511 | tCoords[1] != closeCoord[1]) | ||
| 1512 | { | ||
| 1513 | ProcessLine(hnd, tCoords[0], tCoords[1], | ||
| 1514 | closeCoord[0], closeCoord[1], | ||
| 1515 | pixelInfo); | ||
| 1516 | } | ||
| 1517 | } | ||
| 1518 | hnd.processEndSubPath(); | ||
| 1519 | } | ||
| 1520 | |||
| 1521 | tCoords[0] = coords[0] + transXf; | ||
| 1522 | tCoords[1] = coords[1] + transYf; | ||
| 1523 | |||
| 1524 | /* Checking SEG_MOVETO coordinates if they are out of the | ||
| 1525 | * [LOWER_BND, UPPER_BND] range. This check also handles | ||
| 1526 | * NaN and Infinity values. Skipping next path segment in | ||
| 1527 | * case of invalid data. | ||
| 1528 | */ | ||
| 1529 | |||
| 1530 | if (tCoords[0] < UPPER_BND && | ||
| 1531 | tCoords[0] > LOWER_BND && | ||
| 1532 | tCoords[1] < UPPER_BND && | ||
| 1533 | tCoords[1] > LOWER_BND) | ||
| 1534 | { | ||
| 1535 | subpathStarted = true; | ||
| 1536 | skip = false; | ||
| 1537 | closeCoord[0] = tCoords[0]; | ||
| 1538 | closeCoord[1] = tCoords[1]; | ||
| 1539 | } else { | ||
| 1540 | skip = true; | ||
| 1541 | } | ||
| 1542 | pixelInfo[0] = 0; | ||
| 1543 | break; | ||
| 1544 | case PathIterator.SEG_LINETO: | ||
| 1545 | lastX = tCoords[2] = coords[0] + transXf; | ||
| 1546 | lastY = tCoords[3] = coords[1] + transYf; | ||
| 1547 | |||
| 1548 | /* Checking SEG_LINETO coordinates if they are out of the | ||
| 1549 | * [LOWER_BND, UPPER_BND] range. This check also handles | ||
| 1550 | * NaN and Infinity values. Ignoring current path segment | ||
| 1551 | * in case of invalid data. If segment is skipped its | ||
| 1552 | * endpoint (if valid) is used to begin new subpath. | ||
| 1553 | */ | ||
| 1554 | |||
| 1555 | if (lastX < UPPER_BND && | ||
| 1556 | lastX > LOWER_BND && | ||
| 1557 | lastY < UPPER_BND && | ||
| 1558 | lastY > LOWER_BND) | ||
| 1559 | { | ||
| 1560 | if (skip) { | ||
| 1561 | tCoords[0] = closeCoord[0] = lastX; | ||
| 1562 | tCoords[1] = closeCoord[1] = lastY; | ||
| 1563 | subpathStarted = true; | ||
| 1564 | skip = false; | ||
| 1565 | } else { | ||
| 1566 | ProcessLine(hnd, tCoords[0], tCoords[1], | ||
| 1567 | tCoords[2], tCoords[3], pixelInfo); | ||
| 1568 | tCoords[0] = lastX; | ||
| 1569 | tCoords[1] = lastY; | ||
| 1570 | } | ||
| 1571 | } | ||
| 1572 | break; | ||
| 1573 | case PathIterator.SEG_QUADTO: | ||
| 1574 | tCoords[2] = coords[0] + transXf; | ||
| 1575 | tCoords[3] = coords[1] + transYf; | ||
| 1576 | lastX = tCoords[4] = coords[2] + transXf; | ||
| 1577 | lastY = tCoords[5] = coords[3] + transYf; | ||
| 1578 | |||
| 1579 | /* Checking SEG_QUADTO coordinates if they are out of the | ||
| 1580 | * [LOWER_BND, UPPER_BND] range. This check also handles | ||
| 1581 | * NaN and Infinity values. Ignoring current path segment | ||
| 1582 | * in case of invalid endpoints's data. Equivalent to | ||
| 1583 | * the SEG_LINETO if endpoint coordinates are valid but | ||
| 1584 | * there are invalid data among other coordinates | ||
| 1585 | */ | ||
| 1586 | |||
| 1587 | if (lastX < UPPER_BND && | ||
| 1588 | lastX > LOWER_BND && | ||
| 1589 | lastY < UPPER_BND && | ||
| 1590 | lastY > LOWER_BND) | ||
| 1591 | { | ||
| 1592 | if (skip) { | ||
| 1593 | tCoords[0] = closeCoord[0] = lastX; | ||
| 1594 | tCoords[1] = closeCoord[1] = lastY; | ||
| 1595 | subpathStarted = true; | ||
| 1596 | skip = false; | ||
| 1597 | } else { | ||
| 1598 | if (tCoords[2] < UPPER_BND && | ||
| 1599 | tCoords[2] > LOWER_BND && | ||
| 1600 | tCoords[3] < UPPER_BND && | ||
| 1601 | tCoords[3] > LOWER_BND) | ||
| 1602 | { | ||
| 1603 | ProcessQuad(hnd, tCoords, pixelInfo); | ||
| 1604 | } else { | ||
| 1605 | ProcessLine(hnd, tCoords[0], tCoords[1], | ||
| 1606 | tCoords[4], tCoords[5], | ||
| 1607 | pixelInfo); | ||
| 1608 | } | ||
| 1609 | tCoords[0] = lastX; | ||
| 1610 | tCoords[1] = lastY; | ||
| 1611 | } | ||
| 1612 | } | ||
| 1613 | break; | ||
| 1614 | case PathIterator.SEG_CUBICTO: | ||
| 1615 | tCoords[2] = coords[0] + transXf; | ||
| 1616 | tCoords[3] = coords[1] + transYf; | ||
| 1617 | tCoords[4] = coords[2] + transXf; | ||
| 1618 | tCoords[5] = coords[3] + transYf; | ||
| 1619 | lastX = tCoords[6] = coords[4] + transXf; | ||
| 1620 | lastY = tCoords[7] = coords[5] + transYf; | ||
| 1621 | |||
| 1622 | /* Checking SEG_CUBICTO coordinates if they are out of the | ||
| 1623 | * [LOWER_BND, UPPER_BND] range. This check also handles | ||
| 1624 | * NaN and Infinity values. Ignoring current path segment | ||
| 1625 | * in case of invalid endpoints's data. Equivalent to | ||
| 1626 | * the SEG_LINETO if endpoint coordinates are valid but | ||
| 1627 | * there are invalid data among other coordinates | ||
| 1628 | */ | ||
| 1629 | |||
| 1630 | if (lastX < UPPER_BND && | ||
| 1631 | lastX > LOWER_BND && | ||
| 1632 | lastY < UPPER_BND && | ||
| 1633 | lastY > LOWER_BND) | ||
| 1634 | { | ||
| 1635 | if (skip) { | ||
| 1636 | tCoords[0] = closeCoord[0] = tCoords[6]; | ||
| 1637 | tCoords[1] = closeCoord[1] = tCoords[7]; | ||
| 1638 | subpathStarted = true; | ||
| 1639 | skip = false; | ||
| 1640 | } else { | ||
| 1641 | if (tCoords[2] < UPPER_BND && | ||
| 1642 | tCoords[2] > LOWER_BND && | ||
| 1643 | tCoords[3] < UPPER_BND && | ||
| 1644 | tCoords[3] > LOWER_BND && | ||
| 1645 | tCoords[4] < UPPER_BND && | ||
| 1646 | tCoords[4] > LOWER_BND && | ||
| 1647 | tCoords[5] < UPPER_BND && | ||
| 1648 | tCoords[5] > LOWER_BND) | ||
| 1649 | { | ||
| 1650 | ProcessCubic(hnd, tCoords, pixelInfo); | ||
| 1651 | } else { | ||
| 1652 | ProcessLine(hnd, tCoords[0], tCoords[1], | ||
| 1653 | tCoords[6], tCoords[7], | ||
| 1654 | pixelInfo); | ||
| 1655 | } | ||
| 1656 | tCoords[0] = lastX; | ||
| 1657 | tCoords[1] = lastY; | ||
| 1658 | } | ||
| 1659 | } | ||
| 1660 | break; | ||
| 1661 | case PathIterator.SEG_CLOSE: | ||
| 1662 | if (subpathStarted && !skip) { | ||
| 1663 | skip = false; | ||
| 1664 | if (tCoords[0] != closeCoord[0] || | ||
| 1665 | tCoords[1] != closeCoord[1]) | ||
| 1666 | { | ||
| 1667 | ProcessLine(hnd, tCoords[0], tCoords[1], | ||
| 1668 | closeCoord[0], closeCoord[1], | ||
| 1669 | pixelInfo); | ||
| 1670 | |||
| 1671 | /* Storing last path's point for using in following | ||
| 1672 | * segments without initial moveTo | ||
| 1673 | */ | ||
| 1674 | tCoords[0] = closeCoord[0]; | ||
| 1675 | tCoords[1] = closeCoord[1]; | ||
| 1676 | } | ||
| 1677 | hnd.processEndSubPath(); | ||
| 1678 | } | ||
| 1679 | break; | ||
| 1680 | } | ||
| 1681 | pi.next(); | ||
| 1682 | } | ||
| 1683 | |||
| 1684 | /* Performing closing of the unclosed segments */ | ||
| 1685 | if (subpathStarted & !skip) { | ||
| 1686 | if (hnd.clipMode == PH_MODE_FILL_CLIP) { | ||
| 1687 | if (tCoords[0] != closeCoord[0] || | ||
| 1688 | tCoords[1] != closeCoord[1]) | ||
| 1689 | { | ||
| 1690 | ProcessLine(hnd, tCoords[0], tCoords[1], | ||
| 1691 | closeCoord[0], closeCoord[1], | ||
| 1692 | pixelInfo); | ||
| 1693 | } | ||
| 1694 | } | ||
| 1695 | hnd.processEndSubPath(); | ||
| 1696 | } | ||
| 1697 | return true; | ||
| 1698 | } | ||
| 1699 | |||
| 1700 | private static class Point { | ||
| 1701 | public int x; | ||
| 1702 | public int y; | ||
| 1703 | public boolean lastPoint; | ||
| 1704 | public Point prev; | ||
| 1705 | public Point next; | ||
| 1706 | public Point nextByY; | ||
| 1707 | public Edge edge; | ||
| 1708 | public Point(int x, int y, boolean lastPoint) { | ||
| 1709 | this.x = x; | ||
| 1710 | this.y = y; | ||
| 1711 | this.lastPoint = lastPoint; | ||
| 1712 | } | ||
| 1713 | }; | ||
| 1714 | |||
| 1715 | private static class Edge { | ||
| 1716 | int x; | ||
| 1717 | int dx; | ||
| 1718 | Point p; | ||
| 1719 | int dir; | ||
| 1720 | Edge prev; | ||
| 1721 | Edge next; | ||
| 1722 | |||
| 1723 | public Edge(Point p, int x, int dx, int dir) { | ||
| 1724 | this.p = p; | ||
| 1725 | this.x = x; | ||
| 1726 | this.dx = dx; | ||
| 1727 | this.dir = dir; | ||
| 1728 | } | ||
| 1729 | }; | ||
| 1730 | |||
| 1731 | /* Size of the default buffer in the FillData structure. This buffer is | ||
| 1732 | * replaced with heap allocated in case of large paths. | ||
| 1733 | */ | ||
| 1734 | private static final int DF_MAX_POINT = 256; | ||
| 1735 | |||
| 1736 | /* Following class accumulates points of the non-continuous flattened | ||
| 1737 | * general path during iteration through the origin path's segments . The | ||
| 1738 | * end of the each subpath is marked as lastPoint flag set at the last | ||
| 1739 | * point | ||
| 1740 | */ | ||
| 1741 | private static class FillData { | ||
| 1742 | List<Point> plgPnts; | ||
| 1743 | public int plgYMin; | ||
| 1744 | public int plgYMax; | ||
| 1745 | |||
| 1746 | public FillData() { | ||
| 1747 | plgPnts = new Vector<Point>(DF_MAX_POINT); | ||
| 1748 | } | ||
| 1749 | |||
| 1750 | public void addPoint(int x, int y, boolean lastPoint) { | ||
| 1751 | if (plgPnts.size() == 0) { | ||
| 1752 | plgYMin = plgYMax = y; | ||
| 1753 | } else { | ||
| 1754 | plgYMin = (plgYMin > y)?y:plgYMin; | ||
| 1755 | plgYMax = (plgYMax < y)?y:plgYMax; | ||
| 1756 | } | ||
| 1757 | |||
| 1758 | plgPnts.add(new Point(x, y, lastPoint)); | ||
| 1759 | } | ||
| 1760 | |||
| 1761 | public boolean isEmpty() { | ||
| 1762 | return plgPnts.size() == 0; | ||
| 1763 | } | ||
| 1764 | |||
| 1765 | public boolean isEnded() { | ||
| 1766 | return plgPnts.get(plgPnts.size() - 1).lastPoint; | ||
| 1767 | } | ||
| 1768 | |||
| 1769 | public boolean setEnded() { | ||
| 1770 | return plgPnts.get(plgPnts.size() - 1).lastPoint = true; | ||
| 1771 | } | ||
| 1772 | } | ||
| 1773 | |||
| 1774 | private static class ActiveEdgeList { | ||
| 1775 | Edge head; | ||
| 1776 | |||
| 1777 | public boolean isEmpty() { | ||
| 1778 | return (head == null); | ||
| 1779 | } | ||
| 1780 | |||
| 1781 | public void insert(Point pnt, int cy) { | ||
| 1782 | Point np = pnt.next; | ||
| 1783 | int X1 = pnt.x, Y1 = pnt.y; | ||
| 1784 | int X2 = np.x, Y2 = np.y; | ||
| 1785 | Edge ne; | ||
| 1786 | if (Y1 == Y2) { | ||
| 1787 | /* Skipping horizontal segments */ | ||
| 1788 | return; | ||
| 1789 | } else { | ||
| 1790 | int dX = X2 - X1; | ||
| 1791 | int dY = Y2 - Y1; | ||
| 1792 | int stepx, x0, dy, dir; | ||
| 1793 | |||
| 1794 | if (Y1 < Y2) { | ||
| 1795 | x0 = X1; | ||
| 1796 | dy = cy - Y1; | ||
| 1797 | dir = -1; | ||
| 1798 | } else { // (Y1 > Y2) | ||
| 1799 | x0 = X2; | ||
| 1800 | dy = cy - Y2; | ||
| 1801 | dir = 1; | ||
| 1802 | } | ||
| 1803 | |||
| 1804 | /* We need to worry only about dX because dY is in denominator | ||
| 1805 | * and abs(dy) < MDP_MULT (cy is a first scanline of the scan | ||
| 1806 | * converted segment and we subtract y coordinate of the | ||
| 1807 | * nearest segment's end from it to obtain dy) | ||
| 1808 | */ | ||
| 1809 | if (dX > CALC_UBND || dX < CALC_LBND) { | ||
| 1810 | stepx = (int)((((double)dX)*MDP_MULT)/dY); | ||
| 1811 | x0 = x0 + (int)((((double)dX)*dy)/dY); | ||
| 1812 | } else { | ||
| 1813 | stepx = (dX<<MDP_PREC)/dY; | ||
| 1814 | x0 += (dX*dy)/dY; | ||
| 1815 | } | ||
| 1816 | |||
| 1817 | ne = new Edge(pnt, x0, stepx, dir); | ||
| 1818 | } | ||
| 1819 | |||
| 1820 | ne.next = head; | ||
| 1821 | ne.prev = null; | ||
| 1822 | if (head != null) { | ||
| 1823 | head.prev = ne; | ||
| 1824 | } | ||
| 1825 | head = pnt.edge = ne; | ||
| 1826 | } | ||
| 1827 | |||
| 1828 | public void delete(Edge e) { | ||
| 1829 | Edge prevp = e.prev; | ||
| 1830 | Edge nextp = e.next; | ||
| 1831 | if (prevp != null) { | ||
| 1832 | prevp.next = nextp; | ||
| 1833 | } else { | ||
| 1834 | head = nextp; | ||
| 1835 | } | ||
| 1836 | if (nextp != null) { | ||
| 1837 | nextp.prev = prevp; | ||
| 1838 | } | ||
| 1839 | } | ||
| 1840 | |||
| 1841 | /** | ||
| 1842 | * Bubble sorting in the ascending order of the linked list. This | ||
| 1843 | * implementation stops processing the list if there were no changes | ||
| 1844 | * during the previous pass. | ||
| 1845 | * | ||
| 1846 | * We could not use O(N) Radix sort here because in most cases list of | ||
| 1847 | * edges almost sorted. So, bubble sort (O(N^2)) is working much | ||
| 1848 | * better. Note, in case of array of edges Shell sort is more | ||
| 1849 | * efficient. | ||
| 1850 | */ | ||
| 1851 | public void sort() { | ||
| 1852 | Edge p, q, r, s = null, temp; | ||
| 1853 | boolean wasSwap = true; | ||
| 1854 | |||
| 1855 | // r precedes p and s points to the node up to which | ||
| 1856 | // comparisons are to be made | ||
| 1857 | while (s != head.next && wasSwap) { | ||
| 1858 | r = p = head; | ||
| 1859 | q = p.next; | ||
| 1860 | wasSwap = false; | ||
| 1861 | while (p != s) { | ||
| 1862 | if (p.x >= q.x) { | ||
| 1863 | wasSwap = true; | ||
| 1864 | if (p == head) { | ||
| 1865 | temp = q.next; | ||
| 1866 | q.next = p; | ||
| 1867 | p.next = temp; | ||
| 1868 | head = q; | ||
| 1869 | r = q; | ||
| 1870 | } else { | ||
| 1871 | temp = q.next; | ||
| 1872 | q.next = p; | ||
| 1873 | p.next = temp; | ||
| 1874 | r.next = q; | ||
| 1875 | r = q; | ||
| 1876 | } | ||
| 1877 | } else { | ||
| 1878 | r = p; | ||
| 1879 | p = p.next; | ||
| 1880 | } | ||
| 1881 | q = p.next; | ||
| 1882 | if (q == s) s = p; | ||
| 1883 | } | ||
| 1884 | } | ||
| 1885 | |||
| 1886 | // correction of the back links in the double linked edge list | ||
| 1887 | p = head; | ||
| 1888 | q = null; | ||
| 1889 | while (p != null) { | ||
| 1890 | p.prev = q; | ||
| 1891 | q = p; | ||
| 1892 | p = p.next; | ||
| 1893 | } | ||
| 1894 | } | ||
| 1895 | } | ||
| 1896 | |||
| 1897 | private static void FillPolygon(FillProcessHandler hnd, | ||
| 1898 | int fillRule) { | ||
| 1899 | int k, y, n; | ||
| 1900 | boolean drawing; | ||
| 1901 | Edge active; | ||
| 1902 | int rightBnd = hnd.dhnd.xMax - 1; | ||
| 1903 | FillData fd = hnd.fd; | ||
| 1904 | int yMin = fd.plgYMin; | ||
| 1905 | int yMax = fd.plgYMax; | ||
| 1906 | int hashSize = ((yMax - yMin)>>MDP_PREC) + 4; | ||
| 1907 | |||
| 1908 | /* Because of support of the KEY_STROKE_CONTROL hint we are performing | ||
| 1909 | * shift of the coordinates at the higher level | ||
| 1910 | */ | ||
| 1911 | int hashOffset = ((yMin - 1) & MDP_W_MASK); | ||
| 1912 | |||
| 1913 | /* Winding counter */ | ||
| 1914 | int counter; | ||
| 1915 | |||
| 1916 | /* Calculating mask to be applied to the winding counter */ | ||
| 1917 | int counterMask = | ||
| 1918 | (fillRule == PathIterator.WIND_NON_ZERO)? -1:1; | ||
| 1919 | |||
| 1920 | int pntOffset; | ||
| 1921 | List<Point> pnts = fd.plgPnts; | ||
| 1922 | n = pnts.size(); | ||
| 1923 | |||
| 1924 | if (n <=1) return; | ||
| 1925 | |||
| 1926 | Point[] yHash = new Point[hashSize]; | ||
| 1927 | |||
| 1928 | /* Creating double linked list (prev, next links) describing path order | ||
| 1929 | * and hash table with points which fall between scanlines. nextByY | ||
| 1930 | * link is used for the points which are between same scanlines. | ||
| 1931 | * Scanlines are passed through the centers of the pixels. | ||
| 1932 | */ | ||
| 1933 | Point curpt = pnts.get(0); | ||
| 1934 | curpt.prev = null; | ||
| 1935 | for (int i = 0; i < n - 1; i++) { | ||
| 1936 | curpt = pnts.get(i); | ||
| 1937 | Point nextpt = pnts.get(i + 1); | ||
| 1938 | int curHashInd = (curpt.y - hashOffset - 1) >> MDP_PREC; | ||
| 1939 | curpt.nextByY = yHash[curHashInd]; | ||
| 1940 | yHash[curHashInd] = curpt; | ||
| 1941 | curpt.next = nextpt; | ||
| 1942 | nextpt.prev = curpt; | ||
| 1943 | } | ||
| 1944 | |||
| 1945 | Point ept = pnts.get(n - 1); | ||
| 1946 | int curHashInd = (ept.y - hashOffset - 1) >> MDP_PREC; | ||
| 1947 | ept.nextByY = yHash[curHashInd]; | ||
| 1948 | yHash[curHashInd] = ept; | ||
| 1949 | |||
| 1950 | ActiveEdgeList activeList = new ActiveEdgeList(); | ||
| 1951 | |||
| 1952 | for (y=hashOffset + MDP_MULT,k = 0; | ||
| 1953 | y<=yMax && k < hashSize; y += MDP_MULT, k++) | ||
| 1954 | { | ||
| 1955 | for(Point pt = yHash[k];pt != null; pt=pt.nextByY) { | ||
| 1956 | /* pt.y should be inside hashed interval | ||
| 1957 | * assert(y-MDP_MULT <= pt.y && pt.y < y); | ||
| 1958 | */ | ||
| 1959 | if (pt.prev != null && !pt.prev.lastPoint) { | ||
| 1960 | if (pt.prev.edge != null && pt.prev.y <= y) { | ||
| 1961 | activeList.delete(pt.prev.edge); | ||
| 1962 | pt.prev.edge = null; | ||
| 1963 | } else if (pt.prev.y > y) { | ||
| 1964 | activeList.insert(pt.prev, y); | ||
| 1965 | } | ||
| 1966 | } | ||
| 1967 | |||
| 1968 | if (!pt.lastPoint && pt.next != null) { | ||
| 1969 | if (pt.edge != null && pt.next.y <= y) { | ||
| 1970 | activeList.delete(pt.edge); | ||
| 1971 | pt.edge = null; | ||
| 1972 | } else if (pt.next.y > y) { | ||
| 1973 | activeList.insert(pt, y); | ||
| 1974 | } | ||
| 1975 | } | ||
| 1976 | } | ||
| 1977 | |||
| 1978 | if (activeList.isEmpty()) continue; | ||
| 1979 | |||
| 1980 | activeList.sort(); | ||
| 1981 | |||
| 1982 | counter = 0; | ||
| 1983 | drawing = false; | ||
| 1984 | int xl, xr; | ||
| 1985 | xl = xr = hnd.dhnd.xMin; | ||
| 1986 | Edge curEdge = activeList.head; | ||
| 1987 | while (curEdge != null) { | ||
| 1988 | counter += curEdge.dir; | ||
| 1989 | if ((counter & counterMask) != 0 && !drawing) { | ||
| 1990 | xl = (curEdge.x + MDP_MULT - 1)>>MDP_PREC; | ||
| 1991 | drawing = true; | ||
| 1992 | } | ||
| 1993 | |||
| 1994 | if ((counter & counterMask) == 0 && drawing) { | ||
| 1995 | xr = (curEdge.x - 1) >> MDP_PREC; | ||
| 1996 | if (xl <= xr) { | ||
| 1997 | hnd.dhnd.drawScanline(xl, xr, y >> MDP_PREC); | ||
| 1998 | } | ||
| 1999 | drawing = false; | ||
| 2000 | } | ||
| 2001 | |||
| 2002 | curEdge.x += curEdge.dx; | ||
| 2003 | curEdge = curEdge.next; | ||
| 2004 | } | ||
| 2005 | |||
| 2006 | /* Performing drawing till the right boundary (for correct | ||
| 2007 | * rendering shapes clipped at the right side) | ||
| 2008 | */ | ||
| 2009 | if (drawing && xl <= rightBnd) { | ||
| 2010 | |||
| 2011 | /* Support of the strokeHint was added into the | ||
| 2012 | * draw and fill methods of the sun.java2d.pipe.LoopPipe | ||
| 2013 | */ | ||
| 2014 | hnd.dhnd.drawScanline(xl, rightBnd, y >> MDP_PREC); | ||
| 2015 | } | ||
| 2016 | } | ||
| 2017 | } | ||
| 2018 | |||
| 2019 | private static class FillProcessHandler extends ProcessHandler { | ||
| 2020 | |||
| 2021 | FillData fd; | ||
| 2022 | |||
| 2023 | /* Note: For more easy reading of the code below each java version of | ||
| 2024 | * the macros from the ProcessPath.c preceded by the commented | ||
| 2025 | * origin call containing verbose names of the parameters | ||
| 2026 | */ | ||
| 2027 | public void processFixedLine(int x1, int y1, int x2, int y2, | ||
| 2028 | int[] pixelInfo, boolean checkBounds, | ||
| 2029 | boolean endSubPath) | ||
| 2030 | { | ||
| 2031 | int outXMin, outXMax, outYMin, outYMax; | ||
| 2032 | int res; | ||
| 2033 | |||
| 2034 | /* There is no need to round line coordinates to the forward | ||
| 2035 | * differencing precision anymore. Such a rounding was used for | ||
| 2036 | * preventing the curve go out the endpoint (this sometimes does | ||
| 2037 | * not help). The problem was fixed in the forward differencing | ||
| 2038 | * loops. | ||
| 2039 | */ | ||
| 2040 | if (checkBounds) { | ||
| 2041 | boolean lastClipped; | ||
| 2042 | |||
| 2043 | /* This function is used only for filling shapes, so there is no | ||
| 2044 | * check for the type of clipping | ||
| 2045 | */ | ||
| 2046 | int c[] = new int[]{x1, y1, x2, y2, 0, 0}; | ||
| 2047 | outXMin = (int)(dhnd.xMinf * MDP_MULT); | ||
| 2048 | outXMax = (int)(dhnd.xMaxf * MDP_MULT); | ||
| 2049 | outYMin = (int)(dhnd.yMinf * MDP_MULT); | ||
| 2050 | outYMax = (int)(dhnd.yMaxf * MDP_MULT); | ||
| 2051 | |||
| 2052 | /* | ||
| 2053 | * TESTANDCLIP(outYMin, outYMax, y1, x1, y2, x2, res); | ||
| 2054 | */ | ||
| 2055 | res = TESTANDCLIP(outYMin, outYMax, c, 1, 0, 3, 2); | ||
| 2056 | if (res == CRES_INVISIBLE) return; | ||
| 2057 | |||
| 2058 | /* | ||
| 2059 | * TESTANDCLIP(outYMin, outYMax, y2, x2, y1, x1, res); | ||
| 2060 | */ | ||
| 2061 | res = TESTANDCLIP(outYMin, outYMax, c, 3, 2, 1, 0); | ||
| 2062 | if (res == CRES_INVISIBLE) return; | ||
| 2063 | lastClipped = IS_CLIPPED(res); | ||
| 2064 | |||
| 2065 | /* Clamping starting from first vertex of the the processed | ||
| 2066 | * segment | ||
| 2067 | * | ||
| 2068 | * CLIPCLAMP(outXMin, outXMax, x1, y1, x2, y2, x3, y3, res); | ||
| 2069 | */ | ||
| 2070 | res = CLIPCLAMP(outXMin, outXMax, c, 0, 1, 2, 3, 4, 5); | ||
| 2071 | |||
| 2072 | /* Clamping only by left boundary */ | ||
| 2073 | if (res == CRES_MIN_CLIPPED) { | ||
| 2074 | processFixedLine(c[4], c[5], c[0], c[1], pixelInfo, | ||
| 2075 | false, lastClipped); | ||
| 2076 | |||
| 2077 | } else if (res == CRES_INVISIBLE) { | ||
| 2078 | return; | ||
| 2079 | } | ||
| 2080 | |||
| 2081 | /* Clamping starting from last vertex of the the processed | ||
| 2082 | * segment | ||
| 2083 | * | ||
| 2084 | * CLIPCLAMP(outXMin, outXMax, x2, y2, x1, y1, x3, y3, res); | ||
| 2085 | */ | ||
| 2086 | res = CLIPCLAMP(outXMin, outXMax, c, 2, 3, 0, 1, 4, 5); | ||
| 2087 | |||
| 2088 | /* Checking if there was a clip by right boundary */ | ||
| 2089 | lastClipped = lastClipped || (res == CRES_MAX_CLIPPED); | ||
| 2090 | |||
| 2091 | processFixedLine(c[0], c[1], c[2], c[3], pixelInfo, | ||
| 2092 | false, lastClipped); | ||
| 2093 | |||
| 2094 | /* Clamping only by left boundary */ | ||
| 2095 | if (res == CRES_MIN_CLIPPED) { | ||
| 2096 | processFixedLine(c[2], c[3], c[4], c[5], pixelInfo, | ||
| 2097 | false, lastClipped); | ||
| 2098 | } | ||
| 2099 | |||
| 2100 | return; | ||
| 2101 | } | ||
| 2102 | |||
| 2103 | /* Adding first point of the line only in case of empty or just | ||
| 2104 | * finished path | ||
| 2105 | */ | ||
| 2106 | if (fd.isEmpty() || fd.isEnded()) { | ||
| 2107 | fd.addPoint(x1, y1, false); | ||
| 2108 | } | ||
| 2109 | |||
| 2110 | fd.addPoint(x2, y2, false); | ||
| 2111 | |||
| 2112 | if (endSubPath) { | ||
| 2113 | fd.setEnded(); | ||
| 2114 | } | ||
| 2115 | } | ||
| 2116 | |||
| 2117 | FillProcessHandler(DrawHandler dhnd) { | ||
| 2118 | super(dhnd, PH_MODE_FILL_CLIP); | ||
| 2119 | this.fd = new FillData(); | ||
| 2120 | } | ||
| 2121 | |||
| 2122 | public void processEndSubPath() { | ||
| 2123 | if (!fd.isEmpty()) { | ||
| 2124 | fd.setEnded(); | ||
| 2125 | } | ||
| 2126 | } | ||
| 2127 | } | ||
| 2128 | } | ||
Binary file not shown.
Binary file not shown.
| @@ -0,0 +1,103 @@ | |||
| 1 | /* | ||
| 2 | * Copyright (c) 1999, 2004, Oracle and/or its affiliates. All rights reserved. | ||
| 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 | ||
| 7 | * published by the Free Software Foundation. Oracle designates this | ||
| 8 | * particular file as subject to the "Classpath" exception as provided | ||
| 9 | * by Oracle in the LICENSE file that accompanied this code. | ||
| 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 | * | ||
| 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. | ||
| 24 | */ | ||
| 25 | |||
| 26 | package sun.java2d.loops; | ||
| 27 | |||
| 28 | public final class RenderCache { | ||
| 29 | final class Entry { | ||
| 30 | private SurfaceType src; | ||
| 31 | private CompositeType comp; | ||
| 32 | private SurfaceType dst; | ||
| 33 | private Object value; | ||
| 34 | |||
| 35 | public Entry(SurfaceType src, | ||
| 36 | CompositeType comp, | ||
| 37 | SurfaceType dst, | ||
| 38 | Object value) | ||
| 39 | { | ||
| 40 | this.src = src; | ||
| 41 | this.comp = comp; | ||
| 42 | this.dst = dst; | ||
| 43 | this.value = value; | ||
| 44 | } | ||
| 45 | |||
| 46 | public boolean matches(SurfaceType src, | ||
| 47 | CompositeType comp, | ||
| 48 | SurfaceType dst) | ||
| 49 | { | ||
| 50 | // bug 4725045: using equals() causes different SurfaceType | ||
| 51 | // objects with the same strings to match in the cache, which is | ||
| 52 | // not the behavior we want. Constrain the match to succeed only | ||
| 53 | // on object matches instead. | ||
| 54 | return ((this.src == src) && | ||
| 55 | (this.comp == comp) && | ||
| 56 | (this.dst == dst)); | ||
| 57 | } | ||
| 58 | |||
| 59 | public Object getValue() { | ||
| 60 | return value; | ||
| 61 | } | ||
| 62 | } | ||
| 63 | |||
| 64 | private Entry entries[]; | ||
| 65 | |||
| 66 | public RenderCache(int size) { | ||
| 67 | entries = new Entry[size]; | ||
| 68 | } | ||
| 69 | |||
| 70 | public synchronized Object get(SurfaceType src, | ||
| 71 | CompositeType comp, | ||
| 72 | SurfaceType dst) | ||
| 73 | { | ||
| 74 | int max = entries.length - 1; | ||
| 75 | for (int i = max; i >= 0; i--) { | ||
| 76 | Entry e = entries[i]; | ||
| 77 | if (e == null) { | ||
| 78 | break; | ||
| 79 | } | ||
| 80 | if (e.matches(src, comp, dst)) { | ||
| 81 | if (i < max - 4) { | ||
| 82 | System.arraycopy(entries, i+1, entries, i, max - i); | ||
| 83 | entries[max] = e; | ||
| 84 | } | ||
| 85 | return e.getValue(); | ||
| 86 | } | ||
| 87 | } | ||
| 88 | |||
| 89 | return null; | ||
| 90 | } | ||
| 91 | |||
| 92 | public synchronized void put(SurfaceType src, | ||
| 93 | CompositeType comp, | ||
| 94 | SurfaceType dst, | ||
| 95 | Object value) | ||
| 96 | { | ||
| 97 | Entry e = new Entry(src, comp, dst, value); | ||
| 98 | |||
| 99 | int num = entries.length; | ||
| 100 | System.arraycopy(entries, 1, entries, 0, num - 1); | ||
| 101 | entries[num - 1] = e; | ||
| 102 | } | ||
| 103 | } | ||
Binary file not shown.
| @@ -0,0 +1,55 @@ | |||
| 1 | /* | ||
| 2 | * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved. | ||
| 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 | ||
| 7 | * published by the Free Software Foundation. Oracle designates this | ||
| 8 | * particular file as subject to the "Classpath" exception as provided | ||
| 9 | * by Oracle in the LICENSE file that accompanied this code. | ||
| 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 | * | ||
| 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. | ||
| 24 | */ | ||
| 25 | |||
| 26 | package sun.java2d.loops; | ||
| 27 | |||
| 28 | /* | ||
| 29 | * This class stores the various loops that are used by the | ||
| 30 | * standard rendering pipelines. The loops for a given instance | ||
| 31 | * of this class will all share the same destination type and the | ||
| 32 | * same supported paint and composite operation. | ||
| 33 | * Each instance of this class should be shared by all graphics | ||
| 34 | * objects that render onto the same type of destination with the | ||
| 35 | * same paint and composite combination to reduce the amount of | ||
| 36 | * time spent looking up loops appropriate for the current fill | ||
| 37 | * technique. | ||
| 38 | */ | ||
| 39 | public class RenderLoops { | ||
| 40 | |||
| 41 | public static final int primTypeID = GraphicsPrimitive.makePrimTypeID(); | ||
| 42 | |||
| 43 | public DrawLine drawLineLoop; | ||
| 44 | public FillRect fillRectLoop; | ||
| 45 | public DrawRect drawRectLoop; | ||
| 46 | public DrawPolygons drawPolygonsLoop; | ||
| 47 | public DrawPath drawPathLoop; | ||
| 48 | public FillPath fillPathLoop; | ||
| 49 | public FillSpans fillSpansLoop; | ||
| 50 | public FillParallelogram fillParallelogramLoop; | ||
| 51 | public DrawParallelogram drawParallelogramLoop; | ||
| 52 | public DrawGlyphList drawGlyphListLoop; | ||
| 53 | public DrawGlyphListAA drawGlyphListAALoop; | ||
| 54 | public DrawGlyphListLCD drawGlyphListLCDLoop; | ||
| 55 | } | ||
Binary file not shown.
Binary file not shown.
| @@ -0,0 +1,156 @@ | |||
| 1 | /* | ||
| 2 | * Copyright (c) 2001, 2004, Oracle and/or its affiliates. All rights reserved. | ||
| 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 | ||
| 7 | * published by the Free Software Foundation. Oracle designates this | ||
| 8 | * particular file as subject to the "Classpath" exception as provided | ||
| 9 | * by Oracle in the LICENSE file that accompanied this code. | ||
| 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 | * | ||
| 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. | ||
| 24 | */ | ||
| 25 | |||
| 26 | package sun.java2d.loops; | ||
| 27 | |||
| 28 | import java.awt.Composite; | ||
| 29 | import java.lang.ref.WeakReference; | ||
| 30 | import sun.java2d.loops.GraphicsPrimitive; | ||
| 31 | import sun.java2d.SurfaceData; | ||
| 32 | import sun.java2d.pipe.Region; | ||
| 33 | |||
| 34 | /** | ||
| 35 | * ScaledBlit | ||
| 36 | * 1) copies rectangle of pixels from one surface to another | ||
| 37 | * while scaling the pixels to meet the sizes specified | ||
| 38 | * 2) performs compositing of colors based upon a Composite | ||
| 39 | * parameter | ||
| 40 | * | ||
| 41 | * precise behavior is undefined if the source surface | ||
| 42 | * and the destination surface are the same surface | ||
| 43 | * with overlapping regions of pixels | ||
| 44 | */ | ||
| 45 | |||
| 46 | public class ScaledBlit extends GraphicsPrimitive | ||
| 47 | { | ||
| 48 | public static final String methodSignature = "ScaledBlit(...)".toString(); | ||
| 49 | |||
| 50 | public static final int primTypeID = makePrimTypeID(); | ||
| 51 | |||
| 52 | private static RenderCache blitcache = new RenderCache(20); | ||
| 53 | |||
| 54 | public static ScaledBlit locate(SurfaceType srctype, | ||
| 55 | CompositeType comptype, | ||
| 56 | SurfaceType dsttype) | ||
| 57 | { | ||
| 58 | return (ScaledBlit) | ||
| 59 | GraphicsPrimitiveMgr.locate(primTypeID, | ||
| 60 | srctype, comptype, dsttype); | ||
| 61 | } | ||
| 62 | |||
| 63 | public static ScaledBlit getFromCache(SurfaceType src, | ||
| 64 | CompositeType comp, | ||
| 65 | SurfaceType dst) | ||
| 66 | { | ||
| 67 | Object o = blitcache.get(src, comp, dst); | ||
| 68 | if (o != null) { | ||
| 69 | return (ScaledBlit) o; | ||
| 70 | } | ||
| 71 | ScaledBlit blit = locate(src, comp, dst); | ||
| 72 | if (blit == null) { | ||
| 73 | /* | ||
| 74 | System.out.println("blit loop not found for:"); | ||
| 75 | System.out.println("src: "+src); | ||
| 76 | System.out.println("comp: "+comp); | ||
| 77 | System.out.println("dst: "+dst); | ||
| 78 | */ | ||
| 79 | } else { | ||
| 80 | blitcache.put(src, comp, dst, blit); | ||
| 81 | } | ||
| 82 | return blit; | ||
| 83 | } | ||
| 84 | |||
| 85 | protected ScaledBlit(SurfaceType srctype, | ||
| 86 | CompositeType comptype, | ||
| 87 | SurfaceType dsttype) | ||
| 88 | { | ||
| 89 | super(methodSignature, primTypeID, srctype, comptype, dsttype); | ||
| 90 | } | ||
| 91 | |||
| 92 | public ScaledBlit(long pNativePrim, | ||
| 93 | SurfaceType srctype, | ||
| 94 | CompositeType comptype, | ||
| 95 | SurfaceType dsttype) | ||
| 96 | { | ||
| 97 | super(pNativePrim, methodSignature, primTypeID, | ||
| 98 | srctype, comptype, dsttype); | ||
| 99 | } | ||
| 100 | |||
| 101 | public native void Scale(SurfaceData src, SurfaceData dst, | ||
| 102 | Composite comp, Region clip, | ||
| 103 | int sx1, int sy1, | ||
| 104 | int sx2, int sy2, | ||
| 105 | double dx1, double dy1, | ||
| 106 | double dx2, double dy2); | ||
| 107 | |||
| 108 | static { | ||
| 109 | GraphicsPrimitiveMgr.registerGeneral(new ScaledBlit(null, null, null)); | ||
| 110 | } | ||
| 111 | |||
| 112 | public GraphicsPrimitive makePrimitive(SurfaceType srctype, | ||
| 113 | CompositeType comptype, | ||
| 114 | SurfaceType dsttype) | ||
| 115 | { | ||
| 116 | /* | ||
| 117 | System.out.println("Constructing general blit for:"); | ||
| 118 | System.out.println("src: "+srctype); | ||
| 119 | System.out.println("comp: "+comptype); | ||
| 120 | System.out.println("dst: "+dsttype); | ||
| 121 | */ | ||
| 122 | return null; | ||
| 123 | } | ||
| 124 | |||
| 125 | public GraphicsPrimitive traceWrap() { | ||
| 126 | return new TraceScaledBlit(this); | ||
| 127 | } | ||
| 128 | |||
| 129 | private static class TraceScaledBlit extends ScaledBlit { | ||
| 130 | ScaledBlit target; | ||
| 131 | |||
| 132 | public TraceScaledBlit(ScaledBlit target) { | ||
| 133 | super(target.getSourceType(), | ||
| 134 | target.getCompositeType(), | ||
| 135 | target.getDestType()); | ||
| 136 | this.target = target; | ||
| 137 | } | ||
| 138 | |||
| 139 | public GraphicsPrimitive traceWrap() { | ||
| 140 | return this; | ||
| 141 | } | ||
| 142 | |||
| 143 | public void Scale(SurfaceData src, SurfaceData dst, | ||
| 144 | Composite comp, Region clip, | ||
| 145 | int sx1, int sy1, | ||
| 146 | int sx2, int sy2, | ||
| 147 | double dx1, double dy1, | ||
| 148 | double dx2, double dy2) | ||
| 149 | { | ||
| 150 | tracePrimitive(target); | ||
| 151 | target.Scale(src, dst, comp, clip, | ||
| 152 | sx1, sy1, sx2, sy2, | ||
| 153 | dx1, dy1, dx2, dy2); | ||
| 154 | } | ||
| 155 | } | ||
| 156 | } | ||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
| @@ -0,0 +1,460 @@ | |||
| 1 | /* | ||
| 2 | * Copyright (c) 1999, 2008, Oracle and/or its affiliates. All rights reserved. | ||
| 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 | ||
| 7 | * published by the Free Software Foundation. Oracle designates this | ||
| 8 | * particular file as subject to the "Classpath" exception as provided | ||
| 9 | * by Oracle in the LICENSE file that accompanied this code. | ||
| 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 | * | ||
| 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. | ||
| 24 | */ | ||
| 25 | |||
| 26 | package sun.java2d.loops; | ||
| 27 | |||
| 28 | import java.awt.image.BufferedImage; | ||
| 29 | import java.awt.image.ColorModel; | ||
| 30 | import sun.awt.image.PixelConverter; | ||
| 31 | import java.util.HashMap; | ||
| 32 | |||
| 33 | /** | ||
| 34 | * A SurfaceType object provides a chained description of a type of | ||
| 35 | * drawing surface. The object will provide a single String constant | ||
| 36 | * descriptor which is one way of viewing or accessing a particular | ||
| 37 | * drawing surface as well as a pointer to another SurfaceType which | ||
| 38 | * describes the same drawing surface in a different (typically more | ||
| 39 | * generalized) way. | ||
| 40 | * <p> | ||
| 41 | * A more specific description of a surface is considered a "subtype" | ||
| 42 | * and a more general description is considered a "supertype". Thus, | ||
| 43 | * the deriveSubType method provides a way to create a new SurfaceType | ||
| 44 | * that is related to but more specific than an existing SurfaceType and | ||
| 45 | * the getSuperType method provides a way to ask a given SurfaceType | ||
| 46 | * for a more general way to describe the same surface. | ||
| 47 | * <p> | ||
| 48 | * Note that you cannot construct a brand new root for a chain since | ||
| 49 | * the constructor is private. Every chain of types must at some point | ||
| 50 | * derive from the Any node provided here using the deriveSubType() | ||
| 51 | * method. The presence of this common Any node on every chain | ||
| 52 | * ensures that all chains end with the DESC_ANY descriptor so that | ||
| 53 | * a suitable General GraphicsPrimitive object can be obtained for | ||
| 54 | * the indicated surface if all of the more specific searches fail. | ||
| 55 | */ | ||
| 56 | public final class SurfaceType { | ||
| 57 | |||
| 58 | private static int unusedUID = 1; | ||
| 59 | private static HashMap surfaceUIDMap = new HashMap(100); | ||
| 60 | |||
| 61 | /* | ||
| 62 | * CONSTANTS USED BY ALL PRIMITIVES TO DESCRIBE THE SURFACES | ||
| 63 | * THEY CAN OPERATE ON | ||
| 64 | */ | ||
| 65 | |||
| 66 | /** | ||
| 67 | * surface is unknown color model or sample model. | ||
| 68 | */ | ||
| 69 | public static final String | ||
| 70 | DESC_ANY = "Any Surface"; | ||
| 71 | |||
| 72 | /** | ||
| 73 | * common surface formats defined in BufferedImage | ||
| 74 | */ | ||
| 75 | public static final String | ||
| 76 | DESC_INT_RGB = "Integer RGB"; | ||
| 77 | public static final String | ||
| 78 | DESC_INT_ARGB = "Integer ARGB"; | ||
| 79 | public static final String | ||
| 80 | DESC_INT_ARGB_PRE = "Integer ARGB Premultiplied"; | ||
| 81 | public static final String | ||
| 82 | DESC_INT_BGR = "Integer BGR"; | ||
| 83 | public static final String | ||
| 84 | DESC_3BYTE_BGR = "3 Byte BGR"; | ||
| 85 | public static final String | ||
| 86 | DESC_4BYTE_ABGR = "4 Byte ABGR"; | ||
| 87 | public static final String | ||
| 88 | DESC_4BYTE_ABGR_PRE = "4 Byte ABGR Premultiplied"; | ||
| 89 | public static final String | ||
| 90 | DESC_USHORT_565_RGB = "Short 565 RGB"; | ||
| 91 | public static final String | ||
| 92 | DESC_USHORT_555_RGB = "Short 555 RGB"; | ||
| 93 | public static final String | ||
| 94 | DESC_USHORT_555_RGBx= "Short 555 RGBx"; | ||
| 95 | public static final String | ||
| 96 | DESC_USHORT_4444_ARGB= "Short 4444 ARGB"; | ||
| 97 | public static final String | ||
| 98 | DESC_BYTE_GRAY = "8-bit Gray"; | ||
| 99 | public static final String | ||
| 100 | DESC_USHORT_INDEXED = "16-bit Indexed"; | ||
| 101 | public static final String | ||
| 102 | DESC_USHORT_GRAY = "16-bit Gray"; | ||
| 103 | public static final String | ||
| 104 | DESC_BYTE_BINARY = "Packed Binary Bitmap"; | ||
| 105 | public static final String | ||
| 106 | DESC_BYTE_INDEXED = "8-bit Indexed"; | ||
| 107 | |||
| 108 | /** | ||
| 109 | * wildcard format which indicates that the GraphicsPrimitive | ||
| 110 | * is independent of the color model on an IntegerComponent | ||
| 111 | * sample model surface | ||
| 112 | */ | ||
| 113 | public static final String DESC_ANY_INT = "Any Discrete Integer"; | ||
| 114 | |||
| 115 | /** | ||
| 116 | * wildcard format which indicates that the GraphicsPrimitive | ||
| 117 | * is independent of the color model on a ShortComponent | ||
| 118 | * sample model surface | ||
| 119 | */ | ||
| 120 | public static final String DESC_ANY_SHORT = "Any Discrete Short"; | ||
| 121 | |||
| 122 | /** | ||
| 123 | * wildcard format which indicates that the GraphicsPrimitive | ||
| 124 | * is independent of the color model on a ByteComponent | ||
| 125 | * sample model surface | ||
| 126 | */ | ||
| 127 | public static final String DESC_ANY_BYTE = "Any Discrete Byte"; | ||
| 128 | |||
| 129 | /** | ||
| 130 | * wildcard format which indicates that the GraphicsPrimitive | ||
| 131 | * operates on a surface with 3 component interleaved Raster and | ||
| 132 | * sample model and a ComponentColorModel with an arbitrary ordering | ||
| 133 | * of the RGB channels | ||
| 134 | */ | ||
| 135 | public static final String DESC_ANY_3BYTE = "Any 3 Byte Component"; | ||
| 136 | |||
| 137 | /** | ||
| 138 | * wildcard format which indicates that the GraphicsPrimitive | ||
| 139 | * operates on a surface with 4 component interleaved Raster and | ||
| 140 | * sample model and a ComponentColorModel with an arbitrary ordering | ||
| 141 | * of the ARGB channels | ||
| 142 | */ | ||
| 143 | public static final String DESC_ANY_4BYTE = "Any 4 Byte Component"; | ||
| 144 | |||
| 145 | /** | ||
| 146 | * wildcard format which indicates that the GraphicsPrimitive | ||
| 147 | * operates on a surface with a single component IntegerComponent | ||
| 148 | * sample model and a DirectColorModel with an arbitrary ordering | ||
| 149 | * of the RGB channels | ||
| 150 | */ | ||
| 151 | public static final String DESC_ANY_INT_DCM = "Any Integer DCM"; | ||
| 152 | |||
| 153 | /** | ||
| 154 | * additional IntegerComponent types common on Windows | ||
| 155 | */ | ||
| 156 | public static final String DESC_INT_RGBx = "Integer RGBx"; | ||
| 157 | public static final String DESC_INT_BGRx = "Integer BGRx"; | ||
| 158 | |||
| 159 | /** | ||
| 160 | * additional 3 byte format common on Windows | ||
| 161 | */ | ||
| 162 | public static final String DESC_3BYTE_RGB = "3 Byte RGB"; | ||
| 163 | |||
| 164 | /** | ||
| 165 | * common formats for BITMASK transparency. | ||
| 166 | */ | ||
| 167 | public static final String DESC_INT_ARGB_BM = "Int ARGB (Bitmask)"; | ||
| 168 | public static final String DESC_BYTE_INDEXED_BM = "8-bit Indexed (Bitmask)"; | ||
| 169 | |||
| 170 | /** | ||
| 171 | * Opaque 8-bit indexed images | ||
| 172 | */ | ||
| 173 | public static final String | ||
| 174 | DESC_BYTE_INDEXED_OPAQUE = "8-bit Indexed (Opaque)"; | ||
| 175 | |||
| 176 | /** | ||
| 177 | * Special Gray Scale types for rendering loops. Really indexed | ||
| 178 | * types, but colormap has all gray values. | ||
| 179 | */ | ||
| 180 | public static final String DESC_INDEX8_GRAY = "8-bit Palettized Gray"; | ||
| 181 | public static final String DESC_INDEX12_GRAY = "12-bit Palettized Gray"; | ||
| 182 | |||
| 183 | public static final String | ||
| 184 | DESC_BYTE_BINARY_1BIT = "Packed Binary 1-bit Bitmap"; | ||
| 185 | public static final String | ||
| 186 | DESC_BYTE_BINARY_2BIT = "Packed Binary 2-bit Bitmap"; | ||
| 187 | public static final String | ||
| 188 | DESC_BYTE_BINARY_4BIT = "Packed Binary 4-bit Bitmap"; | ||
| 189 | |||
| 190 | /** | ||
| 191 | * Special type for describing the sources of loops that render the | ||
| 192 | * current foreground color or paint instead of copying colors from | ||
| 193 | * a source surface. | ||
| 194 | */ | ||
| 195 | public static final String DESC_ANY_PAINT = "Paint Object"; | ||
| 196 | public static final String DESC_ANY_COLOR = "Single Color"; | ||
| 197 | public static final String DESC_OPAQUE_COLOR = "Opaque Color"; | ||
| 198 | public static final String | ||
| 199 | DESC_GRADIENT_PAINT = "Gradient Paint"; | ||
| 200 | public static final String | ||
| 201 | DESC_OPAQUE_GRADIENT_PAINT = "Opaque Gradient Paint"; | ||
| 202 | public static final String | ||
| 203 | DESC_TEXTURE_PAINT = "Texture Paint"; | ||
| 204 | public static final String | ||
| 205 | DESC_OPAQUE_TEXTURE_PAINT = "Opaque Texture Paint"; | ||
| 206 | public static final String | ||
| 207 | DESC_LINEAR_GRADIENT_PAINT = "Linear Gradient Paint"; | ||
| 208 | public static final String | ||
| 209 | DESC_OPAQUE_LINEAR_GRADIENT_PAINT = "Opaque Linear Gradient Paint"; | ||
| 210 | public static final String | ||
| 211 | DESC_RADIAL_GRADIENT_PAINT = "Radial Gradient Paint"; | ||
| 212 | public static final String | ||
| 213 | DESC_OPAQUE_RADIAL_GRADIENT_PAINT = "Opaque Radial Gradient Paint"; | ||
| 214 | |||
| 215 | /* | ||
| 216 | * END OF SURFACE TYPE CONSTANTS | ||
| 217 | */ | ||
| 218 | |||
| 219 | |||
| 220 | /** | ||
| 221 | * The root SurfaceType object for all chains of surface descriptions. | ||
| 222 | * The root uses the default PixelConverter object, which uses a given | ||
| 223 | * ColorModel object to calculate its pixelFor() values when asked. | ||
| 224 | * Any SurfaceType objects that are not created with a specific | ||
| 225 | * PixelConverter object will inherit this behavior from the root. | ||
| 226 | */ | ||
| 227 | public static final SurfaceType Any = | ||
| 228 | new SurfaceType(null, DESC_ANY, PixelConverter.instance); | ||
| 229 | |||
| 230 | /* | ||
| 231 | * START OF SurfaceType OBJECTS FOR THE VARIOUS CONSTANTS | ||
| 232 | */ | ||
| 233 | |||
| 234 | public static final SurfaceType | ||
| 235 | AnyInt = Any.deriveSubType(DESC_ANY_INT); | ||
| 236 | public static final SurfaceType | ||
| 237 | AnyShort = Any.deriveSubType(DESC_ANY_SHORT); | ||
| 238 | public static final SurfaceType | ||
| 239 | AnyByte = Any.deriveSubType(DESC_ANY_BYTE); | ||
| 240 | public static final SurfaceType | ||
| 241 | AnyByteBinary = Any.deriveSubType(DESC_BYTE_BINARY); | ||
| 242 | public static final SurfaceType | ||
| 243 | Any3Byte = Any.deriveSubType(DESC_ANY_3BYTE); | ||
| 244 | public static final SurfaceType | ||
| 245 | Any4Byte = Any.deriveSubType(DESC_ANY_4BYTE); | ||
| 246 | public static final SurfaceType | ||
| 247 | AnyDcm = AnyInt.deriveSubType(DESC_ANY_INT_DCM); | ||
| 248 | |||
| 249 | public static final SurfaceType | ||
| 250 | Custom = Any; | ||
| 251 | public static final SurfaceType IntRgb = | ||
| 252 | AnyDcm.deriveSubType(DESC_INT_RGB, PixelConverter.Xrgb.instance); | ||
| 253 | |||
| 254 | public static final SurfaceType IntArgb = | ||
| 255 | AnyDcm.deriveSubType(DESC_INT_ARGB, PixelConverter.Argb.instance); | ||
| 256 | |||
| 257 | public static final SurfaceType IntArgbPre = | ||
| 258 | AnyDcm.deriveSubType(DESC_INT_ARGB_PRE, | ||
| 259 | PixelConverter.ArgbPre.instance); | ||
| 260 | |||
| 261 | public static final SurfaceType IntBgr = | ||
| 262 | AnyDcm.deriveSubType(DESC_INT_BGR, PixelConverter.Xbgr.instance); | ||
| 263 | |||
| 264 | public static final SurfaceType ThreeByteBgr = | ||
| 265 | Any3Byte.deriveSubType(DESC_3BYTE_BGR, PixelConverter.Xrgb.instance); | ||
| 266 | |||
| 267 | public static final SurfaceType FourByteAbgr = | ||
| 268 | Any4Byte.deriveSubType(DESC_4BYTE_ABGR, PixelConverter.Rgba.instance); | ||
| 269 | |||
| 270 | public static final SurfaceType FourByteAbgrPre = | ||
| 271 | Any4Byte.deriveSubType(DESC_4BYTE_ABGR_PRE, | ||
| 272 | PixelConverter.RgbaPre.instance); | ||
| 273 | |||
| 274 | public static final SurfaceType Ushort565Rgb = | ||
| 275 | AnyShort.deriveSubType(DESC_USHORT_565_RGB, | ||
| 276 | PixelConverter.Ushort565Rgb.instance); | ||
| 277 | |||
| 278 | public static final SurfaceType Ushort555Rgb = | ||
| 279 | AnyShort.deriveSubType(DESC_USHORT_555_RGB, | ||
| 280 | PixelConverter.Ushort555Rgb.instance); | ||
| 281 | |||
| 282 | public static final SurfaceType Ushort555Rgbx = | ||
| 283 | AnyShort.deriveSubType(DESC_USHORT_555_RGBx, | ||
| 284 | PixelConverter.Ushort555Rgbx.instance); | ||
| 285 | |||
| 286 | public static final SurfaceType Ushort4444Argb = | ||
| 287 | AnyShort.deriveSubType(DESC_USHORT_4444_ARGB, | ||
| 288 | PixelConverter.Ushort4444Argb.instance); | ||
| 289 | |||
| 290 | public static final SurfaceType UshortIndexed = | ||
| 291 | AnyShort.deriveSubType(DESC_USHORT_INDEXED); | ||
| 292 | |||
| 293 | public static final SurfaceType ByteGray = | ||
| 294 | AnyByte.deriveSubType(DESC_BYTE_GRAY, | ||
| 295 | PixelConverter.ByteGray.instance); | ||
| 296 | |||
| 297 | public static final SurfaceType UshortGray = | ||
| 298 | AnyShort.deriveSubType(DESC_USHORT_GRAY, | ||
| 299 | PixelConverter.UshortGray.instance); | ||
| 300 | |||
| 301 | public static final SurfaceType ByteBinary1Bit = | ||
| 302 | AnyByteBinary.deriveSubType(DESC_BYTE_BINARY_1BIT); | ||
| 303 | public static final SurfaceType ByteBinary2Bit = | ||
| 304 | AnyByteBinary.deriveSubType(DESC_BYTE_BINARY_2BIT); | ||
| 305 | public static final SurfaceType ByteBinary4Bit = | ||
| 306 | AnyByteBinary.deriveSubType(DESC_BYTE_BINARY_4BIT); | ||
| 307 | |||
| 308 | public static final SurfaceType ByteIndexed = | ||
| 309 | AnyByte.deriveSubType(DESC_BYTE_INDEXED); | ||
| 310 | |||
| 311 | public static final SurfaceType IntRgbx = | ||
| 312 | AnyDcm.deriveSubType(DESC_INT_RGBx, PixelConverter.Rgbx.instance); | ||
| 313 | |||
| 314 | public static final SurfaceType IntBgrx = | ||
| 315 | AnyDcm.deriveSubType(DESC_INT_BGRx, PixelConverter.Bgrx.instance); | ||
| 316 | |||
| 317 | public static final SurfaceType ThreeByteRgb = | ||
| 318 | Any3Byte.deriveSubType(DESC_3BYTE_RGB, PixelConverter.Xbgr.instance); | ||
| 319 | |||
| 320 | public static final SurfaceType IntArgbBm = | ||
| 321 | AnyDcm.deriveSubType(DESC_INT_ARGB_BM, PixelConverter.ArgbBm.instance); | ||
| 322 | |||
| 323 | public static final SurfaceType ByteIndexedBm = | ||
| 324 | ByteIndexed.deriveSubType(DESC_BYTE_INDEXED_BM); | ||
| 325 | |||
| 326 | public static final SurfaceType ByteIndexedOpaque = | ||
| 327 | ByteIndexedBm.deriveSubType(DESC_BYTE_INDEXED_OPAQUE); | ||
| 328 | |||
| 329 | public static final SurfaceType Index8Gray = | ||
| 330 | ByteIndexedOpaque.deriveSubType(DESC_INDEX8_GRAY); | ||
| 331 | |||
| 332 | public static final SurfaceType Index12Gray = | ||
| 333 | Any.deriveSubType(DESC_INDEX12_GRAY); | ||
| 334 | |||
| 335 | public static final SurfaceType AnyPaint = | ||
| 336 | Any.deriveSubType(DESC_ANY_PAINT); | ||
| 337 | |||
| 338 | public static final SurfaceType AnyColor = | ||
| 339 | AnyPaint.deriveSubType(DESC_ANY_COLOR); | ||
| 340 | |||
| 341 | public static final SurfaceType OpaqueColor = | ||
| 342 | AnyColor.deriveSubType(DESC_OPAQUE_COLOR); | ||
| 343 | |||
| 344 | public static final SurfaceType GradientPaint = | ||
| 345 | AnyPaint.deriveSubType(DESC_GRADIENT_PAINT); | ||
| 346 | public static final SurfaceType OpaqueGradientPaint = | ||
| 347 | GradientPaint.deriveSubType(DESC_OPAQUE_GRADIENT_PAINT); | ||
| 348 | |||
| 349 | public static final SurfaceType LinearGradientPaint = | ||
| 350 | AnyPaint.deriveSubType(DESC_LINEAR_GRADIENT_PAINT); | ||
| 351 | public static final SurfaceType OpaqueLinearGradientPaint = | ||
| 352 | LinearGradientPaint.deriveSubType(DESC_OPAQUE_LINEAR_GRADIENT_PAINT); | ||
| 353 | |||
| 354 | public static final SurfaceType RadialGradientPaint = | ||
| 355 | AnyPaint.deriveSubType(DESC_RADIAL_GRADIENT_PAINT); | ||
| 356 | public static final SurfaceType OpaqueRadialGradientPaint = | ||
| 357 | RadialGradientPaint.deriveSubType(DESC_OPAQUE_RADIAL_GRADIENT_PAINT); | ||
| 358 | |||
| 359 | public static final SurfaceType TexturePaint = | ||
| 360 | AnyPaint.deriveSubType(DESC_TEXTURE_PAINT); | ||
| 361 | public static final SurfaceType OpaqueTexturePaint = | ||
| 362 | TexturePaint.deriveSubType(DESC_OPAQUE_TEXTURE_PAINT); | ||
| 363 | |||
| 364 | /* | ||
| 365 | * END OF SurfaceType OBJECTS FOR THE VARIOUS CONSTANTS | ||
| 366 | */ | ||
| 367 | |||
| 368 | /** | ||
| 369 | * Return a new SurfaceType object which uses this object as its | ||
| 370 | * more general "supertype" descriptor. If no operation can be | ||
| 371 | * found that manipulates the type of surface described more exactly | ||
| 372 | * by desc, then this object will define the more relaxed specification | ||
| 373 | * of the surface that can be used to find a more general operator. | ||
| 374 | */ | ||
| 375 | public SurfaceType deriveSubType(String desc) { | ||
| 376 | return new SurfaceType(this, desc); | ||
| 377 | } | ||
| 378 | |||
| 379 | public SurfaceType deriveSubType(String desc, | ||
| 380 | PixelConverter pixelConverter) { | ||
| 381 | return new SurfaceType(this, desc, pixelConverter); | ||
| 382 | } | ||
| 383 | |||
| 384 | private int uniqueID; | ||
| 385 | private String desc; | ||
| 386 | private SurfaceType next; | ||
| 387 | protected PixelConverter pixelConverter; | ||
| 388 | |||
| 389 | private SurfaceType(SurfaceType parent, String desc, | ||
| 390 | PixelConverter pixelConverter) { | ||
| 391 | next = parent; | ||
| 392 | this.desc = desc; | ||
| 393 | this.uniqueID = makeUniqueID(desc); | ||
| 394 | this.pixelConverter = pixelConverter; | ||
| 395 | } | ||
| 396 | |||
| 397 | private SurfaceType(SurfaceType parent, String desc) { | ||
| 398 | next = parent; | ||
| 399 | this.desc = desc; | ||
| 400 | this.uniqueID = makeUniqueID(desc); | ||
| 401 | this.pixelConverter = parent.pixelConverter; | ||
| 402 | } | ||
| 403 | |||
| 404 | public synchronized static final int makeUniqueID(String desc) { | ||
| 405 | Integer i = (Integer) surfaceUIDMap.get((Object) desc); | ||
| 406 | |||
| 407 | if (i == null) { | ||
| 408 | if (unusedUID > 255) { | ||
| 409 | throw new InternalError("surface type id overflow"); | ||
| 410 | } | ||
| 411 | i = Integer.valueOf(unusedUID++); | ||
| 412 | surfaceUIDMap.put(desc, i); | ||
| 413 | } | ||
| 414 | return i.intValue(); | ||
| 415 | } | ||
| 416 | |||
| 417 | public int getUniqueID() { | ||
| 418 | return uniqueID; | ||
| 419 | } | ||
| 420 | |||
| 421 | public String getDescriptor() { | ||
| 422 | return desc; | ||
| 423 | } | ||
| 424 | |||
| 425 | public SurfaceType getSuperType() { | ||
| 426 | return next; | ||
| 427 | } | ||
| 428 | |||
| 429 | public PixelConverter getPixelConverter() { | ||
| 430 | return pixelConverter; | ||
| 431 | } | ||
| 432 | |||
| 433 | public int pixelFor(int rgb, ColorModel cm) { | ||
| 434 | return pixelConverter.rgbToPixel(rgb, cm); | ||
| 435 | } | ||
| 436 | |||
| 437 | public int rgbFor(int pixel, ColorModel cm) { | ||
| 438 | return pixelConverter.pixelToRgb(pixel, cm); | ||
| 439 | } | ||
| 440 | |||
| 441 | public int getAlphaMask() { | ||
| 442 | return pixelConverter.getAlphaMask(); | ||
| 443 | } | ||
| 444 | |||
| 445 | public int hashCode() { | ||
| 446 | return desc.hashCode(); | ||
| 447 | } | ||
| 448 | |||
| 449 | public boolean equals(Object o) { | ||
| 450 | if (o instanceof SurfaceType) { | ||
| 451 | return (((SurfaceType) o).uniqueID == this.uniqueID); | ||
| 452 | } | ||
| 453 | return false; | ||
| 454 | } | ||
| 455 | |||
| 456 | public String toString() { | ||
| 457 | return desc; | ||
| 458 | } | ||
| 459 | |||
| 460 | } | ||
| @@ -0,0 +1,157 @@ | |||
| 1 | /* | ||
| 2 | * Copyright (c) 2003, 2004, Oracle and/or its affiliates. All rights reserved. | ||
| 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 | ||
| 7 | * published by the Free Software Foundation. Oracle designates this | ||
| 8 | * particular file as subject to the "Classpath" exception as provided | ||
| 9 | * by Oracle in the LICENSE file that accompanied this code. | ||
| 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 | * | ||
| 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. | ||
| 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 | * TransformBlit | ||
| 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 | |||
| 47 | public class TransformBlit extends GraphicsPrimitive | ||
| 48 | { | ||
| 49 | public static final String methodSignature = | ||
| 50 | "TransformBlit(...)".toString(); | ||
| 51 | |||
| 52 | public static final int primTypeID = makePrimTypeID(); | ||
| 53 | |||
| 54 | private static RenderCache blitcache = new RenderCache(10); | ||
| 55 | |||
| 56 | public static TransformBlit locate(SurfaceType srctype, | ||
| 57 | CompositeType comptype, | ||
| 58 | SurfaceType dsttype) | ||
| 59 | { | ||
| 60 | return (TransformBlit) | ||
| 61 | GraphicsPrimitiveMgr.locate(primTypeID, | ||
| 62 | srctype, comptype, dsttype); | ||
| 63 | } | ||
| 64 | |||
| 65 | public static TransformBlit getFromCache(SurfaceType src, | ||
| 66 | CompositeType comp, | ||
| 67 | SurfaceType dst) | ||
| 68 | { | ||
| 69 | Object o = blitcache.get(src, comp, dst); | ||
| 70 | if (o != null) { | ||
| 71 | return (TransformBlit) o; | ||
| 72 | } | ||
| 73 | TransformBlit blit = locate(src, comp, dst); | ||
| 74 | if (blit == null) { | ||
| 75 | /* | ||
| 76 | System.out.println("blit loop not found for:"); | ||
| 77 | System.out.println("src: "+src); | ||
| 78 | System.out.println("comp: "+comp); | ||
| 79 | System.out.println("dst: "+dst); | ||
| 80 | */ | ||
| 81 | } else { | ||
| 82 | blitcache.put(src, comp, dst, blit); | ||
| 83 | } | ||
| 84 | return blit; | ||
| 85 | } | ||
| 86 | |||
| 87 | protected TransformBlit(SurfaceType srctype, | ||
| 88 | CompositeType comptype, | ||
| 89 | SurfaceType dsttype) | ||
| 90 | { | ||
| 91 | super(methodSignature, primTypeID, srctype, comptype, dsttype); | ||
| 92 | } | ||
| 93 | |||
| 94 | public TransformBlit(long pNativePrim, | ||
| 95 | SurfaceType srctype, | ||
| 96 | CompositeType comptype, | ||
| 97 | SurfaceType dsttype) | ||
| 98 | { | ||
| 99 | super(pNativePrim, methodSignature, primTypeID, | ||
| 100 | srctype, comptype, dsttype); | ||
| 101 | } | ||
| 102 | |||
| 103 | public native void Transform(SurfaceData src, SurfaceData dst, | ||
| 104 | Composite comp, Region clip, | ||
| 105 | AffineTransform at, int hint, | ||
| 106 | int srcx, int srcy, int dstx, int dsty, | ||
| 107 | int width, int height); | ||
| 108 | |||
| 109 | // REMIND: do we have a general loop? | ||
| 110 | static { | ||
| 111 | GraphicsPrimitiveMgr.registerGeneral(new TransformBlit(null, null, | ||
| 112 | null)); | ||
| 113 | } | ||
| 114 | |||
| 115 | public GraphicsPrimitive makePrimitive(SurfaceType srctype, | ||
| 116 | CompositeType comptype, | ||
| 117 | SurfaceType dsttype) | ||
| 118 | { | ||
| 119 | /* | ||
| 120 | System.out.println("Constructing general blit for:"); | ||
| 121 | System.out.println("src: "+srctype); | ||
| 122 | System.out.println("comp: "+comptype); | ||
| 123 | System.out.println("dst: "+dsttype); | ||
| 124 | */ | ||
| 125 | return null; | ||
| 126 | } | ||
| 127 | |||
| 128 | public GraphicsPrimitive traceWrap() { | ||
| 129 | return new TraceTransformBlit(this); | ||
| 130 | } | ||
| 131 | |||
| 132 | private static class TraceTransformBlit extends TransformBlit { | ||
| 133 | TransformBlit target; | ||
| 134 | |||
| 135 | public TraceTransformBlit(TransformBlit target) { | ||
| 136 | super(target.getSourceType(), | ||
| 137 | target.getCompositeType(), | ||
| 138 | target.getDestType()); | ||
| 139 | this.target = target; | ||
| 140 | } | ||
| 141 | |||
| 142 | public GraphicsPrimitive traceWrap() { | ||
| 143 | return this; | ||
| 144 | } | ||
| 145 | |||
| 146 | public void Transform(SurfaceData src, SurfaceData dst, | ||
| 147 | Composite comp, Region clip, | ||
| 148 | AffineTransform at, int hint, | ||
| 149 | int srcx, int srcy, int dstx, int dsty, | ||
| 150 | int width, int height) | ||
| 151 | { | ||
| 152 | tracePrimitive(target); | ||
| 153 | target.Transform(src, dst, comp, clip, at, hint, | ||
| 154 | srcx, srcy, dstx, dsty, width, height); | ||
| 155 | } | ||
| 156 | } | ||
| 157 | } | ||
Binary file not shown.
Binary file not shown.
| @@ -0,0 +1,140 @@ | |||
| 1 | /* | ||
| 2 | * Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved. | ||
| 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 | ||
| 7 | * published by the Free Software Foundation. Oracle designates this | ||
| 8 | * particular file as subject to the "Classpath" exception as provided | ||
| 9 | * by Oracle in the LICENSE file that accompanied this code. | ||
| 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 | * | ||
| 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. | ||
| 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 | } | ||
Binary file not shown.
| @@ -0,0 +1,72 @@ | |||
| 1 | /* | ||
| 2 | * Copyright (c) 1998, 2002, Oracle and/or its affiliates. All rights reserved. | ||
| 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 | ||
| 7 | * published by the Free Software Foundation. Oracle designates this | ||
| 8 | * particular file as subject to the "Classpath" exception as provided | ||
| 9 | * by Oracle in the LICENSE file that accompanied this code. | ||
| 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 | * | ||
| 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. | ||
| 24 | */ | ||
| 25 | |||
| 26 | package sun.java2d.loops; | ||
| 27 | |||
| 28 | import java.awt.image.ColorModel; | ||
| 29 | import java.awt.Color; | ||
| 30 | import java.awt.Composite; | ||
| 31 | import java.awt.CompositeContext; | ||
| 32 | import java.awt.RenderingHints; | ||
| 33 | import sun.java2d.SurfaceData; | ||
| 34 | import sun.java2d.SunCompositeContext; | ||
| 35 | |||
| 36 | /** | ||
| 37 | * Bitwise XOR Composite class. | ||
| 38 | */ | ||
| 39 | |||
| 40 | public final class XORComposite implements Composite { | ||
| 41 | |||
| 42 | Color xorColor; | ||
| 43 | int xorPixel; | ||
| 44 | int alphaMask; | ||
| 45 | |||
| 46 | public XORComposite(Color xorColor, SurfaceData sd) { | ||
| 47 | this.xorColor = xorColor; | ||
| 48 | |||
| 49 | SurfaceType sType = sd.getSurfaceType(); | ||
| 50 | |||
| 51 | this.xorPixel = sd.pixelFor(xorColor.getRGB()); | ||
| 52 | this.alphaMask = sType.getAlphaMask(); | ||
| 53 | } | ||
| 54 | |||
| 55 | public Color getXorColor() { | ||
| 56 | return xorColor; | ||
| 57 | } | ||
| 58 | |||
| 59 | public int getXorPixel() { | ||
| 60 | return xorPixel; | ||
| 61 | } | ||
| 62 | |||
| 63 | public int getAlphaMask() { | ||
| 64 | return alphaMask; | ||
| 65 | } | ||
| 66 | |||
| 67 | public CompositeContext createContext(ColorModel srcColorModel, | ||
| 68 | ColorModel dstColorModel, | ||
| 69 | RenderingHints hints) { | ||
| 70 | return new SunCompositeContext(this, srcColorModel, dstColorModel); | ||
| 71 | } | ||
| 72 | } | ||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
| @@ -0,0 +1,38 @@ | |||
| 1 | <../../../../../mkconfig | ||
| 2 | |||
| 3 | TARG=\ | ||
| 4 | Blit.dis\ | ||
| 5 | BlitBg.dis\ | ||
| 6 | CompositeType.dis\ | ||
| 7 | CustomComponent.dis\ | ||
| 8 | DrawGlyphList.dis\ | ||
| 9 | DrawGlyphListAA.dis\ | ||
| 10 | DrawGlyphListLCD.dis\ | ||
| 11 | DrawLine.dis\ | ||
| 12 | DrawParallelogram.dis\ | ||
| 13 | DrawPath.dis\ | ||
| 14 | DrawPolygons.dis\ | ||
| 15 | DrawRect.dis\ | ||
| 16 | FillParallelogram.dis\ | ||
| 17 | FillPath.dis\ | ||
| 18 | FillRect.dis\ | ||
| 19 | FillSpans.dis\ | ||
| 20 | FontInfo.dis\ | ||
| 21 | GeneralRenderer.dis\ | ||
| 22 | GraphicsPrimitive.dis\ | ||
| 23 | GraphicsPrimitiveMgr.dis\ | ||
| 24 | GraphicsPrimitiveProxy.dis\ | ||
| 25 | MaskBlit.dis\ | ||
| 26 | MaskFill.dis\ | ||
| 27 | ProcessPath.dis\ | ||
| 28 | RenderCache.dis\ | ||
| 29 | RenderLoops.dis\ | ||
| 30 | ScaledBlit.dis\ | ||
| 31 | SurfaceType.dis\ | ||
| 32 | TransformBlit.dis\ | ||
| 33 | TransformHelper.dis\ | ||
| 34 | XORComposite.dis\ | ||
| 35 | |||
| 36 | DISBIN=$ROOT/java/dis/java/java/sun/java2d/loops | ||
| 37 | |||
| 38 | <$ROOT/mkfiles/mkjava | ||