Permalink
Browse files

Moonlight C runtime

svn path=/trunk/moon/; revision=77979
  • Loading branch information...
0 parents commit db8d080f3ac375552f9f6db48c0ff0f4fc57bffd @migueldeicaza migueldeicaza committed May 25, 2007
Showing with 1,550 additions and 0 deletions.
  1. +1 −0 AUTHORS
  2. +1 −0 COPYING
  3. 0 ChangeLog
  4. 0 INSTALL
  5. +8 −0 LICENSE
  6. +1 −0 Makefile.am
  7. 0 NEWS
  8. +121 −0 README
  9. +142 −0 autogen.sh
  10. +43 −0 configure.ac
  11. +22 −0 oMakefile
  12. 0 src/ChangeLog
  13. +14 −0 src/Makefile.am
  14. +101 −0 src/demo.c
  15. +442 −0 src/runtime.c
  16. +134 −0 src/runtime.h
  17. +398 −0 src/video.c
  18. +122 −0 src/video.cpp
@@ -0,0 +1 @@
+Miguel de Icaza, miguel@gnome.org
@@ -0,0 +1 @@
+See the file LICENSE for details
No changes.
No changes.
@@ -0,0 +1,8 @@
+This code is licensed under the terms of the GNU LGPL 2 license.
+
+In addition to the GNU LGPL, this code is available for relicensing
+for non-LGPL use, contact Novell for details (mono@novell.com)
+
+This code might contain code that optionally links to LGPL and
+GPL code, in those cases, if the library is built with those
+bits the code is covered under those licenses.
@@ -0,0 +1 @@
+SUBDIRS = src
0 NEWS
No changes.
121 README
@@ -0,0 +1,121 @@
+This contains a minimal runtime in C for trying out some ideas for the
+Moonlight binding. It is not designed to be our final implementation.
+
+The C++ file here was merely to test Agg, but the public API is pure C
+and without agg (which is currently disabled due to laziness on my
+part) it should build with a C compiler
+
+This is not likely the final version of this code.
+
+* Object System
+
+ This contains a poor man's object system.
+
+ The vtable is the first field in the base object (Item in
+ this case) and is encoded as a void *. You must cast this
+ to ItemVtable to be able to call methods. I do not remember
+ why I did not just go for the hardcoded ItemVtable there.
+
+ Should be fixed perhaps.
+
+ The various XXX_init() methods are here merely to initialize the
+ vtable: they should call into the parent, and then overwrite th
+ vtable if they need to.
+
+* Items
+
+ Items for the base class for all the objects that are rendered,
+ items contain a bounding box (double x1, y1, x2, y2) which must
+ be updated when the virtual method ->getbounds is called.
+
+ In addition each item can contain an affine transformation, the
+ affine transformation is relative. This means that the affine
+ is relative to the parent.
+
+ I chose relative vs absolute for the items as changing an affine
+ in the managed world for a parent would have to change all the
+ affines for all the children contained. With this approach,
+ we can change the affine for a parent, and all the children
+ will get the new affine transformation.
+
+ The encoding of the affine transformation is done with a
+ "double *" which, if not-NULL should point to six doubles in
+ the format expected by cairo_matrix_t (and libart).
+
+ The double [6] can be casted into a cairo_matrix_t, which is why
+ this appers like that in the source code. This was done in
+ case we want to switch to AGG.
+
+ A method to obtain the actual affine that applies to this object is:
+
+ double *item_get_affine (double *container, double *affine, double *result);
+
+ The "container" should be the affine passed by the parent, the "affine" is the
+ item affine (either one can be null) and the compound affine transform is
+ left in "result".
+
+ The "result" has to be allocated by the parent, if both container and affine
+ are null, the NULL value is returned from item_get_affine, so a common
+ code pattern used is:
+
+ double actual [6];
+ double *use_affine = item_get_affine (affine, item->xform, actual);
+
+ And then `use_affine' is used.
+
+* Rendering in Items
+
+ Rendering currently passes the parent affine, but it might be possible to
+ avoid this if we end up using Cairo: just use the affine that is part of
+ the cairo context at the time of the rendering.
+
+* Video
+
+ The video stuff is *incredibly* early at this point and
+ requires an FFmpeg installation from SVN (the only available
+ one).
+
+ The video also has a video hardcoded for now.
+
+ Currently this is very basic, it merely does video frame decoding, and
+ makes no attempt to keep track of the clock (as it should) nor to do any
+ kind of audio output (yet).
+
+ The video is also busted, I do not know why, but the "decoded"
+ video is incorrect, it has the wrong colors.
+
+ The caching is substandard and we create new surfaces when we do not need
+ to create them. We could create the RGB buffer and the
+ surface just once and reuse these.
+
+ We are using cairo_paint, which renders without an affine
+ transformation applied, which means that item_apply_transform
+ is a no-op, this is broken and must be fixed.
+
+* Rendering
+
+ Currently we are creating a bitmap surface and we always copy
+ it to the screen.
+
+ We probably should move to cairo surfaces directly.
+
+* Expose
+
+ Currently repaints happen with an item_invalidate, I need to
+ research if this clears the background before repainting.
+
+* Usage of C++
+
+ I do not know how to initialize instance fields in a structure
+ with the contructor, so there is code like this:
+
+ struct {
+ Agg2D *graphics;
+ }
+
+ Then:
+
+ something->graphics = new Agg2D ()
+
+ Followed by uses of graphics in that way, there is probably a
+ better way.
@@ -0,0 +1,142 @@
+#!/bin/sh
+# Run this to generate all the initial makefiles, etc.
+# Ripped off from GNOME macros version
+
+DIE=0
+
+srcdir=`dirname $0`
+test -z "$srcdir" && srcdir=.
+
+if [ -n "$MONO_PATH" ]; then
+ # from -> /mono/lib:/another/mono/lib
+ # to -> /mono /another/mono
+ for i in `echo ${MONO_PATH} | tr ":" " "`; do
+ i=`dirname ${i}`
+ if [ -n "{i}" -a -d "${i}/share/aclocal" ]; then
+ ACLOCAL_FLAGS="-I ${i}/share/aclocal $ACLOCAL_FLAGS"
+ fi
+ if [ -n "{i}" -a -d "${i}/bin" ]; then
+ PATH="${i}/bin:$PATH"
+ fi
+ done
+ export PATH
+fi
+
+(autoconf --version) < /dev/null > /dev/null 2>&1 || {
+ echo
+ echo "**Error**: You must have \`autoconf' installed to compile Mono."
+ echo "Download the appropriate package for your distribution,"
+ echo "or get the source tarball at ftp://ftp.gnu.org/pub/gnu/"
+ DIE=1
+}
+
+if [ -z "$LIBTOOL" ]; then
+ LIBTOOL=`which glibtool 2>/dev/null`
+ if [ ! -x "$LIBTOOL" ]; then
+ LIBTOOL=`which libtool`
+ fi
+fi
+
+(grep "^AM_PROG_LIBTOOL" $srcdir/configure.ac >/dev/null) && {
+ ($LIBTOOL --version) < /dev/null > /dev/null 2>&1 || {
+ echo
+ echo "**Error**: You must have \`libtool' installed to compile Mono."
+ echo "Get ftp://ftp.gnu.org/pub/gnu/libtool-1.2d.tar.gz"
+ echo "(or a newer version if it is available)"
+ DIE=1
+ }
+}
+
+grep "^AM_GNU_GETTEXT" $srcdir/configure.ac >/dev/null && {
+ grep "sed.*POTFILES" $srcdir/configure.ac >/dev/null || \
+ (gettext --version) < /dev/null > /dev/null 2>&1 || {
+ echo
+ echo "**Error**: You must have \`gettext' installed to compile Mono."
+ echo "Get ftp://alpha.gnu.org/gnu/gettext-0.10.35.tar.gz"
+ echo "(or a newer version if it is available)"
+ DIE=1
+ }
+}
+
+(automake --version) < /dev/null > /dev/null 2>&1 || {
+ echo
+ echo "**Error**: You must have \`automake' installed to compile Mono."
+ echo "Get ftp://ftp.gnu.org/pub/gnu/automake-1.3.tar.gz"
+ echo "(or a newer version if it is available)"
+ DIE=1
+ NO_AUTOMAKE=yes
+}
+
+
+# if no automake, don't bother testing for aclocal
+test -n "$NO_AUTOMAKE" || (aclocal --version) < /dev/null > /dev/null 2>&1 || {
+ echo
+ echo "**Error**: Missing \`aclocal'. The version of \`automake'"
+ echo "installed doesn't appear recent enough."
+ echo "Get ftp://ftp.gnu.org/pub/gnu/automake-1.3.tar.gz"
+ echo "(or a newer version if it is available)"
+ DIE=1
+}
+
+if test "$DIE" -eq 1; then
+ exit 1
+fi
+
+if test -z "$*"; then
+ echo "**Warning**: I am going to run \`configure' with no arguments."
+ echo "If you wish to pass any to it, please specify them on the"
+ echo \`$0\'" command line."
+ echo
+fi
+
+case $CC in
+xlc )
+ am_opt=--include-deps;;
+esac
+
+
+if grep "^AM_PROG_LIBTOOL" configure.ac >/dev/null; then
+ if test -z "$NO_LIBTOOLIZE" ; then
+ echo "Running libtoolize..."
+ ${LIBTOOL}ize --force --copy
+ fi
+fi
+
+echo "Running aclocal $ACLOCAL_FLAGS ..."
+aclocal $ACLOCAL_FLAGS || {
+ echo
+ echo "**Error**: aclocal failed. This may mean that you have not"
+ echo "installed all of the packages you need, or you may need to"
+ echo "set ACLOCAL_FLAGS to include \"-I \$prefix/share/aclocal\""
+ echo "for the prefix where you installed the packages whose"
+ echo "macros were not found"
+ exit 1
+}
+
+if grep "^AM_CONFIG_HEADER" configure.ac >/dev/null; then
+ echo "Running autoheader..."
+ autoheader || { echo "**Error**: autoheader failed."; exit 1; }
+fi
+
+echo "Running automake --gnu $am_opt ..."
+automake --add-missing --gnu $am_opt ||
+ { echo "**Error**: automake failed."; exit 1; }
+echo "Running autoconf ..."
+autoconf || { echo "**Error**: autoconf failed."; exit 1; }
+
+if test -d $srcdir/libgc; then
+ echo Running libgc/autogen.sh ...
+ (cd $srcdir/libgc ; NOCONFIGURE=1 ./autogen.sh "$@")
+ echo Done running libgc/autogen.sh ...
+fi
+
+
+conf_flags="--enable-maintainer-mode --enable-compile-warnings" #--enable-iso-c
+
+if test x$NOCONFIGURE = x; then
+ echo Running $srcdir/configure $conf_flags "$@" ...
+ $srcdir/configure $conf_flags "$@" \
+ && echo Now type \`make\' to compile $PKG_NAME || exit 1
+else
+ echo Skipping configure process.
+fi
@@ -0,0 +1,43 @@
+AC_INIT(README)
+AC_CANONICAL_SYSTEM
+
+AM_CONFIG_HEADER(config.h)
+AM_INIT_AUTOMAKE(moon,0.1)
+AM_MAINTAINER_MODE
+AC_PROG_CXX
+AC_HEADER_STDC
+AC_DISABLE_STATIC
+AC_PROG_LIBTOOL
+
+LIBS_TO_CHECK="gtk+-2.0 libavcodec libavformat gthread-2.0 libswscale"
+
+if pkg-config gtk+-2.0; then
+ echo Gtk+ 2.0 found
+else
+ echo Gtk+ 2.0 development kit is missing
+ exit 1
+fi
+
+#
+# these come from ffmpeg
+#
+if pkg-config libavcodec libavformat libswscale ; then
+ echo ffmpeg developer installation found
+else
+ echo ffmpeg and its associated libraries are not installed
+ echo You need libavcodec, libavformat and libswscale development kits
+ exit 1
+fi
+
+CFLAGS="$CFLAGS `pkg-config --cflags gtk+-2.0 libavcodec libavformat gthread-2.0 libswscale`"
+CXXFLAGS="$CXXFLAGS `pkg-config --cflags gtk+-2.0 libavcodec libavformat gthread-2.0 libswscale`"
+LIBS="$LIBS `pkg-config --libs gtk+-2.0 libavcodec libavformat gthread-2.0 libswscale`"
+
+AC_SUBST(CFLAGS)
+AC_SUBST(CXXFLAGS)
+AC_SUBST(LIBS)
+
+AC_OUTPUT([
+Makefile
+src/Makefile
+])
@@ -0,0 +1,22 @@
+SOURCES = runtime.cpp
+OBJS = runtime.o video.o
+
+HEADERS=`pkg-config --libs gtk+-2.0 libagg libavcodec libavformat gthread-2.0 libswscale`
+LIBS=`pkg-config --cflags gtk+-2.0 libavcodec libavformat gthread-2.0 libswscale freetype2`
+
+CXX=c++ -Wall
+
+demo: runtime.o video.o
+ $(CXX) -g -o demo $(OBJS) $(HEADERS)
+
+demoagg: runtime.o video.o Agg2D.o
+ $(CXX) -g -o demo $(OBJS) $(HEADERS) -laggfontfreetype `pkg-config --libs libagg`
+
+runtime.o: runtime.cpp runtime.h Agg2D.h
+ $(CXX) -g -c runtime.cpp $(LIBS)
+
+video.o: video.c runtime.h Agg2D.h
+ $(CC) -g -c video.c $(LIBS)
+
+Agg2D.o: Agg2D.h Agg2D.cpp
+ $(CXX) -g -c Agg2D.cpp `pkg-config --cflags libagg freetype2`
No changes.
@@ -0,0 +1,14 @@
+bin_PROGRAMS = demo
+
+lib_LTLIBRARIES = libmoon.la
+
+libmoon_la_SOURCES = \
+ runtime.c \
+ runtime.h \
+ video.c \
+ video.h
+
+demo_SOURCES = \
+ demo.c
+
+demo_LDADD = -lmoon
Oops, something went wrong.

0 comments on commit db8d080

Please sign in to comment.