epoger@google.com | ec3ed6a | 2011-07-28 14:26:00 +0000 | [diff] [blame] | 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 | */ |
reed@android.com | 4408cca | 2009-10-27 02:24:03 +0000 | [diff] [blame] | 8 | #ifndef SkBoundaryPatch_DEFINED |
| 9 | #define SkBoundaryPatch_DEFINED |
| 10 | |
| 11 | #include "SkPoint.h" |
| 12 | #include "SkRefCnt.h" |
| 13 | |
reed@android.com | 2ee7c64 | 2009-10-28 14:25:34 +0000 | [diff] [blame] | 14 | class SkBoundary : public SkRefCnt { |
reed@android.com | 4408cca | 2009-10-27 02:24:03 +0000 | [diff] [blame] | 15 | public: |
mtklein | 2766c00 | 2015-06-26 11:45:03 -0700 | [diff] [blame] | 16 | |
robertphillips@google.com | a22e211 | 2012-08-16 14:58:06 +0000 | [diff] [blame] | 17 | |
reed@android.com | 2ee7c64 | 2009-10-28 14:25:34 +0000 | [diff] [blame] | 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; |
robertphillips@google.com | a22e211 | 2012-08-16 14:58:06 +0000 | [diff] [blame] | 27 | |
| 28 | private: |
| 29 | typedef SkRefCnt INHERITED; |
reed@android.com | 4408cca | 2009-10-27 02:24:03 +0000 | [diff] [blame] | 30 | }; |
| 31 | |
| 32 | class SkBoundaryPatch { |
| 33 | public: |
| 34 | SkBoundaryPatch(); |
| 35 | ~SkBoundaryPatch(); |
| 36 | |
reed@android.com | 2ee7c64 | 2009-10-28 14:25:34 +0000 | [diff] [blame] | 37 | SkBoundary* getBoundary() const { return fBoundary; } |
| 38 | SkBoundary* setBoundary(SkBoundary*); |
reed@android.com | 4408cca | 2009-10-27 02:24:03 +0000 | [diff] [blame] | 39 | |
reed@android.com | 2ee7c64 | 2009-10-28 14:25:34 +0000 | [diff] [blame] | 40 | SkPoint eval(SkScalar unitU, SkScalar unitV); |
| 41 | bool evalPatch(SkPoint verts[], int rows, int cols); |
reed@android.com | 4408cca | 2009-10-27 02:24:03 +0000 | [diff] [blame] | 42 | |
| 43 | private: |
reed@android.com | 2ee7c64 | 2009-10-28 14:25:34 +0000 | [diff] [blame] | 44 | SkBoundary* fBoundary; |
reed@android.com | 4408cca | 2009-10-27 02:24:03 +0000 | [diff] [blame] | 45 | }; |
| 46 | |
| 47 | //////////////////////////////////////////////////////////////////////// |
| 48 | |
reed@android.com | 2ee7c64 | 2009-10-28 14:25:34 +0000 | [diff] [blame] | 49 | class SkLineBoundary : public SkBoundary { |
reed@android.com | 4408cca | 2009-10-27 02:24:03 +0000 | [diff] [blame] | 50 | public: |
| 51 | SkPoint fPts[4]; |
rmistry@google.com | fbfcd56 | 2012-08-23 18:09:54 +0000 | [diff] [blame] | 52 | |
reed@android.com | 4408cca | 2009-10-27 02:24:03 +0000 | [diff] [blame] | 53 | // override |
reed@android.com | 2ee7c64 | 2009-10-28 14:25:34 +0000 | [diff] [blame] | 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]; |
rmistry@google.com | fbfcd56 | 2012-08-23 18:09:54 +0000 | [diff] [blame] | 61 | |
reed@android.com | 2ee7c64 | 2009-10-28 14:25:34 +0000 | [diff] [blame] | 62 | // override |
| 63 | virtual SkPoint eval(Edge, SkScalar); |
reed@android.com | 4408cca | 2009-10-27 02:24:03 +0000 | [diff] [blame] | 64 | }; |
| 65 | |
| 66 | #endif |