michael@0: michael@0: /* michael@0: * Copyright 2011 Google Inc. michael@0: * michael@0: * Use of this source code is governed by a BSD-style license that can be michael@0: * found in the LICENSE file. michael@0: */ michael@0: #ifndef SkBoundaryPatch_DEFINED michael@0: #define SkBoundaryPatch_DEFINED michael@0: michael@0: #include "SkPoint.h" michael@0: #include "SkRefCnt.h" michael@0: michael@0: class SkBoundary : public SkRefCnt { michael@0: public: michael@0: SK_DECLARE_INST_COUNT(SkBoundary) michael@0: michael@0: // These must be 0, 1, 2, 3 for efficiency in the subclass implementations michael@0: enum Edge { michael@0: kTop = 0, michael@0: kRight = 1, michael@0: kBottom = 2, michael@0: kLeft = 3 michael@0: }; michael@0: // Edge index goes clockwise around the boundary, beginning at the "top" michael@0: virtual SkPoint eval(Edge, SkScalar unitInterval) = 0; michael@0: michael@0: private: michael@0: typedef SkRefCnt INHERITED; michael@0: }; michael@0: michael@0: class SkBoundaryPatch { michael@0: public: michael@0: SkBoundaryPatch(); michael@0: ~SkBoundaryPatch(); michael@0: michael@0: SkBoundary* getBoundary() const { return fBoundary; } michael@0: SkBoundary* setBoundary(SkBoundary*); michael@0: michael@0: SkPoint eval(SkScalar unitU, SkScalar unitV); michael@0: bool evalPatch(SkPoint verts[], int rows, int cols); michael@0: michael@0: private: michael@0: SkBoundary* fBoundary; michael@0: }; michael@0: michael@0: //////////////////////////////////////////////////////////////////////// michael@0: michael@0: class SkLineBoundary : public SkBoundary { michael@0: public: michael@0: SkPoint fPts[4]; michael@0: michael@0: // override michael@0: virtual SkPoint eval(Edge, SkScalar); michael@0: }; michael@0: michael@0: class SkCubicBoundary : public SkBoundary { michael@0: public: michael@0: // the caller sets the first 12 entries. The 13th is used by the impl. michael@0: SkPoint fPts[13]; michael@0: michael@0: // override michael@0: virtual SkPoint eval(Edge, SkScalar); michael@0: }; michael@0: michael@0: #endif