cedric pushed a commit to branch master.

http://git.enlightenment.org/core/efl.git/commit/?id=c80d7adbc277d6afaa420e199b5c2781b5cf10e4

commit c80d7adbc277d6afaa420e199b5c2781b5cf10e4
Author: Romain Perier <romain.per...@openwide.fr>
Date:   Thu Jan 22 10:26:55 2015 +0100

    evas: use a shared OpenGL context in gl_cocoa backend.
    
    Evas GL backend uses a global OpenGL context for all windows inside
    an application. Each window has its own texture to render its
    content. We use a singleton NSOpenGLContext shared between all
    NSOpenGLView, it solves rendering issues for multiple windows.
    
    Signed-off-by: Cedric BAIL <ced...@osg.samsung.com>
---
 src/modules/evas/engines/gl_cocoa/evas_gl_cocoa_main.m | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)

diff --git a/src/modules/evas/engines/gl_cocoa/evas_gl_cocoa_main.m 
b/src/modules/evas/engines/gl_cocoa/evas_gl_cocoa_main.m
index 67b9453..13bc5e3 100644
--- a/src/modules/evas/engines/gl_cocoa/evas_gl_cocoa_main.m
+++ b/src/modules/evas/engines/gl_cocoa/evas_gl_cocoa_main.m
@@ -4,6 +4,7 @@
 #include "evas_engine.h"
 
 static Evas_GL_Cocoa_Window *_evas_gl_cocoa_window = NULL;
+static NSOpenGLContext *_evas_gl_cocoa_shared_context = NULL;
 
 @interface EvasGLView : NSOpenGLView
 {
@@ -43,6 +44,18 @@ static Evas_GL_Cocoa_Window *_evas_gl_cocoa_window = NULL;
 {
    NSOpenGLPixelFormat * pf = [EvasGLView basicPixelFormat];
    self = [super initWithFrame: frameRect pixelFormat: pf];
+
+
+   NSOpenGLContext *ctx;
+   if (!_evas_gl_cocoa_shared_context) {
+     _evas_gl_cocoa_shared_context = [[NSOpenGLContext alloc] initWithFormat: 
[EvasGLView basicPixelFormat] shareContext: nil];
+     ctx = _evas_gl_cocoa_shared_context;
+   } else {
+     ctx = [[NSOpenGLContext alloc] initWithFormat: [EvasGLView 
basicPixelFormat] shareContext: _evas_gl_cocoa_shared_context];
+   }
+   [self setOpenGLContext: ctx];
+   [ctx setView: self];
+
    return self;
 }
 
@@ -127,4 +140,3 @@ eng_window_resize(Evas_GL_Cocoa_Window *gw, int width, int 
height)
   [(EvasGLView*)gw->view setFrame:view_frame];
   [[(NSOpenGLView*)gw->view openGLContext] flushBuffer];
 }
-

-- 


Reply via email to