< prev index next >

src/java.desktop/unix/classes/sun/java2d/xr/XRCompositeManager.java

Print this page




  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.xr;
  27 
  28 import java.awt.*;
  29 import java.awt.geom.*;
  30 
  31 import java.security.AccessController;
  32 import java.security.PrivilegedAction;
  33 
  34 import sun.font.*;
  35 import sun.java2d.*;
  36 import sun.java2d.jules.*;
  37 import sun.java2d.loops.*;
  38 
  39 /**
  40  * Manages per-application resources, e.g. the 1x1 pixmap used for solid color
  41  * fill as well as per-application state e.g. the currently set source picture
  42  * used for composition .
  43  *
  44  * @author Clemens Eisserer
  45  */
  46 
  47 public class XRCompositeManager {
  48     private static boolean enableGradCache = true;
  49     private static XRCompositeManager instance;
  50 
  51     private static final int SOLID = 0;
  52     private static final int TEXTURE = 1;
  53     private static final int GRADIENT = 2;
  54 
  55     int srcType;
  56     XRSolidSrcPict solidSrc32;


 234     }
 235 
 236     public void XRComposite(int src, int mask, int dst, int srcX, int srcY,
 237             int maskX, int maskY, int dstX, int dstY, int width, int height) {
 238         int cachedSrc = (src == XRUtils.None) ? getCurrentSource().picture : src;
 239         int cachedX = srcX;
 240         int cachedY = srcY;
 241 
 242         if (enableGradCache && gradient != null
 243                 && cachedSrc == gradient.picture) {
 244             con.renderComposite(XRUtils.PictOpSrc, gradient.picture,
 245                     XRUtils.None, gradCachePicture, srcX, srcY, 0, 0, 0, 0,
 246                     width, height);
 247             cachedX = 0;
 248             cachedY = 0;
 249             cachedSrc = gradCachePicture;
 250         }
 251 
 252         con.renderComposite(compRule, cachedSrc, mask, dst, cachedX, cachedY,
 253                 maskX, maskY, dstX, dstY, width, height);
 254     }
 255 
 256     public void XRCompositeTraps(int dst, int srcX, int srcY,
 257             TrapezoidList trapList) {
 258         int renderReferenceX = 0;
 259         int renderReferenceY = 0;
 260 
 261         if (trapList.getP1YLeft(0) < trapList.getP2YLeft(0)) {
 262             renderReferenceX = trapList.getP1XLeft(0);
 263             renderReferenceY = trapList.getP1YLeft(0);
 264         } else {
 265             renderReferenceX = trapList.getP2XLeft(0);
 266             renderReferenceY = trapList.getP2YLeft(0);
 267         }
 268 
 269         renderReferenceX = (int) Math.floor(XRUtils
 270                 .XFixedToDouble(renderReferenceX));
 271         renderReferenceY = (int) Math.floor(XRUtils
 272                 .XFixedToDouble(renderReferenceY));
 273 
 274         con.renderCompositeTrapezoids(compRule, getCurrentSource().picture,
 275                 XRUtils.PictStandardA8, dst, renderReferenceX,
 276                 renderReferenceY, trapList);
 277     }
 278 
 279     public void XRRenderRectangles(XRSurfaceData dst, GrowableRectArray rects) {
 280         if (xorEnabled) {
 281             con.GCRectangles(dst.getXid(), dst.getGC(), rects);
 282         } else {
 283             if (rects.getSize() == 1) {
 284                 con.renderRectangle(dst.getPicture(), compRule, solidColor,
 285                         rects.getX(0), rects.getY(0), rects.getWidth(0), rects.getHeight(0));
 286             } else {
 287                 con.renderRectangles(dst.getPicture(), compRule, solidColor, rects);
 288             }
 289         }
 290     }
 291 
 292     public void XRCompositeRectangles(XRSurfaceData dst, GrowableRectArray rects) {
 293         int srcPict = getCurrentSource().picture;
 294 
 295         for(int i=0; i < rects.getSize(); i++) {
 296             int x = rects.getX(i);




  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.xr;
  27 
  28 import java.awt.*;
  29 import java.awt.geom.*;
  30 
  31 import java.security.AccessController;
  32 import java.security.PrivilegedAction;
  33 
  34 import sun.font.*;
  35 import sun.java2d.*;

  36 import sun.java2d.loops.*;
  37 
  38 /**
  39  * Manages per-application resources, e.g. the 1x1 pixmap used for solid color
  40  * fill as well as per-application state e.g. the currently set source picture
  41  * used for composition .
  42  *
  43  * @author Clemens Eisserer
  44  */
  45 
  46 public class XRCompositeManager {
  47     private static boolean enableGradCache = true;
  48     private static XRCompositeManager instance;
  49 
  50     private static final int SOLID = 0;
  51     private static final int TEXTURE = 1;
  52     private static final int GRADIENT = 2;
  53 
  54     int srcType;
  55     XRSolidSrcPict solidSrc32;


 233     }
 234 
 235     public void XRComposite(int src, int mask, int dst, int srcX, int srcY,
 236             int maskX, int maskY, int dstX, int dstY, int width, int height) {
 237         int cachedSrc = (src == XRUtils.None) ? getCurrentSource().picture : src;
 238         int cachedX = srcX;
 239         int cachedY = srcY;
 240 
 241         if (enableGradCache && gradient != null
 242                 && cachedSrc == gradient.picture) {
 243             con.renderComposite(XRUtils.PictOpSrc, gradient.picture,
 244                     XRUtils.None, gradCachePicture, srcX, srcY, 0, 0, 0, 0,
 245                     width, height);
 246             cachedX = 0;
 247             cachedY = 0;
 248             cachedSrc = gradCachePicture;
 249         }
 250 
 251         con.renderComposite(compRule, cachedSrc, mask, dst, cachedX, cachedY,
 252                 maskX, maskY, dstX, dstY, width, height);























 253     }
 254 
 255     public void XRRenderRectangles(XRSurfaceData dst, GrowableRectArray rects) {
 256         if (xorEnabled) {
 257             con.GCRectangles(dst.getXid(), dst.getGC(), rects);
 258         } else {
 259             if (rects.getSize() == 1) {
 260                 con.renderRectangle(dst.getPicture(), compRule, solidColor,
 261                         rects.getX(0), rects.getY(0), rects.getWidth(0), rects.getHeight(0));
 262             } else {
 263                 con.renderRectangles(dst.getPicture(), compRule, solidColor, rects);
 264             }
 265         }
 266     }
 267 
 268     public void XRCompositeRectangles(XRSurfaceData dst, GrowableRectArray rects) {
 269         int srcPict = getCurrentSource().picture;
 270 
 271         for(int i=0; i < rects.getSize(); i++) {
 272             int x = rects.getX(i);


< prev index next >