History

My first initial commit with all of mine experimental changes.

Dmitry Kabak (userdima committed 13 years ago

Commit d37b88d1 parent 3f5b46618352 files · +2598093 −-8690Browse files

Showing the changes to java/pkg/sun/java2d/pipe/hw/ContextCapabilities.java (1 of 18352 files). Show all

Unified · Split

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