430N/A/*
2362N/A * Copyright (c) 2007, 2008, Oracle and/or its affiliates. All rights reserved.
430N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
430N/A *
430N/A * This code is free software; you can redistribute it and/or modify it
430N/A * under the terms of the GNU General Public License version 2 only, as
2362N/A * published by the Free Software Foundation. Oracle designates this
430N/A * particular file as subject to the "Classpath" exception as provided
2362N/A * by Oracle in the LICENSE file that accompanied this code.
430N/A *
430N/A * This code is distributed in the hope that it will be useful, but WITHOUT
430N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
430N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
430N/A * version 2 for more details (a copy is included in the LICENSE file that
430N/A * accompanied this code).
430N/A *
430N/A * You should have received a copy of the GNU General Public License version
430N/A * 2 along with this work; if not, write to the Free Software Foundation,
430N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
430N/A *
2362N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
2362N/A * or visit www.oracle.com if you need additional information or have any
2362N/A * questions.
430N/A */
430N/A
430N/Apackage sun.java2d.pipe.hw;
430N/A
430N/A/**
430N/A * Represents a set of capabilities of a BufferedContext and associated
430N/A * AccelGraphicsConfig.
430N/A *
430N/A * @see AccelGraphicsConfig
430N/A */
430N/Apublic class ContextCapabilities {
430N/A /** Indicates that the context has no capabilities. */
430N/A public static final int CAPS_EMPTY = (0 << 0);
430N/A /** Indicates that the context supports RT surfaces with alpha channel. */
430N/A public static final int CAPS_RT_PLAIN_ALPHA = (1 << 1);
430N/A /** Indicates that the context supports RT textures with alpha channel. */
430N/A public static final int CAPS_RT_TEXTURE_ALPHA = (1 << 2);
430N/A /** Indicates that the context supports opaque RT textures. */
430N/A public static final int CAPS_RT_TEXTURE_OPAQUE = (1 << 3);
430N/A /** Indicates that the context supports multitexturing. */
430N/A public static final int CAPS_MULTITEXTURE = (1 << 4);
430N/A /** Indicates that the context supports non-pow2 texture dimensions. */
430N/A public static final int CAPS_TEXNONPOW2 = (1 << 5);
430N/A /** Indicates that the context supports non-square textures. */
430N/A public static final int CAPS_TEXNONSQUARE = (1 << 6);
430N/A /** Indicates that the context supports pixel shader 2.0 or better. */
430N/A public static final int CAPS_PS20 = (1 << 7);
430N/A /** Indicates that the context supports pixel shader 3.0 or better. */
430N/A public static final int CAPS_PS30 = (1 << 8);
430N/A /*
430N/A * Pipeline contexts should use this for defining pipeline-specific
430N/A * capabilities, for example:
430N/A * int CAPS_D3D_1 = (FIRST_PRIVATE_CAP << 0);
430N/A * int CAPS_D3D_2 = (FIRST_PRIVATE_CAP << 1);
430N/A */
430N/A protected static final int FIRST_PRIVATE_CAP = (1 << 16);
430N/A
430N/A protected final int caps;
430N/A protected final String adapterId;
430N/A
430N/A /**
430N/A * Constructs a {@code ContextCapabilities} object.
430N/A * @param caps an {@code int} representing the capabilities
430N/A * @param a {@code String} representing the name of the adapter, or null,
430N/A * in which case the adapterId will be set to "unknown adapter".
430N/A */
430N/A protected ContextCapabilities(int caps, String adapterId) {
430N/A this.caps = caps;
430N/A this.adapterId = adapterId != null ? adapterId : "unknown adapter";
430N/A }
430N/A
430N/A /**
430N/A * Returns a string representing the name of the graphics adapter if such
430N/A * could be determined. It is guaranteed to never return {@code null}.
430N/A * @return string representing adapter id
430N/A */
430N/A public String getAdapterId() {
430N/A return adapterId;
430N/A }
430N/A
430N/A /**
430N/A * Returns an {@code int} with capabilities (OR-ed constants defined in
430N/A * this class and its pipeline-specific subclasses).
430N/A * @return capabilities as {@code int}
430N/A */
430N/A public int getCaps() {
430N/A return caps;
430N/A }
430N/A
430N/A @Override
430N/A public String toString() {
430N/A StringBuffer buf =
430N/A new StringBuffer("ContextCapabilities: adapter=" +
430N/A adapterId+", caps=");
430N/A if (caps == CAPS_EMPTY) {
430N/A buf.append("CAPS_EMPTY");
430N/A } else {
430N/A if ((caps & CAPS_RT_PLAIN_ALPHA) != 0) {
430N/A buf.append("CAPS_RT_PLAIN_ALPHA|");
430N/A }
430N/A if ((caps & CAPS_RT_TEXTURE_ALPHA) != 0) {
430N/A buf.append("CAPS_RT_TEXTURE_ALPHA|");
430N/A }
430N/A if ((caps & CAPS_RT_TEXTURE_OPAQUE) != 0) {
430N/A buf.append("CAPS_RT_TEXTURE_OPAQUE|");
430N/A }
430N/A if ((caps & CAPS_MULTITEXTURE) != 0) {
430N/A buf.append("CAPS_MULTITEXTURE|");
430N/A }
430N/A if ((caps & CAPS_TEXNONPOW2) != 0) {
430N/A buf.append("CAPS_TEXNONPOW2|");
430N/A }
430N/A if ((caps & CAPS_TEXNONSQUARE) != 0) {
430N/A buf.append("CAPS_TEXNONSQUARE|");
430N/A }
430N/A if ((caps & CAPS_PS20) != 0) {
430N/A buf.append("CAPS_PS20|");
430N/A }
430N/A if ((caps & CAPS_PS30) != 0) {
430N/A buf.append("CAPS_PS30|");
430N/A }
430N/A }
430N/A return buf.toString();
430N/A }
430N/A}