2009-10-27 02:24:03 +00:00
|
|
|
#ifndef SkBoundaryPatch_DEFINED
|
|
|
|
#define SkBoundaryPatch_DEFINED
|
|
|
|
|
|
|
|
#include "SkPoint.h"
|
|
|
|
#include "SkRefCnt.h"
|
|
|
|
|
2009-10-28 14:25:34 +00:00
|
|
|
class SkBoundary : public SkRefCnt {
|
2009-10-27 02:24:03 +00:00
|
|
|
public:
|
2009-10-28 14:25:34 +00:00
|
|
|
// These must be 0, 1, 2, 3 for efficiency in the subclass implementations
|
|
|
|
enum Edge {
|
|
|
|
kTop = 0,
|
|
|
|
kRight = 1,
|
|
|
|
kBottom = 2,
|
|
|
|
kLeft = 3
|
|
|
|
};
|
|
|
|
// Edge index goes clockwise around the boundary, beginning at the "top"
|
|
|
|
virtual SkPoint eval(Edge, SkScalar unitInterval) = 0;
|
2009-10-27 02:24:03 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
class SkBoundaryPatch {
|
|
|
|
public:
|
|
|
|
SkBoundaryPatch();
|
|
|
|
~SkBoundaryPatch();
|
|
|
|
|
2009-10-28 14:25:34 +00:00
|
|
|
SkBoundary* getBoundary() const { return fBoundary; }
|
|
|
|
SkBoundary* setBoundary(SkBoundary*);
|
2009-10-27 02:24:03 +00:00
|
|
|
|
2009-10-28 14:25:34 +00:00
|
|
|
SkPoint eval(SkScalar unitU, SkScalar unitV);
|
|
|
|
bool evalPatch(SkPoint verts[], int rows, int cols);
|
2009-10-27 02:24:03 +00:00
|
|
|
|
|
|
|
private:
|
2009-10-28 14:25:34 +00:00
|
|
|
SkBoundary* fBoundary;
|
2009-10-27 02:24:03 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2009-10-28 14:25:34 +00:00
|
|
|
class SkLineBoundary : public SkBoundary {
|
2009-10-27 02:24:03 +00:00
|
|
|
public:
|
2009-10-28 14:25:34 +00:00
|
|
|
SkPoint fPts[4];
|
2009-10-27 02:24:03 +00:00
|
|
|
|
|
|
|
// override
|
2009-10-28 14:25:34 +00:00
|
|
|
virtual SkPoint eval(Edge, SkScalar);
|
2009-10-27 02:24:03 +00:00
|
|
|
};
|
|
|
|
|
2009-10-28 14:25:34 +00:00
|
|
|
class SkCubicBoundary : public SkBoundary {
|
2009-10-27 02:24:03 +00:00
|
|
|
public:
|
2009-10-28 14:25:34 +00:00
|
|
|
// the caller sets the first 12 entries. The 13th is used by the impl.
|
|
|
|
SkPoint fPts[13];
|
2009-10-27 02:24:03 +00:00
|
|
|
|
|
|
|
// override
|
2009-10-28 14:25:34 +00:00
|
|
|
virtual SkPoint eval(Edge, SkScalar);
|
2009-10-27 02:24:03 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|