blob: 7e0e8f4de2606b90ac0ad2f0367c33771145183e [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@android.com2ee7c642009-10-28 14:25:34 +00008#ifndef SkMeshUtils_DEFINED
9#define SkMeshUtils_DEFINED
10
11#include "SkPoint.h"
12#include "SkColor.h"
13
14class SkBitmap;
15class SkCanvas;
16class SkPaint;
17
18class SkMeshIndices {
19public:
20 SkMeshIndices();
21 ~SkMeshIndices();
rmistry@google.comfbfcd562012-08-23 18:09:54 +000022
reed@android.com2ee7c642009-10-28 14:25:34 +000023 bool init(int texW, int texH, int rows, int cols) {
24 return this->init(NULL, NULL, texW, texH, rows, cols);
25 }
26
27 bool init(SkPoint tex[], uint16_t indices[],
28 int texW, int texH, int rows, int cols);
29
robertphillips@google.comadacc702013-10-14 21:53:24 +000030 int indexCount() const { return fIndexCount; }
reed@android.com2ee7c642009-10-28 14:25:34 +000031 const uint16_t* indices() const { return fIndices; }
32
33 size_t texCount() const { return fTexCount; }
34 const SkPoint* tex() const { return fTex; }
35
36private:
robertphillips@google.comadacc702013-10-14 21:53:24 +000037 int fIndexCount, fTexCount;
reed@android.com2ee7c642009-10-28 14:25:34 +000038 SkPoint* fTex;
39 uint16_t* fIndices;
40 void* fStorage; // may be null
41};
42
43class SkMeshUtils {
44public:
45 static void Draw(SkCanvas*, const SkBitmap&, int rows, int cols,
46 const SkPoint verts[], const SkColor colors[],
47 const SkPaint& paint);
48};
49
50#endif