1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/gfx/skia/trunk/include/utils/SkBoundaryPatch.h Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,66 @@ 1.4 + 1.5 +/* 1.6 + * Copyright 2011 Google Inc. 1.7 + * 1.8 + * Use of this source code is governed by a BSD-style license that can be 1.9 + * found in the LICENSE file. 1.10 + */ 1.11 +#ifndef SkBoundaryPatch_DEFINED 1.12 +#define SkBoundaryPatch_DEFINED 1.13 + 1.14 +#include "SkPoint.h" 1.15 +#include "SkRefCnt.h" 1.16 + 1.17 +class SkBoundary : public SkRefCnt { 1.18 +public: 1.19 + SK_DECLARE_INST_COUNT(SkBoundary) 1.20 + 1.21 + // These must be 0, 1, 2, 3 for efficiency in the subclass implementations 1.22 + enum Edge { 1.23 + kTop = 0, 1.24 + kRight = 1, 1.25 + kBottom = 2, 1.26 + kLeft = 3 1.27 + }; 1.28 + // Edge index goes clockwise around the boundary, beginning at the "top" 1.29 + virtual SkPoint eval(Edge, SkScalar unitInterval) = 0; 1.30 + 1.31 +private: 1.32 + typedef SkRefCnt INHERITED; 1.33 +}; 1.34 + 1.35 +class SkBoundaryPatch { 1.36 +public: 1.37 + SkBoundaryPatch(); 1.38 + ~SkBoundaryPatch(); 1.39 + 1.40 + SkBoundary* getBoundary() const { return fBoundary; } 1.41 + SkBoundary* setBoundary(SkBoundary*); 1.42 + 1.43 + SkPoint eval(SkScalar unitU, SkScalar unitV); 1.44 + bool evalPatch(SkPoint verts[], int rows, int cols); 1.45 + 1.46 +private: 1.47 + SkBoundary* fBoundary; 1.48 +}; 1.49 + 1.50 +//////////////////////////////////////////////////////////////////////// 1.51 + 1.52 +class SkLineBoundary : public SkBoundary { 1.53 +public: 1.54 + SkPoint fPts[4]; 1.55 + 1.56 + // override 1.57 + virtual SkPoint eval(Edge, SkScalar); 1.58 +}; 1.59 + 1.60 +class SkCubicBoundary : public SkBoundary { 1.61 +public: 1.62 + // the caller sets the first 12 entries. The 13th is used by the impl. 1.63 + SkPoint fPts[13]; 1.64 + 1.65 + // override 1.66 + virtual SkPoint eval(Edge, SkScalar); 1.67 +}; 1.68 + 1.69 +#endif