From 67d11a57eb670cbdb6f4db8e4bcc32b855789d74 Mon Sep 17 00:00:00 2001 From: Jonathan Kew Date: Tue, 4 Mar 2014 05:37:40 +0000 Subject: [PATCH] bug 969814 - build freetype with support for color bitmap (png) glyphs within opentype fonts. r=ted,jrmuizel --- configure.in | 6 ++++-- media/libpng/mozpngconf.h | 27 ++++++++++++++++-------- widget/gonk/libdisplay/BootAnimation.cpp | 2 +- 3 files changed, 23 insertions(+), 12 deletions(-) diff --git a/configure.in b/configure.in index 1e8fb551ea9..a515d34e8ea 100644 --- a/configure.in +++ b/configure.in @@ -952,7 +952,7 @@ MOZ_JPEG_CFLAGS= MOZ_JPEG_LIBS='$(call EXPAND_LIBNAME_PATH,mozjpeg,$(DEPTH)/media/libjpeg)' MOZ_BZ2_CFLAGS= MOZ_BZ2_LIBS='$(call EXPAND_LIBNAME_PATH,bz2,$(DEPTH)/modules/libbz2/src)' -MOZ_PNG_CFLAGS= +MOZ_PNG_CFLAGS="-I$_objdir/dist/include" # needed for freetype compilation MOZ_PNG_LIBS='$(call EXPAND_LIBNAME_PATH,mozpng,$(DEPTH)/media/libpng)' MOZ_JS_STATIC_LIBS='$(call EXPAND_LIBNAME_PATH,js_static,$(LIBXUL_DIST)/lib)' @@ -8927,8 +8927,10 @@ if test "$MOZ_TREE_FREETYPE"; then export CPPFLAGS="$CPPFLAGS $MOZ_DEBUG_FLAGS" export CXXFLAGS="$CXXFLAGS $MOZ_DEBUG_FLAGS" export LDFLAGS="$LDFLAGS $MOZ_DEBUG_LDFLAGS" + export LIBPNG_CFLAGS="$MOZ_PNG_CFLAGS" + export LIBPNG_LDFLAGS="$MOZ_PNG_LIBS" export CONFIG_FILES="unix-cc.mk:unix-cc.in unix-def.mk:unix-def.in freetype-config freetype2.pc:freetype2.in" - ac_configure_args="$ac_configure_args --host=$target --disable-shared --with-pic=yes --without-png" + ac_configure_args="$ac_configure_args --host=$target --disable-shared --with-pic=yes" if ! test -e modules; then mkdir modules diff --git a/media/libpng/mozpngconf.h b/media/libpng/mozpngconf.h index 0b5c7420ab3..101c9ef247d 100644 --- a/media/libpng/mozpngconf.h +++ b/media/libpng/mozpngconf.h @@ -66,19 +66,25 @@ #define PNG_READ_SCALE_16_TO_8_SUPPORTED #define PNG_READ_TRANSFORMS_SUPPORTED -/* necessary for boot animation code */ +/* necessary for freetype color bitmap support (Android & B2G) + and boot animation code (Gonk) */ +#if defined(ANDROID) || defined(FT_CONFIG_OPTION_USE_PNG) +#define PNG_READ_PACK_SUPPORTED +#define PNG_READ_FILLER_SUPPORTED +#define PNG_READ_STRIP_16_TO_8_SUPPORTED +#define PNG_READ_USER_TRANSFORM_SUPPORTED +#define PNG_SEQUENTIAL_READ_SUPPORTED +#endif + +/* necessary for boot animation code (Gonk) */ #ifdef MOZ_WIDGET_GONK #define PNG_UNKNOWN_CHUNKS_SUPPORTED #define PNG_SET_UNKNOWN_CHUNKS_SUPPORTED #define PNG_HANDLE_AS_UNKNOWN_SUPPORTED #define PNG_EASY_ACCESS_SUPPORTED #define PNG_READ_BGR_SUPPORTED -#define PNG_READ_FILLER_SUPPORTED #define PNG_READ_GRAY_TO_RGB_SUPPORTED -#define PNG_READ_STRIP_16_TO_8_SUPPORTED #define PNG_READ_STRIP_ALPHA_SUPPORTED -#define PNG_READ_USER_TRANSFORM_SUPPORTED -#define PNG_SEQUENTIAL_READ_SUPPORTED #endif #define PNG_WRITE_SUPPORTED @@ -109,11 +115,8 @@ #define PNG_SETJMP_SUPPORTED #define PNG_STDIO_SUPPORTED #define PNG_TEXT_SUPPORTED - -#ifdef PR_LOGGING #define PNG_ERROR_TEXT_SUPPORTED #define PNG_WARNINGS_SUPPORTED -#endif /* Mangle names of exported libpng functions so different libpng versions can coexist. It is recommended that if you do this, you give your @@ -644,9 +647,11 @@ #define png_realloc_array MOZ_PNG_realloc_array #define png_zstream_error MOZ_PNG_zstream_error +/* needed by FreeType's PNG support */ +#define png_error MOZ_PNG_error + #if defined(PR_LOGGING) && defined(PNG_WARNINGS_SUPPORTED) #define png_warning MOZ_PNG_warning -#define png_error MOZ_PNG_error #define png_chunk_error MOZ_PNG_chunk_err #define png_fixed_error MOZ_PNG_fixed_err #define png_formatted_warning MOZ_PNG_formatted_warning @@ -656,4 +661,8 @@ #define png_warning_parameter_unsigned MOZ_PNG_warn_param_unsigned #endif +#if defined(PNG_READ_PACK_SUPPORTED) || defined(PNG_WRITE_PACK_SUPPORTED) +#define png_set_packing MOZ_PNG_set_packing +#endif + #endif /* MOZPNGCONF_H */ diff --git a/widget/gonk/libdisplay/BootAnimation.cpp b/widget/gonk/libdisplay/BootAnimation.cpp index a30175a4bdb..49e47623244 100644 --- a/widget/gonk/libdisplay/BootAnimation.cpp +++ b/widget/gonk/libdisplay/BootAnimation.cpp @@ -267,7 +267,7 @@ RawReader(png_structp png_ptr, png_bytep data, png_size_t length) { RawReadState *state = (RawReadState *)png_get_io_ptr(png_ptr); if (length > (state->length - state->offset)) - png_err(png_ptr); + png_error(png_ptr, "PNG read overrun"); memcpy(data, state->start + state->offset, length); state->offset += length;