src/share/classes/sun/java2d/pipe/BufferedContext.java

Print this page


   1 /*
   2  * Copyright (c) 2005, 2008, 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


  82 
  83     /**
  84      * This is a reference to the most recently validated BufferedContext.  If
  85      * this value is null, it means that there is no current context.  It is
  86      * provided here so that validate() only needs to do a quick reference
  87      * check to see if the BufferedContext passed to that method is the same
  88      * as the one we've cached here.
  89      */
  90     protected static BufferedContext currentContext;
  91 
  92     private AccelSurface    validatedSrcData;
  93     private AccelSurface    validatedDstData;
  94     private Region          validatedClip;
  95     private Composite       validatedComp;
  96     private Paint           validatedPaint;
  97     // renamed from isValidatedPaintAColor as part of a work around for 6764257
  98     private boolean         isValidatedPaintJustAColor;
  99     private int             validatedRGB;
 100     private int             validatedFlags;
 101     private boolean         xformInUse;
 102     private int             transX;
 103     private int             transY;
 104 
 105     protected BufferedContext(RenderQueue rq) {
 106         this.rq = rq;
 107         this.buf = rq.getBuffer();
 108     }
 109 
 110     /**
 111      * Fetches the BufferedContextContext associated with the dst. surface
 112      * and validates the context using the given parameters.  Most rendering
 113      * operations will call this method first in order to set the necessary
 114      * state before issuing rendering commands.
 115      *
 116      * Note: must be called while the RenderQueue lock is held.
 117      *
 118      * It's assumed that the type of surfaces has been checked by the Renderer
 119      *
 120      * @throws InvalidPipeException if either src or dest surface is not valid
 121      * or lost
 122      * @see RenderQueue#lock
 123      * @see RenderQueue#unlock


 260         if ((comp != validatedComp) || (flags != validatedFlags)) {
 261             if (comp != null) {
 262                 setComposite(comp, flags);
 263             } else {
 264                 resetComposite();
 265             }
 266             // the paint state is dependent on the composite state, so make
 267             // sure we update the color below
 268             updatePaint = true;
 269             validatedComp = comp;
 270             validatedFlags = flags;
 271         }
 272 
 273         // validate transform
 274         boolean txChanged = false;
 275         if (xform == null) {
 276             if (xformInUse) {
 277                 resetTransform();
 278                 xformInUse = false;
 279                 txChanged = true;
 280             } else if (sg2d != null) {
 281                 if (transX != sg2d.transX || transY != sg2d.transY) {
 282                     txChanged = true;
 283                 }
 284             }
 285             if (sg2d != null) {
 286                 transX = sg2d.transX;
 287                 transY = sg2d.transY;
 288             }
 289         } else {
 290             setTransform(xform);
 291             xformInUse = true;
 292             txChanged = true;
 293         }
 294         // non-Color paints may require paint revalidation
 295         if (!isValidatedPaintJustAColor && txChanged) {
 296             updatePaint = true;
 297         }
 298 
 299         // validate paint
 300         if (updatePaint) {
 301             if (paint != null) {
 302                 BufferedPaints.setPaint(rq, sg2d, paint, flags);
 303             } else {
 304                 BufferedPaints.resetPaint(rq);
 305             }
 306             validatedPaint = paint;
 307         }


   1 /*
   2  * Copyright (c) 2005, 2013, 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


  82 
  83     /**
  84      * This is a reference to the most recently validated BufferedContext.  If
  85      * this value is null, it means that there is no current context.  It is
  86      * provided here so that validate() only needs to do a quick reference
  87      * check to see if the BufferedContext passed to that method is the same
  88      * as the one we've cached here.
  89      */
  90     protected static BufferedContext currentContext;
  91 
  92     private AccelSurface    validatedSrcData;
  93     private AccelSurface    validatedDstData;
  94     private Region          validatedClip;
  95     private Composite       validatedComp;
  96     private Paint           validatedPaint;
  97     // renamed from isValidatedPaintAColor as part of a work around for 6764257
  98     private boolean         isValidatedPaintJustAColor;
  99     private int             validatedRGB;
 100     private int             validatedFlags;
 101     private boolean         xformInUse;
 102     private AffineTransform transform;

 103 
 104     protected BufferedContext(RenderQueue rq) {
 105         this.rq = rq;
 106         this.buf = rq.getBuffer();
 107     }
 108 
 109     /**
 110      * Fetches the BufferedContextContext associated with the dst. surface
 111      * and validates the context using the given parameters.  Most rendering
 112      * operations will call this method first in order to set the necessary
 113      * state before issuing rendering commands.
 114      *
 115      * Note: must be called while the RenderQueue lock is held.
 116      *
 117      * It's assumed that the type of surfaces has been checked by the Renderer
 118      *
 119      * @throws InvalidPipeException if either src or dest surface is not valid
 120      * or lost
 121      * @see RenderQueue#lock
 122      * @see RenderQueue#unlock


 259         if ((comp != validatedComp) || (flags != validatedFlags)) {
 260             if (comp != null) {
 261                 setComposite(comp, flags);
 262             } else {
 263                 resetComposite();
 264             }
 265             // the paint state is dependent on the composite state, so make
 266             // sure we update the color below
 267             updatePaint = true;
 268             validatedComp = comp;
 269             validatedFlags = flags;
 270         }
 271 
 272         // validate transform
 273         boolean txChanged = false;
 274         if (xform == null) {
 275             if (xformInUse) {
 276                 resetTransform();
 277                 xformInUse = false;
 278                 txChanged = true;
 279             } else if (sg2d != null && !sg2d.transform.equals(transform)) {

 280                 txChanged = true;
 281             }
 282             if (sg2d != null && txChanged) {
 283                 transform = new AffineTransform(sg2d.transform);


 284             }
 285         } else {
 286             setTransform(xform);
 287             xformInUse = true;
 288             txChanged = true;
 289         }
 290         // non-Color paints may require paint revalidation
 291         if (!isValidatedPaintJustAColor && txChanged) {
 292             updatePaint = true;
 293         }
 294 
 295         // validate paint
 296         if (updatePaint) {
 297             if (paint != null) {
 298                 BufferedPaints.setPaint(rq, sg2d, paint, flags);
 299             } else {
 300                 BufferedPaints.resetPaint(rq);
 301             }
 302             validatedPaint = paint;
 303         }