Home | History | Annotate | Download | only in utils
      1 #ifndef SkBoundaryPatch_DEFINED
      2 #define SkBoundaryPatch_DEFINED
      3 
      4 #include "SkPoint.h"
      5 #include "SkRefCnt.h"
      6 
      7 class SkBoundary : public SkRefCnt {
      8 public:
      9     // These must be 0, 1, 2, 3 for efficiency in the subclass implementations
     10     enum Edge {
     11         kTop    = 0,
     12         kRight  = 1,
     13         kBottom = 2,
     14         kLeft   = 3
     15     };
     16     // Edge index goes clockwise around the boundary, beginning at the "top"
     17     virtual SkPoint eval(Edge, SkScalar unitInterval) = 0;
     18 };
     19 
     20 class SkBoundaryPatch {
     21 public:
     22     SkBoundaryPatch();
     23     ~SkBoundaryPatch();
     24 
     25     SkBoundary* getBoundary() const { return fBoundary; }
     26     SkBoundary* setBoundary(SkBoundary*);
     27 
     28     SkPoint eval(SkScalar unitU, SkScalar unitV);
     29     bool evalPatch(SkPoint verts[], int rows, int cols);
     30 
     31 private:
     32     SkBoundary* fBoundary;
     33 };
     34 
     35 ////////////////////////////////////////////////////////////////////////
     36 
     37 class SkLineBoundary : public SkBoundary {
     38 public:
     39     SkPoint fPts[4];
     40 
     41     // override
     42     virtual SkPoint eval(Edge, SkScalar);
     43 };
     44 
     45 class SkCubicBoundary : public SkBoundary {
     46 public:
     47     // the caller sets the first 12 entries. The 13th is used by the impl.
     48     SkPoint fPts[13];
     49 
     50     // override
     51     virtual SkPoint eval(Edge, SkScalar);
     52 };
     53 
     54 #endif
     55 
     56