1 2 /* 3 * Copyright 2006 The Android Open Source Project 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 9 10 #ifndef SkPerspIter_DEFINED 11 #define SkPerspIter_DEFINED 12 13 #include "SkMatrix.h" 14 15 class SkPerspIter { 16 public: 17 /** Iterate a line through the matrix [x,y] ... [x+count-1, y]. 18 @param m The matrix we will be iterating a line through 19 @param x The initial X coordinate to be mapped through the matrix 20 @param y The initial Y coordinate to be mapped through the matrix 21 @param count The number of points (x,y) (x+1,y) (x+2,y) ... we will eventually map 22 */ 23 SkPerspIter(const SkMatrix& m, SkScalar x, SkScalar y, int count); 24 25 /** Return the buffer of [x,y] fixed point values we will be filling. 26 This always returns the same value, so it can be saved across calls to 27 next(). 28 */ 29 const SkFixed* getXY() const { return fStorage; } 30 31 /** Return the number of [x,y] pairs that have been filled in the getXY() buffer. 32 When this returns 0, the iterator is finished. 33 */ 34 int next(); 35 36 private: 37 enum { 38 kShift = 4, 39 kCount = (1 << kShift) 40 }; 41 const SkMatrix& fMatrix; 42 SkFixed fStorage[kCount * 2]; 43 SkFixed fX, fY; 44 SkScalar fSX, fSY; 45 int fCount; 46 }; 47 48 #endif 49