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.opengl;
27
28 import java.awt.Component;
29 import java.awt.GraphicsConfiguration;
30 import java.awt.GraphicsDevice;
31 import java.awt.GraphicsEnvironment;
32 import java.awt.Image;
33 import java.awt.Rectangle;
34 import java.awt.geom.AffineTransform;
35 import java.awt.image.ColorModel;
36 import sun.awt.SunToolkit;
37 import sun.awt.Win32GraphicsDevice;
38 import sun.awt.windows.WComponentPeer;
39 import sun.java2d.SurfaceData;
40
41 public abstract class WGLSurfaceData extends OGLSurfaceData {
42
43 protected WComponentPeer peer;
44 private WGLGraphicsConfig graphicsConfig;
45 protected double scaleX = 1;
46 protected double scaleY = 1;
47
48 private native void initOps(long pConfigInfo, WComponentPeer peer,
49 long hwnd);
50
51 protected WGLSurfaceData(WComponentPeer peer, WGLGraphicsConfig gc,
52 ColorModel cm, int type)
53 {
54 super(gc, cm, type);
55 this.peer = peer;
56 this.graphicsConfig = gc;
57 Win32GraphicsDevice device = gc.getDevice();
58 this.scaleX = type == TEXTURE ? 1 : device.getDefaultScaleX();
59 this.scaleY = type == TEXTURE ? 1 : device.getDefaultScaleY();
148 GraphicsDevice gd = env.getDefaultScreenDevice();
149 return (WGLGraphicsConfig)gd.getDefaultConfiguration();
150 }
151 }
152
153 public static class WGLWindowSurfaceData extends WGLSurfaceData {
154
155 public WGLWindowSurfaceData(WComponentPeer peer,
156 WGLGraphicsConfig gc)
157 {
158 super(peer, gc, peer.getColorModel(), WINDOW);
159 }
160
161 public SurfaceData getReplacement() {
162 return peer.getSurfaceData();
163 }
164
165 public Rectangle getBounds() {
166 Rectangle r = peer.getBounds();
167 r.x = r.y = 0;
168 r.width = (int) Math.ceil(r.width * scaleX);
169 r.height = (int) Math.ceil(r.height * scaleY);
170 return r;
171 }
172
173 /**
174 * Returns destination Component associated with this SurfaceData.
175 */
176 public Object getDestination() {
177 return peer.getTarget();
178 }
179 }
180
181 /**
182 * A surface which implements a v-synced flip back-buffer with COPIED
183 * FlipContents.
184 *
185 * This surface serves as a back-buffer to the outside world, while
186 * it is actually an offscreen surface. When the BufferStrategy this surface
187 * belongs to is showed, it is first copied to the real private
188 * FLIP_BACKBUFFER, which is then flipped.
189 */
210 public void flush() {
211 flipSurface.flush();
212 super.flush();
213 }
214
215 }
216
217 public static class WGLOffScreenSurfaceData extends WGLSurfaceData {
218
219 private Image offscreenImage;
220 private int width, height;
221
222 public WGLOffScreenSurfaceData(WComponentPeer peer,
223 WGLGraphicsConfig gc,
224 int width, int height,
225 Image image, ColorModel cm,
226 int type)
227 {
228 super(peer, gc, cm, type);
229
230 this.width = (int) Math.ceil(width * scaleX);
231 this.height = (int) Math.ceil(height * scaleY);
232 offscreenImage = image;
233
234 initSurface(this.width, this.height);
235 }
236
237 public SurfaceData getReplacement() {
238 return restoreContents(offscreenImage);
239 }
240
241 public Rectangle getBounds() {
242 if (type == FLIP_BACKBUFFER) {
243 Rectangle r = peer.getBounds();
244 r.width = (int) Math.ceil(r.width * scaleX);
245 r.height = (int) Math.ceil(r.height * scaleY);
246 r.x = r.y = 0;
247 return r;
248 } else {
249 return new Rectangle(width, height);
250 }
251 }
252
253 /**
254 * Returns destination Image associated with this SurfaceData.
255 */
256 public Object getDestination() {
257 return offscreenImage;
258 }
259 }
260
261 /**
262 * Updates the layered window with the contents of the surface.
263 *
264 * @param psdops pointer to the native ogl sd structure
265 * @param peer pointer to the AwtWindow peer data
|
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.opengl;
27
28 import java.awt.Component;
29 import java.awt.GraphicsConfiguration;
30 import java.awt.GraphicsDevice;
31 import java.awt.GraphicsEnvironment;
32 import java.awt.Image;
33 import java.awt.Rectangle;
34 import java.awt.geom.AffineTransform;
35 import java.awt.image.ColorModel;
36 import sun.awt.SunToolkit;
37 import sun.awt.Win32GraphicsDevice;
38 import sun.awt.windows.WComponentPeer;
39 import sun.java2d.SurfaceData;
40 import sun.java2d.pipe.Region;
41
42 public abstract class WGLSurfaceData extends OGLSurfaceData {
43
44 protected WComponentPeer peer;
45 private WGLGraphicsConfig graphicsConfig;
46 protected double scaleX = 1;
47 protected double scaleY = 1;
48
49 private native void initOps(long pConfigInfo, WComponentPeer peer,
50 long hwnd);
51
52 protected WGLSurfaceData(WComponentPeer peer, WGLGraphicsConfig gc,
53 ColorModel cm, int type)
54 {
55 super(gc, cm, type);
56 this.peer = peer;
57 this.graphicsConfig = gc;
58 Win32GraphicsDevice device = gc.getDevice();
59 this.scaleX = type == TEXTURE ? 1 : device.getDefaultScaleX();
60 this.scaleY = type == TEXTURE ? 1 : device.getDefaultScaleY();
149 GraphicsDevice gd = env.getDefaultScreenDevice();
150 return (WGLGraphicsConfig)gd.getDefaultConfiguration();
151 }
152 }
153
154 public static class WGLWindowSurfaceData extends WGLSurfaceData {
155
156 public WGLWindowSurfaceData(WComponentPeer peer,
157 WGLGraphicsConfig gc)
158 {
159 super(peer, gc, peer.getColorModel(), WINDOW);
160 }
161
162 public SurfaceData getReplacement() {
163 return peer.getSurfaceData();
164 }
165
166 public Rectangle getBounds() {
167 Rectangle r = peer.getBounds();
168 r.x = r.y = 0;
169 r.width = Region.clipRound(r.width * scaleX);
170 r.height = Region.clipRound(r.height * scaleY);
171 return r;
172 }
173
174 /**
175 * Returns destination Component associated with this SurfaceData.
176 */
177 public Object getDestination() {
178 return peer.getTarget();
179 }
180 }
181
182 /**
183 * A surface which implements a v-synced flip back-buffer with COPIED
184 * FlipContents.
185 *
186 * This surface serves as a back-buffer to the outside world, while
187 * it is actually an offscreen surface. When the BufferStrategy this surface
188 * belongs to is showed, it is first copied to the real private
189 * FLIP_BACKBUFFER, which is then flipped.
190 */
211 public void flush() {
212 flipSurface.flush();
213 super.flush();
214 }
215
216 }
217
218 public static class WGLOffScreenSurfaceData extends WGLSurfaceData {
219
220 private Image offscreenImage;
221 private int width, height;
222
223 public WGLOffScreenSurfaceData(WComponentPeer peer,
224 WGLGraphicsConfig gc,
225 int width, int height,
226 Image image, ColorModel cm,
227 int type)
228 {
229 super(peer, gc, cm, type);
230
231 this.width = Region.clipRound(width * scaleX);
232 this.height = Region.clipRound(height * scaleY);
233 offscreenImage = image;
234
235 initSurface(this.width, this.height);
236 }
237
238 public SurfaceData getReplacement() {
239 return restoreContents(offscreenImage);
240 }
241
242 public Rectangle getBounds() {
243 if (type == FLIP_BACKBUFFER) {
244 Rectangle r = peer.getBounds();
245 r.width = Region.clipRound(r.width * scaleX);
246 r.height = Region.clipRound(r.height * scaleY);
247 r.x = r.y = 0;
248 return r;
249 } else {
250 return new Rectangle(width, height);
251 }
252 }
253
254 /**
255 * Returns destination Image associated with this SurfaceData.
256 */
257 public Object getDestination() {
258 return offscreenImage;
259 }
260 }
261
262 /**
263 * Updates the layered window with the contents of the surface.
264 *
265 * @param psdops pointer to the native ogl sd structure
266 * @param peer pointer to the AwtWindow peer data
|