blob: 8b347b9ab4caef0cc8eb80021444b889d264496b [file] [log] [blame]
J. Duke319a3b92007-12-01 00:00:00 +00001/*
2 * Copyright 1998-2002 Sun Microsystems, Inc. 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. Sun designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Sun 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
22 * CA 95054 USA or visit www.sun.com if you need additional information or
23 * have any questions.
24 */
25
26 /*
27 * @author Jim Graham
28 * @author Charlton Innovations, Inc.
29 */
30
31package sun.java2d.loops;
32
33import sun.java2d.loops.GraphicsPrimitive;
34import sun.java2d.pipe.SpanIterator;
35import java.awt.Color;
36import java.awt.image.ColorModel;
37import java.awt.image.Raster;
38import sun.java2d.SunGraphics2D;
39import 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 */
46public 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}