Back to index

lightning-sunbird  0.9+nobinonly
nsSVGCairoGradient.h File Reference
#include "nsISVGGradient.h"
#include "cairo.h"
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.


cairo_pattern_t * CairoGradient (cairo_t *ctx, nsISVGGradient *aGrad, nsISVGGeometrySource *aSource, float aOpacity)

Function Documentation

cairo_pattern_t* CairoGradient ( cairo_t *  ctx,
nsISVGGradient aGrad,
nsISVGGeometrySource aSource,
float  aOpacity 

Definition at line 151 of file nsSVGCairoGradient.cpp.

  NS_ASSERTION(aGrad, "Called CairoGradient without a gradient!");
  if (!aGrad)
    return nsnull;

  // Get the transform list (if there is one)
  nsCOMPtr<nsIDOMSVGMatrix> svgMatrix;
  aGrad->GetGradientTransform(getter_AddRefs(svgMatrix), aSource);
  NS_ASSERTION(svgMatrix, "CairoGradient: GetGradientTransform returns null");

  cairo_matrix_t patternMatrix = SVGToMatrix(svgMatrix);
  if (cairo_matrix_invert(&patternMatrix)) {
    return nsnull;

  cairo_pattern_t *gradient;

  // Linear or Radial?
  PRUint32 type;
  if (type == nsISVGGradient::SVG_LINEAR_GRADIENT)
    gradient = CairoLinearGradient(ctx, aGrad);
  else if (type == nsISVGGradient::SVG_RADIAL_GRADIENT)
    gradient = CairoRadialGradient(ctx, aGrad);
    return nsnull; // Shouldn't happen

  PRUint16 aSpread;
  // We don't call cairo_pattern_set_extend for SVG_SPREADMETHOD_PAD because
  // pad is cairo's default, and the explicit argument used for pad changed
  // from CAIRO_EXTEND_NONE to CAIRO_EXTEND_PAD between cairo 1.0 and 1.2. See
  // bug 358930.
  if (aSpread == nsIDOMSVGGradientElement::SVG_SPREADMETHOD_REFLECT)
    cairo_pattern_set_extend(gradient, CAIRO_EXTEND_REFLECT);
  else if (aSpread == nsIDOMSVGGradientElement::SVG_SPREADMETHOD_REPEAT)
    cairo_pattern_set_extend(gradient, CAIRO_EXTEND_REPEAT);
  cairo_pattern_set_matrix(gradient, &patternMatrix);

  CairoSetStops(gradient, aGrad, aOpacity);

  return gradient;

Here is the call graph for this function: