aboutsummaryrefslogtreecommitdiffhomepage
path: root/gpu/include/GrMesh.h
blob: 4d904e41bd18b77cc0510154b7c1bf21d781472c (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
#ifndef GrMesh_DEFINED
#define GrMesh_DEFINED

#include "SkRect.h"
#include "SkPoint.h"

class SkCanvas;
class SkPaint;

class GrMesh {
public:
    GrMesh();
    ~GrMesh();

    GrMesh& operator=(const GrMesh& src);

    void init(const SkRect& bounds, int rows, int cols,
              const SkRect& texture);

    const SkRect& bounds() const { return fBounds; }

    int rows() const { return fRows; }
    int cols() const { return fCols; }
    SkPoint& pt(int row, int col) {
        return fPts[row * (fRows + 1) + col];
    }

    void draw(SkCanvas*, const SkPaint&);
    void drawWireframe(SkCanvas* canvas, const SkPaint& paint);

private:
    SkRect      fBounds;
    int         fRows, fCols;
    SkPoint*    fPts;
    SkPoint*    fTex;   // just points into fPts, not separately allocated
    int         fCount;
    uint16_t*   fIndices;
    int         fIndexCount;
};

#endif