Back to index

lightning-sunbird  0.9+nobinonly
Defines | Functions
nsSVGFill.cpp File Reference
#include <math.h>
#include "nsSVGFill.h"
#include "nsISVGPathGeometrySource.h"

Go to the source code of this file.

Defines

#define EPSILON   1e-6

Functions

static PRBool ContainsOpenPath (ArtVpath *src)
static ArtVpath * CloseOpenPath (ArtVpath *src)

Define Documentation

#define EPSILON   1e-6

Definition at line 47 of file nsSVGFill.cpp.


Function Documentation

static ArtVpath* CloseOpenPath ( ArtVpath *  src) [static]

Definition at line 60 of file nsSVGFill.cpp.

{
  // We need to insert something extra for each open subpath
  // So we realloc stuff as needed
  int currSize = 0;
  int maxSize = 4;
  ArtVpath *ret = art_new(ArtVpath, maxSize);

  PRBool isOpenSubpath = PR_FALSE;
  double startX=0;
  double startY=0;

  int srcPos;
  for (srcPos=0;src[srcPos].code != ART_END;++srcPos) {
    if (currSize==maxSize)
      art_expand(ret, ArtVpath, maxSize);
    if (src[srcPos].code == ART_MOVETO_OPEN)
      ret[currSize].code = ART_MOVETO; // close it
    else
      ret[currSize].code = src[srcPos].code;
    ret[currSize].x = src[srcPos].x;
    ret[currSize].y = src[srcPos].y;
    ++currSize;

    // OK, it was open
    if (src[srcPos].code == ART_MOVETO_OPEN) {
      startX = src[srcPos].x;
      startY = src[srcPos].y;
      isOpenSubpath = PR_TRUE;
    } else if (src[srcPos+1].code != ART_LINETO) {
      if (isOpenSubpath &&
          ((fabs(startX - src[srcPos].x) > EPSILON) ||
           (fabs(startY - src[srcPos].y) > EPSILON))) {
        // The next one isn't a line, so lets close this
        if (currSize == maxSize)
          art_expand(ret, ArtVpath, maxSize);
        ret[currSize].code = ART_LINETO;
        ret[currSize].x = startX;
        ret[currSize].y = startY;
        ++currSize;
      }
      isOpenSubpath = PR_FALSE;
    }
  }
  if (currSize == maxSize)
    art_expand(ret, ArtVpath, maxSize);
  ret[currSize].code = ART_END;
  ret[currSize].x = 0;
  ret[currSize].y = 0;
  return ret;
}

Here is the caller graph for this function:

static PRBool ContainsOpenPath ( ArtVpath *  src) [static]

Definition at line 49 of file nsSVGFill.cpp.

{
  int pos;
  for(pos=0;src[pos].code != ART_END;++pos) {
    if (src[pos].code==ART_MOVETO_OPEN)
      return PR_TRUE;
  }
  return PR_FALSE;
}

Here is the caller graph for this function: