blob: f8edd594b9515b5384257608a75e7f2c9c953e59 [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:
mtklein2766c002015-06-26 11:45:03 -070016
robertphillips@google.coma22e2112012-08-16 14:58:06 +000017
reed@android.com2ee7c642009-10-28 14:25:34 +000018 // 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;
robertphillips@google.coma22e2112012-08-16 14:58:06 +000027
28private:
29 typedef SkRefCnt INHERITED;
reed@android.com4408cca2009-10-27 02:24:03 +000030};
31
32class SkBoundaryPatch {
33public:
34 SkBoundaryPatch();
35 ~SkBoundaryPatch();
36
reed@android.com2ee7c642009-10-28 14:25:34 +000037 SkBoundary* getBoundary() const { return fBoundary; }
38 SkBoundary* setBoundary(SkBoundary*);
reed@android.com4408cca2009-10-27 02:24:03 +000039
reed@android.com2ee7c642009-10-28 14:25:34 +000040 SkPoint eval(SkScalar unitU, SkScalar unitV);
41 bool evalPatch(SkPoint verts[], int rows, int cols);
reed@android.com4408cca2009-10-27 02:24:03 +000042
43private:
reed@android.com2ee7c642009-10-28 14:25:34 +000044 SkBoundary* fBoundary;
reed@android.com4408cca2009-10-27 02:24:03 +000045};
46
47////////////////////////////////////////////////////////////////////////
48
reed@android.com2ee7c642009-10-28 14:25:34 +000049class SkLineBoundary : public SkBoundary {
reed@android.com4408cca2009-10-27 02:24:03 +000050public:
51 SkPoint fPts[4];
rmistry@google.comfbfcd562012-08-23 18:09:54 +000052
reed@android.com4408cca2009-10-27 02:24:03 +000053 // override
reed@android.com2ee7c642009-10-28 14:25:34 +000054 virtual SkPoint eval(Edge, SkScalar);
55};
56
57class SkCubicBoundary : public SkBoundary {
58public:
59 // the caller sets the first 12 entries. The 13th is used by the impl.
60 SkPoint fPts[13];
rmistry@google.comfbfcd562012-08-23 18:09:54 +000061
reed@android.com2ee7c642009-10-28 14:25:34 +000062 // override
63 virtual SkPoint eval(Edge, SkScalar);
reed@android.com4408cca2009-10-27 02:24:03 +000064};
65
66#endif