aboutsummaryrefslogtreecommitdiffstats
path: root/include/core/SkPerspIter.h
blob: 7f6add289c715ae8116da191c0956eccbbc6cebc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48

/*
 * Copyright 2006 The Android Open Source Project
 *
 * Use of this source code is governed by a BSD-style license that can be
 * found in the LICENSE file.
 */


#ifndef SkPerspIter_DEFINED
#define SkPerspIter_DEFINED

#include "SkMatrix.h"

class SkPerspIter {
public:
    /** Iterate a line through the matrix [x,y] ... [x+count-1, y].
        @param m    The matrix we will be iterating a line through
        @param x    The initial X coordinate to be mapped through the matrix
        @param y    The initial Y coordinate to be mapped through the matrix
        @param count The number of points (x,y) (x+1,y) (x+2,y) ... we will eventually map
    */
    SkPerspIter(const SkMatrix& m, SkScalar x, SkScalar y, int count);
    
    /** Return the buffer of [x,y] fixed point values we will be filling.
        This always returns the same value, so it can be saved across calls to
        next().
    */
    const SkFixed* getXY() const { return fStorage; }

    /** Return the number of [x,y] pairs that have been filled in the getXY() buffer.
        When this returns 0, the iterator is finished.
    */
    int next();
    
private:
    enum {
        kShift  = 4,
        kCount  = (1 << kShift)
    };
    const SkMatrix& fMatrix;
    SkFixed         fStorage[kCount * 2];
    SkFixed         fX, fY;
    SkScalar        fSX, fSY;
    int             fCount;
};

#endif