summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSilenio Quarti <Silenio_Quarti@ca.ibm.com>2011-09-07 14:18:44 -0400
committerSilenio Quarti <Silenio_Quarti@ca.ibm.com>2011-09-07 14:18:44 -0400
commit4222a621d2928b548c2e30cc0978e442beedb1d5 (patch)
treea1c67627e9c0255f6985e358bfb9c500f3a837c8
parent4f704108b0528d9c77c54499cc20715a8573c665 (diff)
downloadeclipse.platform.swt-4222a621d2928b548c2e30cc0978e442beedb1d5.tar.gz
eclipse.platform.swt-4222a621d2928b548c2e30cc0978e442beedb1d5.tar.xz
eclipse.platform.swt-4222a621d2928b548c2e30cc0978e442beedb1d5.zip
Bug 343331 - [Mac] GLCanvas draws on top of fast views
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT OpenGL/cocoa/org/eclipse/swt/opengl/GLCanvas.java1
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/library/os.c27
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/library/os_stats.c9
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/library/os_stats.h5
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/AppKitFull.bridgesupport.extras7
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/NSOpenGLContext.java6
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/OS.java5
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Canvas.java55
8 files changed, 107 insertions, 8 deletions
diff --git a/bundles/org.eclipse.swt/Eclipse SWT OpenGL/cocoa/org/eclipse/swt/opengl/GLCanvas.java b/bundles/org.eclipse.swt/Eclipse SWT OpenGL/cocoa/org/eclipse/swt/opengl/GLCanvas.java
index 0f731454dd..f30a7df4a1 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT OpenGL/cocoa/org/eclipse/swt/opengl/GLCanvas.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT OpenGL/cocoa/org/eclipse/swt/opengl/GLCanvas.java
@@ -117,6 +117,7 @@ public GLCanvas (Composite parent, int style, GLData data) {
SWT.error (SWT.ERROR_UNSUPPORTED_DEPTH);
}
context = context.initWithFormat(pixelFormat, ctx);
+ context.setValues(new int[]{-1}, OS.NSOpenGLCPSurfaceOrder);
setData(GLCONTEXT_KEY, context);
NSNotificationCenter.defaultCenter().addObserver(view, OS.sel_updateOpenGLContext_, OS.NSViewGlobalFrameDidChangeNotification, view);
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/library/os.c b/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/library/os.c
index c9489cb283..7b91d4e421 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/library/os.c
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/library/os.c
@@ -8756,6 +8756,33 @@ fail:
}
#endif
+#if (!defined(NO_objc_1msgSend__II_3II) && !defined(JNI64)) || (!defined(NO_objc_1msgSend__JJ_3II) && defined(JNI64))
+#ifndef JNI64
+JNIEXPORT jintLong JNICALL OS_NATIVE(objc_1msgSend__II_3II)(JNIEnv *env, jclass that, jintLong arg0, jintLong arg1, jintArray arg2, jint arg3)
+#else
+JNIEXPORT jintLong JNICALL OS_NATIVE(objc_1msgSend__JJ_3II)(JNIEnv *env, jclass that, jintLong arg0, jintLong arg1, jintArray arg2, jint arg3)
+#endif
+{
+ jint *lparg2=NULL;
+ jintLong rc = 0;
+#ifndef JNI64
+ OS_NATIVE_ENTER(env, that, objc_1msgSend__II_3II_FUNC);
+#else
+ OS_NATIVE_ENTER(env, that, objc_1msgSend__JJ_3II_FUNC);
+#endif
+ if (arg2) if ((lparg2 = (*env)->GetIntArrayElements(env, arg2, NULL)) == NULL) goto fail;
+ rc = (jintLong)((jintLong (*)(jintLong, jintLong, jint *, jint))objc_msgSend)(arg0, arg1, lparg2, arg3);
+fail:
+ if (arg2 && lparg2) (*env)->ReleaseIntArrayElements(env, arg2, lparg2, 0);
+#ifndef JNI64
+ OS_NATIVE_EXIT(env, that, objc_1msgSend__II_3II_FUNC);
+#else
+ OS_NATIVE_EXIT(env, that, objc_1msgSend__JJ_3II_FUNC);
+#endif
+ return rc;
+}
+#endif
+
#if (!defined(NO_objc_1msgSend__II_3III) && !defined(JNI64)) || (!defined(NO_objc_1msgSend__JJ_3JII) && defined(JNI64))
#ifndef JNI64
JNIEXPORT jintLong JNICALL OS_NATIVE(objc_1msgSend__II_3III)(JNIEnv *env, jclass that, jintLong arg0, jintLong arg1, jintLongArray arg2, jint arg3, jint arg4)
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/library/os_stats.c b/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/library/os_stats.c
index 49ce35e8d6..95d94153c2 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/library/os_stats.c
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/library/os_stats.c
@@ -14,8 +14,8 @@
#ifdef NATIVE_STATS
-int OS_nativeFunctionCount = 629;
-int OS_nativeFunctionCallCount[629];
+int OS_nativeFunctionCount = 630;
+int OS_nativeFunctionCallCount[630];
char * OS_nativeFunctionNames[] = {
"ATSFontActivateFromFileReference",
"AcquireRootMenu",
@@ -940,6 +940,11 @@ char * OS_nativeFunctionNames[] = {
"objc_1msgSend__JJ_3J",
#endif
#ifndef JNI64
+ "objc_1msgSend__II_3II",
+#else
+ "objc_1msgSend__JJ_3II",
+#endif
+#ifndef JNI64
"objc_1msgSend__II_3III",
#else
"objc_1msgSend__JJ_3JII",
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/library/os_stats.h b/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/library/os_stats.h
index 1f4d61bedc..4a3efdb762 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/library/os_stats.h
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/library/os_stats.h
@@ -948,6 +948,11 @@ typedef enum {
objc_1msgSend__JJ_3J_FUNC,
#endif
#ifndef JNI64
+ objc_1msgSend__II_3II_FUNC,
+#else
+ objc_1msgSend__JJ_3II_FUNC,
+#endif
+#ifndef JNI64
objc_1msgSend__II_3III_FUNC,
#else
objc_1msgSend__JJ_3JII_FUNC,
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/AppKitFull.bridgesupport.extras b/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/AppKitFull.bridgesupport.extras
index 8c1c2bd8a5..265e3e613f 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/AppKitFull.bridgesupport.extras
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/AppKitFull.bridgesupport.extras
@@ -2119,6 +2119,11 @@
<method selector="makeCurrentContext" swt_gen="true">
<retval swt_gen="true"></retval>
</method>
+ <method selector="setValues:forParameter:" swt_gen="true">
+ <arg swt_gen="true" swt_java_type="int[]"></arg>
+ <arg swt_gen="true"></arg>
+ <retval swt_gen="true"></retval>
+ </method>
<method selector="setView:" swt_gen="true">
<arg swt_gen="true"></arg>
<retval swt_gen="true"></retval>
@@ -4800,6 +4805,8 @@
<enum name="NSNormalWindowLevel" swt_gen="true"></enum>
<enum name="NSOffState" swt_gen="true"></enum>
<enum name="NSOnState" swt_gen="true"></enum>
+ <enum name="NSOpenGLCPSurfaceOrder" swt_gen="true"></enum>
+ <enum name="NSOpenGLCPSwapInterval" swt_gen="true"></enum>
<enum name="NSOpenGLPFAAccumSize" swt_gen="true"></enum>
<enum name="NSOpenGLPFAAlphaSize" swt_gen="true"></enum>
<enum name="NSOpenGLPFAColorSize" swt_gen="true"></enum>
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/NSOpenGLContext.java b/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/NSOpenGLContext.java
index fd688df582..d03cb56fa2 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/NSOpenGLContext.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/NSOpenGLContext.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2009 IBM Corporation and others.
+ * Copyright (c) 2000, 2011 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -50,6 +50,10 @@ public void makeCurrentContext() {
OS.objc_msgSend(this.id, OS.sel_makeCurrentContext);
}
+public void setValues(int[] vals, int param) {
+ OS.objc_msgSend(this.id, OS.sel_setValues_forParameter_, vals, param);
+}
+
public void setView(NSView view) {
OS.objc_msgSend(this.id, OS.sel_setView_, view != null ? view.id : 0);
}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/OS.java b/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/OS.java
index 0ba6ac949b..29f1098290 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/OS.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/OS.java
@@ -1987,6 +1987,7 @@ public static final int /*long*/ sel_setUsesThreadedAnimation_ = sel_registerNam
public static final int /*long*/ sel_setValue_forHTTPHeaderField_ = sel_registerName("setValue:forHTTPHeaderField:");
public static final int /*long*/ sel_setValue_forKey_ = sel_registerName("setValue:forKey:");
public static final int /*long*/ sel_setValueWraps_ = sel_registerName("setValueWraps:");
+public static final int /*long*/ sel_setValues_forParameter_ = sel_registerName("setValues:forParameter:");
public static final int /*long*/ sel_setVerticalScroller_ = sel_registerName("setVerticalScroller:");
public static final int /*long*/ sel_setView_ = sel_registerName("setView:");
public static final int /*long*/ sel_setVisible_ = sel_registerName("setVisible:");
@@ -2332,6 +2333,8 @@ public static final int NSNonactivatingPanelMask = 128;
public static final int NSNormalWindowLevel = 0;
public static final int NSOffState = 0;
public static final int NSOnState = 1;
+public static final int NSOpenGLCPSurfaceOrder = 235;
+public static final int NSOpenGLCPSwapInterval = 222;
public static final int NSOpenGLPFAAccumSize = 14;
public static final int NSOpenGLPFAAlphaSize = 11;
public static final int NSOpenGLPFAColorSize = 8;
@@ -4047,6 +4050,8 @@ public static final native int /*long*/ objc_msgSend(int /*long*/ id, int /*long
/** @method flags=cast */
public static final native int /*long*/ objc_msgSend(int /*long*/ id, int /*long*/ sel, int[] /*long[]*/ arg0, int arg1, int arg2);
/** @method flags=cast */
+public static final native int /*long*/ objc_msgSend(int /*long*/ id, int /*long*/ sel, int[] arg0, int arg1);
+/** @method flags=cast */
public static final native int objc_msgSend(int id, int sel, float arg0);
/** @method flags=cast */
public static final native long objc_msgSend(long id, long sel, int arg0);
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Canvas.java b/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Canvas.java
index d0bdab747b..a1257fdb0f 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Canvas.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Canvas.java
@@ -41,7 +41,8 @@ import org.eclipse.swt.internal.cocoa.*;
public class Canvas extends Composite {
Caret caret;
IME ime;
- NSOpenGLContext context;
+ NSOpenGLContext glcontext;
+ NSBezierPath visiblePath;
static NSMutableArray supportedPboardTypes;
@@ -135,8 +136,25 @@ public void drawBackground (GC gc, int x, int y, int width, int height) {
drawBackground(gc, x, y, width, height, 0, 0);
}
+void drawBackground (int /*long*/ id, NSGraphicsContext context, NSRect rect) {
+ super.drawBackground(id, context, rect);
+ if (glcontext != null) {
+ context.saveGraphicsState();
+ context.setCompositingOperation(OS.NSCompositeClear);
+ if (visiblePath == null) {
+ int /*long*/ visibleRegion = getVisibleRegion();
+ visiblePath = getPath(visibleRegion);
+ OS.DisposeRgn(visibleRegion);
+ }
+ visiblePath.addClip();
+ NSBezierPath.fillRect(rect);
+ context.restoreGraphicsState();
+ return;
+ }
+}
+
void drawRect (int /*long*/ id, int /*long*/ sel, NSRect rect) {
- if (context != null && context.view() == null) context.setView(view);
+ if (glcontext != null && glcontext.view() == null) glcontext.setView(view);
super.drawRect(id, sel, rect);
}
@@ -257,7 +275,7 @@ boolean insertText (int /*long*/ id, int /*long*/ sel, int /*long*/ string) {
}
boolean isOpaque (int /*long*/ id, int /*long*/ sel) {
- if (context != null) return true;
+ if (glcontext != null) return true;
return super.isOpaque(id, sel);
}
@@ -319,6 +337,18 @@ void reskinChildren (int flags) {
super.reskinChildren (flags);
}
+void releaseWidget () {
+ super.releaseWidget();
+ if (visiblePath != null) visiblePath.release();
+ visiblePath = null;
+}
+
+void resetVisibleRegion () {
+ super.resetVisibleRegion ();
+ if (visiblePath != null) visiblePath.release();
+ visiblePath = null;
+}
+
/**
* Scrolls a rectangular area of the receiver by first copying
* the source area to the destination and then causing the area
@@ -504,7 +534,13 @@ public void setFont (Font font) {
}
void setOpenGLContext(Object value) {
- context = (NSOpenGLContext)value;
+ glcontext = (NSOpenGLContext)value;
+ NSWindow window = view.window();
+ if (glcontext != null) {
+ window.setOpaque(false);
+ } else {
+ window.setOpaque(getShell().region == null);
+ }
}
/**
@@ -567,7 +603,16 @@ int /*long*/ validRequestorForSendType(int /*long*/ id, int /*long*/ sel, int /*
}
void updateOpenGLContext(int /*long*/ id, int /*long*/ sel, int /*long*/ notification) {
- if (context != null) ((NSOpenGLContext)context).update();
+ if (glcontext != null) ((NSOpenGLContext)glcontext).update();
+}
+
+void viewWillMoveToWindow(int /*long*/ id, int /*long*/ sel, int /*long*/ arg0) {
+ super.viewWillMoveToWindow(id, sel, arg0);
+ if (glcontext != null) {
+ new NSWindow(arg0).setOpaque(false);
+ NSWindow window = view.window();
+ window.setOpaque(getShell().region == null);
+ }
}
boolean writeSelectionToPasteboard(int /*long*/ id, int /*long*/ sel, int /*long*/ pasteboardObj, int /*long*/ typesObj) {