| epoger@google.com | ec3ed6a | 2011-07-28 14:26:00 +0000 | [diff] [blame^] | 1 | |
| 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.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 8 | #ifndef GrMesh_DEFINED |
| 9 | #define GrMesh_DEFINED |
| 10 | |
| 11 | #include "SkRect.h" |
| 12 | #include "SkPoint.h" |
| 13 | |
| 14 | class SkCanvas; |
| 15 | class SkPaint; |
| 16 | |
| 17 | class GrMesh { |
| 18 | public: |
| 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 | |
| 38 | private: |
| 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 | |