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 static final String
  43         methodSignature = "DrawGlyphListLCD(...)".toString();
  44 
  45     public static final 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 }