michael@0: michael@0: /* michael@0: * Copyright 2006 The Android Open Source Project 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: michael@0: michael@0: #ifndef SkPerspIter_DEFINED michael@0: #define SkPerspIter_DEFINED michael@0: michael@0: #include "SkMatrix.h" michael@0: michael@0: class SkPerspIter { michael@0: public: michael@0: /** Iterate a line through the matrix [x,y] ... [x+count-1, y]. michael@0: @param m The matrix we will be iterating a line through michael@0: @param x The initial X coordinate to be mapped through the matrix michael@0: @param y The initial Y coordinate to be mapped through the matrix michael@0: @param count The number of points (x,y) (x+1,y) (x+2,y) ... we will eventually map michael@0: */ michael@0: SkPerspIter(const SkMatrix& m, SkScalar x, SkScalar y, int count); michael@0: michael@0: /** Return the buffer of [x,y] fixed point values we will be filling. michael@0: This always returns the same value, so it can be saved across calls to michael@0: next(). michael@0: */ michael@0: const SkFixed* getXY() const { return fStorage; } michael@0: michael@0: /** Return the number of [x,y] pairs that have been filled in the getXY() buffer. michael@0: When this returns 0, the iterator is finished. michael@0: */ michael@0: int next(); michael@0: michael@0: private: michael@0: enum { michael@0: kShift = 4, michael@0: kCount = (1 << kShift) michael@0: }; michael@0: const SkMatrix& fMatrix; michael@0: SkFixed fStorage[kCount * 2]; michael@0: SkFixed fX, fY; michael@0: SkScalar fSX, fSY; michael@0: int fCount; michael@0: }; michael@0: michael@0: #endif