< prev index next >

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

Print this page


   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


  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;
   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


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