Path: blob/master/src/java.desktop/share/classes/sun/java2d/pipe/hw/ContextCapabilities.java
41161 views
/*1* Copyright (c) 2007, 2013, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation. Oracle designates this7* particular file as subject to the "Classpath" exception as provided8* by Oracle in the LICENSE file that accompanied this code.9*10* This code is distributed in the hope that it will be useful, but WITHOUT11* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or12* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License13* version 2 for more details (a copy is included in the LICENSE file that14* accompanied this code).15*16* You should have received a copy of the GNU General Public License version17* 2 along with this work; if not, write to the Free Software Foundation,18* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.19*20* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA21* or visit www.oracle.com if you need additional information or have any22* questions.23*/2425package sun.java2d.pipe.hw;262728/**29* Represents a set of capabilities of a BufferedContext and associated30* AccelGraphicsConfig.31*32* @see AccelGraphicsConfig33*/34public class ContextCapabilities {35/** Indicates that the context has no capabilities. */36public static final int CAPS_EMPTY = (0 << 0);37/** Indicates that the context supports RT surfaces with alpha channel. */38public static final int CAPS_RT_PLAIN_ALPHA = (1 << 1);39/** Indicates that the context supports RT textures with alpha channel. */40public static final int CAPS_RT_TEXTURE_ALPHA = (1 << 2);41/** Indicates that the context supports opaque RT textures. */42public static final int CAPS_RT_TEXTURE_OPAQUE = (1 << 3);43/** Indicates that the context supports multitexturing. */44public static final int CAPS_MULTITEXTURE = (1 << 4);45/** Indicates that the context supports non-pow2 texture dimensions. */46public static final int CAPS_TEXNONPOW2 = (1 << 5);47/** Indicates that the context supports non-square textures. */48public static final int CAPS_TEXNONSQUARE = (1 << 6);49/** Indicates that the context supports pixel shader 2.0 or better. */50public static final int CAPS_PS20 = (1 << 7);51/** Indicates that the context supports pixel shader 3.0 or better. */52public static final int CAPS_PS30 = (1 << 8);53/*54* Pipeline contexts should use this for defining pipeline-specific55* capabilities, for example:56* int CAPS_D3D_1 = (FIRST_PRIVATE_CAP << 0);57* int CAPS_D3D_2 = (FIRST_PRIVATE_CAP << 1);58*/59protected static final int FIRST_PRIVATE_CAP = (1 << 16);6061protected final int caps;62protected final String adapterId;6364/**65* Constructs a {@code ContextCapabilities} object.66* @param caps an {@code int} representing the capabilities67* @param adapterId {@code String} representing the name of the adapter, or null,68* in which case the adapterId will be set to "unknown adapter".69*/70protected ContextCapabilities(int caps, String adapterId) {71this.caps = caps;72this.adapterId = adapterId != null ? adapterId : "unknown adapter";73}7475/**76* Returns a string representing the name of the graphics adapter if such77* could be determined. It is guaranteed to never return {@code null}.78* @return string representing adapter id79*/80public String getAdapterId() {81return adapterId;82}8384/**85* Returns an {@code int} with capabilities (OR-ed constants defined in86* this class and its pipeline-specific subclasses).87* @return capabilities as {@code int}88*/89public int getCaps() {90return caps;91}9293@Override94public String toString() {95StringBuilder sb =96new StringBuilder("ContextCapabilities: adapter=" +97adapterId+", caps=");98if (caps == CAPS_EMPTY) {99sb.append("CAPS_EMPTY");100} else {101if ((caps & CAPS_RT_PLAIN_ALPHA) != 0) {102sb.append("CAPS_RT_PLAIN_ALPHA|");103}104if ((caps & CAPS_RT_TEXTURE_ALPHA) != 0) {105sb.append("CAPS_RT_TEXTURE_ALPHA|");106}107if ((caps & CAPS_RT_TEXTURE_OPAQUE) != 0) {108sb.append("CAPS_RT_TEXTURE_OPAQUE|");109}110if ((caps & CAPS_MULTITEXTURE) != 0) {111sb.append("CAPS_MULTITEXTURE|");112}113if ((caps & CAPS_TEXNONPOW2) != 0) {114sb.append("CAPS_TEXNONPOW2|");115}116if ((caps & CAPS_TEXNONSQUARE) != 0) {117sb.append("CAPS_TEXNONSQUARE|");118}119if ((caps & CAPS_PS20) != 0) {120sb.append("CAPS_PS20|");121}122if ((caps & CAPS_PS30) != 0) {123sb.append("CAPS_PS30|");124}125}126return sb.toString();127}128}129130131