Jason Sams | 221a4b1 | 2012-02-22 15:22:41 -0800 | [diff] [blame] | 1 | |
| 2 | #include "RenderScript.h" |
| 3 | #include "Element.h" |
| 4 | #include "Type.h" |
| 5 | #include "Allocation.h" |
| 6 | |
Jason Sams | f1e6d22 | 2012-02-24 14:24:56 -0800 | [diff] [blame^] | 7 | #include "ScriptC_mono.h" |
| 8 | |
Jason Sams | 221a4b1 | 2012-02-22 15:22:41 -0800 | [diff] [blame] | 9 | int main(int argc, char** argv) |
| 10 | { |
| 11 | |
| 12 | RenderScript *rs = new RenderScript(); |
| 13 | printf("New RS %p\n", rs); |
| 14 | |
Jason Sams | 221a4b1 | 2012-02-22 15:22:41 -0800 | [diff] [blame] | 15 | bool r = rs->init(16); |
| 16 | printf("Init returned %i\n", r); |
| 17 | |
| 18 | const Element *e = Element::RGBA_8888(rs); |
| 19 | printf("Element %p\n", e); |
| 20 | |
| 21 | Type::Builder tb(rs, e); |
| 22 | tb.setX(128); |
| 23 | tb.setY(128); |
| 24 | const Type *t = tb.create(); |
| 25 | printf("Type %p\n", t); |
| 26 | |
| 27 | |
Jason Sams | f1e6d22 | 2012-02-24 14:24:56 -0800 | [diff] [blame^] | 28 | Allocation *a1 = Allocation::createSized(rs, e, 1000); |
Jason Sams | 221a4b1 | 2012-02-22 15:22:41 -0800 | [diff] [blame] | 29 | printf("Allocation %p\n", a1); |
| 30 | |
Jason Sams | f1e6d22 | 2012-02-24 14:24:56 -0800 | [diff] [blame^] | 31 | Allocation *ain = Allocation::createTyped(rs, t); |
| 32 | Allocation *aout = Allocation::createTyped(rs, t); |
| 33 | printf("Allocation %p %p\n", ain, aout); |
| 34 | |
| 35 | ScriptC_mono * sc = new ScriptC_mono(rs, NULL, 0); |
| 36 | printf("new script\n"); |
| 37 | |
| 38 | uint32_t *buf = new uint32_t[t->getCount()]; |
| 39 | for (uint32_t ct=0; ct < t->getCount(); ct++) { |
| 40 | buf[ct] = ct | (ct << 16); |
| 41 | } |
| 42 | //ain->copy1DRangeFrom(0, 128*128, (int32_t *)buf, 128*128*4); |
| 43 | ain->copy1DRangeFromUnchecked(0, t->getCount(), buf, t->getCount()*4); |
| 44 | |
| 45 | |
| 46 | |
| 47 | sc->forEach_root(ain, aout); |
| 48 | printf("for each done\n"); |
Jason Sams | 221a4b1 | 2012-02-22 15:22:41 -0800 | [diff] [blame] | 49 | |
Jason Sams | 221a4b1 | 2012-02-22 15:22:41 -0800 | [diff] [blame] | 50 | |
| 51 | printf("Deleting stuff\n"); |
Jason Sams | f1e6d22 | 2012-02-24 14:24:56 -0800 | [diff] [blame^] | 52 | delete sc; |
Jason Sams | 221a4b1 | 2012-02-22 15:22:41 -0800 | [diff] [blame] | 53 | delete t; |
| 54 | delete a1; |
| 55 | delete e; |
| 56 | delete rs; |
| 57 | printf("Delete OK\n"); |
| 58 | } |