blob: 122613264f62b558a8aceb355852544d0c1e4d52 [file] [log] [blame]
epoger@google.comec3ed6a2011-07-28 14:26:00 +00001
2/*
3 * Copyright 2011 Google Inc.
4 *
5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file.
7 */
reed@google.comac10a2d2010-12-22 21:39:39 +00008#ifndef GrMesh_DEFINED
9#define GrMesh_DEFINED
10
11#include "SkRect.h"
12#include "SkPoint.h"
13
14class SkCanvas;
15class SkPaint;
16
17class GrMesh {
18public:
19 GrMesh();
20 ~GrMesh();
21
22 GrMesh& operator=(const GrMesh& src);
23
24 void init(const SkRect& bounds, int rows, int cols,
25 const SkRect& texture);
26
27 const SkRect& bounds() const { return fBounds; }
28
29 int rows() const { return fRows; }
30 int cols() const { return fCols; }
31 SkPoint& pt(int row, int col) {
32 return fPts[row * (fRows + 1) + col];
33 }
34
35 void draw(SkCanvas*, const SkPaint&);
36 void drawWireframe(SkCanvas* canvas, const SkPaint& paint);
37
38private:
39 SkRect fBounds;
40 int fRows, fCols;
41 SkPoint* fPts;
42 SkPoint* fTex; // just points into fPts, not separately allocated
43 int fCount;
44 uint16_t* fIndices;
45 int fIndexCount;
46};
47
48#endif
49