tim horton's quartz engine for evas.

SVN revision: 36107
This commit is contained in:
Carsten Haitzler 2008-09-20 02:03:22 +00:00
parent ddc956b313
commit fab81faa86
13 changed files with 1849 additions and 5 deletions

View File

@ -13,3 +13,4 @@ Jorge Luis Zapata Muga <jorgeluis.zapata@gmail.com>
Cedric Bail <cedric.bail@free.fr>
Gustavo Sverzut Barbieri <barbieri@gmail.com>
Vincent Torri <vtorri at univ-evry dot fr>
Tim Horton <hortont424@gmail.com>

View File

@ -27,6 +27,7 @@ evas-fb.pc \
evas-glitz-x11.pc \
evas-opengl-x11.pc \
evas-opengl-glew.pc \
evas-quartz.pc \
evas-software-buffer.pc \
evas-software-qtopia.pc \
evas-software-x11.pc \
@ -112,6 +113,10 @@ if BUILD_ENGINE_GL_X11
popenglx11 = evas-opengl-x11.pc
endif
if BUILD_ENGINE_QUARTZ
pquartz = evas-quartz.pc
endif
if BUILD_ENGINE_GL_GLEW
popenglglew = evas-opengl-glew.pc
endif
@ -151,6 +156,6 @@ endif
pkgconfigdir = $(libdir)/pkgconfig
pkgconfig_DATA = \
evas.pc $(psoftwarex11) $(psoftwarexcb) $(pdirectfb) $(pfb) \
$(psoftwarebuffer) $(psoftwareqtopia) $(popenglx11) $(pcairox11) \
$(psoftwarebuffer) $(psoftwareqtopia) $(popenglx11) $(pquartz) $(pcairox11) \
$(pxrenderx11) $(pxrenderxcb) $(pglitzx11) $(psoftwareddraw) $(psoftwaresdl) \
$(psoftware16x11) $(pdirect3d) $(psoftware16ddraw) $(psoftware16wince) $(popenglglew)

View File

@ -595,6 +595,36 @@ if test "x$want_evas_gl_x11" = "xyes"; then
fi
AM_CONDITIONAL(BUILD_ENGINE_GL_X11, test "x$have_evas_gl_x11" = "xyes")
#######################################
## Check if we should build the quartz engine
## FIXME: someone more experienced with Autotools-on-OSX: how do Frameworks work with AC_CHECK_HEADERS?
## I want this to detect Cocoa/Cocoa.h, but it's not in the normal include path.
want_evas_quartz="no";
have_evas_quartz="no";
AC_MSG_CHECKING(whether quartz backend is to be built)
AC_ARG_ENABLE(quartz,
AC_HELP_STRING([--enable-quartz], [enable the Quartz display engine]),
[ want_evas_quartz=$enableval ]
)
AC_MSG_RESULT($want_evas_quartz)
if test "x$want_evas_quartz" = "xyes"; then
AC_PATH_X
AC_PATH_XTRA
AC_CHECK_HEADERS(/System/Library/Frameworks/Cocoa.framework/Headers/Cocoa.h,
[
have_evas_quartz="yes"
],
[
if test "x$want_evas_quartz" = "xyes" -a "x$use_strict" = "xyes" ; then
AC_MSG_ERROR([Quartz not found (strict dependencies checking)])
fi
]
)
fi
AM_CONDITIONAL(BUILD_ENGINE_QUARTZ, test "x$have_evas_quartz" = "xyes")
#######################################
## Check if we should build the gl_glew engine
want_evas_gl_glew="no";
@ -1684,6 +1714,9 @@ AC_SUBST(x_libs)
AC_SUBST(gl_cflags)
AC_SUBST(gl_libs)
AC_SUBST(quartz_cflags)
AC_SUBST(quartz_libs)
AC_SUBST(qt_cflags)
AC_SUBST(qt_libs)
AC_SUBST(qt_moc)
@ -1715,6 +1748,7 @@ evas-fb.pc
evas-glitz-x11.pc
evas-opengl-glew.pc
evas-opengl-x11.pc
evas-quartz.pc
evas-software-buffer.pc
evas-software-qtopia.pc
evas-software-x11.pc
@ -1760,6 +1794,7 @@ src/modules/engines/directfb/Makefile
src/modules/engines/gl_common/Makefile
src/modules/engines/gl_glew/Makefile
src/modules/engines/gl_x11/Makefile
src/modules/engines/quartz/Makefile
src/modules/engines/cairo_common/Makefile
src/modules/engines/cairo_x11/Makefile
src/modules/engines/xrender_x11/Makefile
@ -1814,6 +1849,7 @@ echo " Software XCB...............: $have_evas_software_xcb"
echo " XRender XCB................: $have_evas_xrender_xcb"
echo " Software DirectDraw........: $have_evas_software_ddraw"
echo " Direct3d...................: $have_evas_direct3d"
echo " Quartz.....................: $have_evas_quartz"
echo " OpenGL Glew................: $have_evas_gl_glew"
echo " Software SDL...............: $have_evas_sdl (primitive: $sdl_primitive)"
echo " Software Framebuffer.......: $have_evas_fb"

View File

@ -0,0 +1,3 @@
Name: evas-quartz
Description: Evas Quartz engine
Version: @VERSION@

View File

@ -19,6 +19,7 @@
%bcond_with module_saver_edb
%bcond_with module_engine_directfb
%bcond_with module_engine_gl_x11
%bcond_with module_engine_quartz
%bcond_with module_engine_software_qtopia
%bcond_with module_engine_software_sdl
%bcond_with module_engine_software_xcb
@ -67,6 +68,7 @@
%define ac_with_module_engine_fb --%{?with_module_engine_fb:en}%{!?with_module_engine_fb:dis}able-fb
%define ac_with_module_engine_xrender_x11 --%{?with_module_engine_xrender_x11:en}%{!?with_module_engine_xrender_x11:dis}able-xrender-x11
%define ac_with_module_engine_gl_x11 --%{?with_module_engine_gl_x11:en}%{!?with_module_engine_gl_x11:dis}able-gl-x11
%define ac_with_module_engine_quartz --%{?with_module_engine_quartz:en}%{!?with_module_engine_quartz:dis}able-quartz
%define ac_with_module_engine_directfb --%{?with_module_engine_directfb:en}%{!?with_module_engine_directfb:dis}able-directfb
%define ac_with_module_engine_software_qtopia --%{?with_module_engine_software_qtopia:en}%{!?with_module_engine_software_qtopia:dis}able-software-qtopia
%define ac_with_module_engine_software_sdl --%{?with_module_engine_software_sdl:en}%{!?with_module_engine_software_sdl:dis}able-sdl
@ -287,6 +289,16 @@ Requires: evas
OpenGL under X11 rendering engine module for Evas
%endif
%if %{with module_engine_quartz}
%package module_engine_quartz
Summary: Quartz rendering engine module for Evas
Group: System Environment/Libraries
#BuildSuggests:
Requires: evas
%description module_engine_quartz
Quartz rendering engine module for Evas
%endif
%if %{with module_engine_directfb}
%package module_engine_directfb
Summary: Directfb rendering engine module for Evas
@ -366,6 +378,7 @@ Xrender XCB X11 rendering engine module for Evas
%{?ac_with_module_engine_fb} \
%{?ac_with_module_engine_xrender_x11} \
%{?ac_with_module_engine_gl_x11} \
%{?ac_with_module_engine_quartz} \
%{?ac_with_module_engine_directfb} \
%{?ac_with_module_engine_software_qtopia} \
%{?ac_with_module_engine_software_sdl} \
@ -519,6 +532,12 @@ test "x$RPM_BUILD_ROOT" != "x/" && rm -rf $RPM_BUILD_ROOT
%{_libdir}/evas/modules/engines/gl_x11/*/module.so
%endif
%if %{with module_engine_quartz}
%files module_engine_quartz
%defattr(-, root, root)
%{_libdir}/evas/modules/engines/quartz/*/module.so
%endif
%if %{with module_engine_directfb}
%files module_engine_directfb
%defattr(-, root, root)

View File

@ -24,5 +24,6 @@ software_16_x11 \
direct3d \
software_16_ddraw \
software_16_wince \
software_16_sdl
software_16_sdl \
quartz

View File

@ -20,13 +20,18 @@
#include <sys/time.h>
#include <unistd.h>
#ifdef BUILD_ENGINE_GL_QUARTZ
#include <OpenGL/gl.h>
#include <OpenGL/glu.h>
#else
#include <GL/gl.h>
#include <GL/glu.h>
#endif /* BUILD_ENGINE_GL_QUARTZ */
#ifdef BUILD_ENGINE_GL_GLEW
#include <GL/glew.h>
#endif /* BUILD_ENGINE_GL_GLEW */
#include <GL/gl.h>
#include <GL/glu.h>
typedef struct _Evas_GL_Context Evas_GL_Context;
typedef struct _Evas_GL_Texture Evas_GL_Texture;
typedef struct _Evas_GL_Image Evas_GL_Image;

View File

@ -0,0 +1,22 @@
#ifndef _EVAS_ENGINE_QUARTZ_H
#define _EVAS_ENGINE_QUARTZ_H
#include <ApplicationServices/ApplicationServices.h>
typedef struct _Evas_Engine_Info_Quartz Evas_Engine_Info_Quartz;
struct _Evas_Engine_Info_Quartz
{
/* PRIVATE - don't mess with this baby or evas will poke its tongue out */
/* at you and make nasty noises */
Evas_Engine_Info magic;
/* engine specific data & parameters it needs to set up */
struct {
CGContextRef context;
} info;
};
#endif

View File

@ -0,0 +1,28 @@
MAINTAINERCLEANFILES = Makefile.in
AM_CPPFLAGS = -I. -I$(top_srcdir)/src/lib -I$(top_srcdir)/src/lib/include @quartz_cflags@ @FREETYPE_CFLAGS@
if BUILD_ENGINE_QUARTZ
pkgdir = $(libdir)/evas/modules/engines/quartz/$(MODULE_ARCH)
pkg_LTLIBRARIES = module.la
module_la_SOURCES = \
evas_engine.h \
evas_engine.c
module_la_LIBADD = @quartz_libs@ $(top_builddir)/src/lib/libevas.la
module_la_LDFLAGS = -module -avoid-version
module_la_LIBTOOLFLAGS = --tag=disable-static
module_la_DEPENDENCIES = $(top_builddir)/config.h
include_HEADERS = Evas_Engine_Quartz.h
endif
EXTRA_DIST = \
evas_engine.h \
evas_engine.c \
Evas_Engine_Quartz.h

View File

@ -0,0 +1,32 @@
================
==INSTALLATION==
================
Here's what I had to do to get Evas_Quartz working on a fresh install of Mac OS X Leopard (Evas_Quartz is currently not versions prior to 10.5):
1) Install all system software updates.
2) Install the XCode developer tools (this includes GCC).
3) Install macports.
4) Put /opt/local/bin in your path, permanently. (I put it in front of everything else, because the newer versions of autotools provided by ports are required to build evas)
5) With macports, install the following: m4, autoconf, automake, libtool, pkgconfig, zlib, libpng, jpeg, freetype, tiff.
6) Check out a version of Evas that includes Evas_Quartz (from CVS).
7) Set up your environment. You need to, at the very least, set:
CFLAGS=-I/opt/local/include
LDFLAGS=-L/opt/local/lib
8) Build and install eet.
9) Build and install evas. Make sure to use --enable-quartz when configuring!
==============
==KNOWN BUGS==
==============
**** A few different types of gradients don't currently draw.
** Textbox drawing is a little bit off (because of hardcoded constants that shouldn't exist).

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,71 @@
#ifndef EVAS_ENGINE_H
#define EVAS_ENGINE_H
#include <ApplicationServices/ApplicationServices.h>
typedef struct _Evas_Quartz_Context Evas_Quartz_Context;
struct _Evas_Quartz_Context
{
int w, h;
struct
{
double r, g, b, a;
} col;
struct
{
double r, g, b, a;
int set : 1;
} mul;
unsigned char aa, clipped;
};
typedef struct _Evas_Quartz_Polygon Evas_Quartz_Polygon;
struct _Evas_Quartz_Polygon
{
Evas_List *points;
};
typedef struct _Evas_Quartz_Polygon_Point Evas_Quartz_Polygon_Point;
struct _Evas_Quartz_Polygon_Point
{
int x, y;
};
typedef struct _Evas_Quartz_Image Evas_Quartz_Image;
struct _Evas_Quartz_Image
{
RGBA_Image *im;
CGImageRef cgim;
int references;
};
typedef struct _Evas_Quartz_Font Evas_Quartz_Font;
struct _Evas_Quartz_Font
{
CTFontRef font;
CFDictionaryRef attr;
int hint;
int size;
};
typedef struct _Evas_Quartz_Gradient Evas_Quartz_Gradient;
struct _Evas_Quartz_Gradient
{
DATA32 *buf;
RGBA_Gradient *grad;
Evas_Quartz_Image *im;
unsigned char changed : 1;
int sw, sh;
};
#endif

View File

@ -0,0 +1,109 @@
#ifndef _EVAS_QUARTZ_PRIVATE_H_
#define _EVAS_QUARTZ_PRIVATE_H_
#include "evas_engine.h"
CG_EXTERN void CGContextResetClip (CGContextRef); // undocumented CoreGraphics function to clear clip rect/*
static inline void flip_pixels(int *y, int *h, void *re);
static void *eng_info(Evas *e);
static void eng_info_free(Evas *e, void *info);
static void *eng_output_setup(CGContextRef context, int w, int h);
static void eng_setup(Evas *e, void *in);
static void eng_output_free(void *data);
static void eng_output_resize(void *data, int w, int h);
static void eng_output_redraws_rect_add(void *data, int x, int y, int w, int h);
static void eng_output_redraws_rect_del(void *data, int x, int y, int w, int h);
static void eng_output_redraws_clear(void *data);
static void *eng_output_redraws_next_update_get(void *data, int *x, int *y, int *w, int *h, int *cx, int *cy, int *cw, int *ch);
static void eng_output_redraws_next_update_push(void *data, void *surface, int x, int y, int w, int h);
static void eng_output_flush(void *data);
static void *eng_context_new(void *data);
static void eng_context_free(void *data, void *context);
static void eng_context_clip_set(void *data, void *context, int x, int y, int w, int h);
static void eng_context_clip_unset(void *data, void *context);
static int eng_context_clip_get(void *data, void *context, int *x, int *y, int *w, int *h);
static void eng_context_color_set(void *data, void *context, int r, int g, int b, int a);
static int eng_context_color_get(void *data, void *context, int *r, int *g, int *b, int *a);
static void eng_context_multiplier_set(void *data, void *context, int r, int g, int b, int a);
static void eng_context_multiplier_unset(void *data, void *context);
static int eng_context_multiplier_get(void *data, void *context, int *r, int *g, int *b, int *a);
static void eng_context_cutout_add(void *data, void *context, int x, int y, int w, int h);
static void eng_context_cutout_clear(void *data, void *context);
static void eng_context_anti_alias_set(void *data, void *context, unsigned char aa);
static unsigned char eng_context_anti_alias_get(void *data, void *context);
static void eng_rectangle_draw(void *data, void *context, void *surface, int x, int y, int w, int h);
static void eng_line_draw(void *data, void *context, void *surface, int x1, int y1, int x2, int y2);
static void *eng_polygon_point_add(void *data, void *context, void *polygon, int x, int y);
static void *eng_polygon_points_clear(void *data, void *context, void *polygon);
static void eng_polygon_draw(void *data, void *context, void *surface, void *polygon);
static void *eng_gradient_new(void *data);
static void eng_gradient_free(void *data, void *gradient);
static void eng_gradient_color_stop_add(void *data, void *gradient, int r, int g, int b, int a, int delta);
static void eng_gradient_alpha_stop_add(void *data, void *gradient, int a, int delta);
static void eng_gradient_color_data_set(void *data, void *gradient, void *map, int len, int has_alpha);
static void eng_gradient_alpha_data_set(void *data, void *gradient, void *alpha_map, int len);
static void eng_gradient_clear(void *data, void *gradient);
static void eng_gradient_fill_set(void *data, void *gradient, int x, int y, int w, int h);
static void eng_gradient_fill_angle_set(void *data, void *gradient, double angle);
static void eng_gradient_fill_spread_set(void *data, void *gradient, int spread);
static void eng_gradient_angle_set(void *data, void *gradient, double angle);
static void eng_gradient_offset_set(void *data, void *gradient, float offset);
static void eng_gradient_direction_set(void *data, void *gradient, int direction);
static void eng_gradient_type_set(void *data, void *gradient, char *name, char *params);
static int eng_gradient_is_opaque(void *data, void *context, void *gradient, int x, int y, int w, int h);
static int eng_gradient_is_visible(void *data, void *context, void *gradient, int x, int y, int w, int h);
static void eng_gradient_render_pre(void *data, void *context, void *gradient);
static void eng_gradient_render_post(void *data, void *gradient);
static void eng_gradient_draw(void *data, void *context, void *surface, void *gradient, int x, int y, int w, int h);
static void *eng_image_load(void *data, const char *file, const char *key, int *error, Evas_Image_Load_Opts *lo);
static void *eng_image_new_from_data(void *data, int w, int h, DATA32 *image_data, int alpha, int cspace);
static void *eng_image_new_from_copied_data(void *data, int w, int h, DATA32 *image_data, int alpha, int cspace);
static void eng_image_free(void *data, void *image);
static void eng_image_size_get(void *data, void *image, int *w, int *h);
static void *eng_image_dirty_region(void *data, void *image, int x, int y, int w, int h);
static void *eng_image_alpha_set(void *data, void *image, int has_alpha);
static int eng_image_alpha_get(void *data, void *image);
static char *eng_image_comment_get(void *data, void *image, char *key);
static char *eng_image_format_get(void *data, void *image);
static void eng_image_colorspace_set(void *data, void *image, int cspace);
static int eng_image_colorspace_get(void *data, void *image);
static void eng_image_native_set(void *data, void *image, void *native);
static void *eng_image_native_get(void *data, void *image);
static void *eng_image_data_get(void *data, void *image, int to_write, DATA32 **image_data);
static void *eng_image_data_put(void *data, void *image, DATA32 *image_data);
static void *eng_image_size_set(void *data, void *image, int w, int h);
static void 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);
static void *eng_font_add(void *data, void *font, const char *name, int size);
static Evas_Quartz_Font *quartz_font_from_ats(ATSFontContainerRef container, int size);
static void *eng_font_load(void *data, const char *name, int size);
static void *eng_font_memory_load(void *data, char *name, int size, const void *fdata, int fdata_size);
static void eng_font_free(void *data, void *font);
static int eng_font_ascent_get(void *data, void *font);
static int eng_font_descent_get(void *data, void *font);
static int eng_font_max_ascent_get(void *data, void *font);
static int eng_font_max_descent_get(void *data, void *font);
static void eng_font_string_size_get(void *data, void *font, const char *text, int *w, int *h);
static int eng_font_inset_get(void *data, void *font, const char *text);
static int eng_font_h_advance_get(void *data, void *font, const char *text);
static int eng_font_v_advance_get(void *data, void *font, const char *text);
static int eng_font_char_coords_get(void *data, void *font, const char *text, int pos, int *cx, int *cy, int *cw, int *ch);
static int eng_font_char_at_coords_get(void *data, void *font, const char *text, int x, int y, int *cx, int *cy, int *cw, int *ch);
static void eng_font_draw(void *data, void *context, void *surface, void *font, int x, int y, int w, int h, int ow, int oh, const char *text);
static void eng_font_hinting_set(void *data, void *font, int hinting);
static int eng_font_hinting_can_hint(void *data, int hinting);
EAPI int module_open(Evas_Module *em);
EAPI void module_close(void);
#endif /* _EVAS_QUARTZ_PRIVATE_H_ */