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();
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());
|
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 import sun.java2d.pipe.Region;
40
41 /**
42 * MaskFill
43 * 1) fills rectangles of pixels on a surface
44 * 2) performs compositing of colors based upon a Composite
45 * parameter
46 * 3) blends result of composite with destination using an
47 * alpha coverage mask
48 * 4) the mask may be null in which case it should be treated
49 * as if it were an array of all opaque values (0xff)
50 */
51 public class MaskFill extends GraphicsPrimitive
52 {
53 public static final String methodSignature = "MaskFill(...)".toString();
54 public static final String fillPgramSignature =
55 "FillAAPgram(...)".toString();
56 public static final String drawPgramSignature =
57 "DrawAAPgram(...)".toString();
58
59 public static final int primTypeID = makePrimTypeID();
178 super(srctype, comptype, dsttype);
179 fillop = FillRect.locate(srctype,
180 CompositeType.SrcNoEa,
181 SurfaceType.IntArgb);
182 maskop = MaskBlit.locate(SurfaceType.IntArgb, comptype, dsttype);
183 }
184
185 public void MaskFill(SunGraphics2D sg2d,
186 SurfaceData sData,
187 Composite comp,
188 int x, int y, int w, int h,
189 byte mask[], int offset, int scan)
190 {
191 BufferedImage dstBI =
192 new BufferedImage(w, h, BufferedImage.TYPE_INT_ARGB);
193 SurfaceData tmpData = BufImgSurfaceData.createData(dstBI);
194
195 // REMIND: This is not pretty. It would be nicer if we
196 // passed a "FillData" object to the Pixel loops, instead
197 // of a SunGraphics2D parameter...
198 Region clip = sg2d.clipRegion;
199 sg2d.clipRegion = null;
200 int pixel = sg2d.pixel;
201 sg2d.pixel = tmpData.pixelFor(sg2d.getColor());
202 fillop.FillRect(sg2d, tmpData, 0, 0, w, h);
203 sg2d.pixel = pixel;
204 sg2d.clipRegion = clip;
205
206 maskop.MaskBlit(tmpData, sData, comp, null,
207 0, 0, x, y, w, h,
208 mask, offset, scan);
209 }
210 }
211
212 public GraphicsPrimitive traceWrap() {
213 return new TraceMaskFill(this);
214 }
215
216 private static class TraceMaskFill extends MaskFill {
217 MaskFill target;
218 MaskFill fillPgramTarget;
219 MaskFill drawPgramTarget;
220
221 public TraceMaskFill(MaskFill target) {
222 super(target.getSourceType(),
223 target.getCompositeType(),
224 target.getDestType());
|