diff options
author | Lyubomir Marinov <lyubomir.marinov@jitsi.org> | 2011-03-25 08:32:05 +0000 |
---|---|---|
committer | Lyubomir Marinov <lyubomir.marinov@jitsi.org> | 2011-03-25 08:32:05 +0000 |
commit | cab2ad6b4394b8577965d60d48e07f17ee5af2c0 (patch) | |
tree | c13f91954ce204e377b89b72c304ed92306e6367 | |
parent | 1e389524a589b29409f12d8719bf479ff7fd45ad (diff) | |
download | jitsi-cab2ad6b4394b8577965d60d48e07f17ee5af2c0.zip jitsi-cab2ad6b4394b8577965d60d48e07f17ee5af2c0.tar.gz jitsi-cab2ad6b4394b8577965d60d48e07f17ee5af2c0.tar.bz2 |
Fixes overlapping issues with the JAWTRenderer on Mac OS X.
-rwxr-xr-x | lib/native/mac/libjawtrenderer.jnilib | bin | 45008 -> 89800 bytes | |||
-rw-r--r-- | src/native/jawtrenderer/JAWTRenderer_MacOSX.m | 84 | ||||
-rw-r--r-- | src/net/java/sip/communicator/impl/neomedia/jmfext/media/renderer/video/JAWTRenderer.java | 84 |
3 files changed, 122 insertions, 46 deletions
diff --git a/lib/native/mac/libjawtrenderer.jnilib b/lib/native/mac/libjawtrenderer.jnilib Binary files differindex f4cc02f..c069b10 100755 --- a/lib/native/mac/libjawtrenderer.jnilib +++ b/lib/native/mac/libjawtrenderer.jnilib diff --git a/src/native/jawtrenderer/JAWTRenderer_MacOSX.m b/src/native/jawtrenderer/JAWTRenderer_MacOSX.m index 4464614..0ae6227 100644 --- a/src/native/jawtrenderer/JAWTRenderer_MacOSX.m +++ b/src/native/jawtrenderer/JAWTRenderer_MacOSX.m @@ -398,7 +398,6 @@ JAWTRenderer_removeNotifyLightweightComponent(jlong handle, jobject component) } [self setView:nil]; - [self copyCGLContext:nil forPixelFormat:0]; [super dealloc]; } @@ -413,9 +412,6 @@ JAWTRenderer_removeNotifyLightweightComponent(jlong handle, jobject component) { if ((self = [super init])) { - NSOpenGLPixelFormatAttribute pixelFormatAttribs[] - = { NSOpenGLPFAWindow, 0 }; - NSOpenGLPixelFormat *pixelFormat; glContext = nil; @@ -437,52 +433,15 @@ JAWTRenderer_removeNotifyLightweightComponent(jlong handle, jobject component) subrenderers = nil; superrenderer = nil; - - pixelFormat - = [[NSOpenGLPixelFormat alloc] - initWithAttributes:pixelFormatAttribs]; - if (pixelFormat) - { - glContext - = [[NSOpenGLContext alloc] - initWithFormat:pixelFormat - shareContext:nil]; - if (glContext) - { - GLint surfaceOpacity; - - // prepareOpenGL - [glContext makeCurrentContext]; - - surfaceOpacity = 1; - [glContext setValues:&surfaceOpacity - forParameter:NSOpenGLCPSurfaceOpacity]; - - glDisable(GL_BLEND); - glDisable(GL_DEPTH_TEST); - glDepthMask(GL_FALSE); - glDisable(GL_CULL_FACE); - glClearColor(0.0f, 0.0f, 0.0f, 1.0f); - glClear(GL_COLOR_BUFFER_BIT); - } - else - { - [self release]; - self = nil; - } - [pixelFormat release]; - } - else - { - [self release]; - self = nil; - } } return self; } - (void)paint { + if (!glContext) + return; + [glContext makeCurrentContext]; // drawRect: @@ -676,6 +635,8 @@ JAWTRenderer_removeNotifyLightweightComponent(jlong handle, jobject component) } #endif /* JAWT_RENDERER_USE_NSNOTIFICATIONCENTER */ + [self copyCGLContext:nil forPixelFormat:0]; + [view release]; } @@ -683,13 +644,46 @@ JAWTRenderer_removeNotifyLightweightComponent(jlong handle, jobject component) if (view) { + NSOpenGLPixelFormatAttribute pixelFormatAttribs[] + = { NSOpenGLPFAWindow, 0 }; + NSOpenGLPixelFormat *pixelFormat; + #ifdef JAWT_RENDERER_USE_NSNOTIFICATIONCENTER NSNotificationCenter *notificationCenter; #endif /* JAWT_RENDERER_USE_NSNOTIFICATIONCENTER */ [view retain]; + + pixelFormat + = [[NSOpenGLPixelFormat alloc] + initWithAttributes:pixelFormatAttribs]; + if (pixelFormat) + { + glContext + = [[NSOpenGLContext alloc] initWithFormat:pixelFormat + shareContext:nil]; + if (glContext) + { + GLint surfaceOpacity; + + // prepareOpenGL + [glContext makeCurrentContext]; + + surfaceOpacity = 1; + [glContext setValues:&surfaceOpacity + forParameter:NSOpenGLCPSurfaceOpacity]; + + glDisable(GL_BLEND); + glDisable(GL_DEPTH_TEST); + glDepthMask(GL_FALSE); + glDisable(GL_CULL_FACE); + glClearColor(0.0f, 0.0f, 0.0f, 1.0f); + glClear(GL_COLOR_BUFFER_BIT); + } + [pixelFormat release]; + } - if ([glContext view] != view) + if (glContext && ([glContext view] != view)) [glContext setView:view]; #ifdef JAWT_RENDERER_USE_NSNOTIFICATIONCENTER diff --git a/src/net/java/sip/communicator/impl/neomedia/jmfext/media/renderer/video/JAWTRenderer.java b/src/net/java/sip/communicator/impl/neomedia/jmfext/media/renderer/video/JAWTRenderer.java index e944cb1..e481b2a 100644 --- a/src/net/java/sip/communicator/impl/neomedia/jmfext/media/renderer/video/JAWTRenderer.java +++ b/src/net/java/sip/communicator/impl/neomedia/jmfext/media/renderer/video/JAWTRenderer.java @@ -73,7 +73,7 @@ public class JAWTRenderer * The indicator which determines whether <tt>CALayer</tt>-based painting is * to be performed by <tt>JAWTRenderer</tt> on Mac OS X. */ - private static final boolean USE_MACOSX_CALAYERS = false; + private static final boolean USE_MACOSX_CALAYERS = true; static { @@ -668,6 +668,11 @@ public class JAWTRenderer */ private static class NonVideoComponent { + /** + * The <tt>BufferedImage</tt> into which {@link #component} is to be + * painted so that it can be processed and then rendered by + * {@link #handle}. + */ private BufferedImage bufferedImage; /** @@ -682,12 +687,31 @@ public class JAWTRenderer */ private long handle; + /** + * The height in pixels of {@link #bufferedImage} and {@link #rgb}. + */ private int height; + /** + * The pixels of {@link #bufferedImage} to be processed by + * {@link #handle}. + */ private int[] rgb; + /** + * The width in pixels of {@link #bufferedImage} and {@link #rgb}. + */ private int width; + /** + * Initializes a new <tt>NonVideoComponent</tt> instance which is to + * paint a specific <tt>Component</tt> in the context of a parent + * <tt>JAWTRenderer</tt>. + * + * @param component the <tt>Component</tt> to be painted + * @param parentHandle the handle of the native <tt>JAWTRenderer</tt> in + * the context of which <tt>component</tt> is to be painted + */ public NonVideoComponent(Component component, long parentHandle) { this.component = component; @@ -710,6 +734,10 @@ public class JAWTRenderer } } + /** + * Releases the resources of this <tt>NonVideoComponent</tt> and + * prepares it to be garbage collected. + */ public void dispose() { if (handle != 0) @@ -721,10 +749,19 @@ public class JAWTRenderer } } + /** + * Paints the <tt>Component</tt> associated with this + * <tt>NonVideoComponent</tt> instance. + */ public void paint() { if (handle != 0) { + /* + * Make sure the location, the size and the visibility known to + * the associated native JAWTRenderer are in sync with these of + * the component. + */ Rectangle bounds = component.getBounds(); if (!component.isVisible()) @@ -736,9 +773,17 @@ public class JAWTRenderer handle, bounds.x, bounds.y, bounds.width, bounds.height); + /* + * If the component is not visible, the native JAWTRenderer + * already knows that it is not to be rendered. + */ if ((bounds.height < 1) || (bounds.width < 1)) return; + /* + * Paint the component and tell the native JAWTRenderer about + * the latest painting. + */ if ((height != bounds.height) || (width != bounds.width)) { rgb = new int[bounds.width * bounds.height]; @@ -1167,9 +1212,18 @@ public class JAWTRenderer @Override public boolean contains(int x, int y) { + /* + * Act as a "glass pane" i.e. be transparent with respect to points + * and pretend they are in whatever is underneath. + */ return false; } + /** + * Dispatches <tt>MouseEvent</tt>s to whatever is underneath this + * <tt>SwingVideoComponentCanvas</tt> because it only renders + * <tt>Component</tt>s i.e. it is like a "glass pane". + */ private boolean dispatchMouseEvent(MouseEvent e) { Component srcc = e.getComponent(); @@ -1201,6 +1255,20 @@ public class JAWTRenderer return false; } + /** + * Determines the <tt>Component</tt> which is a child of a specific + * <tt>Container</tt> which contains a specific <tt>Point</tt>. Since + * <tt>SwingVideoComponentCanvas</tt> is like a "glass pane", it never + * contains the specified <tt>point</tt>. + * + * @param parent the <tt>Container</tt> which contains the + * <tt>Component</tt>s which may contain the specified <tt>point</tt> + * @param point the point in the coordinate system of <tt>parent</tt> + * which is to be determined which <tt>Component</tt> contains it + * @return the <tt>Component</tt> which is a child of the specified + * <tt>Container</tt> and contains the specified <tt>Point</tt> or + * <tt>null</tt> if there is no such <tt>Component</tt> + */ private Component getComponentAt(Container parent, Point point) { Component[] components = parent.getComponents(); @@ -1313,6 +1381,10 @@ public class JAWTRenderer @Override protected void processMouseEvent(MouseEvent e) { + /* + * Act as a "glass pane" i.e. be transparent with respect to + * MouseEvents and dispatch them to whatever is underneath. + */ if (!dispatchMouseEvent(e)) super.processMouseEvent(e); } @@ -1320,10 +1392,20 @@ public class JAWTRenderer @Override protected void processMouseMotionEvent(MouseEvent e) { + /* + * Act as a "glass pane" i.e. be transparent with respect to + * MouseEvents and dispatch them to whatever is underneath. + */ if (!dispatchMouseEvent(e)) super.processMouseMotionEvent(e); } + /** + * Removes all <tt>NonVideoComponent</tt>s from this + * <tt>SwingVideoComponentCanvas</tt> so that their associated + * <tt>Component</tt>s are no longer painted by the reperesented native + * <tt>JAWTRenderer</tt>. + */ private void removeAllNonVideoComponents() { synchronized (nonVideoComponents) |