Skip to content
This repository has been archived by the owner on Feb 8, 2018. It is now read-only.

Commit

Permalink
[OSX] Implement the initial PAL backend for native rendering on OSX
Browse files Browse the repository at this point in the history
This is a young implementation of the PAL backend for Moonlight.
It can render animations, text, probably transforms if built will gallium
support.  Mouse events are fully hooked up, the keyboard is about 80%
done.  Check README.darwin for a rough TODO list and instructions
on how to get things started.
  • Loading branch information
Geoff Norton committed Nov 4, 2010
1 parent 4b50058 commit 056fbf0
Show file tree
Hide file tree
Showing 64 changed files with 2,458 additions and 164 deletions.
5 changes: 4 additions & 1 deletion Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,10 @@ endif

#if !PLUGIN_INSTALL
if INCLUDE_DESKTOP_MANAGED_CODE
MONO_SUBDIRS += gtk man data
MONO_SUBDIRS += man data
if GTK_PAL
MONO_SUBDIRS += gtk
endif
if INCLUDE_EXAMPLES
MONO_EXAMPLES = examples
endif
Expand Down
30 changes: 30 additions & 0 deletions README.darwin
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
You must have cairo 1.10 from macport currently.

sudo /opt/local/bin/port install cairo +quartz

You can then make a moon/mono/mono-basic parallel checkout and run with:

PATH=/opt/local/bin/:$PATH ./autogen.sh --prefix=/opt/darwoon --with-pal=cocoa --with-curl=system --host=i386-apple-darwin10 --with-cairo=system CFLAGS="-arch i386" CXXFLAGS="-arch i386" LDFLAGS="-arch i386"

You need to symlink /opt/darwoon/lib/moonlight/plugin/libmoonplugin.dylib -> /opt/darwoon/lib/moonlight/plugin/libmoon.dylib

To run the hacked up lunar-launcher use something like this:

DYLD_FALLBACK_LIBRARY_PATH=/opt/darwoon/lib/moonlight/plugin/ DYLD_INSERT_LIBRARIES=/usr/lib/libiconv.dylib MOON_TRACE=E:all MOONLIGHT_DEBUG=deployment /opt/darwoon/lib/moonlight/plugin/lunar-launcher 1

Put an xap in /tmp/Application.xap

TODO:
1> Subclass NSWindow to properly deliver window realized, resize, et all events
2> Figure out why Invalidate is upside down on the MoonNSView
3> Figure out a proper idle loop
4> Implement mouse events
5> Implement keyboard events
6> Add AppKit and iconv linkage
7> Figure out how [DllImport ("moon")] when running in lunarlauncher doesn't load both shared libs
8> Where or where have my debug syms gone?

LONG TERM TODO:
1> Figure out a proper API for public consumption in monomac
2> Native font backend
3> Plugin?
2 changes: 1 addition & 1 deletion autogen.sh
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ fi

if test -d $srcdir/cairo; then
echo Running cairo/autogen.sh ...
pixmandir=`readlink -f $0`
pixmandir=`readlink -n $0`
pixmandir=`dirname $pixmandir`/pixman

old_pkg=$PKG_CONFIG_PATH
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype"><value>text/microsoft-resx</value></resheader><resheader name="version"><value>1.3</value></resheader><resheader name="reader"><value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value></resheader><resheader name="writer"><value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value></resheader><data name="ListBox_OnItemContainerStyleChanged_CanNotSetStyle"><value>FrameworkElement.Style property can be set only one time.</value></data>
<resheader name="resmimetype"><value>text/microsoft-resx</value></resheader><resheader name="version"><value>1.3</value></resheader><resheader name="reader"><value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value></resheader><resheader name="writer"><value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value></resheader><data name="ListBox_OnItemContainerStyleChanged_CanNotSetStyle"><value>FrameworkElement.Style property can be set only one time.</value></data>
<data name="ToolTipService_SetTimeoutProperty_InvalidValue"><value>Value must be positive.</value></data>
<data name="ScrollViewer_OnReadOnlyDependencyPropertyChanged_ReadOnly"><value>Unable to set a read-only DependencyProperty.</value></data>
<data name="ContentPresenter_OnApplyTemplate_WriteOnce"><value>The template can only be applied one time.</value></data>
Expand Down
20 changes: 10 additions & 10 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ AM_MAINTAINER_MODE

AC_SUBST([ACLOCAL_AMFLAGS], ["-I m4 \${ACLOCAL_FLAGS}"])

AC_PROG_OBJC
AC_PROG_OBJCXX
AC_PROG_CXX
AC_HEADER_STDC
AC_DISABLE_STATIC
Expand All @@ -22,7 +24,7 @@ AC_DEFINE(__STDC_CONSTANT_MACROS, [], [To make avformat work with C++])
AC_DEFINE(__STDC_LIMIT_MACROS, [], [To get limits of specified-width integer types])

AC_SEARCH_LIBS(clock_gettime,rt)
AC_CHECK_HEADERS(sys/time.h)
AC_CHECK_HEADERS(sys/time.h malloc.h)

dnl ********************************************************
dnl *** libiberty.h (included by demangle.h) will define ***
Expand All @@ -40,6 +42,8 @@ changequote(,)dnl
dnl LIBTOOL="${LIBTOOL} \$(shell echo \"\$(MFLAGS)\" | awk '/^[^ ]*s/ { print \"--silent\" }')"
changequote([,])dnl

AC_CHECK_FUNC([sigisemptyset])

dnl
dnl Dependencies
dnl
Expand All @@ -50,15 +54,12 @@ MOONLIGHT_CHECK_LARGE_FILE
MOONLIGHT_CHECK_ZLIB
MOONLIGHT_CHECK_EXPAT

MOONLIGHT_CHECK_PAL

MOONLIGHT_CHECK_FFMPEG
MOONLIGHT_CHECK_CODECS
MOONLIGHT_CHECK_SOUND

MOONLIGHT_CHECK_GLIB
MOONLIGHT_CHECK_DBUS
MOONLIGHT_CHECK_GTK
MOONLIGHT_CHECK_XRANDR
MOONLIGHT_CHECK_FONTS
MOONLIGHT_CHECK_CAIRO
MOONLIGHT_CHECK_LLVM
MOONLIGHT_CHECK_GALLIUM
Expand All @@ -77,8 +78,6 @@ MOONLIGHT_CHECK_CHROME_CRX

MOONLIGHT_CHECK_UNWIND

MOONLIGHT_CHECK_PAL

dnl
dnl The silverlight TargetRuntime versions we claim to support

Expand Down Expand Up @@ -110,9 +109,9 @@ AC_SUBST(PERF_TOOL_LIBS)

MONO_LIBS="-lmono-2.0 -L$MONO_PATH/mono/mini -L$MONO_PATH/mono/mini/.libs"
MONO_STATIC_LIBS="$MONO_PATH/mono/mini/libmono-moon.la"
MOON_CFLAGS="$CAIRO_CFLAGS $FREETYPE2_CFLAGS $FONTCONFIG_CFLAGS $GTK_CFLAGS $ALSA_CFLAGS $PULSEAUDIO_CFLAGS $FFMPEG_CFLAGS $MONO_CFLAGS $DBUS_CFLAGS $CURL_CFLAGS"
MOON_CFLAGS="$GLIB_CFLAGS $CAIRO_CFLAGS $FREETYPE2_CFLAGS $FONTCONFIG_CFLAGS $GTK_CFLAGS $ALSA_CFLAGS $PULSEAUDIO_CFLAGS $FFMPEG_CFLAGS $MONO_CFLAGS $DBUS_CFLAGS $CURL_CFLAGS"
dnl MOON_LIBS is partially defined above for the user-plugin build
MOON_LIBS="$MOON_LIBS $FFMPEG_LIBS $CAIRO_LIBS $FREETYPE2_LIBS $FONTCONFIG_LIBS $GTK_LIBS $ZLIB $PTHREAD_LIBS $EXPAT_LIBS $UNWIND_LIBS $DBUS_LIBS $CURL_LIBS"
MOON_LIBS="$MOON_LIBS $GLIB_LIBS $FFMPEG_LIBS $CAIRO_LIBS $FREETYPE2_LIBS $FONTCONFIG_LIBS $GTK_LIBS $ZLIB $PTHREAD_LIBS $EXPAT_LIBS $UNWIND_LIBS $DBUS_LIBS $CURL_LIBS"

dnl For MOON_XPI_LIBS, only link against libs which will be on all systems
MOON_XPI_LIBS="$CAIRO_LIBS $FREETYPE2_LIBS $FONTCONFIG_LIBS $GTK_LIBS $ZLIB $PTHREAD_LIBS $EXPAT_LIBS"
Expand Down Expand Up @@ -166,6 +165,7 @@ moon.pc
moonlight.spec
Makefile
m4/Makefile
generators/Generator.cs
src/Makefile
src/codec-version.h
runtime/Makefile
Expand Down
4 changes: 3 additions & 1 deletion examples/Makefile.am
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
SUBDIRS = desklet
if GTK_PAL
SUBDIRS = desklet
endif
13 changes: 8 additions & 5 deletions generators/Generator.cs → generators/Generator.cs.in
Original file line number Diff line number Diff line change
Expand Up @@ -1346,15 +1346,15 @@ static GlobalInfo GetTypes2 ()
string srcdir = Path.Combine (Environment.CurrentDirectory, "src");
string plugindir = Path.Combine (Environment.CurrentDirectory, "plugin");
string paldir = Path.Combine (srcdir, "pal");
string palgtkdir = Path.Combine (paldir, "gtk");
string pal@PAL@dir = Path.Combine (paldir, "@PAL@");
List<string> all_files = new List<string> ();

all_files.AddRange (Directory.GetFiles (srcdir, "*.h"));
all_files.AddRange (Directory.GetFiles (plugindir, "*.h"));
all_files.AddRange (Directory.GetFiles (paldir, "*.h"));
all_files.AddRange (Directory.GetFiles (palgtkdir, "*.h"));
all_files.AddRange (Directory.GetFiles (pal@PAL@dir, "*.h"));

RemoveExcludedSrcFiles (srcdir, plugindir, paldir, all_files);
RemoveExcludedSrcFiles (srcdir, plugindir, paldir, pal@PAL@dir, all_files);

Tokenizer tokenizer = new Tokenizer (all_files.ToArray ());
GlobalInfo all = new GlobalInfo ();
Expand Down Expand Up @@ -2208,7 +2208,7 @@ private static void GenerateCBindings (GlobalInfo info, string dir)
header.AppendLine ("#include <cairo.h>");
header.AppendLine ();
header.AppendLine ("#include \"pal.h\"");
header.AppendLine ("#include \"pal/gtk/window-gtk.h\"");
header.AppendLine ("#include \"pal/@PAL@/window-@PAL@.h\"");
header.AppendLine ("#include \"enums.h\"");
header.AppendLine ();
header.AppendLine ("namespace Moonlight {");
Expand Down Expand Up @@ -3170,13 +3170,16 @@ static void WritePInvokeMethod (string NativeMethods_cs, MethodInfo method, Stri
}


static void RemoveExcludedSrcFiles (string srcdir, string plugindir, string paldir, List<string> files)
static void RemoveExcludedSrcFiles (string srcdir, string plugindir, string paldir, string pal@PAL@dir, List<string> files)
{
files.Remove (Path.Combine (srcdir, "authors.h"));
files.Remove (Path.Combine (srcdir, "cbinding.h"));
files.Remove (Path.Combine (srcdir, "factory.h"));
files.Remove (Path.Combine (srcdir, "ptr.h"));
files.Remove (Path.Combine (plugindir, "plugin-domevents.h"));
files.Remove (Path.Combine (pal@PAL@dir, "MLView.h"));
files.Remove (Path.Combine (pal@PAL@dir, "MLEvent.h"));
files.Remove (Path.Combine (pal@PAL@dir, "MLTimer.h"));
}

}
76 changes: 39 additions & 37 deletions m4/firefox-xpi.m4
Original file line number Diff line number Diff line change
Expand Up @@ -12,41 +12,43 @@ AC_DEFUN([MOONLIGHT_CHECK_FIREFOX_XPI],
AM_CONDITIONAL(PLUGIN_INSTALL, [test x$user_plugin = xyes])
case "$target_os" in
*linux*)
TARGET_PLATFORM="Linux"
;;
*)
AC_MSG_ERROR([Target os $target_os is unknown.
Please add the appropriate string to configure.ac.
See http://developer.mozilla.org/en/docs/OS_TARGET])
;;
esac
case "$target_cpu" in
i*86)
TARGET_PLATFORM="$TARGET_PLATFORM"_x86-gcc3
INSTALL_ARCH=i586
;;
x86_64)
TARGET_PLATFORM="$TARGET_PLATFORM"_x86_64-gcc3
INSTALL_ARCH=x86_64
;;
powerpc)
TARGET_PLATFORM="$TARGET_PLATFORM"_ppc-gcc3
INSTALL_ARCH=ppc
;;
sparc64)
TARGET_PLATFORM="$TARGET_PLATFORM"_sparc64-gcc3
INSTALL_ARCH=sparc
;;
*)
AC_MSG_ERROR([Target cpu $target_cpu is unknown.
Please add the appropriate string to configure.ac.
See http://developer.mozilla.org/en/docs/XPCOM_ABI])
;;
esac
AC_SUBST(TARGET_PLATFORM)
AC_SUBST(INSTALL_ARCH)
if test x$user_plugin = "xyes"; then
case "$target_os" in
*linux*)
TARGET_PLATFORM="Linux"
;;
*)
AC_MSG_ERROR([Target os $target_os is unknown.
Please add the appropriate string to configure.ac.
See http://developer.mozilla.org/en/docs/OS_TARGET])
;;
esac
case "$target_cpu" in
i*86)
TARGET_PLATFORM="$TARGET_PLATFORM"_x86-gcc3
INSTALL_ARCH=i586
;;
x86_64)
TARGET_PLATFORM="$TARGET_PLATFORM"_x86_64-gcc3
INSTALL_ARCH=x86_64
;;
powerpc)
TARGET_PLATFORM="$TARGET_PLATFORM"_ppc-gcc3
INSTALL_ARCH=ppc
;;
sparc64)
TARGET_PLATFORM="$TARGET_PLATFORM"_sparc64-gcc3
INSTALL_ARCH=sparc
;;
*)
AC_MSG_ERROR([Target cpu $target_cpu is unknown.
Please add the appropriate string to configure.ac.
See http://developer.mozilla.org/en/docs/XPCOM_ABI])
;;
esac
AC_SUBST(TARGET_PLATFORM)
AC_SUBST(INSTALL_ARCH)
fi
])
35 changes: 20 additions & 15 deletions m4/mono.m4
Original file line number Diff line number Diff line change
Expand Up @@ -54,22 +54,27 @@ AC_DEFUN([MOONLIGHT_CHECK_MONO],
MOON_ARG_ENABLED_BY_DEFAULT([desktop-support], [Disable support for Moonlight-based desktop applications])
desktop_support=$enableval
if test "x$desktop_support" = xyes; then
PKG_CHECK_MODULES(GTKSHARP, gtk-sharp-2.0)
PKG_CHECK_MODULES(WNCKSHARP, wnck-sharp-1.0)
rsvg_sharp_pcs="rsvg-sharp-2.0 rsvg2-sharp-2.0"
for pc in $rsvg_sharp_pcs; do
PKG_CHECK_EXISTS($pc, [rsvg_sharp=$pc])
done
PKG_CHECK_MODULES(RSVGSHARP, $rsvg_sharp, [
RSVG_SHARP=$rsvg_sharp
AC_SUBST(RSVG_SHARP)
AM_CONDITIONAL(HAVE_RSVG_SHARP, true)
], [
if test "x$with_pal" = "xgtk"; then
PKG_CHECK_MODULES(GTKSHARP, gtk-sharp-2.0)
PKG_CHECK_MODULES(WNCKSHARP, wnck-sharp-1.0)
rsvg_sharp_pcs="rsvg-sharp-2.0 rsvg2-sharp-2.0"
for pc in $rsvg_sharp_pcs; do
PKG_CHECK_EXISTS($pc, [rsvg_sharp=$pc])
done
PKG_CHECK_MODULES(RSVGSHARP, $rsvg_sharp, [
RSVG_SHARP=$rsvg_sharp
AC_SUBST(RSVG_SHARP)
AM_CONDITIONAL(HAVE_RSVG_SHARP, true)
], [
AM_CONDITIONAL(HAVE_RSVG_SHARP, false)
])
elif test "x$with_pal" = "xcocoa"; then
dnl FIXME
AM_CONDITIONAL(HAVE_RSVG_SHARP, false)
])
fi
else
AM_CONDITIONAL(HAVE_RSVG_SHARP, false)
fi
Expand Down
65 changes: 54 additions & 11 deletions m4/pal.m4
Original file line number Diff line number Diff line change
@@ -1,27 +1,70 @@
AC_DEFUN([MOONLIGHT_CHECK_PAL],
[
dnl
dnl eventually we need to replace all this with platform and/or --enable checks, but for now...
dnl
AC_ARG_WITH([pal],[ --with-pal=gtk|cocoa Specify which PAL to build (defaults to gtk)], [], [with_pal=gtk])
if test "x$with_pal" = "x"; then
AC_MSG_ERROR([unknown PAL specified])
elif test "x$with_pal" = "xgtk"; then
AC_DEFINE([PAL_GTK_WINDOWING],1,[Hack in support for the pal-gtk so we can start using it.])
pal_windowing="gtk (hardcoded)"
pal_windowing="gtk"
AC_DEFINE([PAL_GLIB_MESSAGING],1,[Hack in support for the pal-glib so we can start using it.])
pal_messaging="glib+unix (hardcoded)"
pal_messaging="glib+unix"
AC_DEFINE([PAL_LINUX_NETWORKAVAILABILITY],1,[Hack in support for the linux network container.])
pal_networking="linux (hardcoded)"
pal_networking="linux"
AC_DEFINE([PAL_DBUS_NETWORKAVAILABILITY],1,[Hack in support for the dbus-glib so we can start using it.])
pal_networking="$pal_networking dbus-glib (hardcoded)"
pal_networking="$pal_networking dbus-glib"
AC_DEFINE([PAL_LINUX_CAPTURE],1,[Hack in support for the linux capture container])
pal_capture="linux (hardcoded)"
pal_capture="linux"
AC_DEFINE([PAL_V4L2_VIDEO_CAPTURE],1,[Hack in support for pal-v4l2 so we can start using it.])
pal_video_capture="v4l2 (hardcoded)"
pal_video_capture="v4l2"
dnl AC_DEFINE([PAL_PULSE_AUDIO_CAPTURE],1,[Hack in support for pal-pulse so we can start using it.])
pal_audio_capture="none (hardcoded)"
])
pal_audio_capture="none"
PKG_CHECK_MODULES(GTK, gtk+-2.0 gthread-2.0 atk)
PKG_CHECK_MODULES(DBUS, dbus-1 dbus-glib-1)
PKG_CHECK_MODULES(XRANDR, xrandr, [
AC_DEFINE([USE_RANDR], [1],
[Include support for the XRANDR extension for querying a monitor's refresh rate])
], [xrandr_present=no])
PKG_CHECK_MODULES(FREETYPE2, freetype2)
PKG_CHECK_MODULES(FONTCONFIG, fontconfig)
PKG_CHECK_MODULES(GLIB, glib-2.0)
PAL=gtk
elif test "x$with_pal" = "xcocoa"; then
dnl We force parsing as objective-c++ since thats what we are, but automake doesn't understand .mm
OBJCFLAGS="-x objective-c++ $CFLAGS"
LDFLAGS="$LDFLAGS -liconv -framework AppKit"
AC_DEFINE([PAL_COCOA_WINDOWING],1,[Hack in support for the pal-cocoa so we can start using it.])
pal_windowing="cocoa"
AC_DEFINE([PAL_OSX_MESSAGING],1,[Hack in support for the pal-osx so we can start using it.])
pal_messaging="cocoa"
pal_networking="none"
pal_capture="none"
pal_video_capture="none"
pal_audio_capture="none"
dnl We need to flesh out eglib enough to drop this dep
PKG_CHECK_MODULES(GLIB, glib-2.0)
PAL=cocoa
fi
AM_CONDITIONAL(GTK_PAL, test x$with_pal = xgtk)
AM_CONDITIONAL(COCOA_PAL, test x$with_pal = xcocoa)
AC_SUBST([PAL])
])
Loading

0 comments on commit 056fbf0

Please sign in to comment.