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.xr;
27
28 import java.awt.*;
29 import java.awt.MultipleGradientPaint.*;
30 import java.awt.image.*;
31 import sun.java2d.loops.*;
32 import static java.awt.AlphaComposite.*;
33
34 /**
35 * XRender constants and utility methods.
36 *
37 * @author Clemens Eisserer
38 */
39
40 public class XRUtils {
41 public static final int None = 0;
42
43 /* Composition Operators */
44 public static final byte PictOpClear = 0;
45 public static final byte PictOpSrc = 1;
46 public static final byte PictOpDst = 2;
47 public static final byte PictOpOver = 3;
48 public static final byte PictOpOverReverse = 4;
240 return PictOpAtop;
241
242 case DST_ATOP:
243 return PictOpAtopReverse;
244
245 case XOR:
246 return PictOpXor;
247 }
248
249 throw new InternalError("No XRender equivalent available for requested java2d composition rule: "+j2dRule);
250 }
251
252 public static short clampToShort(int x) {
253 return (short) (x > Short.MAX_VALUE
254 ? Short.MAX_VALUE
255 : (x < Short.MIN_VALUE ? Short.MIN_VALUE : x));
256 }
257
258 public static int clampToUShort(int x) {
259 return (x > 65535 ? 65535 : (x < 0) ? 0 : x);
260 }
261 }
|
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.xr;
27
28 import java.awt.*;
29 import java.awt.geom.AffineTransform;
30 import java.awt.MultipleGradientPaint.*;
31 import java.awt.image.*;
32 import sun.java2d.loops.*;
33 import static java.awt.AlphaComposite.*;
34
35 /**
36 * XRender constants and utility methods.
37 *
38 * @author Clemens Eisserer
39 */
40
41 public class XRUtils {
42 public static final int None = 0;
43
44 /* Composition Operators */
45 public static final byte PictOpClear = 0;
46 public static final byte PictOpSrc = 1;
47 public static final byte PictOpDst = 2;
48 public static final byte PictOpOver = 3;
49 public static final byte PictOpOverReverse = 4;
241 return PictOpAtop;
242
243 case DST_ATOP:
244 return PictOpAtopReverse;
245
246 case XOR:
247 return PictOpXor;
248 }
249
250 throw new InternalError("No XRender equivalent available for requested java2d composition rule: "+j2dRule);
251 }
252
253 public static short clampToShort(int x) {
254 return (short) (x > Short.MAX_VALUE
255 ? Short.MAX_VALUE
256 : (x < Short.MIN_VALUE ? Short.MIN_VALUE : x));
257 }
258
259 public static int clampToUShort(int x) {
260 return (x > 65535 ? 65535 : (x < 0) ? 0 : x);
261 }
262
263 public static boolean isTransformQuadrantRotated(AffineTransform tr) {
264 return ((tr.getType() & (AffineTransform.TYPE_GENERAL_ROTATION |
265 AffineTransform.TYPE_GENERAL_TRANSFORM)) == 0);
266 }
267
268 public static boolean isMaskEvaluated(byte xrCompRule) {
269 switch (xrCompRule) {
270 case PictOpOver:
271 case PictOpOverReverse:
272 case PictOpAtop:
273 case PictOpXor:
274 return true;
275 }
276
277 return false;
278 }
279 }
|