Back out bbd7b1da5d36:b0d1c4456b73 (bug 974575) and 6e8140ae4961 (bug 969814) for ASan bustage
authorPhil Ringnalda <philringnalda@gmail.com>
Mon, 03 Mar 2014 22:40:07 -0800
changeset 189897 dd9cf2bef6934d39f7f77a814070b28c2f4d450d
parent 189896 bbd7b1da5d36cebcc3a1a3c6a97445879afd1a32
child 189898 765770122c29e765b72e1977bf48946d23cab0ec
push id474
push userasasaki@mozilla.com
push dateMon, 02 Jun 2014 21:01:02 +0000
treeherdermozilla-release@967f4cf1b31c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs974575, 969814
milestone30.0a1
backs outbbd7b1da5d36cebcc3a1a3c6a97445879afd1a32
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Back out bbd7b1da5d36:b0d1c4456b73 (bug 974575) and 6e8140ae4961 (bug 969814) for ASan bustage
configure.in
gfx/cairo/cairo/src/cairo-ft-font.c
gfx/cairo/cairo/src/cairo-image-surface.c
media/libpng/mozpngconf.h
widget/gonk/libdisplay/BootAnimation.cpp
--- a/configure.in
+++ b/configure.in
@@ -947,17 +947,17 @@ IMPORT_LIB_SUFFIX=
 TARGET_MD_ARCH=unix
 DIRENT_INO=d_ino
 MOZ_USER_DIR=".mozilla"
 
 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="-I$_objdir/dist/include" # needed for freetype compilation
+MOZ_PNG_CFLAGS=
 MOZ_PNG_LIBS='$(call EXPAND_LIBNAME_PATH,mozpng,$(DEPTH)/media/libpng)'
 
 MOZ_JS_STATIC_LIBS='$(call EXPAND_LIBNAME_PATH,js_static,$(LIBXUL_DIST)/lib)'
 MOZ_JS_SHARED_LIBS='$(call EXPAND_LIBNAME_PATH,mozjs,$(LIBXUL_DIST)/lib)'
 MOZ_FIX_LINK_PATHS='-Wl,-rpath-link,$(LIBXUL_DIST)/bin -Wl,-rpath-link,$(prefix)/lib'
 XPCOM_FROZEN_LDOPTS='$(call EXPAND_LIBNAME_PATH,xul mozalloc,$(LIBXUL_DIST)/bin)'
 LIBXUL_LIBS='$(XPCOM_FROZEN_LDOPTS)'
 XPCOM_GLUE_LDOPTS='$(LIBXUL_DIST)/lib/$(LIB_PREFIX)xpcomglue_s.$(LIB_SUFFIX) $(XPCOM_FROZEN_LDOPTS)'
@@ -8922,20 +8922,18 @@ fi
 
 # Run freetype configure script
 
 if test "$MOZ_TREE_FREETYPE"; then
    export CFLAGS="$CFLAGS $MOZ_DEBUG_FLAGS -std=c99"
    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"
+   ac_configure_args="$ac_configure_args --host=$target --disable-shared --with-pic=yes --without-png"
 
    if ! test -e modules; then
      mkdir modules
    fi
 
    AC_OUTPUT_SUBDIRS(modules/freetype2)
 fi
 
--- a/gfx/cairo/cairo/src/cairo-ft-font.c
+++ b/gfx/cairo/cairo/src/cairo-ft-font.c
@@ -47,17 +47,16 @@
 #include <float.h>
 
 #include "cairo-fontconfig-private.h"
 
 #include <ft2build.h>
 #include FT_FREETYPE_H
 #include FT_OUTLINE_H
 #include FT_IMAGE_H
-#include FT_BITMAP_H
 #include FT_TRUETYPE_TABLES_H
 #if HAVE_FT_GLYPHSLOT_EMBOLDEN
 #include FT_SYNTHESIS_H
 #endif
 
 #if HAVE_FT_LIBRARY_SETLCDFILTER
 #include FT_LCD_FILTER_H
 #endif
@@ -698,18 +697,17 @@ void
     unscaled->lock_count--;
 
     CAIRO_MUTEX_UNLOCK (unscaled->mutex);
 }
 
 
 static cairo_status_t
 _compute_transform (cairo_ft_font_transform_t *sf,
-		    cairo_matrix_t      *scale,
-		    cairo_ft_unscaled_font_t *unscaled)
+		    cairo_matrix_t      *scale)
 {
     cairo_status_t status;
     double x_scale, y_scale;
     cairo_matrix_t normalized = *scale;
 
     /* The font matrix has x and y "scale" components which we extract and
      * use as character scale values. These influence the way freetype
      * chooses hints, as well as selecting different bitmaps in
@@ -727,49 +725,16 @@ static cairo_status_t
      * "A character width or height smaller than 1pt is set to 1pt;"
      * So, we cap them from below at 1.0 and let the FT transform
      * take care of sub-1.0 scaling. */
     if (x_scale < 1.0)
       x_scale = 1.0;
     if (y_scale < 1.0)
       y_scale = 1.0;
 
-    if (unscaled && (unscaled->face->face_flags & FT_FACE_FLAG_SCALABLE) == 0) {
-	double min_distance = DBL_MAX;
-	cairo_bool_t magnify = TRUE;
-	int i;
-	int best_i = 0;
-	double best_x_size = 0;
-	double best_y_size = 0;
-
-	for (i = 0; i < unscaled->face->num_fixed_sizes; i++) {
-	    double x_size = unscaled->face->available_sizes[i].y_ppem / 64.;
-	    double y_size = unscaled->face->available_sizes[i].y_ppem / 64.;
-	    double distance = y_size - y_scale;
-
-	    /*
-	     * distance is positive if current strike is larger than desired
-	     * size, and negative if smaller.
-	     *
-	     * We like to prefer down-scaling to upscaling.
-	     */
-
-	    if ((magnify && distance >= 0) || fabs (distance) <= min_distance) {
-		magnify = distance < 0;
-		min_distance = fabs (distance);
-		best_i = i;
-		best_x_size = x_size;
-		best_y_size = y_size;
-	    }
-	}
-
-	x_scale = best_x_size;
-	y_scale = best_y_size;
-    }
-
     sf->x_scale = x_scale;
     sf->y_scale = y_scale;
 
     cairo_matrix_scale (&normalized, 1.0 / x_scale, 1.0 / y_scale);
 
     _cairo_matrix_get_affine (&normalized,
 			      &sf->shape[0][0], &sf->shape[0][1],
 			      &sf->shape[1][0], &sf->shape[1][1],
@@ -797,17 +762,17 @@ static cairo_status_t
 	scale->yx == unscaled->current_scale.yx &&
 	scale->xy == unscaled->current_scale.xy &&
 	scale->yy == unscaled->current_scale.yy)
 	return CAIRO_STATUS_SUCCESS;
 
     unscaled->have_scale = TRUE;
     unscaled->current_scale = *scale;
 
-    status = _compute_transform (&sf, scale, unscaled);
+    status = _compute_transform (&sf, scale);
     if (unlikely (status))
 	return status;
 
     unscaled->x_scale = sf.x_scale;
     unscaled->y_scale = sf.y_scale;
 
     mat.xx = DOUBLE_TO_16_16(sf.shape[0][0]);
     mat.yx = - DOUBLE_TO_16_16(sf.shape[0][1]);
@@ -822,22 +787,56 @@ static cairo_status_t
     unscaled->Current_Shape = mat;
     cairo_matrix_init (&unscaled->current_shape,
 		       sf.shape[0][0], sf.shape[0][1],
 		       sf.shape[1][0], sf.shape[1][1],
 		       0.0, 0.0);
 
     FT_Set_Transform(unscaled->face, &mat, NULL);
 
-    error = FT_Set_Char_Size (unscaled->face,
-			      sf.x_scale * 64.0 + .5,
-			      sf.y_scale * 64.0 + .5,
-			      0, 0);
-    if (error)
-      return _cairo_error (CAIRO_STATUS_NO_MEMORY);
+    if ((unscaled->face->face_flags & FT_FACE_FLAG_SCALABLE) != 0) {
+	double x_scale = MIN(sf.x_scale, MAX_FONT_SIZE);
+	double y_scale = MIN(sf.y_scale, MAX_FONT_SIZE);
+	error = FT_Set_Char_Size (unscaled->face,
+				  x_scale * 64.0 + .5,
+				  y_scale * 64.0 + .5,
+				  0, 0);
+	if (error)
+	    return _cairo_error (CAIRO_STATUS_NO_MEMORY);
+    } else {
+	double min_distance = DBL_MAX;
+	int i;
+	int best_i = 0;
+
+	for (i = 0; i < unscaled->face->num_fixed_sizes; i++) {
+#if HAVE_FT_BITMAP_SIZE_Y_PPEM
+	    double size = unscaled->face->available_sizes[i].y_ppem / 64.;
+#else
+	    double size = unscaled->face->available_sizes[i].height;
+#endif
+	    double distance = fabs (size - sf.y_scale);
+
+	    if (distance <= min_distance) {
+		min_distance = distance;
+		best_i = i;
+	    }
+	}
+#if HAVE_FT_BITMAP_SIZE_Y_PPEM
+	error = FT_Set_Char_Size (unscaled->face,
+				  unscaled->face->available_sizes[best_i].x_ppem,
+				  unscaled->face->available_sizes[best_i].y_ppem,
+				  0, 0);
+	if (error)
+#endif
+	    error = FT_Set_Pixel_Sizes (unscaled->face,
+					unscaled->face->available_sizes[best_i].width,
+					unscaled->face->available_sizes[best_i].height);
+	if (error)
+	    return _cairo_error (CAIRO_STATUS_NO_MEMORY);
+    }
 
     return CAIRO_STATUS_SUCCESS;
 }
 
 /* we sometimes need to convert the glyph bitmap in a FT_GlyphSlot
  * into a different format. For example, we want to convert a
  * FT_PIXEL_MODE_LCD or FT_PIXEL_MODE_LCD_V bitmap into a 32-bit
  * ARGB or ABGR bitmap.
@@ -1110,26 +1109,24 @@ static void
     }
 }
 
 
 /* Fills in val->image with an image surface created from @bitmap
  */
 static cairo_status_t
 _get_bitmap_surface (FT_Bitmap		     *bitmap,
-		     FT_Library		      library,
 		     cairo_bool_t	      own_buffer,
 		     cairo_font_options_t    *font_options,
 		     cairo_image_surface_t  **surface)
 {
     int width, height, stride;
     unsigned char *data;
     int format = CAIRO_FORMAT_A8;
     cairo_image_surface_t *image;
-    cairo_bool_t component_alpha = FALSE;
 
     width = bitmap->width;
     height = bitmap->rows;
 
     if (width == 0 || height == 0) {
 	*surface = (cairo_image_surface_t *)
 	    cairo_image_surface_create_for_data (NULL, format, 0, 0, 0);
 	return (*surface)->base.status;
@@ -1150,17 +1147,19 @@ static cairo_status_t
 		memcpy (data, bitmap->buffer, stride * height);
 	    } else {
 		int i;
 		unsigned char *source, *dest;
 
 		source = bitmap->buffer;
 		dest = data;
 		for (i = height; i; i--) {
-		    memcpy (dest, source, stride);
+		    memcpy (dest, source, bitmap->pitch);
+		    memset (dest + bitmap->pitch, '\0', stride - bitmap->pitch);
+
 		    source += bitmap->pitch;
 		    dest += stride;
 		}
 	    }
 	}
 
 #ifndef WORDS_BIGENDIAN
 	{
@@ -1174,104 +1173,43 @@ static cairo_status_t
 	}
 #endif
 	format = CAIRO_FORMAT_A1;
 	break;
 
     case FT_PIXEL_MODE_LCD:
     case FT_PIXEL_MODE_LCD_V:
     case FT_PIXEL_MODE_GRAY:
-	if (font_options->antialias != CAIRO_ANTIALIAS_SUBPIXEL ||
-	    bitmap->pixel_mode == FT_PIXEL_MODE_GRAY)
-	{
+        if (font_options->antialias != CAIRO_ANTIALIAS_SUBPIXEL) {
 	    stride = bitmap->pitch;
-
-	    /* We don't support stride not multiple of 4. */
-	    if (stride & 3)
-	    {
-		assert (!own_buffer);
-		goto convert;
-	    }
-
 	    if (own_buffer) {
 		data = bitmap->buffer;
 	    } else {
 		data = _cairo_malloc_ab (height, stride);
 		if (!data)
 		    return _cairo_error (CAIRO_STATUS_NO_MEMORY);
 
 		memcpy (data, bitmap->buffer, stride * height);
 	    }
 
-	    format = CAIRO_FORMAT_A8;
+	format = CAIRO_FORMAT_A8;
 	} else {
-	    data = bitmap->buffer;
-	    stride = bitmap->pitch;
-	    format = CAIRO_FORMAT_ARGB32;
-	    component_alpha = TRUE;
+	    /* if we get there, the  data from the source bitmap
+	     * really comes from _fill_xrender_bitmap, and is
+	     * made of 32-bit ARGB or ABGR values */
+	    assert (own_buffer != 0);
+	    assert (bitmap->pixel_mode != FT_PIXEL_MODE_GRAY);
+
+		data = bitmap->buffer;
+		stride = bitmap->pitch;
+		format = CAIRO_FORMAT_ARGB32;
 	}
 	break;
-#ifdef FT_LOAD_COLOR
-    case FT_PIXEL_MODE_BGRA:
-	stride = width * 4;
-	if (own_buffer) {
-	    data = bitmap->buffer;
-	} else {
-	    data = _cairo_malloc_ab (height, stride);
-	    if (!data)
-		return _cairo_error (CAIRO_STATUS_NO_MEMORY);
-
-	    memcpy (data, bitmap->buffer, stride * height);
-	}
-	format = CAIRO_FORMAT_ARGB32;
-	break;
-#endif
     case FT_PIXEL_MODE_GRAY2:
     case FT_PIXEL_MODE_GRAY4:
-    convert:
-	if (!own_buffer && library)
-	{
-	    /* This is pretty much the only case that we can get in here. */
-	    /* Convert to 8bit grayscale. */
-
-	    FT_Bitmap  tmp;
-	    FT_Int     align;
-
-	    format = CAIRO_FORMAT_A8;
-
-	    align = cairo_format_stride_for_width (format, bitmap->width);
-
-	    FT_Bitmap_New( &tmp );
-
-	    if (FT_Bitmap_Convert( library, bitmap, &tmp, align ))
-		return _cairo_error (CAIRO_STATUS_NO_MEMORY);
-
-	    FT_Bitmap_Done( library, bitmap );
-	    *bitmap = tmp;
-
-	    stride = bitmap->pitch;
-	    data = _cairo_malloc_ab (height, stride);
-	    if (!data)
-		return _cairo_error (CAIRO_STATUS_NO_MEMORY);
-
-	    if (bitmap->num_grays != 256)
-	    {
-	      unsigned int x, y;
-	      unsigned int mul = 255 / (bitmap->num_grays - 1);
-	      FT_Byte *p = bitmap->buffer;
-	      for (y = 0; y < height; y++) {
-	        for (x = 0; x < width; x++)
-		  p[x] *= mul;
-		p += bitmap->pitch;
-	      }
-	    }
-
-	    memcpy (data, bitmap->buffer, stride * height);
-	    break;
-	}
 	/* These could be triggered by very rare types of TrueType fonts */
     default:
 	if (own_buffer)
 	    free (bitmap->buffer);
 	return _cairo_error (CAIRO_STATUS_NO_MEMORY);
     }
 
     /* XXX */
@@ -1279,17 +1217,17 @@ static cairo_status_t
 	cairo_image_surface_create_for_data (data,
 					     format,
 					     width, height, stride);
     if (image->base.status) {
 	free (data);
 	return (*surface)->base.status;
     }
 
-    if (component_alpha)
+    if (format == CAIRO_FORMAT_ARGB32)
 	pixman_image_set_component_alpha (image->pixman_image, TRUE);
 
     _cairo_image_surface_assume_ownership_of_data (image);
 
     _cairo_debug_check_image_surface_is_defined (&image->base);
 
     return CAIRO_STATUS_SUCCESS;
 }
@@ -1460,17 +1398,17 @@ static cairo_status_t
 		return _cairo_error (CAIRO_STATUS_NO_MEMORY);
 
 	_fill_xrender_bitmap (&bitmap, face->glyph, render_mode,
 			      (rgba == FC_RGBA_BGR || rgba == FC_RGBA_VBGR));
 
 	/* Note:
 	 * _get_bitmap_surface will free bitmap.buffer if there is an error
 	 */
-	status = _get_bitmap_surface (&bitmap, NULL, TRUE, font_options, surface);
+	status = _get_bitmap_surface (&bitmap, TRUE, font_options, surface);
 	if (unlikely (status))
 	    return status;
 
 	/* Note: the font's coordinate system is upside down from ours, so the
 	 * Y coordinate of the control box needs to be negated.  Moreover, device
 	 * offsets are position of glyph origin relative to top left while xMin
 	 * and yMax are offsets of top left relative to origin.  Another negation.
 	 */
@@ -1501,17 +1439,16 @@ static cairo_status_t
      */
     error = FT_Render_Glyph (glyphslot, FT_RENDER_MODE_NORMAL);
     /* XXX ignoring all other errors for now.  They are not fatal, typically
      * just a glyph-not-found. */
     if (error == FT_Err_Out_Of_Memory)
 	return _cairo_error (CAIRO_STATUS_NO_MEMORY);
 
     status = _get_bitmap_surface (&glyphslot->bitmap,
-				  glyphslot->library,
 				  FALSE, font_options,
 				  surface);
     if (unlikely (status))
 	return status;
 
     /*
      * Note: the font's coordinate system is upside down from ours, so the
      * Y coordinate of the control box needs to be negated.  Moreover, device
@@ -1543,17 +1480,17 @@ static cairo_status_t
     cairo_status_t status;
     cairo_surface_pattern_t pattern;
 
     /* We want to compute a transform that takes the origin
      * (device_x_offset, device_y_offset) to 0,0, then applies
      * the "shape" portion of the font transform
      */
     original_to_transformed = *shape;
-
+    
     cairo_surface_get_device_offset (&(*surface)->base, &origin_x, &origin_y);
     orig_width = (*surface)->width;
     orig_height = (*surface)->height;
 
     cairo_matrix_translate (&original_to_transformed,
 			    -origin_x, -origin_y);
 
     /* Find the bounding box of the original bitmap under that
@@ -1593,21 +1530,17 @@ static cairo_status_t
     width  = x_max - x_min;
     height = y_max - y_min;
 
     transformed_to_original = original_to_transformed;
     status = cairo_matrix_invert (&transformed_to_original);
     if (unlikely (status))
 	return status;
 
-    if (cairo_image_surface_get_format (*surface) == CAIRO_FORMAT_ARGB32 &&
-        !pixman_image_get_component_alpha ((*surface)->pixman_image))
-      image = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, width, height);
-    else
-      image = cairo_image_surface_create (CAIRO_FORMAT_A8, width, height);
+    image = cairo_image_surface_create (CAIRO_FORMAT_A8, width, height);
     if (unlikely (image->status))
 	return image->status;
 
     /* Draw the original bitmap transformed into the new bitmap
      */
     _cairo_pattern_init_for_surface (&pattern, &(*surface)->base);
     cairo_pattern_set_matrix (&pattern.base, &transformed_to_original);
 
@@ -2231,28 +2164,16 @@ static cairo_int_status_t
      * Don't pass FT_LOAD_VERTICAL_LAYOUT to FT_Load_Glyph here as
      * suggested by freetype people.
      */
     if (load_flags & FT_LOAD_VERTICAL_LAYOUT) {
 	load_flags &= ~FT_LOAD_VERTICAL_LAYOUT;
 	vertical_layout = TRUE;
     }
 
-#ifdef FT_LOAD_COLOR
-    /* Color-glyph support:
-     *
-     * This flags needs plumbing through fontconfig (does it?), and
-     * maybe we should cache color and grayscale bitmaps separately
-     * such that users of the font (ie. the surface) can choose which
-     * version to use based on target content type.
-     */
-
-    load_flags |= FT_LOAD_COLOR;
-#endif
-
     error = FT_Load_Glyph (scaled_font->unscaled->face,
 			   _cairo_scaled_glyph_index(scaled_glyph),
 			   load_flags);
     /* XXX ignoring all other errors for now.  They are not fatal, typically
      * just a glyph-not-found. */
     if (error == FT_Err_Out_Of_Memory) {
 	status = _cairo_error (CAIRO_STATUS_NO_MEMORY);
 	goto FAIL;
@@ -3000,17 +2921,17 @@ static cairo_font_face_t *
     cairo_font_face_t *font_face;
 
     scale = *ctm;
     scale.x0 = scale.y0 = 0;
     cairo_matrix_multiply (&scale,
                            font_matrix,
                            &scale);
 
-    status = _compute_transform (&sf, &scale, NULL);
+    status = _compute_transform (&sf, &scale);
     if (unlikely (status))
 	return (cairo_font_face_t *)&_cairo_font_face_nil;
 
     pattern = FcPatternDuplicate (pattern);
     if (pattern == NULL)
 	return (cairo_font_face_t *)&_cairo_font_face_nil;
 
     if (! FcPatternAddDouble (pattern, FC_PIXEL_SIZE, sf.y_scale)) {
--- a/gfx/cairo/cairo/src/cairo-image-surface.c
+++ b/gfx/cairo/cairo/src/cairo-image-surface.c
@@ -3953,16 +3953,26 @@ static cairo_status_t
     composite_glyphs_info_t *info = closure;
     cairo_scaled_glyph_t *glyph_cache[64];
     pixman_op_t pixman_op = _pixman_operator (op);
     pixman_image_t *src = NULL;
     int src_x = 0, src_y = 0;
     cairo_status_t status;
     int i;
 
+    if (pattern != NULL) {
+	src = _pixman_image_for_pattern (pattern, FALSE, extents, &src_x, &src_y);
+	src_x -= dst_x;
+	src_y -= dst_y;
+    } else {
+	src = _pixman_white_image ();
+    }
+    if (unlikely (src == NULL))
+	return _cairo_error (CAIRO_STATUS_NO_MEMORY);
+
     memset (glyph_cache, 0, sizeof (glyph_cache));
     status = CAIRO_STATUS_SUCCESS;
 
     _cairo_scaled_font_freeze_cache (info->font);
     for (i = 0; i < info->num_glyphs; i++) {
 	int x, y;
 	cairo_image_surface_t *glyph_surface;
 	cairo_scaled_glyph_t *scaled_glyph;
@@ -4003,53 +4013,27 @@ static cairo_status_t
 
 	    y1 = y;
 	    if (y1 < extents->y)
 		y1 = extents->y;
 	    y2 = y + glyph_surface->height;
 	    if (y2 > extents->y + extents->height)
 		y2 = extents->y + extents->height;
 
-	    if (glyph_surface->format == CAIRO_FORMAT_A8 ||
-	        glyph_surface->format == CAIRO_FORMAT_A1)
-	    {
-		if (unlikely (src == NULL)) {
-		    if (pattern != NULL) {
-			src = _pixman_image_for_pattern (pattern, FALSE, extents, &src_x, &src_y);
-			src_x -= dst_x;
-			src_y -= dst_y;
-		    } else {
-			src = _pixman_white_image ();
-		    }
-		    if (unlikely (src == NULL)) {
-			status = _cairo_error (CAIRO_STATUS_NO_MEMORY);
-			break;
-		    }
-		}
-
-		pixman_image_composite32 (pixman_op,
-					  src, glyph_surface->pixman_image, dst,
-					  x1 + src_x, y1 + src_y,
-					  x1 - x, y1 - y,
-					  x1 - dst_x, y1 - dst_y,
-					  x2 - x1, y2 - y1);
-	    } else {
-		pixman_image_composite32 (pixman_op,
-					  glyph_surface->pixman_image, NULL, dst,
-					  x1 - x, y1 - y,
-					  0, 0,
-					  x1 - dst_x, y1 - dst_y,
-					  x2 - x1, y2 - y1);
-	    }
+	    pixman_image_composite32 (pixman_op,
+                                      src, glyph_surface->pixman_image, dst,
+                                      x1 + src_x,  y1 + src_y,
+                                      x1 - x, y1 - y,
+                                      x1 - dst_x, y1 - dst_y,
+                                      x2 - x1, y2 - y1);
 	}
     }
     _cairo_scaled_font_thaw_cache (info->font);
 
-    if (src != NULL)
-	pixman_image_unref (src);
+    pixman_image_unref (src);
 
     return status;
 }
 
 static cairo_int_status_t
 _cairo_image_surface_glyphs (void			*abstract_surface,
 			     cairo_operator_t		 op,
 			     const cairo_pattern_t	*source,
--- a/media/libpng/mozpngconf.h
+++ b/media/libpng/mozpngconf.h
@@ -61,35 +61,29 @@
 #define PNG_READ_COMPRESSED_TEXT_SUPPORTED
 #define PNG_READ_EXPAND_SUPPORTED
 #define PNG_READ_GAMMA_SUPPORTED
 #define PNG_READ_GRAY_TO_RGB_SUPPORTED
 #define PNG_READ_INTERLACING_SUPPORTED
 #define PNG_READ_SCALE_16_TO_8_SUPPORTED
 #define PNG_READ_TRANSFORMS_SUPPORTED
 
-/* 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) */
+/* necessary for boot animation code */
 #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
 #define PNG_WRITE_APNG_SUPPORTED
 #define PNG_WRITE_tRNS_SUPPORTED
 #define PNG_WRITE_16BIT_SUPPORTED
 #define PNG_WRITE_ANCILLARY_CHUNKS_SUPPORTED
 #define PNG_WRITE_FLUSH_SUPPORTED
@@ -110,18 +104,21 @@
 #define PNG_16BIT_SUPPORTED
 #define PNG_CHECK_cHRM_SUPPORTED
 #define PNG_FLOATING_ARITHMETIC_SUPPORTED
 #define PNG_FLOATING_POINT_SUPPORTED
 #define PNG_POINTER_INDEXING_SUPPORTED
 #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
    library a different name such as "mozlibpng" instead of "libpng". */
 
 /* The following has been present since libpng-0.88, has never changed, and
    is unaffected by conditional compilation macros.  It will not be mangled
    and it is the only choice for use in configure scripts for detecting the
@@ -642,27 +639,21 @@
 #define png_icc_check_length                      MOZ_PNG_icc_check_length
 #define png_icc_check_tag_table                   MOZ_PNG_icc_check_tags
 #define png_icc_set_sRGB                          MOZ_PNG_icc_set_sRGB
 #define png_malloc_array                          MOZ_PNG_malloc_array
 #define png_malloc_base                           MOZ_PNG_malloc_base
 #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
 #define png_chunk_warning               MOZ_PNG_chunk_warn
 #define png_warning_parameter           MOZ_PNG_warn_param
 #define png_warning_parameter_signed    MOZ_PNG_warn_param_signed
 #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 */
--- a/widget/gonk/libdisplay/BootAnimation.cpp
+++ b/widget/gonk/libdisplay/BootAnimation.cpp
@@ -262,17 +262,17 @@ struct RawReadState {
     uint32_t length;
 };
 
 static void
 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_error(png_ptr, "PNG read overrun");
+        png_err(png_ptr);
 
     memcpy(data, state->start + state->offset, length);
     state->offset += length;
 }
 
 static void
 TransformTo565(png_structp png_ptr, png_row_infop row_info, png_bytep data)
 {