Compare commits

...

21 Commits

Author SHA1 Message Date
Raoul Hecky b1c9ef04ce evas_gl: add more matching formats to make cocoa_gl happy 2014-06-17 22:19:26 +02:00
Raoul Hecky 77c54f7a60 evas_cocoa: more changes copied from sdl engine 2014-06-17 22:19:26 +02:00
Raoul Hecky 9193033518 evas_cocoa: Update cocoa gl engine 2014-06-17 22:19:26 +02:00
Raoul Hecky 056619e5e2 ecore_cocoa: make engine works again 2014-06-17 22:19:25 +02:00
Raoul Hecky 2d96273c2b evas_cocoa: correct include for GL 2014-06-17 22:19:25 +02:00
Raoul Hecky 0635871af5 ecore_cocoa: missing link flag 2014-06-17 22:19:25 +02:00
Raoul Hecky 5a484feb9d evas_cocoa: build gl_common 2014-06-17 22:19:25 +02:00
Raoul Hecky f788fb8883 evas_cocoa: remove eng_image_mask_create 2014-06-17 22:19:25 +02:00
Raoul Hecky 1060a27e57 ecore_cocoa: add code from old branch 2014-06-17 22:19:25 +02:00
Raoul Hecky 840d36f107 ecore_cocoa: add missing header from my old branch 2014-06-17 22:19:25 +02:00
Raoul Hecky 98e11cb600 ecore_cocoa: Add missing opengl framework 2014-06-17 22:19:25 +02:00
Raoul Hecky e91552582c Add cocoa engine checks again 2014-06-17 22:19:25 +02:00
Benjamin Cohen 6ad191af5d configure: fix net/if.h detection on osx (10.7) 2014-06-17 22:19:25 +02:00
Nicolas Aguirre a003a4e936 evas: force equality in check otherwise i get debug output even if the environnement variable is not set. 2014-06-17 22:19:24 +02:00
Nicolas Aguirre 7f9ea6bf74 ecore_cocoa: switch keys to map correctly on OS-X.
os-x is notoriously switching the meaning of those keys
calling "BackSpace" "Delete, and "Delete" "Forward Delete"

Original patch by Pierre Tardy
2014-06-17 22:19:24 +02:00
Nicolas Aguirre 8705d2ff9d ecore_cocoa: fix button order. 2014-06-17 22:19:24 +02:00
Nicolas Aguirre bd037fd811 ecore_evas: fix warnings in Ecore_Evas Cocoa. 2014-06-17 22:19:24 +02:00
Nicolas Aguirre f0729102d2 ecore_cocoa: indent with efl style 2014-06-17 22:19:24 +02:00
Nicolas Aguirre 709a4c5c2a ecore_cocoa: fix Key up/down usage, the event window was missing and the ev->key was not specified 2014-06-17 22:19:24 +02:00
Nicolas Aguirre 9d794ec148 ecore_evas: use Eina_List to store Ecore_Evases and return the first one when asked for a match. 2014-06-17 22:19:24 +02:00
Nicolas Aguirre 737912cf8b ecore_cocoa: remove printf 2014-06-17 22:19:24 +02:00
15 changed files with 379 additions and 151 deletions

View File

@ -1293,22 +1293,56 @@ if test "${want_sdl}" = "yes" && test "${with_opengl}" = "full"; then
fi
# Cocoa
dnl AC_ARG_ENABLE([cocoa],
dnl [AC_HELP_STRING([--enable-cocoa],
dnl [enable MacOS X Cocoa . @<:@default=disabled@:>@])],
dnl [
dnl if test "x${enableval}" = "xyes" ; then
dnl want_cocoa="yes"
dnl else
dnl want_cocoa="no"
dnl fi
dnl ],
dnl [want_cocoa="no"])
dnl
dnl if test "${want_cocoa}" = "yes"; then
dnl test cocoa requirements (objc and Cocoa/Cocoa.h)
dnl fi
want_cocoa="no"
AC_ARG_ENABLE([cocoa],
[AC_HELP_STRING([--enable-cocoa],
[enable MacOS X Cocoa . @<:@default=disabled@:>@])],
[
if test "x${enableval}" = "xyes" ; then
want_cocoa="yes"
else
want_cocoa="no"
fi
],
[want_cocoa="no"])
if test "${want_cocoa}" = "yes"; then
#test cocoa requirements (objc and Cocoa/Cocoa.h)
cocoa_ldflags=""
have_cocoa="no"
m4_ifdef([AC_PROG_OBJC],
[
if test "x${have_gnu_objc}" = "xyes" ; then
AC_LANG_PUSH([Objective C])
LIBS_save="$LIBS"
LIBS="$LIBS -framework Cocoa"
AC_LINK_IFELSE(
[AC_LANG_PROGRAM(
[[
#include <Cocoa/Cocoa.h>
]],
[[
NSWindow *window;
window = [[NSWindow alloc]
initWithContentRect:NSMakeRect(0, 0, 1, 1)
styleMask:(NSTitledWindowMask)
backing:NSBackingStoreBuffered
defer:NO
screen:nil
];
]])],
[
have_cocoa="yes"
cocoa_ldflags="-framework Cocoa"
],
[have_cocoa="no"])
LIBS="$LIBS_save"
AC_MSG_CHECKING([whether Cocoa framework is supported])
AC_MSG_RESULT([${have_cocoa}])
AC_LANG_POP([Objective C])
fi
])
fi
AC_SUBST(cocoa_ldflags)
# Drm
AC_ARG_ENABLE([drm],
@ -2255,7 +2289,6 @@ AC_CHECK_HEADERS([ \
arpa/inet.h \
langinfo.h \
features.h \
net/if.h \
netinet/in.h \
netinet/tcp.h \
sys/prctl.h \
@ -2269,6 +2302,21 @@ sys/un.h \
#endif
])
AC_CHECK_HEADERS([net/if.h], [], [],
[#include <stdio.h>
#if STDC_HEADERS
# include <stdlib.h>
# include <stddef.h>
#else
# if HAVE_STDLIB_H
# include <stdlib.h>
# endif
#endif
#if HAVE_SYS_SOCKET_H
# include <sys/socket.h>
#endif
])
### Checks for types
### Checks for structures
@ -2645,9 +2693,7 @@ EFL_INTERNAL_DEPEND_PKG([ECORE_COCOA], [eina])
### Checks for header files
dnl TODO: once cocoa is fixed and test-able, add required libs here
dnl to ECORE_COCOA_LIBS and ECORE_COCOA_CFLAGS.
dnl Evas already tests for ObjC and Cocoa/Cocoa.h
EFL_ADD_LIBS([ECORE_COCOA], [-framework Cocoa])
### Checks for types

View File

@ -391,7 +391,7 @@ window = [[NSWindow alloc]
]])],
[
have_dep="yes"
evas_engine_[]$1[]_libs="-framework Cocoa"
evas_engine_[]$1[]_libs="-framework Cocoa -framework OpenGL"
],
[have_dep="no"])
LIBS="$LIBS_save"

View File

@ -17,5 +17,5 @@ lib/ecore_cocoa/ecore_cocoa_private.h
lib_ecore_cocoa_libecore_cocoa_la_CPPFLAGS = -I$(top_builddir)/src/lib/efl @ECORE_COCOA_CFLAGS@
lib_ecore_cocoa_libecore_cocoa_la_LIBADD = @ECORE_COCOA_LIBS@
lib_ecore_cocoa_libecore_cocoa_la_DEPENDENCIES = @ECORE_COCOA_INTERNAL_LIBS@
lib_ecore_cocoa_libecore_cocoa_la_LDFLAGS = @EFL_LTLIBRARY_FLAGS@
lib_ecore_cocoa_libecore_cocoa_la_LDFLAGS = @EFL_LTLIBRARY_FLAGS@ @cocoa_ldflags@
endif

View File

@ -889,7 +889,9 @@ endif
modules_evas_engines_gl_cocoa_module_la_LIBADD += \
@USE_EVAS_LIBS@ \
@evas_engine_gl_cocoa_libs@
modules_evas_engines_gl_cocoa_module_la_DEPENDENCIES = @USE_EVAS_INTERNAL_LIBS@
modules_evas_engines_gl_cocoa_module_la_DEPENDENCIES = \
@USE_EVAS_INTERNAL_LIBS@ \
modules/evas/engines/gl_common/libevas_engine_gl_common.la
modules_evas_engines_gl_cocoa_module_la_LDFLAGS = -module @EFL_LTMODULE_FLAGS@
modules_evas_engines_gl_cocoa_module_la_LIBTOOLFLAGS = --tag=disable-static
endif

View File

@ -30,6 +30,7 @@ extern "C" {
#endif
typedef struct _Ecore_Cocoa_Window Ecore_Cocoa_Window;
typedef struct _Ecore_Cocoa_Screen Ecore_Cocoa_Screen;
EAPI extern int ECORE_COCOA_EVENT_GOT_FOCUS;
EAPI extern int ECORE_COCOA_EVENT_LOST_FOCUS;
@ -43,6 +44,10 @@ struct _Ecore_Cocoa_Event_Video_Resize
int h;
};
struct _Ecore_Cocoa_Screen
{
int dummy;
};
/* Core */
@ -50,6 +55,10 @@ EAPI int ecore_cocoa_init(void);
EAPI int ecore_cocoa_shutdown(void);
EAPI void ecore_cocoa_feed_events(void);
/* Screen */
EAPI void ecore_cocoa_screen_size_get(Ecore_Cocoa_Screen *screen, int *w, int *h);
/* Window */
EAPI Ecore_Cocoa_Window *ecore_cocoa_window_new(int x,

View File

@ -14,7 +14,7 @@ static const struct _ecore_cocoa_keys_s keystable[] =
{ 0, "0x00", "" },
{ 0, "First", "" },
{ 3, "Return", "\015" },
{ 8, "BackSpace", "\010" },
{ 8, "Delete", "\010" },
{ 9, "Tab", "\011" },
{ 12, "Clear", "" },
{ 13, "Return", "\015" },
@ -90,7 +90,7 @@ static const struct _ecore_cocoa_keys_s keystable[] =
{ 123, "braceleft", "" },
{ 124, "pipe", "" },
{ 125, "braceright", "" },
{ 127, "Delete", "\177" },
{ 127, "BackSpace", "\177" },
{ 126, "asciitilde", "~" },
{ 160, "w0", "" },
@ -257,8 +257,8 @@ static const struct _ecore_cocoa_keys_s keystable[] =
{ NSClearLineFunctionKey, "Num_Lock", "" },
{ 301, "Caps_Lock", "" },
{ NSScrollLockFunctionKey, "Scroll_Lock", "" },
{ 303, "Shift_R", "" },
{ 304, "Shift_L", "" },
{ 303, "Shift_R", "Shift_R" },
{ 304, "Shift_L", "Shift_L" },
{ 305, "Control_R", "" },
{ 306, "Control_L", "" },
{ 307, "Alt_R", "" },

View File

@ -2,7 +2,8 @@
# include <config.h>
#endif
#include <Cocoa/Cocoa.h>
#import <Cocoa/Cocoa.h>
#import "ecore_cocoa_window.h"
#include <Eina.h>
@ -59,9 +60,25 @@ ecore_cocoa_shutdown(void)
return _ecore_cocoa_init_count;
}
static unsigned int
_ecore_cocoa_event_modifiers(unsigned int mod)
{
unsigned int modifiers = 0;
if(mod & NSShiftKeyMask) modifiers |= ECORE_EVENT_MODIFIER_SHIFT;
if(mod & NSControlKeyMask) modifiers |= ECORE_EVENT_MODIFIER_CTRL;
if(mod & NSAlternateKeyMask) modifiers |= ECORE_EVENT_MODIFIER_ALT;
if(mod & NSCommandKeyMask) modifiers |= ECORE_EVENT_MODIFIER_WIN;
if(mod & NSNumericPadKeyMask) modifiers |= ECORE_EVENT_LOCK_NUM;
printf("key modifiers: %d, %d\n", mod, modifiers);
return modifiers;
}
EAPI void
ecore_cocoa_feed_events(void)
{
Ecore_Event *ev;
NSDate *date = [NSDate dateWithTimeIntervalSinceNow:0.001];
NSEvent *event = [NSApp nextEventMatchingMask:NSAnyEventMask
untilDate:date
@ -81,12 +98,18 @@ ecore_cocoa_feed_events(void)
{
Ecore_Event_Mouse_Move * ev = calloc(1, sizeof(Ecore_Event_Mouse_Move));
if (!ev) return;
ev->x = [event locationInWindow].x;
ev->y = [event locationInWindow].y;
EcoreCocoaWindow *window = (EcoreCocoaWindow *)[event window];
NSView *view = [window contentView];
NSPoint pt = [event locationInWindow];
ev->x = pt.x;
ev->y = [view frame].size.height - pt.y;
ev->root.x = ev->x;
ev->root.y = ev->y;
ev->timestamp = time;
ev->window = [event window];
ev->window = window.ecore_window_data;
ev->event_window = ev->window;
ev->modifiers = 0; /* FIXME: keep modifier around. */
ecore_event_add(ECORE_EVENT_MOUSE_MOVE, ev, NULL, NULL);
@ -100,12 +123,25 @@ ecore_cocoa_feed_events(void)
{
Ecore_Event_Mouse_Button * ev = calloc(1, sizeof(Ecore_Event_Mouse_Button));
if (!ev) return;
ev->x = [event locationInWindow].x;
ev->y = [event locationInWindow].y;
EcoreCocoaWindow *window = (EcoreCocoaWindow *)[event window];
NSView *view = [window contentView];
NSPoint pt = [event locationInWindow];
ev->x = pt.x;
ev->y = [view frame].size.height - pt.y;
ev->root.x = ev->x;
ev->root.y = ev->y;
ev->timestamp = time;
ev->buttons = [event buttonNumber] + 1; // Apple indexes buttons from 0
switch ([event buttonNumber])
{
case 0: ev->buttons = 1; break;
case 1: ev->buttons = 3; break;
case 2: ev->buttons = 2; break;
default: ev->buttons = 0; break;
}
ev->window = window.ecore_window_data;
ev->event_window = ev->window;
if ([event clickCount] == 2)
ev->double_click = 1;
@ -128,12 +164,25 @@ ecore_cocoa_feed_events(void)
{
Ecore_Event_Mouse_Button * ev = calloc(1, sizeof(Ecore_Event_Mouse_Button));
if (!ev) return;
ev->x = [event locationInWindow].x;
ev->y = [event locationInWindow].y;
EcoreCocoaWindow *window = (EcoreCocoaWindow *)[event window];
NSView *view = [window contentView];
NSPoint pt = [event locationInWindow];
ev->x = pt.x;
ev->y = [view frame].size.height - pt.y;
ev->root.x = ev->x;
ev->root.y = ev->y;
ev->timestamp = time;
ev->buttons = [event buttonNumber] + 1; // Apple indexes buttons from 0
switch ([event buttonNumber])
{
case 0: ev->buttons = 1; break;
case 1: ev->buttons = 3; break;
case 2: ev->buttons = 2; break;
default: ev->buttons = 0; break;
}
ev->window = window.ecore_window_data;
ev->event_window = ev->window;
if ([event clickCount] == 2)
ev->double_click = 1;
@ -154,18 +203,23 @@ ecore_cocoa_feed_events(void)
{
Ecore_Event_Key *ev;
unsigned int i;
EcoreCocoaWindow *window = (EcoreCocoaWindow *)[event window];
ev = calloc(1, sizeof (Ecore_Event_Key));
if (!ev) return;
ev->timestamp = time;
ev->modifiers = _ecore_cocoa_event_modifiers([event modifierFlags]);
for (i = 0; i < sizeof (keystable) / sizeof (struct _ecore_cocoa_keys_s); ++i)
{
if (keystable[i].code == tolower([[event charactersIgnoringModifiers] characterAtIndex:0]))
{
printf("Key pressed : %s\n", keystable[i].name);
ev->keyname = keystable[i].name;
ev->key = keystable[i].name;
ev->string = keystable[i].compose;
ev->window = window.ecore_window_data;
ev->event_window = ev->window;
ecore_event_add(ECORE_EVENT_KEY_DOWN, ev, NULL, NULL);
return;
}
@ -177,18 +231,24 @@ ecore_cocoa_feed_events(void)
{
Ecore_Event_Key *ev;
unsigned int i;
EcoreCocoaWindow *window = (EcoreCocoaWindow *)[event window];
printf("Key Up\n");
ev = calloc(1, sizeof (Ecore_Event_Key));
if (!ev) return;
ev->timestamp = time;
ev->modifiers = _ecore_cocoa_event_modifiers([event modifierFlags]);
for (i = 0; i < sizeof (keystable) / sizeof (struct _ecore_cocoa_keys_s); ++i)
{
if (keystable[i].code == tolower([[event charactersIgnoringModifiers] characterAtIndex:0]))
{
ev->keyname = keystable[i].name;
ev->key = keystable[i].name;
ev->string = keystable[i].compose;
ev->window = window.ecore_window_data;
ev->event_window = ev->window;
ecore_event_add(ECORE_EVENT_KEY_UP, ev, NULL, NULL);
return;
}
@ -270,6 +330,7 @@ ecore_cocoa_feed_events(void)
}
case NSScrollWheel:
{
printf("Scroll Wheel\n");
break;
}
default:
@ -281,3 +342,12 @@ ecore_cocoa_feed_events(void)
[event release];
}
EAPI void
ecore_cocoa_screen_size_get(Ecore_Cocoa_Screen *screen, int *w, int *h)
{
NSSize pt = [[[NSScreen screens] objectAtIndex:0] frame].size;
if (w) *w = (int)pt.width;
if (h) *h = (int)pt.height;
}

View File

@ -0,0 +1,14 @@
#import <Cocoa/Cocoa.h>
@interface EcoreCocoaWindow: NSWindow <NSWindowDelegate>
{
void *ecore_window_data;
}
@property (nonatomic, assign) void *ecore_window_data;
- (id) initWithContentRect: (NSRect) contentRect
styleMask: (unsigned int) aStyle
backing: (NSBackingStoreType) bufferingType
defer: (BOOL) flag;
@end

View File

@ -2,11 +2,61 @@
# include <config.h>
#endif
#include <Cocoa/Cocoa.h>
#import "ecore_cocoa_window.h"
@implementation EcoreCocoaWindow
@synthesize ecore_window_data;
- (id) initWithContentRect: (NSRect) contentRect
styleMask: (unsigned int) aStyle
backing: (NSBackingStoreType) bufferingType
defer: (BOOL) flag
{
if (![super initWithContentRect: contentRect
styleMask: aStyle
backing: bufferingType
defer: flag]) return nil;
[self setBackgroundColor: [NSColor whiteColor]];
[self makeKeyWindow];
[self setDelegate:self];
[self setAcceptsMouseMovedEvents:YES];
return self;
}
- (BOOL)acceptsFirstResponder
{
return YES;
}
- (BOOL)canBecomeKeyWindow
{
return YES;
}
- (void)windowWillClose:(NSNotification *)notification
{
NSLog(@"window is going to be closed");
}
@end
#include "Ecore_Cocoa.h"
#include "ecore_cocoa_private.h"
static float _title_bar_height(void)
{
NSRect frame = NSMakeRect (0, 0, 100, 100);
NSRect contentRect;
contentRect = [NSWindow contentRectForFrameRect: frame
styleMask: NSTitledWindowMask];
return (frame.size.height - contentRect.size.height);
}
Ecore_Cocoa_Window *
ecore_cocoa_window_new(int x,
int y,
@ -15,26 +65,32 @@ ecore_cocoa_window_new(int x,
{
Ecore_Cocoa_Window *w;
NSWindow *window = [[NSWindow alloc]
initWithContentRect:NSMakeRect(x, y, width, height)
styleMask:(NSTitledWindowMask |
NSClosableWindowMask |
NSResizableWindowMask |
NSMiniaturizableWindowMask)
backing:NSBackingStoreBuffered
defer:NO
screen:nil
];
EcoreCocoaWindow *window = [[EcoreCocoaWindow alloc]
initWithContentRect:NSMakeRect(x, y, width, height)
styleMask:(NSTitledWindowMask |
NSClosableWindowMask |
NSResizableWindowMask |
NSMiniaturizableWindowMask)
backing:NSBackingStoreBuffered
defer:NO];
if (!window)
return NULL;
[window setBackgroundColor:[NSColor whiteColor]];
//Set the process to be a foreground process,
//without that it prevents the window to become the key window and
//receive all mouse mouve events.
ProcessSerialNumber psn;
GetCurrentProcess(&psn);
TransformProcessType(&psn, kProcessTransformToForegroundApplication);
SetFrontProcess(&psn);
w = calloc(1, sizeof(Ecore_Cocoa_Window));
w->window = window;
w->borderless = 0;
window.ecore_window_data = w;
return w;
}
@ -79,7 +135,7 @@ ecore_cocoa_window_resize(Ecore_Cocoa_Window *window,
return;
win_frame = [window->window frame];
win_frame.size.height = height;
win_frame.size.height = height + _title_bar_height();
win_frame.size.width = width;
[window->window setFrame:win_frame display:YES];
@ -101,7 +157,7 @@ ecore_cocoa_window_move_resize(Ecore_Cocoa_Window *window,
return;
win_frame = [window->window frame];
win_frame.size.height = height;
win_frame.size.height = height + _title_bar_height();
win_frame.size.width = width;
win_frame.origin.x = x;
win_frame.origin.y = y;
@ -158,6 +214,16 @@ ecore_cocoa_window_view_set(Ecore_Cocoa_Window *window,
if (!window || !view)
return;
[[window->window contentView] addSubview:view];
//[[window->window contentView] addSubview:view];
[window->window setContentView:view];
NSTrackingArea *area = [[NSTrackingArea alloc] initWithRect:[view frame]
options:NSTrackingMouseMoved |
NSTrackingActiveInActiveApp |
NSTrackingInVisibleRect
owner:view
userInfo:nil];
[view addTrackingArea:area];
[area release];
}

View File

@ -97,7 +97,7 @@ static Ecore_Evas *
_ecore_evas_cocoa_match(void)
{
DBG("Match");
return ecore_evases;
return eina_list_nth(ecore_evases, 0);
}
static int
@ -174,12 +174,13 @@ static int
_ecore_evas_idle_enter(void *data EINA_UNUSED)
{
Ecore_Evas *ee;
Eina_List *l;
double t1 = 0.;
double t2 = 0.;
DBG("Idle enter");
EINA_INLIST_FOREACH(ecore_evases, ee)
EINA_LIST_FOREACH(ecore_evases, l, ee)
{
if (ee->visible)
evas_render(ee->evas);
@ -193,10 +194,12 @@ _ecore_evas_idle_enter(void *data EINA_UNUSED)
static int
_ecore_evas_cocoa_event(void *data)
{
// ecore_cocoa_feed_events();
Ecore_Evas *ee = data;
DBG("Cocoa Event");
ecore_cocoa_feed_events();
return 1;
}
@ -207,26 +210,29 @@ _ecore_evas_cocoa_init(void)
_ecore_evas_init_count++;
if (_ecore_evas_init_count > 1)
return _ecore_evas_init_count;
ecore_event_evas_init();
ecore_evas_event_handlers[0] = ecore_event_handler_add(ECORE_COCOA_EVENT_GOT_FOCUS, _ecore_evas_cocoa_event_got_focus, NULL);
ecore_evas_event_handlers[1] = ecore_event_handler_add(ECORE_COCOA_EVENT_LOST_FOCUS, _ecore_evas_cocoa_event_lost_focus, NULL);
ecore_evas_event_handlers[2] = ecore_event_handler_add(ECORE_COCOA_EVENT_RESIZE, _ecore_evas_cocoa_event_video_resize, NULL);
ecore_evas_event_handlers[3] = ecore_event_handler_add(ECORE_COCOA_EVENT_EXPOSE, _ecore_evas_cocoa_event_video_expose, NULL);
ecore_event_evas_init();
return _ecore_evas_init_count;
}
static int
_ecore_evas_cocoa_shutdown(void)
{
Ecore_Evas *ee;
DBG("Cocoa SHutodwn");
_ecore_evas_init_count--;
if (_ecore_evas_init_count == 0)
{
int i;
while (ecore_evases) _ecore_evas_free(ecore_evases);
EINA_LIST_FREE(ecore_evases, ee)
_ecore_evas_free(ee);
for (i = 0; i < sizeof (ecore_evas_event_handlers) / sizeof (Ecore_Event_Handler*); i++)
ecore_event_handler_del(ecore_evas_event_handlers[i]);
@ -246,7 +252,7 @@ static void
_ecore_evas_cocoa_free(Ecore_Evas *ee)
{
DBG("Cocoa Free");
ecore_evases = (Ecore_Evas *) eina_inlist_remove(EINA_INLIST_GET(ecore_evases), EINA_INLIST_GET(ee));
ecore_evases = eina_list_remove(ecore_evases, ee);
ecore_event_window_unregister(0);
_ecore_evas_cocoa_shutdown();
ecore_cocoa_shutdown();
@ -257,6 +263,8 @@ _ecore_evas_resize(Ecore_Evas *ee, int w, int h)
{
DBG("Resize");
if ((w == ee->w) && (h == ee->h)) return;
ee->req.w = w;
ee->req.h = h;
ee->w = w;
ee->h = h;
@ -275,9 +283,17 @@ static void
_ecore_evas_move_resize(Ecore_Evas *ee, int x, int y, int w, int h)
{
DBG("Move Resize");
if ((w == ee->w) && (h == ee->h)) return;
if ((ee->w == w) && (ee->h == h) && (x == ee->x) && (y == ee->y))
return;
ee->req.x = x;
ee->req.y = y;
ee->req.w = w;
ee->req.h = h;
ee->w = w;
ee->h = h;
ee->x = x;
ee->y = y;
ecore_cocoa_window_move_resize(ee->prop.window, x, y, w, h);
@ -338,45 +354,36 @@ _ecore_evas_object_cursor_del(void *data, Evas *e, Evas_Object *obj, void *event
static void
_ecore_evas_object_cursor_set(Ecore_Evas *ee, Evas_Object *obj, int layer, int hot_x, int hot_y)
{
int x, y;
Evas_Object *old;
DBG("Cursor Set");
int x, y;
DBG("Cursor Set");
if (ee->prop.cursor.object) evas_object_del(ee->prop.cursor.object);
old = ee->prop.cursor.object;
if (obj == NULL)
{
ee->prop.cursor.object = NULL;
ee->prop.cursor.layer = 0;
ee->prop.cursor.hot.x = 0;
ee->prop.cursor.hot.y = 0;
goto end;
}
ee->prop.cursor.object = obj;
ee->prop.cursor.layer = layer;
ee->prop.cursor.hot.x = hot_x;
ee->prop.cursor.hot.y = hot_y;
if (obj != old)
{
evas_pointer_output_xy_get(ee->evas, &x, &y);
evas_object_layer_set(ee->prop.cursor.object, ee->prop.cursor.layer);
evas_object_pass_events_set(ee->prop.cursor.object, 1);
if (evas_pointer_inside_get(ee->evas))
evas_object_show(ee->prop.cursor.object);
evas_object_event_callback_add(obj, EVAS_CALLBACK_DEL,
_ecore_evas_object_cursor_del, ee);
}
if (obj == NULL)
{
ee->prop.cursor.object = NULL;
ee->prop.cursor.layer = 0;
ee->prop.cursor.hot.x = 0;
ee->prop.cursor.hot.y = 0;
return;
}
ee->prop.cursor.object = obj;
ee->prop.cursor.layer = layer;
ee->prop.cursor.hot.x = hot_x;
ee->prop.cursor.hot.y = hot_y;
evas_pointer_output_xy_get(ee->evas, &x, &y);
evas_object_layer_set(ee->prop.cursor.object, ee->prop.cursor.layer);
evas_object_move(ee->prop.cursor.object,
x - ee->prop.cursor.hot.x,
y - ee->prop.cursor.hot.y);
end:
if ((old) && (obj != old))
{
evas_object_event_callback_del_full
(old, EVAS_CALLBACK_DEL, _ecore_evas_object_cursor_del, ee);
evas_object_del(old);
}
evas_object_pass_events_set(ee->prop.cursor.object, 1);
if (evas_pointer_inside_get(ee->evas))
evas_object_show(ee->prop.cursor.object);
evas_object_event_callback_add(obj, EVAS_CALLBACK_DEL, _ecore_evas_object_cursor_del, ee);
}
static int
@ -420,6 +427,15 @@ _ecore_evas_engine_cocoa_init(Ecore_Evas *ee)
return 1;
}
static void
_ecore_evas_screen_geometry_get(const Ecore_Evas *ee EINA_UNUSED, int *x, int *y, int *w, int *h)
{
if (x) *x = 0;
if (y) *y = 0;
ecore_cocoa_screen_size_get(NULL, w, h);
printf("screen geometry_get %dx%d\n", w, h);
}
static Ecore_Evas_Engine_Func _ecore_cocoa_engine_func =
{
_ecore_evas_cocoa_free,
@ -479,20 +495,10 @@ static Ecore_Evas_Engine_Func _ecore_cocoa_engine_func =
NULL,
NULL, // render
NULL,
_ecore_evas_screen_geometry_get,
NULL, // screen_dpi_get
NULL,
NULL, // msg_send
NULL, // pointer_xy_get
NULL, // pointer_warp
NULL, // wm_rot_preferred_rotation_set
NULL, // wm_rot_available_rotations_set
NULL, // wm_rot_manual_rotation_done_set
NULL, // wm_rot_manual_rotation_done
NULL // aux_hints_set
NULL // msg_send
};
EAPI Ecore_Evas *
@ -500,7 +506,6 @@ ecore_evas_cocoa_new_internal(Ecore_Cocoa_Window *parent, int x, int y, int w, i
{
Evas_Engine_Info_GL_Cocoa *einfo;
Ecore_Evas *ee;
int rmethod;
DBG("Cocoa new");
@ -516,6 +521,14 @@ ecore_evas_cocoa_new_internal(Ecore_Cocoa_Window *parent, int x, int y, int w, i
_ecore_evas_cocoa_init();
ee->engine.func = (Ecore_Evas_Engine_Func *)&_ecore_cocoa_engine_func;
/* this is pretty bad: poller? and set poll time? pol time is meant to be
* adjustable for things like polling battery state, or amoutn of spare
* memory etc. I know it's bad but cedric did it for ecore_evas_sdl
* so why not me ? BTW why 0.006s ?
*/
ecore_evas_event = ecore_poller_add(ECORE_POLLER_CORE, 1, _ecore_evas_cocoa_event, ee);
ecore_poller_poll_interval_set(ECORE_POLLER_CORE, 0.006);
if (w < 1) w = 1;
if (h < 1) h = 1;
@ -547,7 +560,6 @@ ecore_evas_cocoa_new_internal(Ecore_Cocoa_Window *parent, int x, int y, int w, i
goto free_name;
evas_data_attach_set(ee->evas, ee);
evas_output_method_set(ee->evas, rmethod);
evas_output_size_set(ee->evas, w, h);
evas_output_viewport_set(ee->evas, 0, 0, w, h);
@ -572,10 +584,17 @@ ecore_evas_cocoa_new_internal(Ecore_Cocoa_Window *parent, int x, int y, int w, i
ee->engine.func->fn_render = _ecore_evas_cocoa_render;
_ecore_evas_register(ee);
ecore_event_window_register(0, ee, ee->evas, NULL, NULL, NULL, NULL);
ecore_event_window_register(ee->prop.window, ee, ee->evas,
(Ecore_Event_Mouse_Move_Cb)_ecore_evas_mouse_move_process,
(Ecore_Event_Multi_Move_Cb)_ecore_evas_mouse_multi_move_process,
(Ecore_Event_Multi_Down_Cb)_ecore_evas_mouse_multi_down_process,
(Ecore_Event_Multi_Up_Cb)_ecore_evas_mouse_multi_up_process);
evas_event_feed_mouse_in(ee->evas, (unsigned int)((unsigned long long)(ecore_time_get() * 1000.0) & 0xffffffff), NULL);
printf("Ecore Evas returned : %p\n", ee);
ecore_evases = eina_list_append(ecore_evases, ee);
return ee;
free_window:

View File

@ -236,6 +236,7 @@ eng_output_redraws_next_update_get(void *data, int *x, int *y, int *w, int *h, i
re = (Render_Engine *)data;
evas_gl_common_context_flush(re->win->gl_context);
evas_gl_common_context_newframe(re->win->gl_context);
/* get the upate rect surface - return engine data as dummy */
if (!re->win->draw.redraw)
{
@ -330,7 +331,7 @@ eng_context_cutout_clear(void *data EINA_UNUSED, void *context)
}
static void
eng_rectangle_draw(void *data, void *context, void *surface, int x, int y, int w, int h)
eng_rectangle_draw(void *data, void *context, void *surface, int x, int y, int w, int h, Eina_Bool do_async EINA_UNUSED)
{
Render_Engine *re;
@ -342,7 +343,7 @@ eng_rectangle_draw(void *data, void *context, void *surface, int x, int y, int w
}
static void
eng_line_draw(void *data, void *context, void *surface, int x1, int y1, int x2, int y2)
eng_line_draw(void *data, void *context, void *surface, int p1x, int p1y, int p2x, int p2y, Eina_Bool do_async EINA_UNUSED)
{
Render_Engine *re;
@ -350,7 +351,7 @@ eng_line_draw(void *data, void *context, void *surface, int x1, int y1, int x2,
eng_window_use(re->win);
evas_gl_common_context_target_surface_set(re->win->gl_context, surface);
re->win->gl_context->dc = context;
evas_gl_common_line_draw(re->win->gl_context, x1, y1, x2, y2);
evas_gl_common_line_draw(re->win->gl_context, p1x, p1y, p2x, p2y);
}
static void *
@ -372,7 +373,7 @@ eng_polygon_points_clear(void *data, void *context EINA_UNUSED, void *polygon)
}
static void
eng_polygon_draw(void *data, void *context, void *surface EINA_UNUSED, void *polygon, int x, int y)
eng_polygon_draw(void *data, void *context, void *surface EINA_UNUSED, void *polygon, int x, int y, Eina_Bool do_async EINA_UNUSED)
{
Render_Engine *re;
@ -407,20 +408,6 @@ eng_image_colorspace_get(void *data EINA_UNUSED, void *image)
return im->cs.space;
}
static void
eng_image_mask_create(void *data EINA_UNUSED, void *image)
{
Evas_GL_Image *im;
if (!image) return;
im = image;
if (!im->im->image.data)
evas_cache_image_load_data(&im->im->cache_entry);
if (!im->tex)
im->tex = evas_gl_common_texture_new(im->gc, im->im);
}
static void *
eng_image_alpha_set(void *data, void *image, int has_alpha)
{
@ -538,6 +525,9 @@ eng_image_colorspace_set(void *data, void *image, Evas_Colorspace cspace)
break;
case EVAS_COLORSPACE_YCBCR422P601_PL:
case EVAS_COLORSPACE_YCBCR422P709_PL:
case EVAS_COLORSPACE_YCBCR422601_PL:
case EVAS_COLORSPACE_YCBCR420NV12601_PL:
case EVAS_COLORSPACE_YCBCR420TM12601_PL:
if (im->tex) evas_gl_common_texture_free(im->tex, EINA_TRUE);
im->tex = NULL;
if (im->cs.data)
@ -676,6 +666,7 @@ eng_image_size_set(void *data, void *image, int w, int h)
case EVAS_COLORSPACE_YCBCR420NV12601_PL:
case EVAS_COLORSPACE_YCBCR420TM12601_PL:
w &= ~0x1;
default:
break;
}
@ -770,6 +761,9 @@ eng_image_data_get(void *data, void *image, int to_write, DATA32 **image_data, i
break;
case EVAS_COLORSPACE_YCBCR422P601_PL:
case EVAS_COLORSPACE_YCBCR422P709_PL:
case EVAS_COLORSPACE_YCBCR422601_PL:
case EVAS_COLORSPACE_YCBCR420NV12601_PL:
case EVAS_COLORSPACE_YCBCR420TM12601_PL:
*image_data = im->cs.data;
break;
default:
@ -878,7 +872,7 @@ eng_image_data_preload_cancel(void *data EINA_UNUSED, void *image, const Eo *tar
}
static Eina_Bool
eng_image_draw(void *data, void *context, void *surface, void *image, int src_x, int src_y, int src_w, int src_h, int dst_x, int dst_y, int dst_w, int dst_h, int smooth)
eng_image_draw(void *data, void *context, void *surface, void *image, int src_x, int src_y, int src_w, int src_h, int dst_x, int dst_y, int dst_w, int dst_h, int smooth, Eina_Bool do_async EINA_UNUSED)
{
Render_Engine *re;
@ -909,7 +903,7 @@ eng_image_scale_hint_get(void *data EINA_UNUSED, void *image)
}
static Eina_Bool
eng_image_map_draw(void *data EINA_UNUSED, void *context, void *surface, void *image, RGBA_Map *m, int smooth, int level)
eng_image_map_draw(void *data, void *context, void *surface, void *image, RGBA_Map *m, int smooth, int level, Eina_Bool do_async)
{
Evas_GL_Image *gim = image;
Render_Engine *re;
@ -950,7 +944,7 @@ eng_image_map_draw(void *data EINA_UNUSED, void *context, void *surface, void *i
dw = (m->pts[2].x >> FP) - dx;
dh = (m->pts[2].y >> FP) - dy;
eng_image_draw(data, context, surface, image,
0, 0, gim->w, gim->h, dx, dy, dw, dh, smooth);
0, 0, gim->w, gim->h, dx, dy, dw, dh, smooth, do_async);
}
else
{
@ -1043,30 +1037,29 @@ eng_image_stride_get(void *data EINA_UNUSED, void *image, int *stride)
}
static Eina_Bool
eng_font_draw(void *data, void *context, void *surface, Evas_Font_Set *font, int x, int y, int w EINA_UNUSED, int h EINA_UNUSED, int ow EINA_UNUSED, int oh EINA_UNUSED, Evas_Text_Props *intl_props)
eng_font_draw(void *data, void *context, void *surface, Evas_Font_Set *font EINA_UNUSED, int x, int y, int w EINA_UNUSED, int h EINA_UNUSED, int ow EINA_UNUSED, int oh EINA_UNUSED, Evas_Text_Props *intl_props, Eina_Bool do_async EINA_UNUSED)
{
Render_Engine *re;
re = (Render_Engine *)data;
Render_Engine *re = data;
eng_window_use(re->win);
evas_gl_common_context_target_surface_set(re->win->gl_context, surface);
re->win->gl_context->dc = context;
{
// FIXME: put im into context so we can free it
static RGBA_Image *im = NULL;
static RGBA_Image *im = NULL;
if (!im)
im = (RGBA_Image *)evas_cache_image_empty(evas_common_image_cache_get());
im->cache_entry.w = re->win->width;
im->cache_entry.h = re->win->height;
im->cache_entry.w = re->win->gl_context->shared->w;
im->cache_entry.h = re->win->gl_context->shared->h;
evas_common_draw_context_font_ext_set(context,
re->win->gl_context,
evas_gl_font_texture_new,
evas_gl_font_texture_free,
evas_gl_font_texture_draw);
evas_common_font_draw_prepare(intl_props);
evas_common_font_draw(im, context, x, y, intl_props);
evas_common_draw_context_font_ext_set(context,
evas_common_font_draw_prepare(intl_props);
evas_common_font_draw(im, context, x, y, intl_props->glyphs);
evas_common_draw_context_font_ext_set(context,
NULL,
NULL,
NULL,
@ -1348,6 +1341,7 @@ static int
module_open(Evas_Module *em)
{
if (!em) return 0;
if (!evas_gl_common_module_open()) return 0;
/* get whatever engine module we inherit from */
if (!_evas_module_engine_inherit(&pfunc, "software_generic")) return 0;
_evas_engine_gl_cocoa_log_dom = eina_log_domain_register("EvasGLCocoa", EVAS_DEFAULT_LOG_COLOR);
@ -1404,7 +1398,6 @@ module_open(Evas_Module *em)
ORD(image_format_get);
ORD(image_colorspace_set);
ORD(image_colorspace_get);
ORD(image_mask_create);
// ORD(image_native_set);
// ORD(image_native_get);
@ -1435,9 +1428,10 @@ module_open(Evas_Module *em)
}
static void
module_close(Evas_Module *em)
module_close(Evas_Module *em EINA_UNUSED)
{
eina_log_domain_unregister(_evas_engine_gl_cocoa_log_dom);
evas_gl_common_module_close();
}
static Evas_Module_Api evas_modapi =

View File

@ -64,6 +64,6 @@ void eng_window_free(Evas_GL_Cocoa_Window *gw);
void eng_window_use(Evas_GL_Cocoa_Window *gw);
void eng_window_swap_buffers(Evas_GL_Cocoa_Window *gw);
void eng_window_vsync_set(int on);
void ng_window_resize(Evas_GL_Cocoa_Window *gw, int width, int height);
void eng_window_resize(Evas_GL_Cocoa_Window *gw, int width, int height);
#endif /* __EVAS_ENGINE_H__ */

View File

@ -7,8 +7,13 @@
#include <EGL/egl.h>
#include <EGL/eglext.h>
#else
# include <GL/glext.h>
# include <GL/glx.h>
# ifdef BUILD_ENGINE_GL_COCOA
# include <OpenGL/gl.h>
# include <OpenGL/glext.h>
# else
# include <GL/glext.h>
# include <GL/glx.h>
# endif
#endif
/////////////////////////////////////////////////////////////////////////////////////////////////////

View File

@ -3209,7 +3209,7 @@ shader_array_flush(Evas_Engine_GL_Context *gc)
glDisableVertexAttribArray(SHAD_TEXUV3);
GLERR(__FUNCTION__, __FILE__, __LINE__, "");
}
if (dbgflushnum)
if (dbgflushnum == 1)
{
const char *types[6] =
{"----", "RECT", "IMAG", "FONT", "YUV-", "MAP"};
@ -3289,7 +3289,7 @@ shader_array_flush(Evas_Engine_GL_Context *gc)
gc->pipe[i].region.type = 0;
}
gc->state.top_pipe = 0;
if (dbgflushnum)
if (dbgflushnum == 1)
{
if (done > 0) printf("DONE (pipes): %i\n", done);
}

View File

@ -77,6 +77,7 @@ static const struct {
{ EINA_FALSE, EINA_TRUE, EVAS_COLORSPACE_RGBA8_ETC2_EAC, &etc2_rgba_fmt, &etc2_rgba_fmt }
};
static const GLenum matching_rgb[] = { GL_RGB4, GL_RGB8, GL_RGB12, GL_RGB16, 0x0 };
static const GLenum matching_rgba[] = { GL_RGBA4, GL_RGBA8, GL_RGBA12, GL_RGBA16, 0x0 };
static const GLenum matching_alpha[] = { GL_ALPHA4, GL_ALPHA8, GL_ALPHA12, GL_ALPHA16, 0x0 };
static const GLenum matching_luminance[] = { GL_LUMINANCE4, GL_LUMINANCE8, GL_LUMINANCE12, GL_LUMINANCE16, 0x0 };
@ -86,8 +87,10 @@ static const struct {
GLenum master;
const GLenum *matching;
} matching_fmt[] = {
{ GL_RGB, matching_rgb },
{ GL_RGBA, matching_rgba },
{ GL_ALPHA, matching_alpha },
{ GL_ALPHA4, matching_alpha },
{ GL_LUMINANCE, matching_luminance },
{ GL_LUMINANCE_ALPHA, matching_luminance_alpha }
};
@ -252,7 +255,7 @@ _tex_2d(Evas_Engine_GL_Context *gc, int intfmt, int w, int h, int fmt, int type)
GL_TEXTURE_INTERNAL_FORMAT, &intfmtret);
if (!_evas_gl_texture_match(intfmt, intfmtret))
{
ERR("Fail tex alloc %ix%i", w, h);
ERR("Fail tex alloc %ix%i, intfmt: %X intfmtret: %X", w, h, intfmt, intfmtret);
// XXX send async err to evas
return EINA_FALSE;
}