bug 462908 - Follow up to fix indentation and include patch in gfx/cairo
authorBrad Lassey <blassey@mozilla.com>
Fri, 23 Jan 2009 02:59:24 -0500
changeset 24106 027a7966d5f0db026f1570b64473d6242d99f039
parent 24105 13e903f17346aca3d2e193b8f89a18ff546aaa5d
child 24107 9ea3fd0e41f557c391d50b02c14c03409f375e98
push id1
push userroot
push dateTue, 26 Apr 2011 22:38:44 +0000
treeherdermozilla-beta@bfdb6e623a36 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs462908
milestone1.9.2a1pre
bug 462908 - Follow up to fix indentation and include patch in gfx/cairo
gfx/cairo/README
gfx/cairo/wince-fontconfig.patch
gfx/thebes/public/gfxFT2Fonts.h
gfx/thebes/public/gfxWindowsPlatform.h
gfx/thebes/src/gfxFT2Fonts.cpp
gfx/thebes/src/gfxWindowsFonts.cpp
--- a/gfx/cairo/README
+++ b/gfx/cairo/README
@@ -33,15 +33,17 @@ cairo-version-fixes.patch: fix up cairo-
 win32-ddb-dib.patch: fix for bug 455513; not upstream yet pending feebdack
 
 qpainter-type.patch: add SURFACE_TYPE_QPAINTER to cairo.h
 
 wince-fixes.patch: stubs out win32 functions we use but are not supported on win32.  Also implements ExtSelectClipRgn in terms of other functions available on wince.
 
 ft-done-face.patch: bug 467874; only destroy FT_Faces created by cairo
 
+wince-fontconfig.patch: bug 462908; fixes required to compile for windows ce.  Also allows for building without fontconfig
+
 ==== pixman patches ====
 
 endian.patch: include cairo-platform.h for endian macros
 
 ==== disable printing patch ====
 
 disable-printing.patch:  allows us to use NS_PRINTING to disable printing.
new file mode 100644
--- /dev/null
+++ b/gfx/cairo/wince-fontconfig.patch
@@ -0,0 +1,349 @@
+diff --git a/gfx/cairo/cairo/src/Makefile.in b/gfx/cairo/cairo/src/Makefile.in
+--- a/gfx/cairo/cairo/src/Makefile.in
++++ b/gfx/cairo/cairo/src/Makefile.in
+@@ -141,22 +141,25 @@ PDF_CSRCS = \
+ 	cairo-pdf-surface.c \
+ 	cairo-pdf-operators.c \
+ 	$(NULL)
+ 
+ PS_CSRCS = cairo-ps-surface.c
+ 
+ PDF_EXPORTS = cairo-pdf.h
+ PS_EXPORTS = cairo-ps.h
+ 
+ ifeq ($(MOZ_WIDGET_TOOLKIT),windows)
+-CSRCS	+= 	cairo-win32-font.c \
+-			cairo-win32-surface.c
++CSRCS	+=	cairo-win32-surface.c
++
++ifndef WINCE
++CSRCS	+=	cairo-win32-font.c
++endif
+ 
+ ifdef NS_PRINTING
+ CSRCS   += cairo-win32-printing-surface.c
+ else
+ DEFINES += -DCAIRO_OMIT_WIN32_PRINTING
+ endif
+ 
+ EXPORTS += cairo-win32.h
+ CSRCS   += $(PSPDF_BASE_CSRCS) $(PDF_CSRCS)
+ EXPORTS += $(PDF_EXPORTS)
+diff --git a/gfx/cairo/cairo/src/cairo-features.h.in b/gfx/cairo/cairo/src/cairo-features.h.in
+--- a/gfx/cairo/cairo/src/cairo-features.h.in
++++ b/gfx/cairo/cairo/src/cairo-features.h.in
+@@ -82,11 +82,12 @@
+ @QPAINTER_SURFACE_FEATURE@
+ 
+ @FT_FONT_FEATURE@
+ 
+ @WIN32_FONT_FEATURE@
+ 
+ @QUARTZ_FONT_FEATURE@
+ 
+ @PNG_FUNCTIONS_FEATURE@
+ 
++@FC_FONT_FEATURE@
+ #endif
+diff --git a/gfx/cairo/cairo/src/cairo-ft-font.c b/gfx/cairo/cairo/src/cairo-ft-font.c
+--- a/gfx/cairo/cairo/src/cairo-ft-font.c
++++ b/gfx/cairo/cairo/src/cairo-ft-font.c
+@@ -38,22 +38,24 @@
+  *      Carl Worth <cworth@cworth.org>
+  */
+ 
+ #define _BSD_SOURCE /* for strdup() */
+ #include "cairoint.h"
+ 
+ #include "cairo-ft-private.h"
+ 
+ #include <float.h>
+ 
++#ifndef CAIRO_DISABLE_FONTCONFIG
+ #include <fontconfig/fontconfig.h>
+ #include <fontconfig/fcfreetype.h>
++#endif
+ 
+ #include <ft2build.h>
+ #include FT_FREETYPE_H
+ #include FT_OUTLINE_H
+ #include FT_IMAGE_H
+ #include FT_TRUETYPE_TABLES_H
+ #if HAVE_FT_GLYPHSLOT_EMBOLDEN
+ #include FT_SYNTHESIS_H
+ #endif
+ 
+@@ -114,23 +116,25 @@ struct _cairo_ft_unscaled_font {
+     cairo_ft_font_face_t *faces;	/* Linked list of faces for this font */
+ };
+ 
+ static int
+ _cairo_ft_unscaled_font_keys_equal (const void *key_a,
+ 				    const void *key_b);
+ 
+ static void
+ _cairo_ft_unscaled_font_fini (cairo_ft_unscaled_font_t *unscaled);
+ 
++#ifndef CAIRO_DISABLE_FONTCONFIG
+ static cairo_status_t
+ _cairo_ft_font_options_substitute (const cairo_font_options_t *options,
+ 				   FcPattern                  *pattern);
++#endif
+ 
+ typedef enum _cairo_ft_extra_flags {
+     CAIRO_FT_OPTIONS_HINT_METRICS = (1 << 0),
+     CAIRO_FT_OPTIONS_EMBOLDEN = (1 << 1)
+ } cairo_ft_extra_flags_t;
+ 
+ typedef struct _cairo_ft_options {
+     cairo_font_options_t    base;
+     int			    load_flags;	 /* flags for FT_Load_Glyph */
+     cairo_ft_extra_flags_t  extra_flags; /* other flags that affect results */
+@@ -457,21 +461,21 @@ UNWIND_UNSCALED_FONT_INIT:
+ UNWIND_UNSCALED_FONT_INIT:
+     _cairo_ft_unscaled_font_fini (unscaled);
+ UNWIND_UNSCALED_MALLOC:
+     free (unscaled);
+ UNWIND_FONT_MAP_LOCK:
+     _cairo_ft_unscaled_font_map_unlock ();
+ UNWIND:
+     return NULL;
+ }
+ 
+-
++#ifndef CAIRO_DISABLE_FONTCONFIG
+ static cairo_ft_unscaled_font_t *
+ _cairo_ft_unscaled_font_create_for_pattern (FcPattern *pattern)
+ {
+     FT_Face font_face = NULL;
+     char *filename = NULL;
+     int id = 0;
+ 
+     if (FcPatternGetFTFace (pattern, FC_FT_FACE, 0, &font_face) != FcResultMatch) {
+ 	FcChar8 *fc_filename = NULL;
+ 
+@@ -481,20 +485,21 @@ _cairo_ft_unscaled_font_create_for_patte
+ 
+ 	if (FcPatternGetInteger (pattern, FC_INDEX, 0, &id) != FcResultMatch)
+ 	    goto UNWIND;
+     }
+ 
+     return _cairo_ft_unscaled_font_create_internal (font_face != NULL, filename, id, font_face);
+ 
+ UNWIND:
+     return NULL;
+ }
++#endif
+ 
+ static cairo_ft_unscaled_font_t *
+ _cairo_ft_unscaled_font_create_from_face (FT_Face face)
+ {
+     return _cairo_ft_unscaled_font_create_internal (TRUE, NULL, 0, face);
+ }
+ 
+ static void
+ _cairo_ft_unscaled_font_destroy (void *abstract_font)
+ {
+@@ -1283,20 +1288,21 @@ static const cairo_unscaled_font_backend
+ /* #cairo_ft_scaled_font_t */
+ 
+ typedef struct _cairo_ft_scaled_font {
+     cairo_scaled_font_t base;
+     cairo_ft_unscaled_font_t *unscaled;
+     cairo_ft_options_t ft_options;
+ } cairo_ft_scaled_font_t;
+ 
+ const cairo_scaled_font_backend_t _cairo_ft_scaled_font_backend;
+ 
++#ifndef CAIRO_DISABLE_FONTCONFIG
+ /* The load flags passed to FT_Load_Glyph control aspects like hinting and
+  * antialiasing. Here we compute them from the fields of a FcPattern.
+  */
+ static void
+ _get_pattern_ft_options (FcPattern *pattern, cairo_ft_options_t *ret)
+ {
+     FcBool antialias, vertical_layout, hinting, autohint, bitmap, embolden;
+     cairo_ft_options_t ft_options;
+     int rgba;
+ #ifdef FC_HINT_STYLE
+@@ -1418,20 +1424,21 @@ _get_pattern_ft_options (FcPattern *patt
+ #endif
+     if (FcPatternGetBool (pattern,
+ 			  FC_EMBOLDEN, 0, &embolden) != FcResultMatch)
+ 	embolden = FcFalse;
+     
+     if (embolden)
+ 	ft_options.extra_flags |= CAIRO_FT_OPTIONS_EMBOLDEN;
+ 
+     *ret = ft_options;
+ }
++#endif /* CAIRO_DISABLE_FONTCONFIG */
+ 
+ static void
+ _cairo_ft_options_merge (cairo_ft_options_t *options,
+ 			 cairo_ft_options_t *other)
+ {
+     int load_flags = other->load_flags;
+     int load_target = FT_LOAD_TARGET_NORMAL;
+ 
+     /* clear load target mode */
+     load_flags &= ~(FT_LOAD_TARGET_(FT_LOAD_TARGET_MODE(other->load_flags)));
+@@ -1614,20 +1621,21 @@ _cairo_scaled_font_is_ft (cairo_scaled_f
+     return scaled_font->backend == &_cairo_ft_scaled_font_backend;
+ }
+ 
+ static cairo_status_t
+ _cairo_ft_scaled_font_create_toy (cairo_toy_font_face_t	      *toy_face,
+ 				  const cairo_matrix_t	      *font_matrix,
+ 				  const cairo_matrix_t	      *ctm,
+ 				  const cairo_font_options_t  *font_options,
+ 				  cairo_scaled_font_t	     **font)
+ {
++#ifndef CAIRO_DISABLE_FONTCONFIG
+     FcPattern *pattern, *resolved;
+     cairo_ft_unscaled_font_t *unscaled;
+     FcResult result;
+     int fcslant;
+     int fcweight;
+     cairo_matrix_t scale;
+     cairo_status_t status;
+     cairo_ft_font_transform_t sf;
+     cairo_ft_options_t ft_options;
+ 
+@@ -1720,20 +1728,23 @@ _cairo_ft_scaled_font_create_toy (cairo_
+ 
+     _cairo_unscaled_font_destroy (&unscaled->base);
+ 
+  FREE_RESOLVED:
+     FcPatternDestroy (resolved);
+ 
+  FREE_PATTERN:
+     FcPatternDestroy (pattern);
+ 
+     return status;
++#else
++    return CAIRO_INT_STATUS_UNSUPPORTED;
++#endif  /* CAIRO_DISABLE_FONTCONFIG */
+ }
+ 
+ static void
+ _cairo_ft_scaled_font_fini (void *abstract_font)
+ {
+     cairo_ft_scaled_font_t *scaled_font = abstract_font;
+ 
+     if (scaled_font == NULL)
+         return;
+ 
+@@ -2141,24 +2152,25 @@ _cairo_ft_ucs4_to_index (void	    *abstr
+ {
+     cairo_ft_scaled_font_t *scaled_font = abstract_font;
+     cairo_ft_unscaled_font_t *unscaled = scaled_font->unscaled;
+     FT_Face face;
+     FT_UInt index;
+ 
+     face = _cairo_ft_unscaled_font_lock_face (unscaled);
+     if (!face)
+ 	return 0;
+ 
+-    /* If making this compile without fontconfig, use:
+-     * index = FT_Get_Char_Index (face, ucs4); */
++#ifdef CAIRO_DISABLE_FONTCONFIG
++    index = FT_Get_Char_Index (face, ucs4); 
++#else
+     index = FcFreeTypeCharIndex (face, ucs4);
+-
++#endif
+     _cairo_ft_unscaled_font_unlock_face (unscaled);
+     return index;
+ }
+ 
+ static cairo_int_status_t
+ _cairo_ft_load_truetype_table (void	       *abstract_font,
+                               unsigned long     tag,
+                               long              offset,
+                               unsigned char    *buffer,
+                               unsigned long    *length)
+@@ -2366,20 +2378,21 @@ _cairo_ft_font_face_create (cairo_ft_uns
+     font_face->ft_options = *ft_options;
+ 
+     font_face->next = unscaled->faces;
+     unscaled->faces = font_face;
+ 
+     _cairo_font_face_init (&font_face->base, &_cairo_ft_font_face_backend);
+ 
+     return &font_face->base;
+ }
+ 
++#ifndef CAIRO_DISABLE_FONTCONFIG
+ /* implement the platform-specific interface */
+ 
+ static cairo_status_t
+ _cairo_ft_font_options_substitute (const cairo_font_options_t *options,
+ 				   FcPattern                  *pattern)
+ {
+     FcValue v;
+ 
+     if (options->antialias != CAIRO_ANTIALIAS_DEFAULT)
+     {
+@@ -2541,20 +2554,21 @@ cairo_ft_font_face_create_for_pattern (F
+ 	_cairo_error_throw (CAIRO_STATUS_NO_MEMORY);
+ 	return (cairo_font_face_t *)&_cairo_font_face_nil;
+     }
+ 
+     _get_pattern_ft_options (pattern, &ft_options);
+     font_face = _cairo_ft_font_face_create (unscaled, &ft_options);
+     _cairo_unscaled_font_destroy (&unscaled->base);
+ 
+     return font_face;
+ }
++#endif /* CAIRO_DISABLE_FONTCONFIG */
+ 
+ /**
+  * cairo_ft_font_face_create_for_ft_face:
+  * @face: A FreeType face object, already opened. This must
+  *   be kept around until the face's ref_count drops to
+  *   zero and it is freed. Since the face may be referenced
+  *   internally to Cairo, the best way to determine when it
+  *   is safe to free the face is to pass a
+  *   #cairo_destroy_func_t to cairo_font_face_set_user_data()
+  * @load_flags: flags to pass to FT_Load_Glyph when loading
+diff --git a/gfx/cairo/cairo/src/cairo-ft.h b/gfx/cairo/cairo/src/cairo-ft.h
+--- a/gfx/cairo/cairo/src/cairo-ft.h
++++ b/gfx/cairo/cairo/src/cairo-ft.h
+@@ -36,32 +36,36 @@
+ 
+ #ifndef CAIRO_FT_H
+ #define CAIRO_FT_H
+ 
+ #include "cairo.h"
+ 
+ #if CAIRO_HAS_FT_FONT
+ 
+ /* Fontconfig/Freetype platform-specific font interface */
+ 
++#ifndef CAIRO_DISABLE_FONTCONFIG
+ #include <fontconfig/fontconfig.h>
++#endif
+ #include <ft2build.h>
+ #include FT_FREETYPE_H
+ 
+ CAIRO_BEGIN_DECLS
+ 
++#ifndef CAIRO_DISABLE_FONTCONFIG
+ cairo_public cairo_font_face_t *
+ cairo_ft_font_face_create_for_pattern (FcPattern *pattern);
+ 
+ cairo_public void
+ cairo_ft_font_options_substitute (const cairo_font_options_t *options,
+ 				  FcPattern                  *pattern);
++#endif
+ 
+ cairo_public cairo_font_face_t *
+ cairo_ft_font_face_create_for_ft_face (FT_Face         face,
+ 				       int             load_flags);
+ 
+ cairo_public FT_Face
+ cairo_ft_scaled_font_lock_face (cairo_scaled_font_t *scaled_font);
+ 
+ cairo_public void
+ cairo_ft_scaled_font_unlock_face (cairo_scaled_font_t *scaled_font);
--- a/gfx/thebes/public/gfxFT2Fonts.h
+++ b/gfx/thebes/public/gfxFT2Fonts.h
@@ -87,17 +87,17 @@ public:
 
     const nsString& GetName() const {
         return mFaceName;
     }
 
 
     static FontEntry* 
     CreateFontEntry(const gfxProxyFontEntry &aProxyEntry, nsISupports *aLoader,
-                 const PRUint8 *aFontData, PRUint32 aLength);
+                    const PRUint8 *aFontData, PRUint32 aLength);
     
     static FontEntry* 
     CreateFontEntryFromFace(FT_Face aFace);
     
     cairo_font_face_t *CairoFontFace();
 
     cairo_font_face_t *mFontFace;
 
--- a/gfx/thebes/public/gfxWindowsPlatform.h
+++ b/gfx/thebes/public/gfxWindowsPlatform.h
@@ -109,17 +109,17 @@ public:
     /* Given a string and a font we already have find the font that
      * supports the most code points and most closely resembles aFont
      *
      * this involves looking at the fonts on your machine and seeing which
      * code points they support as well as looking at things like the font
      * family, style, weight, etc.
      */
     already_AddRefed<gfxFont>
-    gfxWindowsPlatform::FindFontForChar(PRUint32 aCh, gfxFont *aFont);
+    FindFontForChar(PRUint32 aCh, gfxFont *aFont);
 
     /* Find a FontFamily/FontEntry object that represents a font on your system given a name */
     FontFamily *FindFontFamily(const nsAString& aName);
     FontEntry *FindFontEntry(const nsAString& aName, const gfxFontStyle& aFontStyle);
 
     PRBool GetPrefFontEntries(const nsCString& aLangGroup, nsTArray<nsRefPtr<FontEntry> > *array);
     void SetPrefFontEntries(const nsCString& aLangGroup, nsTArray<nsRefPtr<FontEntry> >& array);
 
--- a/gfx/thebes/src/gfxFT2Fonts.cpp
+++ b/gfx/thebes/src/gfxFT2Fonts.cpp
@@ -73,17 +73,16 @@ FontEntry::~FontEntry()
 {
     if (mFontFace) {
         cairo_font_face_destroy(mFontFace);
         mFontFace = nsnull;
     }
 }
 
 /* static */
-
 FontEntry*  
 FontEntry::CreateFontEntry(const gfxProxyFontEntry &aProxyEntry, 
                            nsISupports *aLoader, const PRUint8 *aFontData, 
                            PRUint32 aLength) {
     if (!gfxFontUtils::ValidateSFNTHeaders(aFontData, aLength))
         return nsnull;
     FT_Face face;
     FT_Error error =
@@ -101,18 +100,18 @@ FontEntry::CreateFontEntry(const gfxProx
 
 static void
 FTFontDestroyFunc(void *data)
 {
     FT_Face face = (FT_Face)data;
     FT_Done_Face(face);
 }
 
-/* static */
-FontEntry*  FontEntry::CreateFontEntryFromFace(FT_Face aFace) {
+/* static */ FontEntry*  
+FontEntry::CreateFontEntryFromFace(FT_Face aFace) {
     static cairo_user_data_key_t key;
 
     if (!aFace->family_name) {
         FT_Done_Face(aFace);
         return nsnull;
     }
     // Construct font name from family name and style name, regular fonts
     // do not have the modifier by convention.
@@ -235,17 +234,17 @@ gfxFT2FontGroup::gfxFT2FontGroup(const n
 #elif defined(MOZ_WIDGET_GTK2)
         FcResult result;
         FcChar8 *family = nsnull;
         FcPattern* pat = FcPatternCreate();
         FcPattern *match = FcFontMatch(nsnull, pat, &result);
         if (match)
             FcPatternGetString(match, FC_FAMILY, 0, &family);
         if (family)
-            familyArray.AppendString(NS_ConvertUTF8toUTF16((char*)family));
+            familyArray.AppendElement(NS_ConvertUTF8toUTF16((char*)family));
 #elif defined(XP_WIN)
         HGDIOBJ hGDI = ::GetStockObject(SYSTEM_FONT);
         LOGFONTW logFont;
         if (hGDI && ::GetObjectW(hGDI, sizeof(logFont), &logFont)) 
             familyArray.AppendElement(nsDependentString(logFont.lfFaceName));
 #else
 #error "Platform not supported"
 #endif
--- a/gfx/thebes/src/gfxWindowsFonts.cpp
+++ b/gfx/thebes/src/gfxWindowsFonts.cpp
@@ -492,18 +492,19 @@ static void MakeUniqueFontName(nsAString
     ++fontCount;
 
     sprintf(buf, "mozfont%8.8x%8.8x", ::GetTickCount(), fontCount);  // slightly retarded, figure something better later...
     aName.AssignASCII(buf);
 }
 
 /* static */
 FontEntry* 
-FontEntry::CreateFontEntry(const gfxProxyFontEntry &aProxyEntry, nsISupports *aLoader,
-             const PRUint8 *aFontData, PRUint32 aLength) {
+FontEntry::CreateFontEntry(const gfxProxyFontEntry &aProxyEntry, 
+                           nsISupports *aLoader,const PRUint8 *aFontData, 
+                           PRUint32 aLength) {
     // if calls aren't available, bail
     if (!TTLoadEmbeddedFontPtr || !TTDeleteEmbeddedFontPtr)
         return nsnull;
 
     PRBool isCFF;
     if (!gfxFontUtils::ValidateSFNTHeaders(aFontData, aLength, &isCFF))
         return nsnull;