blob: 9d4b5ad1ef1fc57cff0a3807710c61af08f93522 [file] [log] [blame]
epoger@google.comec3ed6a2011-07-28 14:26:00 +00001
2/*
3 * Copyright 2011 Google Inc.
4 *
5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file.
7 */
reed@android.com4408cca2009-10-27 02:24:03 +00008#ifndef SkBoundaryPatch_DEFINED
9#define SkBoundaryPatch_DEFINED
10
11#include "SkPoint.h"
12#include "SkRefCnt.h"
13
reed@android.com2ee7c642009-10-28 14:25:34 +000014class SkBoundary : public SkRefCnt {
reed@android.com4408cca2009-10-27 02:24:03 +000015public:
reed@android.com2ee7c642009-10-28 14:25:34 +000016 // These must be 0, 1, 2, 3 for efficiency in the subclass implementations
17 enum Edge {
18 kTop = 0,
19 kRight = 1,
20 kBottom = 2,
21 kLeft = 3
22 };
23 // Edge index goes clockwise around the boundary, beginning at the "top"
24 virtual SkPoint eval(Edge, SkScalar unitInterval) = 0;
reed@android.com4408cca2009-10-27 02:24:03 +000025};
26
27class SkBoundaryPatch {
28public:
29 SkBoundaryPatch();
30 ~SkBoundaryPatch();
31
reed@android.com2ee7c642009-10-28 14:25:34 +000032 SkBoundary* getBoundary() const { return fBoundary; }
33 SkBoundary* setBoundary(SkBoundary*);
reed@android.com4408cca2009-10-27 02:24:03 +000034
reed@android.com2ee7c642009-10-28 14:25:34 +000035 SkPoint eval(SkScalar unitU, SkScalar unitV);
36 bool evalPatch(SkPoint verts[], int rows, int cols);
reed@android.com4408cca2009-10-27 02:24:03 +000037
38private:
reed@android.com2ee7c642009-10-28 14:25:34 +000039 SkBoundary* fBoundary;
reed@android.com4408cca2009-10-27 02:24:03 +000040};
41
42////////////////////////////////////////////////////////////////////////
43
reed@android.com2ee7c642009-10-28 14:25:34 +000044class SkLineBoundary : public SkBoundary {
reed@android.com4408cca2009-10-27 02:24:03 +000045public:
46 SkPoint fPts[4];
47
48 // override
reed@android.com2ee7c642009-10-28 14:25:34 +000049 virtual SkPoint eval(Edge, SkScalar);
50};
51
52class SkCubicBoundary : public SkBoundary {
53public:
54 // the caller sets the first 12 entries. The 13th is used by the impl.
55 SkPoint fPts[13];
56
57 // override
58 virtual SkPoint eval(Edge, SkScalar);
reed@android.com4408cca2009-10-27 02:24:03 +000059};
60
61#endif
62