Home | History | Annotate | Download | only in utils
      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     // 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;
     25 };
     26 
     27 class SkBoundaryPatch {
     28 public:
     29     SkBoundaryPatch();
     30     ~SkBoundaryPatch();
     31 
     32     SkBoundary* getBoundary() const { return fBoundary; }
     33     SkBoundary* setBoundary(SkBoundary*);
     34 
     35     SkPoint eval(SkScalar unitU, SkScalar unitV);
     36     bool evalPatch(SkPoint verts[], int rows, int cols);
     37 
     38 private:
     39     SkBoundary* fBoundary;
     40 };
     41 
     42 ////////////////////////////////////////////////////////////////////////
     43 
     44 class SkLineBoundary : public SkBoundary {
     45 public:
     46     SkPoint fPts[4];
     47 
     48     // override
     49     virtual SkPoint eval(Edge, SkScalar);
     50 };
     51 
     52 class SkCubicBoundary : public SkBoundary {
     53 public:
     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);
     59 };
     60 
     61 #endif
     62 
     63