Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/openjdk-multiarch-jdk8u
Path: blob/aarch64-shenandoah-jdk8u272-b10/jdk/src/macosx/native_NOTIOS/sun/java2d/opengl/CGLSurfaceData.m
38829 views
1
/*
2
* Copyright (c) 2011, 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
#import <stdlib.h>
27
#import <JavaNativeFoundation/JavaNativeFoundation.h>
28
29
#import "sun_java2d_opengl_CGLSurfaceData.h"
30
31
#import "jni.h"
32
#import "jni_util.h"
33
#import "OGLRenderQueue.h"
34
#import "CGLGraphicsConfig.h"
35
#import "CGLSurfaceData.h"
36
#import "CGLLayer.h"
37
#import "ThreadUtilities.h"
38
39
/* JDK's glext.h is already included and will prevent the Apple glext.h
40
* being included, so define the externs directly
41
*/
42
extern void glBindFramebufferEXT(GLenum target, GLuint framebuffer);
43
extern CGLError CGLTexImageIOSurface2D(
44
CGLContextObj ctx, GLenum target, GLenum internal_format,
45
GLsizei width, GLsizei height, GLenum format, GLenum type,
46
IOSurfaceRef ioSurface, GLuint plane);
47
48
/**
49
* The methods in this file implement the native windowing system specific
50
* layer (CGL) for the OpenGL-based Java 2D pipeline.
51
*/
52
53
#pragma mark -
54
#pragma mark "--- Mac OS X specific methods for GL pipeline ---"
55
56
// TODO: hack that's called from OGLRenderQueue to test out unlockFocus behavior
57
#if 0
58
void
59
OGLSD_UnlockFocus(OGLContext *oglc, OGLSDOps *dstOps)
60
{
61
CGLCtxInfo *ctxinfo = (CGLCtxInfo *)oglc->ctxInfo;
62
CGLSDOps *cglsdo = (CGLSDOps *)dstOps->privOps;
63
fprintf(stderr, "about to unlock focus: %p %p\n",
64
cglsdo->peerData, ctxinfo->context);
65
66
NSOpenGLView *nsView = cglsdo->peerData;
67
if (nsView != NULL) {
68
JNF_COCOA_ENTER(env);
69
[nsView unlockFocus];
70
JNF_COCOA_EXIT(env);
71
}
72
}
73
#endif
74
75
/**
76
* Makes the given context current to its associated "scratch" surface. If
77
* the operation is successful, this method will return JNI_TRUE; otherwise,
78
* returns JNI_FALSE.
79
*/
80
static jboolean
81
CGLSD_MakeCurrentToScratch(JNIEnv *env, OGLContext *oglc)
82
{
83
J2dTraceLn(J2D_TRACE_INFO, "CGLSD_MakeCurrentToScratch");
84
85
if (oglc == NULL) {
86
J2dRlsTraceLn(J2D_TRACE_ERROR,
87
"CGLSD_MakeCurrentToScratch: context is null");
88
return JNI_FALSE;
89
}
90
91
JNF_COCOA_ENTER(env);
92
93
CGLCtxInfo *ctxinfo = (CGLCtxInfo *)oglc->ctxInfo;
94
#if USE_NSVIEW_FOR_SCRATCH
95
[ctxinfo->context makeCurrentContext];
96
#else
97
[ctxinfo->context clearDrawable];
98
[ctxinfo->context makeCurrentContext];
99
[ctxinfo->context setPixelBuffer: ctxinfo->scratchSurface
100
cubeMapFace: 0
101
mipMapLevel: 0
102
currentVirtualScreen: [ctxinfo->context currentVirtualScreen]];
103
#endif
104
105
JNF_COCOA_EXIT(env);
106
107
return JNI_TRUE;
108
}
109
110
/**
111
* This function disposes of any native windowing system resources associated
112
* with this surface. For instance, if the given OGLSDOps is of type
113
* OGLSD_PBUFFER, this method implementation will destroy the actual pbuffer
114
* surface.
115
*/
116
void
117
OGLSD_DestroyOGLSurface(JNIEnv *env, OGLSDOps *oglsdo)
118
{
119
J2dTraceLn(J2D_TRACE_INFO, "OGLSD_DestroyOGLSurface");
120
121
JNF_COCOA_ENTER(env);
122
123
CGLSDOps *cglsdo = (CGLSDOps *)oglsdo->privOps;
124
if (oglsdo->drawableType == OGLSD_PBUFFER) {
125
if (oglsdo->textureID != 0) {
126
j2d_glDeleteTextures(1, &oglsdo->textureID);
127
oglsdo->textureID = 0;
128
}
129
if (cglsdo->pbuffer != NULL) {
130
[cglsdo->pbuffer release];
131
cglsdo->pbuffer = NULL;
132
}
133
} else if (oglsdo->drawableType == OGLSD_WINDOW) {
134
// detach the NSView from the NSOpenGLContext
135
CGLGraphicsConfigInfo *cglInfo = cglsdo->configInfo;
136
OGLContext *oglc = cglInfo->context;
137
CGLCtxInfo *ctxinfo = (CGLCtxInfo *)oglc->ctxInfo;
138
[ctxinfo->context clearDrawable];
139
}
140
141
oglsdo->drawableType = OGLSD_UNDEFINED;
142
143
JNF_COCOA_EXIT(env);
144
}
145
146
/**
147
* Makes the given GraphicsConfig's context current to its associated
148
* "scratch" surface. If there is a problem making the context current,
149
* this method will return NULL; otherwise, returns a pointer to the
150
* OGLContext that is associated with the given GraphicsConfig.
151
*/
152
OGLContext *
153
OGLSD_SetScratchSurface(JNIEnv *env, jlong pConfigInfo)
154
{
155
J2dTraceLn(J2D_TRACE_INFO, "OGLSD_SetScratchContext");
156
157
CGLGraphicsConfigInfo *cglInfo = (CGLGraphicsConfigInfo *)jlong_to_ptr(pConfigInfo);
158
if (cglInfo == NULL) {
159
J2dRlsTraceLn(J2D_TRACE_ERROR, "OGLSD_SetScratchContext: cgl config info is null");
160
return NULL;
161
}
162
163
OGLContext *oglc = cglInfo->context;
164
if (oglc == NULL) {
165
J2dRlsTraceLn(J2D_TRACE_ERROR, "OGLSD_SetScratchContext: ogl context is null");
166
return NULL;
167
}
168
169
CGLCtxInfo *ctxinfo = (CGLCtxInfo *)oglc->ctxInfo;
170
171
JNF_COCOA_ENTER(env);
172
173
// avoid changing the context's target view whenever possible, since
174
// calling setView causes flickering; as long as our context is current
175
// to some view, it's not necessary to switch to the scratch surface
176
if ([ctxinfo->context view] == nil) {
177
// it seems to be necessary to explicitly flush between context changes
178
OGLContext *currentContext = OGLRenderQueue_GetCurrentContext();
179
if (currentContext != NULL) {
180
j2d_glFlush();
181
}
182
183
if (!CGLSD_MakeCurrentToScratch(env, oglc)) {
184
return NULL;
185
}
186
// make sure our context is current
187
} else if ([NSOpenGLContext currentContext] != ctxinfo->context) {
188
[ctxinfo->context makeCurrentContext];
189
}
190
191
if (OGLC_IS_CAP_PRESENT(oglc, CAPS_EXT_FBOBJECT)) {
192
// the GL_EXT_framebuffer_object extension is present, so this call
193
// will ensure that we are bound to the scratch surface (and not
194
// some other framebuffer object)
195
j2d_glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
196
}
197
198
JNF_COCOA_EXIT(env);
199
200
return oglc;
201
}
202
203
/**
204
* Makes a context current to the given source and destination
205
* surfaces. If there is a problem making the context current, this method
206
* will return NULL; otherwise, returns a pointer to the OGLContext that is
207
* associated with the destination surface.
208
*/
209
OGLContext *
210
OGLSD_MakeOGLContextCurrent(JNIEnv *env, OGLSDOps *srcOps, OGLSDOps *dstOps)
211
{
212
J2dTraceLn(J2D_TRACE_INFO, "OGLSD_MakeOGLContextCurrent");
213
214
CGLSDOps *dstCGLOps = (CGLSDOps *)dstOps->privOps;
215
216
J2dTraceLn4(J2D_TRACE_VERBOSE, " src: %d %p dst: %d %p", srcOps->drawableType, srcOps, dstOps->drawableType, dstOps);
217
218
OGLContext *oglc = dstCGLOps->configInfo->context;
219
if (oglc == NULL) {
220
J2dRlsTraceLn(J2D_TRACE_ERROR, "OGLSD_MakeOGLContextCurrent: context is null");
221
return NULL;
222
}
223
224
CGLCtxInfo *ctxinfo = (CGLCtxInfo *)oglc->ctxInfo;
225
226
// it seems to be necessary to explicitly flush between context changes
227
OGLContext *currentContext = OGLRenderQueue_GetCurrentContext();
228
if (currentContext != NULL) {
229
j2d_glFlush();
230
}
231
232
if (dstOps->drawableType == OGLSD_FBOBJECT) {
233
// first make sure we have a current context (if the context isn't
234
// already current to some drawable, we will make it current to
235
// its scratch surface)
236
if (oglc != currentContext) {
237
if (!CGLSD_MakeCurrentToScratch(env, oglc)) {
238
return NULL;
239
}
240
}
241
242
// now bind to the fbobject associated with the destination surface;
243
// this means that all rendering will go into the fbobject destination
244
// (note that we unbind the currently bound texture first; this is
245
// recommended procedure when binding an fbobject)
246
j2d_glBindTexture(GL_TEXTURE_2D, 0);
247
j2d_glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, dstOps->fbobjectID);
248
249
return oglc;
250
}
251
252
JNF_COCOA_ENTER(env);
253
254
// set the current surface
255
if (dstOps->drawableType == OGLSD_PBUFFER) {
256
// REMIND: pbuffers are not fully tested yet...
257
[ctxinfo->context clearDrawable];
258
[ctxinfo->context makeCurrentContext];
259
[ctxinfo->context setPixelBuffer: dstCGLOps->pbuffer
260
cubeMapFace: 0
261
mipMapLevel: 0
262
currentVirtualScreen: [ctxinfo->context currentVirtualScreen]];
263
} else {
264
CGLSDOps *cglsdo = (CGLSDOps *)dstOps->privOps;
265
NSView *nsView = (NSView *)cglsdo->peerData;
266
267
if ([ctxinfo->context view] != nsView) {
268
[ctxinfo->context makeCurrentContext];
269
[ctxinfo->context setView: nsView];
270
}
271
}
272
273
if (OGLC_IS_CAP_PRESENT(oglc, CAPS_EXT_FBOBJECT)) {
274
// the GL_EXT_framebuffer_object extension is present, so we
275
// must bind to the default (windowing system provided)
276
// framebuffer
277
j2d_glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
278
}
279
280
if ((srcOps != dstOps) && (srcOps->drawableType == OGLSD_PBUFFER)) {
281
// bind pbuffer to the render texture object (since we are preparing
282
// to copy from the pbuffer)
283
CGLSDOps *srcCGLOps = (CGLSDOps *)srcOps->privOps;
284
j2d_glBindTexture(GL_TEXTURE_2D, srcOps->textureID);
285
[ctxinfo->context
286
setTextureImageToPixelBuffer: srcCGLOps->pbuffer
287
colorBuffer: GL_FRONT];
288
}
289
290
JNF_COCOA_EXIT(env);
291
292
return oglc;
293
}
294
295
/**
296
* This function initializes a native window surface and caches the window
297
* bounds in the given OGLSDOps. Returns JNI_TRUE if the operation was
298
* successful; JNI_FALSE otherwise.
299
*/
300
jboolean
301
OGLSD_InitOGLWindow(JNIEnv *env, OGLSDOps *oglsdo)
302
{
303
J2dTraceLn(J2D_TRACE_INFO, "OGLSD_InitOGLWindow");
304
305
if (oglsdo == NULL) {
306
J2dRlsTraceLn(J2D_TRACE_ERROR, "OGLSD_InitOGLWindow: ops are null");
307
return JNI_FALSE;
308
}
309
310
CGLSDOps *cglsdo = (CGLSDOps *)oglsdo->privOps;
311
if (cglsdo == NULL) {
312
J2dRlsTraceLn(J2D_TRACE_ERROR, "OGLSD_InitOGLWindow: cgl ops are null");
313
return JNI_FALSE;
314
}
315
316
AWTView *v = cglsdo->peerData;
317
if (v == NULL) {
318
J2dRlsTraceLn(J2D_TRACE_ERROR, "OGLSD_InitOGLWindow: view is invalid");
319
return JNI_FALSE;
320
}
321
322
JNF_COCOA_ENTER(env);
323
NSRect surfaceBounds = [v bounds];
324
oglsdo->drawableType = OGLSD_WINDOW;
325
oglsdo->isOpaque = JNI_TRUE;
326
oglsdo->width = surfaceBounds.size.width;
327
oglsdo->height = surfaceBounds.size.height;
328
JNF_COCOA_EXIT(env);
329
330
J2dTraceLn2(J2D_TRACE_VERBOSE, " created window: w=%d h=%d", oglsdo->width, oglsdo->height);
331
332
return JNI_TRUE;
333
}
334
335
void
336
OGLSD_SwapBuffers(JNIEnv *env, jlong pPeerData)
337
{
338
J2dTraceLn(J2D_TRACE_INFO, "OGLSD_SwapBuffers");
339
340
JNF_COCOA_ENTER(env);
341
[[NSOpenGLContext currentContext] flushBuffer];
342
JNF_COCOA_EXIT(env);
343
}
344
345
void
346
OGLSD_Flush(JNIEnv *env)
347
{
348
OGLSDOps *dstOps = OGLRenderQueue_GetCurrentDestination();
349
if (dstOps != NULL) {
350
CGLSDOps *dstCGLOps = (CGLSDOps *)dstOps->privOps;
351
CGLLayer *layer = (CGLLayer*)dstCGLOps->layer;
352
if (layer != NULL) {
353
[JNFRunLoop performOnMainThreadWaiting:NO withBlock:^(){
354
AWT_ASSERT_APPKIT_THREAD;
355
[layer setNeedsDisplay];
356
357
#ifdef REMOTELAYER
358
/* If there's a remote layer (being used for testing)
359
* then we want to have that also receive the texture.
360
* First sync. up its dimensions with that of the layer
361
* we have attached to the local window and tell it that
362
* it also needs to copy the texture.
363
*/
364
if (layer.remoteLayer != nil) {
365
CGLLayer* remoteLayer = layer.remoteLayer;
366
remoteLayer.target = GL_TEXTURE_2D;
367
remoteLayer.textureID = layer.textureID;
368
remoteLayer.textureWidth = layer.textureWidth;
369
remoteLayer.textureHeight = layer.textureHeight;
370
[remoteLayer setNeedsDisplay];
371
}
372
#endif /* REMOTELAYER */
373
}];
374
}
375
}
376
}
377
378
#pragma mark -
379
#pragma mark "--- CGLSurfaceData methods ---"
380
381
extern LockFunc OGLSD_Lock;
382
extern GetRasInfoFunc OGLSD_GetRasInfo;
383
extern UnlockFunc OGLSD_Unlock;
384
extern DisposeFunc OGLSD_Dispose;
385
386
JNIEXPORT void JNICALL
387
Java_sun_java2d_opengl_CGLSurfaceData_initOps
388
(JNIEnv *env, jobject cglsd, jobject gc,
389
jlong pConfigInfo, jlong pPeerData, jlong layerPtr,
390
jint xoff, jint yoff, jboolean isOpaque)
391
{
392
J2dTraceLn(J2D_TRACE_INFO, "CGLSurfaceData_initOps");
393
J2dTraceLn1(J2D_TRACE_INFO, " pPeerData=%p", jlong_to_ptr(pPeerData));
394
J2dTraceLn2(J2D_TRACE_INFO, " xoff=%d, yoff=%d", (int)xoff, (int)yoff);
395
396
gc = (*env)->NewGlobalRef(env, gc);
397
if (gc == NULL) {
398
JNU_ThrowOutOfMemoryError(env, "Initialization of SurfaceData failed.");
399
return;
400
}
401
402
OGLSDOps *oglsdo = (OGLSDOps *)
403
SurfaceData_InitOps(env, cglsd, sizeof(OGLSDOps));
404
if (oglsdo == NULL) {
405
(*env)->DeleteGlobalRef(env, gc);
406
JNU_ThrowOutOfMemoryError(env, "Initialization of SurfaceData failed.");
407
return;
408
}
409
// later the graphicsConfig will be used for deallocation of oglsdo
410
oglsdo->graphicsConfig = gc;
411
412
CGLSDOps *cglsdo = (CGLSDOps *)malloc(sizeof(CGLSDOps));
413
if (cglsdo == NULL) {
414
JNU_ThrowOutOfMemoryError(env, "creating native cgl ops");
415
return;
416
}
417
418
oglsdo->privOps = cglsdo;
419
420
oglsdo->sdOps.Lock = OGLSD_Lock;
421
oglsdo->sdOps.GetRasInfo = OGLSD_GetRasInfo;
422
oglsdo->sdOps.Unlock = OGLSD_Unlock;
423
oglsdo->sdOps.Dispose = OGLSD_Dispose;
424
425
oglsdo->drawableType = OGLSD_UNDEFINED;
426
oglsdo->activeBuffer = GL_FRONT;
427
oglsdo->needsInit = JNI_TRUE;
428
oglsdo->xOffset = xoff;
429
oglsdo->yOffset = yoff;
430
oglsdo->isOpaque = isOpaque;
431
432
cglsdo->peerData = (AWTView *)jlong_to_ptr(pPeerData);
433
cglsdo->layer = (CGLLayer *)jlong_to_ptr(layerPtr);
434
cglsdo->configInfo = (CGLGraphicsConfigInfo *)jlong_to_ptr(pConfigInfo);
435
436
if (cglsdo->configInfo == NULL) {
437
free(cglsdo);
438
JNU_ThrowNullPointerException(env, "Config info is null in initOps");
439
}
440
}
441
442
JNIEXPORT void JNICALL
443
Java_sun_java2d_opengl_CGLSurfaceData_clearWindow
444
(JNIEnv *env, jobject cglsd)
445
{
446
J2dTraceLn(J2D_TRACE_INFO, "CGLSurfaceData_clearWindow");
447
448
OGLSDOps *oglsdo = (OGLSDOps*) SurfaceData_GetOps(env, cglsd);
449
CGLSDOps *cglsdo = (CGLSDOps*) oglsdo->privOps;
450
451
cglsdo->peerData = NULL;
452
cglsdo->layer = NULL;
453
}
454
455
JNIEXPORT jboolean JNICALL
456
Java_sun_java2d_opengl_CGLSurfaceData_initPbuffer
457
(JNIEnv *env, jobject cglsd,
458
jlong pData, jlong pConfigInfo, jboolean isOpaque,
459
jint width, jint height)
460
{
461
J2dTraceLn3(J2D_TRACE_INFO, "CGLSurfaceData_initPbuffer: w=%d h=%d opq=%d", width, height, isOpaque);
462
463
OGLSDOps *oglsdo = (OGLSDOps *)jlong_to_ptr(pData);
464
if (oglsdo == NULL) {
465
J2dRlsTraceLn(J2D_TRACE_ERROR, "CGLSurfaceData_initPbuffer: ops are null");
466
return JNI_FALSE;
467
}
468
469
CGLSDOps *cglsdo = (CGLSDOps *)oglsdo->privOps;
470
if (cglsdo == NULL) {
471
J2dRlsTraceLn(J2D_TRACE_ERROR, "CGLSurfaceData_initPbuffer: cgl ops are null");
472
return JNI_FALSE;
473
}
474
475
CGLGraphicsConfigInfo *cglInfo = (CGLGraphicsConfigInfo *)
476
jlong_to_ptr(pConfigInfo);
477
if (cglInfo == NULL) {
478
J2dRlsTraceLn(J2D_TRACE_ERROR, "CGLSurfaceData_initPbuffer: cgl config info is null");
479
return JNI_FALSE;
480
}
481
482
// find the maximum allowable texture dimensions (this value ultimately
483
// determines our maximum pbuffer size)
484
int pbMax = 0;
485
j2d_glGetIntegerv(GL_MAX_TEXTURE_SIZE, &pbMax);
486
487
int pbWidth = 0;
488
int pbHeight = 0;
489
if (OGLC_IS_CAP_PRESENT(cglInfo->context, CAPS_TEXNONPOW2)) {
490
// use non-power-of-two dimensions directly
491
pbWidth = (width <= pbMax) ? width : 0;
492
pbHeight = (height <= pbMax) ? height : 0;
493
} else {
494
// find the appropriate power-of-two dimensions
495
pbWidth = OGLSD_NextPowerOfTwo(width, pbMax);
496
pbHeight = OGLSD_NextPowerOfTwo(height, pbMax);
497
}
498
499
J2dTraceLn3(J2D_TRACE_VERBOSE, " desired pbuffer dimensions: w=%d h=%d max=%d", pbWidth, pbHeight, pbMax);
500
501
// if either dimension is 0, we cannot allocate a pbuffer/texture with the
502
// requested dimensions
503
if (pbWidth == 0 || pbHeight == 0) {
504
J2dRlsTraceLn(J2D_TRACE_ERROR, "CGLSurfaceData_initPbuffer: dimensions too large");
505
return JNI_FALSE;
506
}
507
508
int format = isOpaque ? GL_RGB : GL_RGBA;
509
510
JNF_COCOA_ENTER(env);
511
512
cglsdo->pbuffer =
513
[[NSOpenGLPixelBuffer alloc]
514
initWithTextureTarget: GL_TEXTURE_2D
515
textureInternalFormat: format
516
textureMaxMipMapLevel: 0
517
pixelsWide: pbWidth
518
pixelsHigh: pbHeight];
519
if (cglsdo->pbuffer == nil) {
520
J2dRlsTraceLn(J2D_TRACE_ERROR, "CGLSurfaceData_initPbuffer: could not create pbuffer");
521
return JNI_FALSE;
522
}
523
524
// make sure the actual dimensions match those that we requested
525
GLsizei actualWidth = [cglsdo->pbuffer pixelsWide];
526
GLsizei actualHeight = [cglsdo->pbuffer pixelsHigh];
527
if (actualWidth != pbWidth || actualHeight != pbHeight) {
528
J2dRlsTraceLn2(J2D_TRACE_ERROR, "CGLSurfaceData_initPbuffer: actual (w=%d h=%d) != requested", actualWidth, actualHeight);
529
[cglsdo->pbuffer release];
530
return JNI_FALSE;
531
}
532
533
GLuint texID = 0;
534
j2d_glGenTextures(1, &texID);
535
j2d_glBindTexture(GL_TEXTURE_2D, texID);
536
537
oglsdo->drawableType = OGLSD_PBUFFER;
538
oglsdo->isOpaque = isOpaque;
539
oglsdo->width = width;
540
oglsdo->height = height;
541
oglsdo->textureID = texID;
542
oglsdo->textureWidth = pbWidth;
543
oglsdo->textureHeight = pbHeight;
544
oglsdo->activeBuffer = GL_FRONT;
545
oglsdo->needsInit = JNI_TRUE;
546
547
OGLSD_INIT_TEXTURE_FILTER(oglsdo, GL_NEAREST);
548
549
JNF_COCOA_EXIT(env);
550
551
return JNI_TRUE;
552
}
553
554
#pragma mark -
555
#pragma mark "--- CGLSurfaceData methods - Mac OS X specific ---"
556
557
// Must be called on the QFT...
558
JNIEXPORT void JNICALL
559
Java_sun_java2d_opengl_CGLSurfaceData_validate
560
(JNIEnv *env, jobject jsurfacedata,
561
jint xoff, jint yoff, jint width, jint height, jboolean isOpaque)
562
{
563
J2dTraceLn2(J2D_TRACE_INFO, "CGLSurfaceData_validate: w=%d h=%d", width, height);
564
565
OGLSDOps *oglsdo = (OGLSDOps*)SurfaceData_GetOps(env, jsurfacedata);
566
oglsdo->needsInit = JNI_TRUE;
567
oglsdo->xOffset = xoff;
568
oglsdo->yOffset = yoff;
569
570
oglsdo->width = width;
571
oglsdo->height = height;
572
oglsdo->isOpaque = isOpaque;
573
574
if (oglsdo->drawableType == OGLSD_WINDOW) {
575
OGLContext_SetSurfaces(env, ptr_to_jlong(oglsdo), ptr_to_jlong(oglsdo));
576
577
// we have to explicitly tell the NSOpenGLContext that its target
578
// drawable has changed size
579
CGLSDOps *cglsdo = (CGLSDOps *)oglsdo->privOps;
580
OGLContext *oglc = cglsdo->configInfo->context;
581
CGLCtxInfo *ctxinfo = (CGLCtxInfo *)oglc->ctxInfo;
582
583
JNF_COCOA_ENTER(env);
584
[ctxinfo->context update];
585
JNF_COCOA_EXIT(env);
586
}
587
}
588
589