gfx/cairo/quartz-const-globals.patch

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

     1 # HG changeset patch
     2 # User Robert O'Callahan <robert@ocallahan.org>
     3 # Date 1249558626 -43200
     4 # Node ID 963b9451ad305924738d05d997a640698cd3af91
     5 # Parent  e564f3ab4ea6e3b5dd9c4e9e6042d3a84c229dde
     6 Bug 508730. Clean up Quartz gradient code by moving some local variables to static const globals. r=jmuizelaar
     8 diff --git a/gfx/cairo/cairo/src/cairo-quartz-surface.c b/gfx/cairo/cairo/src/cairo-quartz-surface.c
     9 --- a/gfx/cairo/cairo/src/cairo-quartz-surface.c
    10 +++ b/gfx/cairo/cairo/src/cairo-quartz-surface.c
    11 @@ -684,51 +684,50 @@ ComputeGradientValue (void *info, const 
    12  	    grad->stops[i-1].color.blue * ap +
    13  	    grad->stops[i].color.blue * bp;
    14  	out[3] =
    15  	    grad->stops[i-1].color.alpha * ap +
    16  	    grad->stops[i].color.alpha * bp;
    17      }
    18  }
    20 +static const float gradient_output_value_ranges[8] = {
    21 +    0.f, 1.f, 0.f, 1.f, 0.f, 1.f, 0.f, 1.f
    22 +};
    23 +static const CGFunctionCallbacks gradient_callbacks = {
    24 +    0, ComputeGradientValue, (CGFunctionReleaseInfoCallback) cairo_pattern_destroy
    25 +};
    26 +
    27  static CGFunctionRef
    28  CreateGradientFunction (const cairo_gradient_pattern_t *gpat)
    29  {
    30      cairo_pattern_t *pat;
    31      float input_value_range[2] = { 0.f, 1.f };
    32 -    float output_value_ranges[8] = { 0.f, 1.f, 0.f, 1.f, 0.f, 1.f, 0.f, 1.f };
    33 -    CGFunctionCallbacks callbacks = {
    34 -	0, ComputeGradientValue, (CGFunctionReleaseInfoCallback) cairo_pattern_destroy
    35 -    };
    37      if (_cairo_pattern_create_copy (&pat, &gpat->base))
    38  	/* quartz doesn't deal very well with malloc failing, so there's
    39  	 * not much point in us trying either */
    40  	return NULL;
    42      return CGFunctionCreate (pat,
    43  			     1,
    44  			     input_value_range,
    45  			     4,
    46 -			     output_value_ranges,
    47 -			     &callbacks);
    48 +			     gradient_output_value_ranges,
    49 +			     &gradient_callbacks);
    50  }
    52  static CGFunctionRef
    53  CreateRepeatingLinearGradientFunction (cairo_quartz_surface_t *surface,
    54  				       const cairo_gradient_pattern_t *gpat,
    55  				       CGPoint *start, CGPoint *end,
    56  				       CGAffineTransform matrix)
    57  {
    58      cairo_pattern_t *pat;
    59      float input_value_range[2];
    60 -    float output_value_ranges[8] = { 0.f, 1.f, 0.f, 1.f, 0.f, 1.f, 0.f, 1.f };
    61 -    CGFunctionCallbacks callbacks = {
    62 -	0, ComputeGradientValue, (CGFunctionReleaseInfoCallback) cairo_pattern_destroy
    63 -    };
    65      CGPoint mstart, mend;
    67      double dx, dy;
    68      int x_rep_start = 0, x_rep_end = 0;
    69      int y_rep_start = 0, y_rep_end = 0;
    71      int rep_start, rep_end;
    72 @@ -787,18 +786,18 @@ CreateRepeatingLinearGradientFunction (c
    73  	/* quartz doesn't deal very well with malloc failing, so there's
    74  	 * not much point in us trying either */
    75  	return NULL;
    77      return CGFunctionCreate (pat,
    78  			     1,
    79  			     input_value_range,
    80  			     4,
    81 -			     output_value_ranges,
    82 -			     &callbacks);
    83 +			     gradient_output_value_ranges,
    84 +			     &gradient_callbacks);
    85  }
    87  static void
    88  UpdateRadialParameterToIncludePoint(double *max_t, CGPoint *center,
    89                                      double dr, double dx, double dy,
    90                                      double x, double y)
    91  {
    92      /* Compute a parameter t such that a circle centered at
    93 @@ -847,20 +846,16 @@ CreateRepeatingRadialGradientFunction (c
    94                                         const cairo_gradient_pattern_t *gpat,
    95                                         CGPoint *start, double *start_radius,
    96                                         CGPoint *end, double *end_radius)
    97  {
    98      CGRect clip = CGContextGetClipBoundingBox (surface->cgContext);
    99      CGAffineTransform transform;
   100      cairo_pattern_t *pat;
   101      float input_value_range[2];
   102 -    float output_value_ranges[8] = { 0.f, 1.f, 0.f, 1.f, 0.f, 1.f, 0.f, 1.f };
   103 -    CGFunctionCallbacks callbacks = {
   104 -        0, ComputeGradientValue, (CGFunctionReleaseInfoCallback) cairo_pattern_destroy
   105 -    };
   106      CGPoint *inner;
   107      double *inner_radius;
   108      CGPoint *outer;
   109      double *outer_radius;
   110      /* minimum and maximum t-parameter values that will make our gradient
   111         cover the clipBox */
   112      double t_min, t_max, t_temp;
   113      /* outer minus inner */
   114 @@ -927,18 +922,18 @@ CreateRepeatingRadialGradientFunction (c
   115    /* quartz doesn't deal very well with malloc failing, so there's
   116     * not much point in us trying either */
   117    return NULL;
   119      return CGFunctionCreate (pat,
   120             1,
   121             input_value_range,
   122             4,
   123 -           output_value_ranges,
   124 -           &callbacks);
   125 +           gradient_output_value_ranges,
   126 +           &gradient_callbacks);
   127  }
   129  /* Obtain a CGImageRef from a #cairo_surface_t * */
   131  static void
   132  DataProviderReleaseCallback (void *info, const void *data, size_t size)
   133  {
   134      cairo_surface_t *surface = (cairo_surface_t *) info;

mercurial