changeset 4923:ec8c141b4c28

7131793: [macosx] some cleanup in OGL pipeline code Reviewed-by: swingler, art
author dcherepanov
date Wed, 01 Feb 2012 14:31:15 +0300
parents 5b524b43fdd1
children a7595ca81597
files make/sun/lwawt/Makefile src/macosx/native/sun/awt/AWTView.m src/macosx/native/sun/java2d/opengl/CGLGraphicsConfig.h src/macosx/native/sun/java2d/opengl/CGLLayer.h src/macosx/native/sun/java2d/opengl/CGLLayer.m src/macosx/native/sun/java2d/opengl/CGLSurfaceData.h src/macosx/native/sun/java2d/opengl/CGLSurfaceData.m src/share/native/sun/java2d/opengl/OGLSurfaceData.c src/share/native/sun/java2d/opengl/OGLSurfaceData.h
diffstat 9 files changed, 58 insertions(+), 380 deletions(-) [+]
line wrap: on
line diff
--- a/make/sun/lwawt/Makefile	Wed Feb 01 01:41:21 2012 -0800
+++ b/make/sun/lwawt/Makefile	Wed Feb 01 14:31:15 2012 +0300
@@ -82,7 +82,6 @@
 	-framework JavaNativeFoundation \
 	-framework JavaRuntimeSupport \
 	-framework OpenGL \
-	-framework IOSurface \
         -framework QuartzCore
 CPPFLAGS += \
         -I$(CLASSHDRDIR) \
--- a/src/macosx/native/sun/awt/AWTView.m	Wed Feb 01 01:41:21 2012 -0800
+++ b/src/macosx/native/sun/awt/AWTView.m	Wed Feb 01 14:31:15 2012 +0300
@@ -87,37 +87,30 @@
         [self.layer addSublayer: (CALayer *)cglLayer];
         [self setLayerContentsRedrawPolicy: NSViewLayerContentsRedrawDuringViewResize];
         [self setLayerContentsPlacement: NSViewLayerContentsPlacementTopLeft];
-        [self setAutoresizingMask: NSViewHeightSizable | NSViewWidthSizable];    
+        [self setAutoresizingMask: NSViewHeightSizable | NSViewWidthSizable];
+        
+#ifdef REMOTELAYER
+        CGLLayer *parentLayer = (CGLLayer*)self.cglLayer;
+        parentLayer.parentLayer = NULL;
+        parentLayer.remoteLayer = NULL;
+        if (JRSRemotePort != 0 && remoteSocketFD > 0) {
+            CGLLayer *remoteLayer = [[CGLLayer alloc] initWithJavaLayer: parentLayer.javaLayer];
+            remoteLayer.target = GL_TEXTURE_2D;
+            NSLog(@"Creating Parent=%p, Remote=%p", parentLayer, remoteLayer);
+            parentLayer.remoteLayer = remoteLayer;
+            remoteLayer.parentLayer = parentLayer;
+            remoteLayer.remoteLayer = NULL;
+            remoteLayer.jrsRemoteLayer = [remoteLayer createRemoteLayerBoundTo:JRSRemotePort];
+            CFRetain(remoteLayer);  // REMIND
+            remoteLayer.frame = CGRectMake(0, 0, 720, 500); // REMIND
+            CFRetain(remoteLayer.jrsRemoteLayer); // REMIND
+            int layerID = [remoteLayer.jrsRemoteLayer layerID];
+            NSLog(@"layer id to send = %d", layerID);
+            sendLayerID(layerID);
+        }
+#endif /* REMOTELAYER */        
     }
-    
-#if USE_INTERMEDIATE_BUFFER
-    self.cglLayer = windowLayer;
-    [self setWantsLayer: YES];
-    [self.layer addSublayer: (CALayer *)cglLayer];
-    [self setLayerContentsRedrawPolicy: NSViewLayerContentsRedrawDuringViewResize];
-    [self setLayerContentsPlacement: NSViewLayerContentsPlacementTopLeft];
-    [self setAutoresizingMask: NSViewHeightSizable | NSViewWidthSizable];
-#ifdef REMOTELAYER
-    CGLLayer *parentLayer = (CGLLayer*)self.cglLayer;
-    parentLayer.parentLayer = NULL;
-    parentLayer.remoteLayer = NULL;
-    if (JRSRemotePort != 0 && remoteSocketFD > 0) {
-        CGLLayer *remoteLayer = [CGLLayer layer];
-        remoteLayer.target = GL_TEXTURE_2D;
-        NSLog(@"Creating Parent=%p, Remote=%p", parentLayer, remoteLayer);
-        parentLayer.remoteLayer = remoteLayer;
-        remoteLayer.parentLayer = parentLayer;
-        remoteLayer.remoteLayer = NULL;
-        remoteLayer.jrsRemoteLayer = [remoteLayer createRemoteLayerBoundTo:JRSRemotePort];
-        CFRetain(remoteLayer);  // REMIND
-        remoteLayer.frame = CGRectMake(0, 0, 720, 500); // REMIND
-        CFRetain(remoteLayer.jrsRemoteLayer); // REMIND
-        int layerID = [remoteLayer.jrsRemoteLayer layerID];
-        NSLog(@"layer id to send = %d", layerID);
-        sendLayerID(layerID);
-    }
-#endif /* REMOTELAYER */
-#endif
+
     return self;
 }
 
@@ -125,9 +118,6 @@
 AWT_ASSERT_APPKIT_THREAD;
 
     self.cglLayer = nil;
-#if USE_INTERMEDIATE_BUFFER
-    self.cglLayer = nil;
-#endif
 
     JNIEnv *env = [ThreadUtilities getJNIEnv];
     (*env)->DeleteGlobalRef(env, m_cPlatformView);
--- a/src/macosx/native/sun/java2d/opengl/CGLGraphicsConfig.h	Wed Feb 01 01:41:21 2012 -0800
+++ b/src/macosx/native/sun/java2d/opengl/CGLGraphicsConfig.h	Wed Feb 01 14:31:15 2012 +0300
@@ -36,23 +36,6 @@
 + (void) _getCGLConfigInfo: (NSMutableArray *)argValue;
 @end
 
-// Prototyped CAOpenGLLayer drawing directly from Java2D OpenGL rendering
-// pipe fails to draw entire scene. So, the following enables alternative
-// codepath that uses a FBO backed with a texture as an intermediate buffer.
-// Java2D OpenGL rendering pipe performs rendering to the intermediate buffer
-// and CAOpenGLLayer copies the entire intermediate buffer to layer.
-
-// The prototype implementation creates a CAOpenGLLayer tied to a NSView/NSWindow.
-// To provide purely offscreen CAOpenGLLayer, disable the prototype and
-// enable the alternative codepath implemented as a part of MACOSX_PORT-766.
-//#define USE_INTERMEDIATE_BUFFER 1
-
-// Uncomment the next line to enable using IO Surface based drawing.
-// It has to be used *in conjunction* with USE_INTERMEDIATE_BUFFERS
-// It presently has more artifacts than the straight 2D texture drawing
-// but both seem to have some of the same issues.
-//#define USE_IOS 1
-
 // REMIND: Using an NSOpenGLPixelBuffer as the scratch surface has been
 // problematic thus far (seeing garbage and flickering when switching
 // between an NSView and the scratch surface), so the following enables
@@ -61,8 +44,8 @@
 // situations.  It appears that calling [NSOpenGLContext setView] too
 // frequently contributes to the bad behavior, so we should try to avoid
 // switching to the scratch surface whenever possible.
-#ifndef USE_IOS
-/* Do we we need this if we are using all off-screen drawing ? */
+
+/* Do we need this if we are using all off-screen drawing ? */
 #define USE_NSVIEW_FOR_SCRATCH 1
 
 /* Uncomment to have an additional CAOGLLayer instance tied to
@@ -72,9 +55,7 @@
  * This is only for testing purposes and can be removed if/when no
  * longer needed.
  */
-//#ifdef USE_INTERMEDIATE_BUFFER
 //#define REMOTELAYER 1
-//#endif
 
 #ifdef REMOTELAYER
 #import <JavaRuntimeSupport/JRSRemoteLayer.h>
@@ -90,9 +71,6 @@
 
 #endif /* REMOTELAYER */
 
-#endif
-
-
 
 /**
  * The CGLGraphicsConfigInfo structure contains information specific to a
--- a/src/macosx/native/sun/java2d/opengl/CGLLayer.h	Wed Feb 01 01:41:21 2012 -0800
+++ b/src/macosx/native/sun/java2d/opengl/CGLLayer.h	Wed Feb 01 14:31:15 2012 +0300
@@ -31,7 +31,7 @@
 @interface CGLLayer : CAOpenGLLayer
 {
 @private
-    jobject javaLayer;
+    JNFJObjectWrapper *javaLayer;
 
     // intermediate buffer, used the RQ lock to synchronize
     GLuint textureID;
@@ -45,6 +45,7 @@
 #endif /* REMOTELAYER */
 }
 
+@property (nonatomic, retain) JNFJObjectWrapper *javaLayer;
 @property (readwrite, assign) GLuint textureID;
 @property (readwrite, assign) GLenum target;
 @property (readwrite, assign) float textureWidth;
@@ -56,7 +57,7 @@
 @property (nonatomic, retain) NSObject<JRSRemoteLayer> *jrsRemoteLayer;
 #endif
 
-- (id) initWithJavaLayer:(jobject)javaLayer;
+- (id) initWithJavaLayer:(JNFJObjectWrapper *)javaLayer;
 - (void) blitTexture;
 @end
 
--- a/src/macosx/native/sun/java2d/opengl/CGLLayer.m	Wed Feb 01 01:41:21 2012 -0800
+++ b/src/macosx/native/sun/java2d/opengl/CGLLayer.m	Wed Feb 01 14:31:15 2012 +0300
@@ -35,6 +35,7 @@
 
 @implementation CGLLayer
 
+@synthesize javaLayer;
 @synthesize textureID;
 @synthesize target;
 @synthesize textureWidth;
@@ -45,14 +46,14 @@
 @synthesize jrsRemoteLayer;
 #endif
 
-- (id) initWithJavaLayer:(jobject)layer;
+- (id) initWithJavaLayer:(JNFJObjectWrapper *)layer;
 {
 AWT_ASSERT_APPKIT_THREAD;
     // Initialize ourselves
     self = [super init];
     if (self == nil) return self;
 
-    javaLayer = layer;
+    self.javaLayer = layer;
     
     // NOTE: async=YES means that the layer is re-cached periodically
     self.asynchronous = FALSE;
@@ -65,11 +66,8 @@
     return self;
 }
 
-- (void) dealloc {
-    JNIEnv *env = [ThreadUtilities getJNIEnv];
-    (*env)->DeleteGlobalRef(env, javaLayer);
-    javaLayer = NULL;
-    
+- (void) dealloc {    
+    self.javaLayer = nil;
     [super dealloc];
 }
 
@@ -114,7 +112,7 @@
 -(void)drawInCGLContext:(CGLContextObj)glContext pixelFormat:(CGLPixelFormatObj)pixelFormat forLayerTime:(CFTimeInterval)timeInterval displayTime:(const CVTimeStamp *)timeStamp
 {
     AWT_ASSERT_APPKIT_THREAD;
-
+    
     // Set the current context to the one given to us.
     CGLSetCurrentContext(glContext);
 
@@ -123,7 +121,10 @@
     JNIEnv *env = [ThreadUtilities getJNIEnv];
     static JNF_CLASS_CACHE(jc_JavaLayer, "sun/java2d/opengl/CGLLayer");
     static JNF_MEMBER_CACHE(jm_drawInCGLContext, jc_JavaLayer, "drawInCGLContext", "()V");
-    JNFCallVoidMethod(env, javaLayer, jm_drawInCGLContext);
+
+    jobject javaLayerLocalRef = [self.javaLayer jObjectWithEnv:env];
+    JNFCallVoidMethod(env, javaLayerLocalRef, jm_drawInCGLContext);
+    (*env)->DeleteLocalRef(env, javaLayerLocalRef);
 
     // Call super to finalize the drawing. By default all it does is call glFlush().
     [super drawInCGLContext:glContext pixelFormat:pixelFormat forLayerTime:timeInterval displayTime:timeStamp];
@@ -147,7 +148,7 @@
 JNF_COCOA_ENTER(env);
 AWT_ASSERT_NOT_APPKIT_THREAD;
 
-    jobject javaLayer = (*env)->NewGlobalRef(env, obj);
+    JNFJObjectWrapper *javaLayer = [JNFJObjectWrapper wrapperWithJObject:obj withEnv:env];
     
     [JNFRunLoop performOnMainThreadWaiting:YES withBlock:^(){
         AWT_ASSERT_APPKIT_THREAD;
--- a/src/macosx/native/sun/java2d/opengl/CGLSurfaceData.h	Wed Feb 01 01:41:21 2012 -0800
+++ b/src/macosx/native/sun/java2d/opengl/CGLSurfaceData.h	Wed Feb 01 14:31:15 2012 +0300
@@ -26,8 +26,6 @@
 #ifndef CGLSurfaceData_h_Included
 #define CGLSurfaceData_h_Included
 
-#import <IOSurface/IOSurface.h>
-
 #import "OGLSurfaceData.h"
 #import "CGLGraphicsConfig.h"
 #import "AWTWindow.h"
@@ -43,7 +41,6 @@
     GLclampf              argb[4]; // background clear color
     NSOpenGLPixelBuffer   *pbuffer;
     CGLGraphicsConfigInfo *configInfo;
-    IOSurfaceRef          surfaceRef;
 } CGLSDOps;
 
 #endif /* CGLSurfaceData_h_Included */
--- a/src/macosx/native/sun/java2d/opengl/CGLSurfaceData.m	Wed Feb 01 01:41:21 2012 -0800
+++ b/src/macosx/native/sun/java2d/opengl/CGLSurfaceData.m	Wed Feb 01 14:31:15 2012 +0300
@@ -132,27 +132,11 @@
             cglsdo->pbuffer = NULL;
         }
     } else if (oglsdo->drawableType == OGLSD_WINDOW) {
-#if USE_INTERMEDIATE_BUFFER
-        // REMIND: duplicates code in OGLSD_Delete invoked from the Dispose thread
-        if (oglsdo->textureID != 0) {
-            j2d_glDeleteTextures(1, &oglsdo->textureID);
-            oglsdo->textureID = 0;
-        }
-        if (oglsdo->depthID != 0) {
-            j2d_glDeleteRenderbuffersEXT(1, &oglsdo->depthID);
-            oglsdo->depthID = 0;
-        }
-        if (oglsdo->fbobjectID != 0) {
-            j2d_glDeleteFramebuffersEXT(1, &oglsdo->fbobjectID);
-            oglsdo->fbobjectID = 0;
-        }
-#else
         // detach the NSView from the NSOpenGLContext
         CGLGraphicsConfigInfo *cglInfo = cglsdo->configInfo;
         OGLContext *oglc = cglInfo->context;
         CGLCtxInfo *ctxinfo = (CGLCtxInfo *)oglc->ctxInfo;
         [ctxinfo->context clearDrawable];
-#endif
     }
 
     oglsdo->drawableType = OGLSD_UNDEFINED;
@@ -279,13 +263,7 @@
         // this means that all rendering will go into the fbobject destination
         // (note that we unbind the currently bound texture first; this is
         // recommended procedure when binding an fbobject)
-#ifndef USE_IOS
         j2d_glBindTexture(GL_TEXTURE_2D, 0);
-#else
-        GLenum target = GL_TEXTURE_RECTANGLE_ARB;
-        j2d_glBindTexture(target, 0);
-        j2d_glDisable(target);
-#endif
         j2d_glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, dstOps->fbobjectID);
 
         return oglc;
@@ -303,16 +281,6 @@
                 mipMapLevel: 0
                 currentVirtualScreen: [ctxinfo->context currentVirtualScreen]];
     } else {
-#if USE_INTERMEDIATE_BUFFER
-#ifndef USE_IOS
-        j2d_glBindTexture(GL_TEXTURE_2D, 0);
-#else
-    GLenum target = GL_TEXTURE_RECTANGLE_ARB;
-    j2d_glBindTexture(target, 0);
-    j2d_glDisable(target);
-#endif
-        j2d_glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, dstOps->fbobjectID);
-#else
         CGLSDOps *cglsdo = (CGLSDOps *)dstOps->privOps;
         NSView *nsView = (NSView *)cglsdo->peerData;
 
@@ -320,17 +288,14 @@
             [ctxinfo->context makeCurrentContext];
             [ctxinfo->context setView: nsView];
         }
-#endif
     }
 
-#ifndef USE_INTERMEDIATE_BUFFER
     if (OGLC_IS_CAP_PRESENT(oglc, CAPS_EXT_FBOBJECT)) {
         // the GL_EXT_framebuffer_object extension is present, so we
         // must bind to the default (windowing system provided)
         // framebuffer
         j2d_glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
     }
-#endif
 
     if ((srcOps != dstOps) && (srcOps->drawableType == OGLSD_PBUFFER)) {
         // bind pbuffer to the render texture object (since we are preparing
@@ -348,202 +313,6 @@
 }
 
 /**
- * Returns true if OpenGL textures can have non-power-of-two dimensions
- * when using the basic GL_TEXTURE_2D target.
- */
-BOOL isTexNonPow2Available(CGLGraphicsConfigInfo *cglinfo) {
-    jint caps;
-    if ((cglinfo == NULL) || (cglinfo->context == NULL)) {
-        return FALSE;
-    } else {
-        caps = cglinfo->context->caps;
-    }
-    return ((caps & CAPS_TEXNONPOW2) != 0);
-}
-
-/**
- * Returns true if OpenGL textures can have non-power-of-two dimensions
- * when using the GL_TEXTURE_RECTANGLE_ARB target (only available when the
- * GL_ARB_texture_rectangle extension is present).
- */
-BOOL isTexRectAvailable(CGLGraphicsConfigInfo *cglinfo) {
-    jint caps;
-    if ((cglinfo == NULL) || (cglinfo->context == NULL)) {
-        return FALSE;
-    } else {
-        caps = cglinfo->context->caps;
-    }
-    return ((caps & CAPS_EXT_TEXRECT) != 0);
-}
-
-/**
- * Recreates the intermediate buffer associated with the given OGLSDOps
- * and with the buffer's new size specified in OGLSDOps.
- */
-jboolean RecreateBuffer(JNIEnv *env, OGLSDOps *oglsdo)
-{
-    // destroy previous buffer first
-    OGLSD_DestroyOGLSurface(env, oglsdo);
-
-    CGLSDOps *cglsdo = (CGLSDOps *)oglsdo->privOps;
-    jboolean result =
-        OGLSurfaceData_initFBObject(env, NULL, ptr_to_jlong(oglsdo), oglsdo->isOpaque,
-                                    isTexNonPow2Available(cglsdo->configInfo),
-                                    isTexRectAvailable(cglsdo->configInfo),
-                                    oglsdo->width, oglsdo->height);
-
-    // NOTE: OGLSD_WINDOW type is reused for offscreen rendering
-    //       when intermediate buffer is enabled
-    oglsdo->drawableType = OGLSD_WINDOW;
-
-    AWTView *view = cglsdo->peerData;
-    CGLLayer *layer = (CGLLayer *)view.cglLayer;
-    layer.textureID = oglsdo->textureID;
-    layer.target = GL_TEXTURE_2D;
-    layer.textureWidth = oglsdo->width;
-    layer.textureHeight = oglsdo->height;
-
-    return result;
-}
-
-
-static inline IOSurfaceRef createIoSurface(int width, int height)
-{
-    // Get an error return for 0 size. Maybe should skip creation
-    // for that case, but for now make a 1X1 surface
-    if (width <= 0) width = 1;
-    if (height <= 0) height = 1;
-
-    NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
-    NSMutableDictionary *properties = [NSMutableDictionary dictionaryWithCapacity:4];
-    [properties setObject:[NSNumber numberWithInt:width] forKey:(id)kIOSurfaceWidth];
-    [properties setObject:[NSNumber numberWithInt:height] forKey:(id)kIOSurfaceHeight];
-    [properties setObject:[NSNumber numberWithInt:4] forKey:(id)kIOSurfaceBytesPerElement];
-    IOSurfaceRef surface = IOSurfaceCreate((CFDictionaryRef)properties);
-    CFRetain(surface); // REMIND: do I need to do this ?
-    [pool drain];
-
-    if (surface == NULL) {
-        NSLog(@"IOSurfaceCreate error, surface: %p", surface);
-    } else {
-        //NSLog(@"Plugin iosurface OK");
-        //NSLog(@"    surface: %p", surface);
-        //NSLog(@"    IOSurfaceGetID(self->surface): %d", IOSurfaceGetID(surface));
-    }
-    return surface;
-}
-
-/**
- * Recreates the intermediate buffer associated with the given OGLSDOps
- * and with the buffer's new size specified in OGLSDOps.
- */
-jboolean RecreateIOSBuffer(JNIEnv *env, OGLSDOps *oglsdo)
-{
-    CGLSDOps *cglsdo = (CGLSDOps *)oglsdo->privOps;
-    // destroy previous buffer first
-    if (oglsdo->textureID != 0) {
-        OGLSD_DestroyOGLSurface(env, oglsdo);
-        if (cglsdo->surfaceRef != NULL) {
-            CFRelease(cglsdo->surfaceRef);
-            cglsdo->surfaceRef = NULL;
-        }
-    }
-
-    oglsdo->textureID = 0;
-    cglsdo->surfaceRef = NULL;
-    int width = oglsdo->width;
-    int height = oglsdo->height;
-    if (width <= 0) width = 1;
-    if (height <= 0) height = 1;
-    IOSurfaceRef _surfaceRef = createIoSurface(width, height);
-    if (_surfaceRef == NULL) {
-        return JNI_FALSE;
-    }
-
-    GLenum target = GL_TEXTURE_RECTANGLE_ARB;
-    glEnable(target);
-    GLuint texture;
-    glGenTextures(1, &texture);
-    glBindTexture(target, texture);
-    glTexParameteri(target, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
-    glTexParameteri(target, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
-    glTexParameteri(target, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
-    glTexParameteri(target, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
-
-    OGLContext *oglc = cglsdo->configInfo->context;
-    CGLCtxInfo *ctxinfo = (CGLCtxInfo *)oglc->ctxInfo;
-    CGLContextObj context = ctxinfo->context.CGLContextObj;
-
-    /* These parameters are documented only in the header file
-     * and apart from the requirement that it must be one of
-     * the combinations listed there its not as clear as I'd like
-     * what the choices mean.
-     */
-    GLenum format = GL_BGRA;
-    GLenum internal_format = GL_RGB;
-    GLenum type = GL_UNSIGNED_INT_8_8_8_8_REV;
-
-    CGLError err =
-    CGLTexImageIOSurface2D(context, target, internal_format,
-         width, height, format, type, _surfaceRef, 0);
-
-    if (err != kCGLNoError) {
-        J2dRlsTraceLn(J2D_TRACE_ERROR,
-                      "OGLSurfaceData_RecreateIOSBuffer: could not init texture");
-        j2d_glDeleteTextures(1, &texture);
-        CFRelease(_surfaceRef);
-        return JNI_FALSE;
-    }
-
-    oglsdo->drawableType = OGLSD_FBOBJECT;
-    oglsdo->xOffset = 0;
-    oglsdo->yOffset = 0;
-    oglsdo->width = width;
-    oglsdo->height = height;
-    oglsdo->textureID = texture;
-    oglsdo->textureWidth = width;
-    oglsdo->textureHeight = height;
-    // init_FBO fails if we don't use target GL_TEXTURE_RECTANGLE_ARB for the IOS texture.
-    oglsdo->textureTarget = target;
-    OGLSD_INIT_TEXTURE_FILTER(oglsdo, GL_NEAREST);
-    OGLSD_RESET_TEXTURE_WRAP(target);
-
-    // initialize framebuffer object using color texture created above
-    GLuint fbobjectID, depthID;
-    if (!OGLSD_InitFBObject(&fbobjectID, &depthID,
-                            oglsdo->textureID, oglsdo->textureTarget,
-                            oglsdo->textureWidth, oglsdo->textureHeight))
-    {
-        J2dRlsTraceLn(J2D_TRACE_ERROR,
-                      "OGLSurfaceData_RecreateIOSBuffer: could not init fbobject");
-        j2d_glDeleteTextures(1, &oglsdo->textureID);
-        CFRelease(_surfaceRef);
-        return JNI_FALSE;
-    }
-
-    oglsdo->fbobjectID = fbobjectID;
-    oglsdo->depthID = depthID;
-    // NOTE: OGLSD_WINDOW type is reused for offscreen rendering
-    //       when intermediate buffer is enabled
-    oglsdo->drawableType = OGLSD_WINDOW;
-
-    OGLSD_SetNativeDimensions(env, oglsdo,
-                              oglsdo->textureWidth, oglsdo->textureHeight);
-
-    cglsdo->surfaceRef = _surfaceRef;
-    AWTView *view = cglsdo->peerData;
-    CGLLayer *layer = (CGLLayer *)view.cglLayer;
-    layer.textureID = oglsdo->textureID;
-    layer.target = target;
-    layer.textureWidth = oglsdo->width;
-    layer.textureHeight = oglsdo->height;
-
-    glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
-
-    return JNI_TRUE;
-}
-
-/**
  * This function initializes a native window surface and caches the window
  * bounds in the given OGLSDOps.  Returns JNI_TRUE if the operation was
  * successful; JNI_FALSE otherwise.
@@ -573,27 +342,14 @@
 JNF_COCOA_ENTER(env);
     NSRect surfaceBounds = [v bounds];
     oglsdo->drawableType = OGLSD_WINDOW;
-#ifndef USE_INTERMEDIATE_BUFFER
     oglsdo->isOpaque = JNI_TRUE;
-#endif
-
     oglsdo->width = surfaceBounds.size.width;
     oglsdo->height = surfaceBounds.size.height;
 JNF_COCOA_EXIT(env);
 
-    jboolean result = JNI_TRUE;
-
-#if USE_INTERMEDIATE_BUFFER
-#ifdef USE_IOS
-    result = RecreateIOSBuffer(env, oglsdo);
-#else
-    result = RecreateBuffer(env, oglsdo);
-#endif
-#endif
-
     J2dTraceLn2(J2D_TRACE_VERBOSE, "  created window: w=%d h=%d", oglsdo->width, oglsdo->height);
-
-    return result;
+    
+    return JNI_TRUE;
 }
 
 void
@@ -617,37 +373,26 @@
             [JNFRunLoop performOnMainThreadWaiting:NO withBlock:^(){
                 AWT_ASSERT_APPKIT_THREAD;
                 [layer setNeedsDisplay];
+
+#ifdef REMOTELAYER
+                /* If there's a remote layer (being used for testing)
+                 * then we want to have that also receive the texture.
+                 * First sync. up its dimensions with that of the layer
+                 * we have attached to the local window and tell it that
+                 * it also needs to copy the texture.
+                 */
+                if (layer.remoteLayer != nil) {
+                    CGLLayer* remoteLayer = layer.remoteLayer;
+                    remoteLayer.target = GL_TEXTURE_2D;
+                    remoteLayer.textureID = layer.textureID;
+                    remoteLayer.textureWidth = layer.textureWidth;
+                    remoteLayer.textureHeight = layer.textureHeight;
+                    [remoteLayer setNeedsDisplay];
+                }
+#endif /* REMOTELAYER */                
             }];
         }
     }
-#if USE_INTERMEDIATE_BUFFER
-    OGLSDOps *dstOps = OGLRenderQueue_GetCurrentDestination();
-    if (dstOps != NULL) {
-        [JNFRunLoop performOnMainThreadWaiting:NO withBlock:^(){
-            AWT_ASSERT_APPKIT_THREAD;
-            CGLSDOps *dstCGLOps = (CGLSDOps *)dstOps->privOps;
-            AWTView *view = dstCGLOps->peerData;
-            [view.cglLayer setNeedsDisplay];
-#ifdef REMOTELAYER
-            /* If there's a remote layer (being used for testing)
-             * then we want to have that also receive the texture.
-             * First sync. up its dimensions with that of the layer
-             * we have attached to the local window and tell it that
-             * it also needs to copy the texture.
-             */
-             CGLLayer* cglLayer = (CGLLayer*)view.cglLayer;
-             if (cglLayer.remoteLayer != nil) {
-                 CGLLayer* remoteLayer = cglLayer.remoteLayer;
-                 remoteLayer.target = GL_TEXTURE_2D;
-                 remoteLayer.textureID = cglLayer.textureID;
-                 remoteLayer.textureWidth = cglLayer.textureWidth;
-                 remoteLayer.textureHeight = cglLayer.textureHeight;
-                 [remoteLayer setNeedsDisplay];
-            }
-#endif /* REMOTELAYER */
-        }];
-    }
-#endif
 }
 
 #pragma mark -
@@ -828,26 +573,11 @@
     oglsdo->xOffset = xoff;
     oglsdo->yOffset = yoff;
 
-    BOOL newSize = (oglsdo->width != width || oglsdo->height != height);
-    BOOL newOpaque = (oglsdo->isOpaque != isOpaque);
-
     oglsdo->width = width;
     oglsdo->height = height;
     oglsdo->isOpaque = isOpaque;
 
     if (oglsdo->drawableType == OGLSD_WINDOW) {
-JNF_COCOA_ENTER(env);
-#ifdef USE_INTERMEDIATE_BUFFER
-        if (newSize || newOpaque) {
-#ifdef USE_IOS
-            RecreateIOSBuffer(env, oglsdo);
-#else
-            RecreateBuffer(env, oglsdo);
-#endif
-        }
-#endif
-JNF_COCOA_EXIT(env);
-
         OGLContext_SetSurfaces(env, ptr_to_jlong(oglsdo), ptr_to_jlong(oglsdo));
 
         // we have to explicitly tell the NSOpenGLContext that its target
@@ -857,9 +587,7 @@
         CGLCtxInfo *ctxinfo = (CGLCtxInfo *)oglc->ctxInfo;
 
 JNF_COCOA_ENTER(env);
-#ifndef USE_INTERMEDIATE_BUFFER
         [ctxinfo->context update];
-#endif
 JNF_COCOA_EXIT(env);
     }
 }
--- a/src/share/native/sun/java2d/opengl/OGLSurfaceData.c	Wed Feb 01 01:41:21 2012 -0800
+++ b/src/share/native/sun/java2d/opengl/OGLSurfaceData.c	Wed Feb 01 14:31:15 2012 +0300
@@ -396,16 +396,6 @@
      jboolean texNonPow2, jboolean texRect,
      jint width, jint height)
 {
-    return OGLSurfaceData_initFBObject(env, oglsd, pData, isOpaque,
-                                       texNonPow2, texRect, width, height);
-}
-
-jboolean OGLSurfaceData_initFBObject
-    (JNIEnv *env, jobject oglsd,
-     jlong pData, jboolean isOpaque,
-     jboolean texNonPow2, jboolean texRect,
-     jint width, jint height)
-{
     OGLSDOps *oglsdo = (OGLSDOps *)jlong_to_ptr(pData);
     GLuint fbobjectID, depthID;
 
--- a/src/share/native/sun/java2d/opengl/OGLSurfaceData.h	Wed Feb 01 01:41:21 2012 -0800
+++ b/src/share/native/sun/java2d/opengl/OGLSurfaceData.h	Wed Feb 01 14:31:15 2012 +0300
@@ -291,11 +291,5 @@
 jboolean OGLSD_InitFBObject(GLuint *fbobjectID, GLuint *depthID,
                             GLuint textureID, GLenum textureTarget,
                             jint textureWidth, jint textureHeight);
-// needed by Mac OS X port
-jboolean OGLSurfaceData_initFBObject(JNIEnv *env, jobject oglsd,
-                                     jlong pData, jboolean isOpaque,
-                                     jboolean texNonPow2, jboolean texRect,
-                                     jint width, jint height);
-void OGLSD_SetNativeDimensions(JNIEnv *env, OGLSDOps *oglsdo, jint w, jint h);
 
 #endif /* OGLSurfaceData_h_Included */