1 /* 2 * Copyright (C) 2006 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 #ifndef SkPerspIter_DEFINED 18 #define SkPerspIter_DEFINED 19 20 #include "SkMatrix.h" 21 22 class SkPerspIter { 23 public: 24 /** Iterate a line through the matrix [x,y] ... [x+count-1, y]. 25 @param m The matrix we will be iterating a line through 26 @param x The initial X coordinate to be mapped through the matrix 27 @param y The initial Y coordinate to be mapped through the matrix 28 @param count The number of points (x,y) (x+1,y) (x+2,y) ... we will eventually map 29 */ 30 SkPerspIter(const SkMatrix& m, SkScalar x, SkScalar y, int count); 31 32 /** Return the buffer of [x,y] fixed point values we will be filling. 33 This always returns the same value, so it can be saved across calls to 34 next(). 35 */ getXY()36 const SkFixed* getXY() const { return fStorage; } 37 38 /** Return the number of [x,y] pairs that have been filled in the getXY() buffer. 39 When this returns 0, the iterator is finished. 40 */ 41 int next(); 42 43 private: 44 enum { 45 kShift = 4, 46 kCount = (1 << kShift) 47 }; 48 const SkMatrix& fMatrix; 49 SkFixed fStorage[kCount * 2]; 50 SkFixed fX, fY; 51 SkScalar fSX, fSY; 52 int fCount; 53 }; 54 55 #endif 56