[vlc-devel] [PATCH 4/5] Add coreanim.m for Core Animation code that must use Objective C.

David Menestrina dmenest-vlc at ofb.net
Tue May 11 00:32:04 CEST 2010


---
 projects/mozilla/Makefile.am |   15 +++++++---
 projects/mozilla/coreanim.h  |   40 ++++++++++++++++++++++++++++
 projects/mozilla/coreanim.m  |   60 ++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 111 insertions(+), 4 deletions(-)
 create mode 100644 projects/mozilla/coreanim.h
 create mode 100644 projects/mozilla/coreanim.m

diff --git a/projects/mozilla/Makefile.am b/projects/mozilla/Makefile.am
index 230b720..b7b2874 100644
--- a/projects/mozilla/Makefile.am
+++ b/projects/mozilla/Makefile.am
@@ -2,6 +2,11 @@
 # Building the Mozilla plugin
 ###############################################################################
 
+# Automake forgets to add a proper tag to libtool with Objective-C files.
+# Moreover Libtool should default tag to CC when none is specified but
+# obviously does not. Here is a fix for that.
+LIBTOOL=@LIBTOOL@ --tag=CC
+
 MOSTLYCLEANFILES = 
 CLEANFILES = $(BUILT_SOURCES)
 EXTRA_DIST = $(DIST_sources) npvlc_rc.rc.in COPYING npvlc.dll.manifest
@@ -19,7 +24,7 @@ SOURCES_mozilla_common = \
 	support/classinfo.h
 
 DIST_sources = $(SOURCES_mozilla_common) \
-	support/npwin.cpp support/npmac.cpp support/npunix.c
+	support/npwin.cpp support/npmac.cpp support/npunix.c coreanim.m coreanim.h
 
 if BUILD_MOZILLA
 
@@ -62,18 +67,20 @@ if HAVE_DARWIN
 
 lib_LTLIBRARIES = npvlc.la
 
-SOURCES_support = support/npmac.cpp
+SOURCES_support = support/npmac.cpp coreanim.m
 CPPFLAGS_mozilla_EXTRA = -I. -I$(top_builddir) -I$(srcdir)/../include -c \
 	-F/System/Library/Frameworks/CoreFoundation.framework $(moz_CFLAGS) \
 	-I/Developer/Headers/FlatCarbon -fno-common -fpascal-strings \
 	-Wmost -Wno-four-char-constants -Wno-unknown-pragmas -DXP_MACOSX=1 \
-	-DNO_X11=1 -DUSE_SYSTEM_CONSOLE=1 -pipe -fmessage-length=0 
+	-DNO_X11=1 -DUSE_SYSTEM_CONSOLE=1 -pipe -fmessage-length=0
+OBJCFLAGS_mozilla_EXTRA = $(CPPFLAGS_mozilla_EXTRA)
 LDFLAGS_mozilla_EXTRA = -no-undefined -bundle -Wl,-read_only_relocs -Wl,suppress \
-	-Wl,-headerpad_max_install_names -shrext $(LIBEXT) -Wl,-framework,Carbon -Wl,-framework,System
+	-Wl,-headerpad_max_install_names -shrext $(LIBEXT) -Wl,-framework,Carbon -Wl,-framework,System -Wl,-framework,Cocoa -Wl,-framework,QuartzCore
 
 npvlc_la_SOURCES = $(SOURCES_mozilla_common) $(SOURCES_support)
 npvlc_la_CFLAGS = `$(VLC_CONFIG) --cflags mozilla` $(CPPFLAGS_mozilla_EXTRA)
 npvlc_la_CXXFLAGS = `$(VLC_CONFIG) --cxxflags mozilla` $(CPPFLAGS_mozilla_EXTRA) 
+npvlc_la_OBJCFLAGS = `$(VLC_CONFIG) --objcflags mozilla` $(OBJCFLAGS_mozilla_extra)
 npvlc_la_DEPENDENCIES = $(LIBRARIES_libvlc)
 npvlc_la_LDFLAGS = `$(VLC_CONFIG) --ldflags mozilla` -module -avoid-version \
 				   $(LDFLAGS_mozilla_EXTRA)
diff --git a/projects/mozilla/coreanim.h b/projects/mozilla/coreanim.h
new file mode 100644
index 0000000..00737b9
--- /dev/null
+++ b/projects/mozilla/coreanim.h
@@ -0,0 +1,40 @@
+/*****************************************************************************
+ * coreanim.h:
+ *****************************************************************************
+ * Copyright (C) 2010 Veetle, Inc.
+ * $Id$
+ *
+ * Authors: David Menestrina <dmenest-vlc at ofb.net>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
+ *****************************************************************************/
+
+#ifndef __VLCPLUGIN_COREANIM_H__
+#define __VLCPLUGIN_COREANIM_H__
+
+typedef struct coreanim_instance_t coreanim_instance_t;
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+coreanim_instance_t *coreanim_init();
+void *coreanim_get_calayer(coreanim_instance_t *inst);
+void coreanim_destroy(coreanim_instance_t *inst);
+#ifdef __cplusplus
+}
+#endif
+
+#endif // __VLCPLUGIN_COREANIM_H__
diff --git a/projects/mozilla/coreanim.m b/projects/mozilla/coreanim.m
new file mode 100644
index 0000000..acbe849
--- /dev/null
+++ b/projects/mozilla/coreanim.m
@@ -0,0 +1,60 @@
+/*****************************************************************************
+ * coreanim.m:
+ *****************************************************************************
+ * Copyright (C) 2010 Veetle, Inc.
+ * $Id$
+ *
+ * Authors: David Menestrina <dmenest-vlc at ofb.net>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
+ *****************************************************************************/
+
+#import <Cocoa/Cocoa.h>
+#import <QuartzCore/QuartzCore.h>
+#include "coreanim.h"
+
+struct coreanim_instance_t {
+    CALayer *browserLayer;
+};
+
+coreanim_instance_t *coreanim_init()
+{
+    coreanim_instance_t *inst = calloc(1, sizeof(coreanim_instance_t));
+
+    [CATransaction begin];
+
+    inst->browserLayer = [[CALayer layer] retain];
+    inst->browserLayer.layoutManager=[CAConstraintLayoutManager layoutManager];
+    inst->browserLayer.backgroundColor = CGColorGetConstantColor(kCGColorBlack);
+
+    [CATransaction commit];
+
+    return inst;
+}
+
+void coreanim_destroy(coreanim_instance_t *inst)
+{
+    if( inst )
+    {
+        [inst->browserLayer release];
+
+        free(inst);
+    }
+}
+
+void *coreanim_get_calayer(coreanim_instance_t *inst)
+{
+    return inst->browserLayer;
+}
-- 
1.7.0.3




More information about the vlc-devel mailing list