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 23 * questions. 24 */ 25 26 package sun.java2d.pipe; 27 28 import java.awt.AlphaComposite; 29 import java.awt.Color; 30 import java.awt.Composite; 31 import java.awt.Paint; 32 import java.awt.geom.AffineTransform; 33 import sun.java2d.pipe.hw.AccelSurface; 34 import sun.java2d.InvalidPipeException; 35 import sun.java2d.SunGraphics2D; 36 import sun.java2d.loops.XORComposite; 37 import static sun.java2d.pipe.BufferedOpCodes.*; 38 import static sun.java2d.pipe.BufferedRenderPipe.BYTES_PER_SPAN; 39 40 import javax.tools.annotation.GenerateNativeHeader; 41 42 /** 43 * Base context class for managing state in a single-threaded rendering 44 * environment. Each state-setting operation (e.g. SET_COLOR) is added to 45 * the provided RenderQueue, which will be processed at a later time by a 46 * single thread. Note that the RenderQueue lock must be acquired before 47 * calling the validate() method (or any other method in this class). See 48 * the RenderQueue class comments for a sample usage scenario. 49 * 50 * @see RenderQueue 51 */ 52 /* No native methods here, but the constants are needed in the supporting JNI code */ 53 @GenerateNativeHeader 54 public abstract class BufferedContext { 55 56 /* 57 * The following flags help the internals of validate() determine 58 * the appropriate (meaning correct, or optimal) code path when 59 * setting up the current context. The flags can be bitwise OR'd 60 * together as needed. 61 */ 62 63 /** 64 * Indicates that no flags are needed; take all default code paths. 65 */ 66 public static final int NO_CONTEXT_FLAGS = (0 << 0); 67 /** 68 * Indicates that the source surface (or color value, if it is a simple 69 * rendering operation) is opaque (has an alpha value of 1.0). If this 70 * flag is present, it allows us to disable blending in certain 71 * situations in order to improve performance. 72 */ 73 public static final int SRC_IS_OPAQUE = (1 << 0); 74 /** 75 * Indicates that the operation uses an alpha mask, which may determine 76 * the code path that is used when setting up the current paint state. 77 */ 78 public static final int USE_MASK = (1 << 1); 79 80 protected RenderQueue rq; 81 protected RenderBuffer buf; 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; | 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 23 * questions. 24 */ 25 26 package sun.java2d.pipe; 27 28 import java.awt.AlphaComposite; 29 import java.awt.Color; 30 import java.awt.Composite; 31 import java.awt.Paint; 32 import java.awt.geom.AffineTransform; 33 import sun.java2d.pipe.hw.AccelSurface; 34 import sun.java2d.InvalidPipeException; 35 import sun.java2d.SunGraphics2D; 36 import sun.java2d.loops.XORComposite; 37 import static sun.java2d.pipe.BufferedOpCodes.*; 38 import static sun.java2d.pipe.BufferedRenderPipe.BYTES_PER_SPAN; 39 40 import java.lang.annotation.Native; 41 42 /** 43 * Base context class for managing state in a single-threaded rendering 44 * environment. Each state-setting operation (e.g. SET_COLOR) is added to 45 * the provided RenderQueue, which will be processed at a later time by a 46 * single thread. Note that the RenderQueue lock must be acquired before 47 * calling the validate() method (or any other method in this class). See 48 * the RenderQueue class comments for a sample usage scenario. 49 * 50 * @see RenderQueue 51 */ 52 public abstract class BufferedContext { 53 54 /* 55 * The following flags help the internals of validate() determine 56 * the appropriate (meaning correct, or optimal) code path when 57 * setting up the current context. The flags can be bitwise OR'd 58 * together as needed. 59 */ 60 61 /** 62 * Indicates that no flags are needed; take all default code paths. 63 */ 64 @Native public static final int NO_CONTEXT_FLAGS = (0 << 0); 65 /** 66 * Indicates that the source surface (or color value, if it is a simple 67 * rendering operation) is opaque (has an alpha value of 1.0). If this 68 * flag is present, it allows us to disable blending in certain 69 * situations in order to improve performance. 70 */ 71 @Native public static final int SRC_IS_OPAQUE = (1 << 0); 72 /** 73 * Indicates that the operation uses an alpha mask, which may determine 74 * the code path that is used when setting up the current paint state. 75 */ 76 @Native public static final int USE_MASK = (1 << 1); 77 78 protected RenderQueue rq; 79 protected RenderBuffer buf; 80 81 /** 82 * This is a reference to the most recently validated BufferedContext. If 83 * this value is null, it means that there is no current context. It is 84 * provided here so that validate() only needs to do a quick reference 85 * check to see if the BufferedContext passed to that method is the same 86 * as the one we've cached here. 87 */ 88 protected static BufferedContext currentContext; 89 90 private AccelSurface validatedSrcData; 91 private AccelSurface validatedDstData; 92 private Region validatedClip; 93 private Composite validatedComp; 94 private Paint validatedPaint; 95 // renamed from isValidatedPaintAColor as part of a work around for 6764257 96 private boolean isValidatedPaintJustAColor; |