< prev index next >

src/java.desktop/share/classes/sun/java2d/loops/DrawGlyphListAA.java

Print this page


   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


  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;
   1 /*
   2  * Copyright (c) 2000, 2018, 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


  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;
< prev index next >