consolidate NSGLView

This commit is contained in:
Robin Gareus 2017-03-21 15:45:21 +01:00
parent d294d03670
commit 5e9492b996
3 changed files with 22 additions and 22 deletions

View file

@ -409,10 +409,8 @@ GtkCanvas::use_nsglview ()
assert (!_nsglview); assert (!_nsglview);
assert (!is_realized()); assert (!is_realized());
#ifdef ARDOUR_CANVAS_NSVIEW_TAG // patched gdkquartz.h #ifdef ARDOUR_CANVAS_NSVIEW_TAG // patched gdkquartz.h
# ifndef __ppc__ // would need to flip RGBA <> RGBA
_nsglview = Gtkmm2ext::nsglview_create (this); _nsglview = Gtkmm2ext::nsglview_create (this);
#endif #endif
#endif
} }
void void

View file

@ -85,10 +85,8 @@ CairoWidget::use_nsglview ()
assert (!_canvas_widget); assert (!_canvas_widget);
assert (!is_realized()); assert (!is_realized());
#ifdef ARDOUR_CANVAS_NSVIEW_TAG // patched gdkquartz.h #ifdef ARDOUR_CANVAS_NSVIEW_TAG // patched gdkquartz.h
# ifndef __ppc__ // would need to flip RGBA <> RGBA
_nsglview = Gtkmm2ext::nsglview_create (this); _nsglview = Gtkmm2ext::nsglview_create (this);
#endif #endif
#endif
} }
int int

View file

@ -19,20 +19,6 @@
*/ */
/* the API is currently only used on intel mac
* for big-endian RGBA <> RGBA byte order of the texture
* will have to be swapped.
*
* Also it does not currently compile as-is:
*
* warning: Mac OS X version 10.5 or later is needed for use of property
* error: synthesized property 'tag' must either be named the same as a compatible ivar or must explicitly name an ivar
*
* the wscipt would have to relax MAC_OS_X_VERSION_MIN_REQUIRED=1040
* (ardour's PPC build-stack is 10.5)
*/
#ifndef __ppc__
/* include order matter due to apple defines */ /* include order matter due to apple defines */
#include <gtkmm/window.h> #include <gtkmm/window.h>
@ -45,8 +31,19 @@
#include <OpenGL/gl.h> #include <OpenGL/gl.h>
#import <Cocoa/Cocoa.h> #import <Cocoa/Cocoa.h>
/* the gtk-quartz library which ardour links against
* is patched to pass events directly through to
* NSView child-views (AU Plugin GUIs).
*
* In this particular case however we do want the
* events to reach the GTK widget instead of the
* NSView subview.
*
* If a NSVIew tag equals to the given magic-number,
* Gdk events propagate.
*/
#ifndef ARDOUR_CANVAS_NSVIEW_TAG #ifndef ARDOUR_CANVAS_NSVIEW_TAG
#define ARDOUR_CANVAS_NSVIEW_TAG 0xa2d0c2c4 #define ARDOUR_CANVAS_NSVIEW_TAG 0x0
#endif #endif
__attribute__ ((visibility ("hidden"))) __attribute__ ((visibility ("hidden")))
@ -58,6 +55,7 @@ __attribute__ ((visibility ("hidden")))
int _height; int _height;
Cairo::RefPtr<Cairo::ImageSurface> surf; Cairo::RefPtr<Cairo::ImageSurface> surf;
Gtkmm2ext::CairoCanvas *cairo_canvas; Gtkmm2ext::CairoCanvas *cairo_canvas;
NSInteger _tag;
} }
@property (readwrite) NSInteger tag; @property (readwrite) NSInteger tag;
@ -74,7 +72,7 @@ __attribute__ ((visibility ("hidden")))
@implementation ArdourCanvasOpenGLView @implementation ArdourCanvasOpenGLView
@synthesize tag = tag; @synthesize tag = _tag;
- (id) initWithFrame:(NSRect)frame - (id) initWithFrame:(NSRect)frame
{ {
@ -260,6 +258,7 @@ __attribute__ ((visibility ("hidden")))
glFlush(); glFlush();
glSwapAPPLE(); glSwapAPPLE();
[NSOpenGLContext clearCurrentContext]; [NSOpenGLContext clearCurrentContext];
[super setNeedsDisplay:NO];
} }
@end @end
@ -267,6 +266,13 @@ __attribute__ ((visibility ("hidden")))
void* void*
Gtkmm2ext::nsglview_create (Gtkmm2ext::CairoCanvas* canvas) Gtkmm2ext::nsglview_create (Gtkmm2ext::CairoCanvas* canvas)
{ {
/* the API is currently only used on intel mac
* for big-endian RGBA <> RGBA byte order of the texture
* will have to be swapped.
*/
#ifdef __ppc__
return 0;
#endif
ArdourCanvasOpenGLView* gl_view = [ArdourCanvasOpenGLView new]; ArdourCanvasOpenGLView* gl_view = [ArdourCanvasOpenGLView new];
if (!gl_view) { if (!gl_view) {
return 0; return 0;
@ -308,5 +314,3 @@ Gtkmm2ext::nsglview_set_visible (void* glv, bool vis)
[gl_view setHidden:YES]; [gl_view setHidden:YES];
} }
} }
#endif