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 (16 of 18352 files). Show all

Unified · Split

16 files
  1. java/pkg/sun/java2d/pipe/hw/AccelDeviceEventListener.class +0 −0
  2. java/pkg/sun/java2d/pipe/hw/AccelDeviceEventListener.java +59 −0
  3. java/pkg/sun/java2d/pipe/hw/AccelDeviceEventNotifier.java +167 −0
  4. java/pkg/sun/java2d/pipe/hw/AccelGraphicsConfig.class +0 −0
  5. java/pkg/sun/java2d/pipe/hw/AccelGraphicsConfig.java +95 −0
  6. java/pkg/sun/java2d/pipe/hw/AccelSurface.class +0 −0
  7. java/pkg/sun/java2d/pipe/hw/AccelSurface.java +136 −0
  8. java/pkg/sun/java2d/pipe/hw/AccelTypedVolatileImage.java +74 −0
  9. java/pkg/sun/java2d/pipe/hw/BufferedContextProvider.class +0 −0
  10. java/pkg/sun/java2d/pipe/hw/BufferedContextProvider.java +45 −0
  11. java/pkg/sun/java2d/pipe/hw/ContextCapabilities.class +0 −0
  12. java/pkg/sun/java2d/pipe/hw/ContextCapabilities.java +128 −0
  13. java/pkg/sun/java2d/pipe/hw/ExtendedBufferCapabilities$VSyncType.class +0 −0
  14. java/pkg/sun/java2d/pipe/hw/ExtendedBufferCapabilities.class +0 −0
  15. java/pkg/sun/java2d/pipe/hw/ExtendedBufferCapabilities.java +154 −0
  16. java/pkg/sun/java2d/pipe/hw/mkfile +15 −0
java/pkg/sun/java2d/pipe/hw/AccelDeviceEventListener.class+0−0

Binary file not shown.

java/pkg/sun/java2d/pipe/hw/AccelDeviceEventListener.java+59−0
@@ -0,0 +1,59 @@
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+/**
29+ * An interface for receiving notifications about imminent accelerated device's
30+ * events. Upon receiving such event appropriate actions can be taken (for
31+ * example, resources associated with the device can be freed).
32+ */
33+public interface AccelDeviceEventListener {
34+ /**
35+ * Called when the device is about to be reset.
36+ *
37+ * One must release all native resources associated with the device which
38+ * prevent the device from being reset (such as Default Pool resources for
39+ * the D3D pipeline).
40+ *
41+ * It is safe to remove the listener while in the call back.
42+ *
43+ * Note: this method is called on the rendering thread,
44+ * do not call into user code, do not take RQ lock!
45+ */
46+ public void onDeviceReset();
47+
48+ /**
49+ * Called when the device is about to be disposed of.
50+ *
51+ * One must release all native resources associated with the device.
52+ *
53+ * It is safe to remove the listener while in the call back.
54+ *
55+ * Note: this method is called on the rendering thread,
56+ * do not call into user code, do not take RQ lock!
57+ */
58+ public void onDeviceDispose();
59+}
java/pkg/sun/java2d/pipe/hw/AccelDeviceEventNotifier.java+167−0
@@ -0,0 +1,167 @@
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 java.util.Collections;
29+import java.util.HashMap;
30+import java.util.Iterator;
31+import java.util.Map;
32+import java.util.Set;
33+
34+/**
35+ * This class is used to notify listeners about accelerated device's
36+ * events such as device reset or dispose that are about to occur.
37+ */
38+public class AccelDeviceEventNotifier {
39+
40+ private static AccelDeviceEventNotifier theInstance;
41+
42+ /**
43+ * A device is about to be reset. The listeners have to release all
44+ * resources associated with the device which are required for the device
45+ * to be reset.
46+ */
47+ public static final int DEVICE_RESET = 0;
48+
49+ /**
50+ * A device is about to be disposed. The listeners have to release all
51+ * resources associated with the device.
52+ */
53+ public static final int DEVICE_DISPOSED = 1;
54+
55+ private final Map<AccelDeviceEventListener, Integer> listeners;
56+
57+ private AccelDeviceEventNotifier() {
58+ listeners = Collections.synchronizedMap(
59+ new HashMap<AccelDeviceEventListener, Integer>(1));
60+ }
61+
62+ /**
63+ * Returns a singleton of AccelDeviceEventNotifier if it exists. If the
64+ * passed boolean is false and singleton doesn't exist yet, null is
65+ * returned. If the passed boolean is {@code true} and singleton doesn't
66+ * exist it will be created and returned.
67+ *
68+ * @param create whether to create a singleton instance if doesn't yet
69+ * exist
70+ * @return a singleton instance or null
71+ */
72+ private static synchronized
73+ AccelDeviceEventNotifier getInstance(boolean create)
74+ {
75+ if (theInstance == null && create) {
76+ theInstance = new AccelDeviceEventNotifier();
77+ }
78+ return theInstance;
79+ }
80+
81+ /**
82+ * Called to indicate that a device event had occured.
83+ * If a singleton exists, the listeners (those associated with
84+ * the device) will be notified.
85+ *
86+ * @param screen a screen number of the device which is a source of
87+ * the event
88+ * @param eventType a type of the event
89+ * @see #DEVICE_DISPOSED
90+ * @see #DEVICE_RESET
91+ */
92+ public static final void eventOccured(int screen, int eventType) {
93+ AccelDeviceEventNotifier notifier = getInstance(false);
94+ if (notifier != null) {
95+ notifier.notifyListeners(eventType, screen);
96+ }
97+ }
98+
99+ /**
100+ * Adds the listener associated with a device on particular screen.
101+ *
102+ * Note: the listener must be removed as otherwise it will forever
103+ * be referenced by the notifier.
104+ *
105+ * @param l the listener
106+ * @param screen the screen number indicating which device the listener is
107+ * interested in.
108+ */
109+ public static final void addListener(AccelDeviceEventListener l,int screen){
110+ getInstance(true).add(l, screen);
111+ }
112+
113+ /**
114+ * Removes the listener.
115+ *
116+ * @param l the listener
117+ */
118+ public static final void removeListener(AccelDeviceEventListener l) {
119+ getInstance(true).remove(l);
120+ }
121+
122+ private final void add(AccelDeviceEventListener theListener, int screen) {
123+ listeners.put(theListener, screen);
124+ }
125+ private final void remove(AccelDeviceEventListener theListener) {
126+ listeners.remove(theListener);
127+ }
128+
129+ /**
130+ * Notifies the listeners associated with the screen's device about the
131+ * event.
132+ *
133+ * Implementation note: the current list of listeners is first duplicated
134+ * which allows the listeners to remove themselves during the iteration.
135+ *
136+ * @param screen a screen number with which the device which is a source of
137+ * the event is associated with
138+ * @param eventType a type of the event
139+ * @see #DEVICE_DISPOSED
140+ * @see #DEVICE_RESET
141+ */
142+ private final void notifyListeners(int deviceEventType, int screen) {
143+ HashMap<AccelDeviceEventListener, Integer> listClone;
144+ Set<AccelDeviceEventListener> cloneSet;
145+
146+ synchronized(listeners) {
147+ listClone =
148+ new HashMap<AccelDeviceEventListener, Integer>(listeners);
149+ }
150+
151+ cloneSet = listClone.keySet();
152+ Iterator<AccelDeviceEventListener> itr = cloneSet.iterator();
153+ while (itr.hasNext()) {
154+ AccelDeviceEventListener current = itr.next();
155+ Integer i = listClone.get(current);
156+ // only notify listeners which are interested in this device
157+ if (i != null && i.intValue() != screen) {
158+ continue;
159+ }
160+ if (deviceEventType == DEVICE_RESET) {
161+ current.onDeviceReset();
162+ } else if (deviceEventType == DEVICE_DISPOSED) {
163+ current.onDeviceDispose();
164+ }
165+ }
166+ }
167+}
java/pkg/sun/java2d/pipe/hw/AccelGraphicsConfig.class+0−0

Binary file not shown.

java/pkg/sun/java2d/pipe/hw/AccelGraphicsConfig.java+95−0
@@ -0,0 +1,95 @@
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 java.awt.image.VolatileImage;
29+
30+/**
31+ * Implementors of this interface provida a way to create a
32+ * {@code VolatileImage} whose destination surface is an
33+ * {@link AccelSurface} of specified type.
34+ *
35+ * @see AccelSurface
36+ */
37+public interface AccelGraphicsConfig extends BufferedContextProvider {
38+ /**
39+ * Returns a VolatileImage with specified width, height, transparency
40+ * and guaranteed accelerated surface type. If such image can not be created
41+ * (out of vram error, specific surface type is not supported) null
42+ * is returned.
43+ *
44+ * Note: if {@link AccelSurface#TEXTURE} type is requested, rendering
45+ * to the image will be denied by throwing
46+ * {@code UnsupportedOperationException }
47+ * from {@link java.awt.image.VolatileImage#getGraphics} and
48+ * {@link java.awt.image.VolatileImage#createGraphics}
49+ *
50+ * @param width the width of the returned {@code VolatileImage}
51+ * @param height the height of the returned {@code VolatileImage}
52+ * @param transparency the specified transparency mode
53+ * @param type requested accelerated surface type as specified by constants
54+ * in AccelSurface interface
55+ * @return a {@code VolatileImage} backed up by requested accelerated
56+ * surface type or null
57+ * @throws IllegalArgumentException if the transparency is not a valid value
58+ * @see AccelSurface#TEXTURE
59+ * @see AccelSurface#RT_PLAIN
60+ * @see AccelSurface#RT_TEXTURE
61+ */
62+ public VolatileImage createCompatibleVolatileImage(int width, int height,
63+ int transparency,
64+ int type);
65+ /**
66+ * Returns object representing capabilities of the context associated
67+ * with this {@code AccelGraphicsConfig}.
68+ *
69+ * @return ContextCapabilities object representing caps
70+ * @see ContextCapabilities
71+ */
72+ public ContextCapabilities getContextCapabilities();
73+
74+ /**
75+ * Adds an {@code AccelDeviceEventListener} to listen to accelerated
76+ * device's (which is associated with this {@code AccelGraphicsConfig})
77+ * events.
78+ *
79+ * Note: a hard link to the listener may be kept so it must be explicitly
80+ * removed via {@link #removeDeviceEventListener()}.
81+ *
82+ * @param l the listener
83+ * @see AccelDeviceEventListener
84+ */
85+ public void addDeviceEventListener(AccelDeviceEventListener l);
86+
87+ /**
88+ * Removes an {@code AccelDeviceEventListener} from the list of listeners
89+ * for this device's events.
90+ *
91+ * @param l the listener
92+ * @see AccelDeviceEventListener
93+ */
94+ public void removeDeviceEventListener(AccelDeviceEventListener l);
95+}
java/pkg/sun/java2d/pipe/hw/AccelSurface.class+0−0

Binary file not shown.

java/pkg/sun/java2d/pipe/hw/AccelSurface.java+136−0
@@ -0,0 +1,136 @@
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 java.awt.Rectangle;
29+import sun.java2d.Surface;
30+
31+/**
32+ * Abstraction for a hardware accelerated surface.
33+ */
34+public interface AccelSurface extends BufferedContextProvider, Surface {
35+ /**
36+ * Undefined
37+ */
38+ public static final int UNDEFINED = 0;
39+ /**
40+ * Window (or window substitute) surface
41+ */
42+ public static final int WINDOW = 1;
43+ /**
44+ * Render-To Plain surface (pbuffer for OpenGL, Render Target surface
45+ * for Direct3D)
46+ */
47+ public static final int RT_PLAIN = 2;
48+ /**
49+ * Texture surface
50+ */
51+ public static final int TEXTURE = 3;
52+ /**
53+ * A back-buffer surface (SwapChain surface for Direct3D, backbuffer for
54+ * OpenGL)
55+ */
56+ public static final int FLIP_BACKBUFFER = 4;
57+ /**
58+ * Render-To Texture surface (fbobject for OpenGL, texture with render-to
59+ * attribute for Direct3D)
60+ */
61+ public static final int RT_TEXTURE = 5;
62+
63+ /**
64+ * Returns {@code int} representing surface's type as defined by constants
65+ * in this interface.
66+ *
67+ * @return an integer representing this surface's type
68+ * @see AccelSurface#UNDEFINED
69+ * @see AccelSurface#WINDOW
70+ * @see AccelSurface#RT_PLAIN
71+ * @see AccelSurface#TEXTURE
72+ * @see AccelSurface#FLIP_BACKBUFFER
73+ * @see AccelSurface#RT_TEXTURE
74+ */
75+ public int getType();
76+
77+ /**
78+ * Returns a pointer to the native surface data associated with this
79+ * surface.
80+ * Note: this pointer is only valid on the rendering thread.
81+ *
82+ * @return pointer to the native surface's data
83+ */
84+ public long getNativeOps();
85+
86+ /**
87+ * Returns a pointer to the real native resource
88+ * of the specified type associated with this AccelSurface.
89+ * Note: this pointer is only valid on the rendering thread.
90+ *
91+ * @param resType the type of the requested resource
92+ * @return a long containing a pointer to the native resource of the
93+ * specified type or 0L if such resource doesn't exist for this surface
94+ */
95+ public long getNativeResource(int resType);
96+
97+ /**
98+ * Marks this surface dirty.
99+ */
100+ public void markDirty();
101+
102+ /**
103+ * Returns whether the pipeline considers this surface valid. A surface
104+ * may become invalid if it is disposed of, or resized.
105+ *
106+ * @return true if valid, false otherwise
107+ */
108+ public boolean isValid();
109+
110+ /**
111+ * Returns whether this surface is lost. The return value is only valid
112+ * on the render thread, meaning that even if this method returns
113+ * {@code true} it could be lost in the next moment unless it is called
114+ * on the rendering thread.
115+ *
116+ * @return true if the surface is known to be lost, false otherwise
117+ */
118+ public boolean isSurfaceLost();
119+
120+ /**
121+ * Returns the requested bounds of the destination surface. The real bounds
122+ * of the native accelerated surface may differ. Use
123+ * {@link #getNativeBounds} to get the bounds of the native surface.
124+ *
125+ * @return Rectangle representing java surface's bounds
126+ */
127+ public Rectangle getBounds();
128+
129+ /**
130+ * Returns real bounds of the native surface, which may differ from those
131+ * returned by {@link #getBounds}.
132+ *
133+ * @return Rectangle representing native surface's bounds
134+ */
135+ public Rectangle getNativeBounds();
136+}
java/pkg/sun/java2d/pipe/hw/AccelTypedVolatileImage.java+74−0
@@ -0,0 +1,74 @@
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 java.awt.Graphics;
29+import java.awt.Graphics2D;
30+import java.awt.GraphicsConfiguration;
31+import sun.awt.image.SunVolatileImage;
32+import static sun.java2d.pipe.hw.AccelSurface.*;
33+
34+/**
35+ * This is an image with forced type of the accelerated surface.
36+ */
37+public class AccelTypedVolatileImage extends SunVolatileImage {
38+
39+ /**
40+ * Creates a volatile image with specified type of accelerated surface.
41+ *
42+ * @param graphicsConfig a GraphicsConfiguration for which this image should
43+ * be created.
44+ * @param width width
45+ * @param height width
46+ * @param transparency type of {@link java.awt.Transparency transparency}
47+ * requested for the image
48+ * @param accType type of the desired accelerated surface as defined in
49+ * AccelSurface interface
50+ * @see sun.java2d.pipe.hw.AccelSurface
51+ */
52+ public AccelTypedVolatileImage(GraphicsConfiguration graphicsConfig,
53+ int width, int height, int transparency,
54+ int accType)
55+ {
56+ super(null, graphicsConfig, width, height, null, transparency,
57+ null, accType);
58+ }
59+
60+ /**
61+ * {@inheritDoc}
62+ *
63+ * This method will throw {@code UnsupportedOperationException} if it this
64+ * image's destination surface can not be rendered to.
65+ */
66+ @Override
67+ public Graphics2D createGraphics() {
68+ if (getForcedAccelSurfaceType() == TEXTURE) {
69+ throw new UnsupportedOperationException("Can't render " +
70+ "to a non-RT Texture");
71+ }
72+ return super.createGraphics();
73+ }
74+}
java/pkg/sun/java2d/pipe/hw/BufferedContextProvider.class+0−0

Binary file not shown.

java/pkg/sun/java2d/pipe/hw/BufferedContextProvider.java+45−0
@@ -0,0 +1,45 @@
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 sun.java2d.pipe.BufferedContext;
29+
30+/**
31+ * Classes implementing this interface can provide the {@code BufferedContext}
32+ * associated with or used by them.
33+ *
34+ * @see sun.java2d.pipe.BufferedContext
35+ */
36+public interface BufferedContextProvider {
37+ /**
38+ * Retrieves a context associated with object implementing this
39+ * interface.
40+ *
41+ * @return associated context
42+ * @see sun.java2d.pipe.BufferedContext
43+ */
44+ public BufferedContext getContext();
45+}
java/pkg/sun/java2d/pipe/hw/ContextCapabilities.class+0−0

Binary file not shown.

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+
26+package sun.java2d.pipe.hw;
27+
28+/**
29+ * Represents a set of capabilities of a BufferedContext and associated
30+ * AccelGraphicsConfig.
31+ *
32+ * @see AccelGraphicsConfig
33+ */
34+public 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+}
java/pkg/sun/java2d/pipe/hw/ExtendedBufferCapabilities$VSyncType.class+0−0

Binary file not shown.

java/pkg/sun/java2d/pipe/hw/ExtendedBufferCapabilities.class+0−0

Binary file not shown.

java/pkg/sun/java2d/pipe/hw/ExtendedBufferCapabilities.java+154−0
@@ -0,0 +1,154 @@
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 java.awt.BufferCapabilities;
29+import java.awt.ImageCapabilities;
30+
31+/**
32+ * Provides extended BufferStrategy capabilities, allowing to specify
33+ * the type of vertical refresh synchronization for a buffer strategy.
34+ *
35+ * This BS capability is always page flipping because v-sync is only relevant
36+ * to flipping buffer strategies.
37+ *
38+ * Note that asking for a v-synced BS doesn't necessarily guarantee that it will
39+ * be v-synced since the vsync capability may be disabled in the driver, or
40+ * there may be other restriction (like a number of v-synced buffer strategies
41+ * allowed per vm). Because of this {@code createBufferStrategy} doesn't
42+ * throw {@code AWTException} when a v-synced BS could not be created when
43+ * requested.
44+ *
45+ * @see java.awt.Canvas#createBufferStrategy(int, BufferCapabilities)
46+ * @see java.awt.Window#createBufferStrategy(int, BufferCapabilities)
47+ */
48+public class ExtendedBufferCapabilities extends BufferCapabilities {
49+
50+ /**
51+ * Type of synchronization on vertical retrace.
52+ */
53+ public static enum VSyncType {
54+ /**
55+ * Use the default v-sync mode appropriate for given BufferStrategy
56+ * and situation.
57+ */
58+ VSYNC_DEFAULT(0),
59+
60+ /**
61+ * Synchronize flip on vertical retrace.
62+ */
63+ VSYNC_ON(1),
64+
65+ /**
66+ * Do not synchronize flip on vertical retrace.
67+ */
68+ VSYNC_OFF(2);
69+
70+ /**
71+ * Used to identify the v-sync type (independent of the constants
72+ * order as opposed to {@code ordinal()}).
73+ */
74+ public int id() {
75+ return id;
76+ }
77+
78+ private VSyncType(int id) {
79+ this.id = id;
80+ }
81+ private int id;
82+ }
83+
84+ private VSyncType vsync;
85+
86+ /**
87+ * Creates an ExtendedBufferCapabilities object with front/back/flip caps
88+ * from the passed cap, and VSYNC_DEFAULT v-sync mode.
89+ */
90+ public ExtendedBufferCapabilities(BufferCapabilities caps) {
91+ super(caps.getFrontBufferCapabilities(),
92+ caps.getBackBufferCapabilities(),
93+ caps.getFlipContents());
94+
95+ this.vsync = VSyncType.VSYNC_DEFAULT;
96+ }
97+
98+ /**
99+ * Creates an ExtendedBufferCapabilities instance with front/back/flip caps
100+ * from the passed caps, and VSYNC_DEFAULT v-sync mode.
101+ */
102+ public ExtendedBufferCapabilities(ImageCapabilities front,
103+ ImageCapabilities back, FlipContents flip)
104+ {
105+ super(front, back, flip);
106+
107+ this.vsync = VSyncType.VSYNC_DEFAULT;
108+ }
109+
110+ /**
111+ * Creates an ExtendedBufferCapabilities instance with front/back/flip caps
112+ * from the passed image/flip caps, and the v-sync type.
113+ */
114+ public ExtendedBufferCapabilities(ImageCapabilities front,
115+ ImageCapabilities back, FlipContents flip,
116+ VSyncType t)
117+ {
118+ super(front, back, flip);
119+
120+ this.vsync = t;
121+ }
122+
123+ /**
124+ * Creates an ExtendedBufferCapabilities instance with front/back/flip caps
125+ * from the passed cap, and the passed v-sync mode.
126+ */
127+ public ExtendedBufferCapabilities(BufferCapabilities caps, VSyncType t) {
128+ super(caps.getFrontBufferCapabilities(),
129+ caps.getBackBufferCapabilities(),
130+ caps.getFlipContents());
131+
132+ this.vsync = t;
133+ }
134+
135+ /**
136+ * Creates an ExtendedBufferCapabilities instance with front/back/flip caps
137+ * from the object, and passed v-sync mode.
138+ */
139+ public ExtendedBufferCapabilities derive(VSyncType t) {
140+ return new ExtendedBufferCapabilities(this, t);
141+ }
142+
143+ /**
144+ * Returns the type of v-sync requested by this capabilities instance.
145+ */
146+ public VSyncType getVSync() {
147+ return vsync;
148+ }
149+
150+ @Override
151+ public final boolean isPageFlipping() {
152+ return true;
153+ }
154+}
java/pkg/sun/java2d/pipe/hw/mkfile+15−0
@@ -0,0 +1,15 @@
1+<../../../../../../mkconfig
2+
3+TARG=\
4+ AccelDeviceEventListener.dis\
5+ AccelDeviceEventNotifier.dis\
6+ AccelGraphicsConfig.dis\
7+ AccelSurface.dis\
8+ AccelTypedVolatileImage.dis\
9+ BufferedContextProvider.dis\
10+ ContextCapabilities.dis\
11+ ExtendedBufferCapabilities.dis\
12+
13+DISBIN=$ROOT/java/dis/java/java/sun/java2d/pipe/hw
14+
15+<$ROOT/mkfiles/mkjava