Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/openjdk-multiarch-jdk8u
Path: blob/aarch64-shenandoah-jdk8u272-b10/jdk/src/share/classes/sun/java2d/opengl/OGLSurfaceData.java
38918 views
1
/*
2
* Copyright (c) 2003, 2012, 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.opengl;
27
28
import java.awt.AlphaComposite;
29
import java.awt.Composite;
30
import java.awt.GraphicsConfiguration;
31
import java.awt.GraphicsEnvironment;
32
import java.awt.Rectangle;
33
import java.awt.Transparency;
34
import java.awt.image.ColorModel;
35
import java.awt.image.Raster;
36
import sun.awt.SunHints;
37
import sun.awt.image.PixelConverter;
38
import sun.java2d.pipe.hw.AccelSurface;
39
import sun.java2d.SunGraphics2D;
40
import sun.java2d.SurfaceData;
41
import sun.java2d.SurfaceDataProxy;
42
import sun.java2d.loops.CompositeType;
43
import sun.java2d.loops.GraphicsPrimitive;
44
import sun.java2d.loops.MaskFill;
45
import sun.java2d.loops.SurfaceType;
46
import sun.java2d.pipe.ParallelogramPipe;
47
import sun.java2d.pipe.PixelToParallelogramConverter;
48
import sun.java2d.pipe.RenderBuffer;
49
import sun.java2d.pipe.TextPipe;
50
import static sun.java2d.pipe.BufferedOpCodes.*;
51
import static sun.java2d.opengl.OGLContext.OGLContextCaps.*;
52
53
/**
54
* This class describes an OpenGL "surface", that is, a region of pixels
55
* managed via OpenGL. An OGLSurfaceData can be tagged with one of three
56
* different SurfaceType objects for the purpose of registering loops, etc.
57
* This diagram shows the hierarchy of OGL SurfaceTypes:
58
*
59
* Any
60
* / \
61
* OpenGLSurface OpenGLTexture
62
* |
63
* OpenGLSurfaceRTT
64
*
65
* OpenGLSurface
66
* This kind of surface can be rendered to using OpenGL APIs. It is also
67
* possible to copy an OpenGLSurface to another OpenGLSurface (or to itself).
68
* This is typically accomplished by calling MakeContextCurrent(dstSD, srcSD)
69
* and then calling glCopyPixels() (although there are other techniques to
70
* achieve the same goal).
71
*
72
* OpenGLTexture
73
* This kind of surface cannot be rendered to using OpenGL (in the same sense
74
* as in OpenGLSurface). However, it is possible to upload a region of pixels
75
* to an OpenGLTexture object via glTexSubImage2D(). One can also copy a
76
* surface of type OpenGLTexture to an OpenGLSurface by binding the texture
77
* to a quad and then rendering it to the destination surface (this process
78
* is known as "texture mapping").
79
*
80
* OpenGLSurfaceRTT
81
* This kind of surface can be thought of as a sort of hybrid between
82
* OpenGLSurface and OpenGLTexture, in that one can render to this kind of
83
* surface as if it were of type OpenGLSurface, but the process of copying
84
* this kind of surface to another is more like an OpenGLTexture. (Note that
85
* "RTT" stands for "render-to-texture".)
86
*
87
* In addition to these SurfaceType variants, we have also defined some
88
* constants that describe in more detail the type of underlying OpenGL
89
* surface. This table helps explain the relationships between those
90
* "type" constants and their corresponding SurfaceType:
91
*
92
* OGL Type Corresponding SurfaceType
93
* -------- -------------------------
94
* WINDOW OpenGLSurface
95
* PBUFFER OpenGLSurface
96
* TEXTURE OpenGLTexture
97
* FLIP_BACKBUFFER OpenGLSurface
98
* FBOBJECT OpenGLSurfaceRTT
99
*/
100
public abstract class OGLSurfaceData extends SurfaceData
101
implements AccelSurface {
102
103
/**
104
* OGL-specific surface types
105
*
106
* @see sun.java2d.pipe.hw.AccelSurface
107
*/
108
public static final int PBUFFER = RT_PLAIN;
109
public static final int FBOBJECT = RT_TEXTURE;
110
111
/**
112
* Pixel formats
113
*/
114
public static final int PF_INT_ARGB = 0;
115
public static final int PF_INT_ARGB_PRE = 1;
116
public static final int PF_INT_RGB = 2;
117
public static final int PF_INT_RGBX = 3;
118
public static final int PF_INT_BGR = 4;
119
public static final int PF_INT_BGRX = 5;
120
public static final int PF_USHORT_565_RGB = 6;
121
public static final int PF_USHORT_555_RGB = 7;
122
public static final int PF_USHORT_555_RGBX = 8;
123
public static final int PF_BYTE_GRAY = 9;
124
public static final int PF_USHORT_GRAY = 10;
125
public static final int PF_3BYTE_BGR = 11;
126
127
/**
128
* SurfaceTypes
129
*/
130
private static final String DESC_OPENGL_SURFACE = "OpenGL Surface";
131
private static final String DESC_OPENGL_SURFACE_RTT =
132
"OpenGL Surface (render-to-texture)";
133
private static final String DESC_OPENGL_TEXTURE = "OpenGL Texture";
134
135
static final SurfaceType OpenGLSurface =
136
SurfaceType.Any.deriveSubType(DESC_OPENGL_SURFACE,
137
PixelConverter.ArgbPre.instance);
138
static final SurfaceType OpenGLSurfaceRTT =
139
OpenGLSurface.deriveSubType(DESC_OPENGL_SURFACE_RTT);
140
static final SurfaceType OpenGLTexture =
141
SurfaceType.Any.deriveSubType(DESC_OPENGL_TEXTURE);
142
143
/** This will be true if the fbobject system property has been enabled. */
144
private static boolean isFBObjectEnabled;
145
146
/** This will be true if the lcdshader system property has been enabled.*/
147
private static boolean isLCDShaderEnabled;
148
149
/** This will be true if the biopshader system property has been enabled.*/
150
private static boolean isBIOpShaderEnabled;
151
152
/** This will be true if the gradshader system property has been enabled.*/
153
private static boolean isGradShaderEnabled;
154
155
private OGLGraphicsConfig graphicsConfig;
156
protected int type;
157
// these fields are set from the native code when the surface is
158
// initialized
159
private int nativeWidth, nativeHeight;
160
161
protected static OGLRenderer oglRenderPipe;
162
protected static PixelToParallelogramConverter oglTxRenderPipe;
163
protected static ParallelogramPipe oglAAPgramPipe;
164
protected static OGLTextRenderer oglTextPipe;
165
protected static OGLDrawImage oglImagePipe;
166
167
protected native boolean initTexture(long pData,
168
boolean isOpaque, boolean texNonPow2,
169
boolean texRect,
170
int width, int height);
171
protected native boolean initFBObject(long pData,
172
boolean isOpaque, boolean texNonPow2,
173
boolean texRect,
174
int width, int height);
175
protected native boolean initFlipBackbuffer(long pData);
176
protected abstract boolean initPbuffer(long pData, long pConfigInfo,
177
boolean isOpaque,
178
int width, int height);
179
180
private native int getTextureTarget(long pData);
181
private native int getTextureID(long pData);
182
183
static {
184
if (!GraphicsEnvironment.isHeadless()) {
185
// fbobject currently enabled by default; use "false" to disable
186
String fbo = (String)java.security.AccessController.doPrivileged(
187
new sun.security.action.GetPropertyAction(
188
"sun.java2d.opengl.fbobject"));
189
isFBObjectEnabled = !"false".equals(fbo);
190
191
// lcdshader currently enabled by default; use "false" to disable
192
String lcd = (String)java.security.AccessController.doPrivileged(
193
new sun.security.action.GetPropertyAction(
194
"sun.java2d.opengl.lcdshader"));
195
isLCDShaderEnabled = !"false".equals(lcd);
196
197
// biopshader currently enabled by default; use "false" to disable
198
String biop = (String)java.security.AccessController.doPrivileged(
199
new sun.security.action.GetPropertyAction(
200
"sun.java2d.opengl.biopshader"));
201
isBIOpShaderEnabled = !"false".equals(biop);
202
203
// gradshader currently enabled by default; use "false" to disable
204
String grad = (String)java.security.AccessController.doPrivileged(
205
new sun.security.action.GetPropertyAction(
206
"sun.java2d.opengl.gradshader"));
207
isGradShaderEnabled = !"false".equals(grad);
208
209
OGLRenderQueue rq = OGLRenderQueue.getInstance();
210
oglImagePipe = new OGLDrawImage();
211
oglTextPipe = new OGLTextRenderer(rq);
212
oglRenderPipe = new OGLRenderer(rq);
213
if (GraphicsPrimitive.tracingEnabled()) {
214
oglTextPipe = oglTextPipe.traceWrap();
215
//The wrapped oglRenderPipe will wrap the AA pipe as well...
216
//oglAAPgramPipe = oglRenderPipe.traceWrap();
217
}
218
oglAAPgramPipe = oglRenderPipe.getAAParallelogramPipe();
219
oglTxRenderPipe =
220
new PixelToParallelogramConverter(oglRenderPipe,
221
oglRenderPipe,
222
1.0, 0.25, true);
223
224
OGLBlitLoops.register();
225
OGLMaskFill.register();
226
OGLMaskBlit.register();
227
}
228
}
229
230
protected OGLSurfaceData(OGLGraphicsConfig gc,
231
ColorModel cm, int type)
232
{
233
super(getCustomSurfaceType(type), cm);
234
this.graphicsConfig = gc;
235
this.type = type;
236
setBlitProxyKey(gc.getProxyKey());
237
}
238
239
@Override
240
public SurfaceDataProxy makeProxyFor(SurfaceData srcData) {
241
return OGLSurfaceDataProxy.createProxy(srcData, graphicsConfig);
242
}
243
244
/**
245
* Returns the appropriate SurfaceType corresponding to the given OpenGL
246
* surface type constant (e.g. TEXTURE -> OpenGLTexture).
247
*/
248
private static SurfaceType getCustomSurfaceType(int oglType) {
249
switch (oglType) {
250
case TEXTURE:
251
return OpenGLTexture;
252
case FBOBJECT:
253
return OpenGLSurfaceRTT;
254
case PBUFFER:
255
default:
256
return OpenGLSurface;
257
}
258
}
259
260
/**
261
* Note: This should only be called from the QFT under the AWT lock.
262
* This method is kept separate from the initSurface() method below just
263
* to keep the code a bit cleaner.
264
*/
265
private void initSurfaceNow(int width, int height) {
266
boolean isOpaque = (getTransparency() == Transparency.OPAQUE);
267
boolean success = false;
268
269
switch (type) {
270
case PBUFFER:
271
success = initPbuffer(getNativeOps(),
272
graphicsConfig.getNativeConfigInfo(),
273
isOpaque,
274
width, height);
275
break;
276
277
case TEXTURE:
278
success = initTexture(getNativeOps(),
279
isOpaque, isTexNonPow2Available(),
280
isTexRectAvailable(),
281
width, height);
282
break;
283
284
case FBOBJECT:
285
success = initFBObject(getNativeOps(),
286
isOpaque, isTexNonPow2Available(),
287
isTexRectAvailable(),
288
width, height);
289
break;
290
291
case FLIP_BACKBUFFER:
292
success = initFlipBackbuffer(getNativeOps());
293
break;
294
295
default:
296
break;
297
}
298
299
if (!success) {
300
throw new OutOfMemoryError("can't create offscreen surface");
301
}
302
}
303
304
/**
305
* Initializes the appropriate OpenGL offscreen surface based on the value
306
* of the type parameter. If the surface creation fails for any reason,
307
* an OutOfMemoryError will be thrown.
308
*/
309
protected void initSurface(final int width, final int height) {
310
OGLRenderQueue rq = OGLRenderQueue.getInstance();
311
rq.lock();
312
try {
313
switch (type) {
314
case TEXTURE:
315
case PBUFFER:
316
case FBOBJECT:
317
// need to make sure the context is current before
318
// creating the texture (or pbuffer, or fbobject)
319
OGLContext.setScratchSurface(graphicsConfig);
320
break;
321
default:
322
break;
323
}
324
rq.flushAndInvokeNow(new Runnable() {
325
public void run() {
326
initSurfaceNow(width, height);
327
}
328
});
329
} finally {
330
rq.unlock();
331
}
332
}
333
334
/**
335
* Returns the OGLContext for the GraphicsConfig associated with this
336
* surface.
337
*/
338
public final OGLContext getContext() {
339
return graphicsConfig.getContext();
340
}
341
342
/**
343
* Returns the OGLGraphicsConfig associated with this surface.
344
*/
345
final OGLGraphicsConfig getOGLGraphicsConfig() {
346
return graphicsConfig;
347
}
348
349
/**
350
* Returns one of the surface type constants defined above.
351
*/
352
public final int getType() {
353
return type;
354
}
355
356
/**
357
* If this surface is backed by a texture object, returns the target
358
* for that texture (either GL_TEXTURE_2D or GL_TEXTURE_RECTANGLE_ARB).
359
* Otherwise, this method will return zero.
360
*/
361
public final int getTextureTarget() {
362
return getTextureTarget(getNativeOps());
363
}
364
365
/**
366
* If this surface is backed by a texture object, returns the texture ID
367
* for that texture.
368
* Otherwise, this method will return zero.
369
*/
370
public final int getTextureID() {
371
return getTextureID(getNativeOps());
372
}
373
374
/**
375
* Returns native resource of specified {@code resType} associated with
376
* this surface.
377
*
378
* Specifically, for {@code OGLSurfaceData} this method returns the
379
* the following:
380
* <pre>
381
* TEXTURE - texture id
382
* </pre>
383
*
384
* Note: the resource returned by this method is only valid on the rendering
385
* thread.
386
*
387
* @return native resource of specified type or 0L if
388
* such resource doesn't exist or can not be retrieved.
389
* @see sun.java2d.pipe.hw.AccelSurface#getNativeResource
390
*/
391
public long getNativeResource(int resType) {
392
if (resType == TEXTURE) {
393
return getTextureID();
394
}
395
return 0L;
396
}
397
398
public Raster getRaster(int x, int y, int w, int h) {
399
throw new InternalError("not implemented yet");
400
}
401
402
/**
403
* For now, we can only render LCD text if:
404
* - the fragment shader extension is available, and
405
* - the source color is opaque, and
406
* - blending is SrcOverNoEa or disabled
407
* - and the destination is opaque
408
*
409
* Eventually, we could enhance the native OGL text rendering code
410
* and remove the above restrictions, but that would require significantly
411
* more code just to support a few uncommon cases.
412
*/
413
public boolean canRenderLCDText(SunGraphics2D sg2d) {
414
return
415
graphicsConfig.isCapPresent(CAPS_EXT_LCD_SHADER) &&
416
sg2d.surfaceData.getTransparency() == Transparency.OPAQUE &&
417
sg2d.paintState <= SunGraphics2D.PAINT_OPAQUECOLOR &&
418
(sg2d.compositeState <= SunGraphics2D.COMP_ISCOPY ||
419
(sg2d.compositeState <= SunGraphics2D.COMP_ALPHA && canHandleComposite(sg2d.composite)));
420
}
421
422
private boolean canHandleComposite(Composite c) {
423
if (c instanceof AlphaComposite) {
424
AlphaComposite ac = (AlphaComposite)c;
425
426
return ac.getRule() == AlphaComposite.SRC_OVER && ac.getAlpha() >= 1f;
427
}
428
return false;
429
}
430
431
public void validatePipe(SunGraphics2D sg2d) {
432
TextPipe textpipe;
433
boolean validated = false;
434
435
// OGLTextRenderer handles both AA and non-AA text, but
436
// only works with the following modes:
437
// (Note: For LCD text we only enter this code path if
438
// canRenderLCDText() has already validated that the mode is
439
// CompositeType.SrcNoEa (opaque color), which will be subsumed
440
// by the CompositeType.SrcNoEa (any color) test below.)
441
442
if (/* CompositeType.SrcNoEa (any color) */
443
(sg2d.compositeState <= SunGraphics2D.COMP_ISCOPY &&
444
sg2d.paintState <= SunGraphics2D.PAINT_ALPHACOLOR) ||
445
446
/* CompositeType.SrcOver (any color) */
447
(sg2d.compositeState == SunGraphics2D.COMP_ALPHA &&
448
sg2d.paintState <= SunGraphics2D.PAINT_ALPHACOLOR &&
449
(((AlphaComposite)sg2d.composite).getRule() ==
450
AlphaComposite.SRC_OVER)) ||
451
452
/* CompositeType.Xor (any color) */
453
(sg2d.compositeState == SunGraphics2D.COMP_XOR &&
454
sg2d.paintState <= SunGraphics2D.PAINT_ALPHACOLOR))
455
{
456
textpipe = oglTextPipe;
457
} else {
458
// do this to initialize textpipe correctly; we will attempt
459
// to override the non-text pipes below
460
super.validatePipe(sg2d);
461
textpipe = sg2d.textpipe;
462
validated = true;
463
}
464
465
PixelToParallelogramConverter txPipe = null;
466
OGLRenderer nonTxPipe = null;
467
468
if (sg2d.antialiasHint != SunHints.INTVAL_ANTIALIAS_ON) {
469
if (sg2d.paintState <= SunGraphics2D.PAINT_ALPHACOLOR) {
470
if (sg2d.compositeState <= SunGraphics2D.COMP_XOR) {
471
txPipe = oglTxRenderPipe;
472
nonTxPipe = oglRenderPipe;
473
}
474
} else if (sg2d.compositeState <= SunGraphics2D.COMP_ALPHA) {
475
if (OGLPaints.isValid(sg2d)) {
476
txPipe = oglTxRenderPipe;
477
nonTxPipe = oglRenderPipe;
478
}
479
// custom paints handled by super.validatePipe() below
480
}
481
} else {
482
if (sg2d.paintState <= SunGraphics2D.PAINT_ALPHACOLOR) {
483
if (graphicsConfig.isCapPresent(CAPS_PS30) &&
484
(sg2d.imageComp == CompositeType.SrcOverNoEa ||
485
sg2d.imageComp == CompositeType.SrcOver))
486
{
487
if (!validated) {
488
super.validatePipe(sg2d);
489
validated = true;
490
}
491
PixelToParallelogramConverter aaConverter =
492
new PixelToParallelogramConverter(sg2d.shapepipe,
493
oglAAPgramPipe,
494
1.0/8.0, 0.499,
495
false);
496
sg2d.drawpipe = aaConverter;
497
sg2d.fillpipe = aaConverter;
498
sg2d.shapepipe = aaConverter;
499
} else if (sg2d.compositeState == SunGraphics2D.COMP_XOR) {
500
// install the solid pipes when AA and XOR are both enabled
501
txPipe = oglTxRenderPipe;
502
nonTxPipe = oglRenderPipe;
503
}
504
}
505
// other cases handled by super.validatePipe() below
506
}
507
508
if (txPipe != null) {
509
if (sg2d.transformState >= SunGraphics2D.TRANSFORM_TRANSLATESCALE) {
510
sg2d.drawpipe = txPipe;
511
sg2d.fillpipe = txPipe;
512
} else if (sg2d.strokeState != SunGraphics2D.STROKE_THIN) {
513
sg2d.drawpipe = txPipe;
514
sg2d.fillpipe = nonTxPipe;
515
} else {
516
sg2d.drawpipe = nonTxPipe;
517
sg2d.fillpipe = nonTxPipe;
518
}
519
// Note that we use the transforming pipe here because it
520
// will examine the shape and possibly perform an optimized
521
// operation if it can be simplified. The simplifications
522
// will be valid for all STROKE and TRANSFORM types.
523
sg2d.shapepipe = txPipe;
524
} else {
525
if (!validated) {
526
super.validatePipe(sg2d);
527
}
528
}
529
530
// install the text pipe based on our earlier decision
531
sg2d.textpipe = textpipe;
532
533
// always override the image pipe with the specialized OGL pipe
534
sg2d.imagepipe = oglImagePipe;
535
}
536
537
@Override
538
protected MaskFill getMaskFill(SunGraphics2D sg2d) {
539
if (sg2d.paintState > SunGraphics2D.PAINT_ALPHACOLOR) {
540
/*
541
* We can only accelerate non-Color MaskFill operations if
542
* all of the following conditions hold true:
543
* - there is an implementation for the given paintState
544
* - the current Paint can be accelerated for this destination
545
* - multitexturing is available (since we need to modulate
546
* the alpha mask texture with the paint texture)
547
*
548
* In all other cases, we return null, in which case the
549
* validation code will choose a more general software-based loop.
550
*/
551
if (!OGLPaints.isValid(sg2d) ||
552
!graphicsConfig.isCapPresent(CAPS_MULTITEXTURE))
553
{
554
return null;
555
}
556
}
557
return super.getMaskFill(sg2d);
558
}
559
560
public boolean copyArea(SunGraphics2D sg2d,
561
int x, int y, int w, int h, int dx, int dy)
562
{
563
if (sg2d.transformState < SunGraphics2D.TRANSFORM_TRANSLATESCALE &&
564
sg2d.compositeState < SunGraphics2D.COMP_XOR)
565
{
566
x += sg2d.transX;
567
y += sg2d.transY;
568
569
oglRenderPipe.copyArea(sg2d, x, y, w, h, dx, dy);
570
571
return true;
572
}
573
return false;
574
}
575
576
public void flush() {
577
invalidate();
578
OGLRenderQueue rq = OGLRenderQueue.getInstance();
579
rq.lock();
580
try {
581
// make sure we have a current context before
582
// disposing the native resources (e.g. texture object)
583
OGLContext.setScratchSurface(graphicsConfig);
584
585
RenderBuffer buf = rq.getBuffer();
586
rq.ensureCapacityAndAlignment(12, 4);
587
buf.putInt(FLUSH_SURFACE);
588
buf.putLong(getNativeOps());
589
590
// this call is expected to complete synchronously, so flush now
591
rq.flushNow();
592
} finally {
593
rq.unlock();
594
}
595
}
596
597
/**
598
* Disposes the native resources associated with the given OGLSurfaceData
599
* (referenced by the pData parameter). This method is invoked from
600
* the native Dispose() method from the Disposer thread when the
601
* Java-level OGLSurfaceData object is about to go away. Note that we
602
* also pass a reference to the OGLGraphicsConfig
603
* for the purposes of making a context current.
604
*/
605
static void dispose(long pData, OGLGraphicsConfig gc) {
606
OGLRenderQueue rq = OGLRenderQueue.getInstance();
607
rq.lock();
608
try {
609
// make sure we have a current context before
610
// disposing the native resources (e.g. texture object)
611
OGLContext.setScratchSurface(gc);
612
613
RenderBuffer buf = rq.getBuffer();
614
rq.ensureCapacityAndAlignment(12, 4);
615
buf.putInt(DISPOSE_SURFACE);
616
buf.putLong(pData);
617
618
// this call is expected to complete synchronously, so flush now
619
rq.flushNow();
620
} finally {
621
rq.unlock();
622
}
623
}
624
625
static void swapBuffers(long window) {
626
OGLRenderQueue rq = OGLRenderQueue.getInstance();
627
rq.lock();
628
try {
629
RenderBuffer buf = rq.getBuffer();
630
rq.ensureCapacityAndAlignment(12, 4);
631
buf.putInt(SWAP_BUFFERS);
632
buf.putLong(window);
633
rq.flushNow();
634
} finally {
635
rq.unlock();
636
}
637
}
638
639
/**
640
* Returns true if OpenGL textures can have non-power-of-two dimensions
641
* when using the basic GL_TEXTURE_2D target.
642
*/
643
boolean isTexNonPow2Available() {
644
return graphicsConfig.isCapPresent(CAPS_TEXNONPOW2);
645
}
646
647
/**
648
* Returns true if OpenGL textures can have non-power-of-two dimensions
649
* when using the GL_TEXTURE_RECTANGLE_ARB target (only available when the
650
* GL_ARB_texture_rectangle extension is present).
651
*/
652
boolean isTexRectAvailable() {
653
return graphicsConfig.isCapPresent(CAPS_EXT_TEXRECT);
654
}
655
656
public Rectangle getNativeBounds() {
657
OGLRenderQueue rq = OGLRenderQueue.getInstance();
658
rq.lock();
659
try {
660
return new Rectangle(nativeWidth, nativeHeight);
661
} finally {
662
rq.unlock();
663
}
664
}
665
666
/**
667
* Returns true if the surface is an on-screen window surface or
668
* a FBO texture attached to an on-screen CALayer.
669
*
670
* Needed by Mac OS X port.
671
*/
672
boolean isOnScreen() {
673
return getType() == WINDOW;
674
}
675
}
676
677