1 /* 2 * Copyright (c) 2007, 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.hw; 27 28 import javax.tools.annotation.GenerateNativeHeader; 29 30 /** 31 * Represents a set of capabilities of a BufferedContext and associated 32 * AccelGraphicsConfig. 33 * 34 * @see AccelGraphicsConfig 35 */ 36 /* No native methods here, but the constants are needed in the supporting JNI code */ 37 @GenerateNativeHeader 38 public class ContextCapabilities { 39 /** Indicates that the context has no capabilities. */ 40 public static final int CAPS_EMPTY = (0 << 0); 41 /** Indicates that the context supports RT surfaces with alpha channel. */ 42 public static final int CAPS_RT_PLAIN_ALPHA = (1 << 1); 43 /** Indicates that the context supports RT textures with alpha channel. */ 44 public static final int CAPS_RT_TEXTURE_ALPHA = (1 << 2); 45 /** Indicates that the context supports opaque RT textures. */ 46 public static final int CAPS_RT_TEXTURE_OPAQUE = (1 << 3); 47 /** Indicates that the context supports multitexturing. */ 48 public static final int CAPS_MULTITEXTURE = (1 << 4); 49 /** Indicates that the context supports non-pow2 texture dimensions. */ 50 public static final int CAPS_TEXNONPOW2 = (1 << 5); 51 /** Indicates that the context supports non-square textures. */ 52 public static final int CAPS_TEXNONSQUARE = (1 << 6); 53 /** Indicates that the context supports pixel shader 2.0 or better. */ 54 public static final int CAPS_PS20 = (1 << 7); 55 /** Indicates that the context supports pixel shader 3.0 or better. */ 56 public static final int CAPS_PS30 = (1 << 8); 57 /* 58 * Pipeline contexts should use this for defining pipeline-specific 59 * capabilities, for example: 60 * int CAPS_D3D_1 = (FIRST_PRIVATE_CAP << 0); 61 * int CAPS_D3D_2 = (FIRST_PRIVATE_CAP << 1); 62 */ 63 protected static final int FIRST_PRIVATE_CAP = (1 << 16); 64 65 protected final int caps; 66 protected final String adapterId; 67 68 /** 69 * Constructs a {@code ContextCapabilities} object. 70 * @param caps an {@code int} representing the capabilities 71 * @param a {@code String} representing the name of the adapter, or null, 72 * in which case the adapterId will be set to "unknown adapter". 73 */ 74 protected ContextCapabilities(int caps, String adapterId) { 75 this.caps = caps; 76 this.adapterId = adapterId != null ? adapterId : "unknown adapter"; 77 } 78 79 /** 80 * Returns a string representing the name of the graphics adapter if such 81 * could be determined. It is guaranteed to never return {@code null}. 82 * @return string representing adapter id 83 */ 84 public String getAdapterId() { 85 return adapterId; 86 } 87 88 /** 89 * Returns an {@code int} with capabilities (OR-ed constants defined in 90 * this class and its pipeline-specific subclasses). 91 * @return capabilities as {@code int} 92 */ 93 public int getCaps() { 94 return caps; 95 } 96 97 @Override 98 public String toString() { 99 StringBuffer buf = 100 new StringBuffer("ContextCapabilities: adapter=" + 101 adapterId+", caps="); 102 if (caps == CAPS_EMPTY) { 103 buf.append("CAPS_EMPTY"); 104 } else { 105 if ((caps & CAPS_RT_PLAIN_ALPHA) != 0) { 106 buf.append("CAPS_RT_PLAIN_ALPHA|"); 107 } 108 if ((caps & CAPS_RT_TEXTURE_ALPHA) != 0) { 109 buf.append("CAPS_RT_TEXTURE_ALPHA|"); 110 } 111 if ((caps & CAPS_RT_TEXTURE_OPAQUE) != 0) { 112 buf.append("CAPS_RT_TEXTURE_OPAQUE|"); 113 } 114 if ((caps & CAPS_MULTITEXTURE) != 0) { 115 buf.append("CAPS_MULTITEXTURE|"); 116 } 117 if ((caps & CAPS_TEXNONPOW2) != 0) { 118 buf.append("CAPS_TEXNONPOW2|"); 119 } 120 if ((caps & CAPS_TEXNONSQUARE) != 0) { 121 buf.append("CAPS_TEXNONSQUARE|"); 122 } 123 if ((caps & CAPS_PS20) != 0) { 124 buf.append("CAPS_PS20|"); 125 } 126 if ((caps & CAPS_PS30) != 0) { 127 buf.append("CAPS_PS30|"); 128 } 129 } 130 return buf.toString(); 131 } 132 }