0N/A/*
2362N/A * Copyright (c) 1998, 1999, Oracle and/or its affiliates. All rights reserved.
0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
0N/A *
0N/A * This code is free software; you can redistribute it and/or modify it
0N/A * under the terms of the GNU General Public License version 2 only, as
2362N/A * published by the Free Software Foundation. Oracle designates this
0N/A * particular file as subject to the "Classpath" exception as provided
2362N/A * by Oracle in the LICENSE file that accompanied this code.
0N/A *
0N/A * This code is distributed in the hope that it will be useful, but WITHOUT
0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
0N/A * version 2 for more details (a copy is included in the LICENSE file that
0N/A * accompanied this code).
0N/A *
0N/A * You should have received a copy of the GNU General Public License version
0N/A * 2 along with this work; if not, write to the Free Software Foundation,
0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
0N/A *
2362N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
2362N/A * or visit www.oracle.com if you need additional information or have any
2362N/A * questions.
0N/A */
0N/A
0N/Apackage sun.java2d.pipe;
0N/A
0N/Aimport java.awt.Rectangle;
0N/Aimport java.awt.Shape;
0N/Aimport java.awt.geom.PathIterator;
0N/Aimport sun.java2d.SunGraphics2D;
0N/A
0N/A/**
0N/A * This class uses a Region iterator to modify the extents of alpha
0N/A * tiles created during Shape rendering based upon a non-rectangular
0N/A * clipping path.
0N/A */
0N/Apublic class SpanClipRenderer implements CompositePipe
0N/A{
0N/A CompositePipe outpipe;
0N/A
0N/A static Class RegionClass = Region.class;
0N/A static Class RegionIteratorClass = RegionIterator.class;
0N/A
0N/A static {
0N/A initIDs(RegionClass, RegionIteratorClass);
0N/A }
0N/A
0N/A static native void initIDs(Class rc, Class ric);
0N/A
0N/A public SpanClipRenderer(CompositePipe pipe) {
0N/A outpipe = pipe;
0N/A }
0N/A
0N/A class SCRcontext {
0N/A RegionIterator iterator;
0N/A Object outcontext;
0N/A int band[];
0N/A byte tile[];
0N/A
0N/A public SCRcontext(RegionIterator ri, Object outctx) {
0N/A iterator = ri;
0N/A outcontext = outctx;
0N/A band = new int[4];
0N/A }
0N/A }
0N/A
0N/A public Object startSequence(SunGraphics2D sg, Shape s, Rectangle devR,
0N/A int[] abox) {
0N/A RegionIterator ri = sg.clipRegion.getIterator();
0N/A
0N/A return new SCRcontext(ri, outpipe.startSequence(sg, s, devR, abox));
0N/A }
0N/A
0N/A public boolean needTile(Object ctx, int x, int y, int w, int h) {
0N/A SCRcontext context = (SCRcontext) ctx;
0N/A return (outpipe.needTile(context.outcontext, x, y, w, h));
0N/A }
0N/A
0N/A public void renderPathTile(Object ctx,
0N/A byte[] atile, int offset, int tsize,
0N/A int x, int y, int w, int h,
0N/A ShapeSpanIterator sr) {
0N/A renderPathTile(ctx, atile, offset, tsize, x, y, w, h);
0N/A }
0N/A
0N/A public void renderPathTile(Object ctx,
0N/A byte[] atile, int offset, int tsize,
0N/A int x, int y, int w, int h) {
0N/A SCRcontext context = (SCRcontext) ctx;
0N/A RegionIterator ri = context.iterator.createCopy();
0N/A int[] band = context.band;
0N/A band[0] = x;
0N/A band[1] = y;
0N/A band[2] = x + w;
0N/A band[3] = y + h;
0N/A if (atile == null) {
0N/A int size = w * h;
0N/A atile = context.tile;
0N/A if (atile != null && atile.length < size) {
0N/A atile = null;
0N/A }
0N/A if (atile == null) {
0N/A atile = new byte[size];
0N/A context.tile = atile;
0N/A }
0N/A offset = 0;
0N/A tsize = w;
0N/A fillTile(ri, atile, offset, tsize, band);
0N/A } else {
0N/A eraseTile(ri, atile, offset, tsize, band);
0N/A }
0N/A
0N/A if (band[2] > band[0] && band[3] > band[1]) {
0N/A offset += (band[1] - y) * tsize + (band[0] - x);
0N/A outpipe.renderPathTile(context.outcontext,
0N/A atile, offset, tsize,
0N/A band[0], band[1],
0N/A band[2] - band[0],
0N/A band[3] - band[1]);
0N/A }
0N/A }
0N/A
0N/A public native void fillTile(RegionIterator ri,
0N/A byte[] alpha, int offset, int tsize,
0N/A int[] band);
0N/A
0N/A public native void eraseTile(RegionIterator ri,
0N/A byte[] alpha, int offset, int tsize,
0N/A int[] band);
0N/A
0N/A public void skipTile(Object ctx, int x, int y) {
0N/A SCRcontext context = (SCRcontext) ctx;
0N/A outpipe.skipTile(context.outcontext, x, y);
0N/A }
0N/A
0N/A public void endSequence(Object ctx) {
0N/A SCRcontext context = (SCRcontext) ctx;
0N/A outpipe.endSequence(context.outcontext);
0N/A }
0N/A}