gfx/skia/trunk/include/utils/SkBoundaryPatch.h

branch
TOR_BUG_3246
changeset 7
129ffea94266
equal deleted inserted replaced
-1:000000000000 0:ffb63afa5872
1
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 */
8 #ifndef SkBoundaryPatch_DEFINED
9 #define SkBoundaryPatch_DEFINED
10
11 #include "SkPoint.h"
12 #include "SkRefCnt.h"
13
14 class SkBoundary : public SkRefCnt {
15 public:
16 SK_DECLARE_INST_COUNT(SkBoundary)
17
18 // These must be 0, 1, 2, 3 for efficiency in the subclass implementations
19 enum Edge {
20 kTop = 0,
21 kRight = 1,
22 kBottom = 2,
23 kLeft = 3
24 };
25 // Edge index goes clockwise around the boundary, beginning at the "top"
26 virtual SkPoint eval(Edge, SkScalar unitInterval) = 0;
27
28 private:
29 typedef SkRefCnt INHERITED;
30 };
31
32 class SkBoundaryPatch {
33 public:
34 SkBoundaryPatch();
35 ~SkBoundaryPatch();
36
37 SkBoundary* getBoundary() const { return fBoundary; }
38 SkBoundary* setBoundary(SkBoundary*);
39
40 SkPoint eval(SkScalar unitU, SkScalar unitV);
41 bool evalPatch(SkPoint verts[], int rows, int cols);
42
43 private:
44 SkBoundary* fBoundary;
45 };
46
47 ////////////////////////////////////////////////////////////////////////
48
49 class SkLineBoundary : public SkBoundary {
50 public:
51 SkPoint fPts[4];
52
53 // override
54 virtual SkPoint eval(Edge, SkScalar);
55 };
56
57 class SkCubicBoundary : public SkBoundary {
58 public:
59 // the caller sets the first 12 entries. The 13th is used by the impl.
60 SkPoint fPts[13];
61
62 // override
63 virtual SkPoint eval(Edge, SkScalar);
64 };
65
66 #endif

mercurial