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