Jason Sams | 221a4b1 | 2012-02-22 15:22:41 -0800 | [diff] [blame] | 1 | |
| 2 | #include "RenderScript.h" |
Jason Sams | 221a4b1 | 2012-02-22 15:22:41 -0800 | [diff] [blame] | 3 | |
Jason Sams | f1e6d22 | 2012-02-24 14:24:56 -0800 | [diff] [blame] | 4 | #include "ScriptC_mono.h" |
| 5 | |
Jason Sams | 69cccdf | 2012-04-02 19:11:49 -0700 | [diff] [blame] | 6 | using namespace android; |
| 7 | using namespace renderscriptCpp; |
| 8 | |
Jason Sams | 221a4b1 | 2012-02-22 15:22:41 -0800 | [diff] [blame] | 9 | int main(int argc, char** argv) |
| 10 | { |
| 11 | |
Tim Murray | 8d8fb3e | 2012-11-02 17:02:32 -0700 | [diff] [blame^] | 12 | sp<RS> rs = new RS(); |
| 13 | printf("New RS %p\n", rs.get()); |
Jason Sams | 221a4b1 | 2012-02-22 15:22:41 -0800 | [diff] [blame] | 14 | |
Tim Murray | 8d8fb3e | 2012-11-02 17:02:32 -0700 | [diff] [blame^] | 15 | bool r = rs->init(); |
Jason Sams | 221a4b1 | 2012-02-22 15:22:41 -0800 | [diff] [blame] | 16 | printf("Init returned %i\n", r); |
| 17 | |
Jason Sams | 69cccdf | 2012-04-02 19:11:49 -0700 | [diff] [blame] | 18 | sp<const Element> e = Element::RGBA_8888(rs); |
| 19 | printf("Element %p\n", e.get()); |
Jason Sams | 221a4b1 | 2012-02-22 15:22:41 -0800 | [diff] [blame] | 20 | |
| 21 | Type::Builder tb(rs, e); |
| 22 | tb.setX(128); |
| 23 | tb.setY(128); |
Jason Sams | 69cccdf | 2012-04-02 19:11:49 -0700 | [diff] [blame] | 24 | sp<const Type> t = tb.create(); |
| 25 | printf("Type %p\n", t.get()); |
Jason Sams | 221a4b1 | 2012-02-22 15:22:41 -0800 | [diff] [blame] | 26 | |
| 27 | |
Jason Sams | 69cccdf | 2012-04-02 19:11:49 -0700 | [diff] [blame] | 28 | sp<Allocation> a1 = Allocation::createSized(rs, e, 1000); |
| 29 | printf("Allocation %p\n", a1.get()); |
Jason Sams | 221a4b1 | 2012-02-22 15:22:41 -0800 | [diff] [blame] | 30 | |
Jason Sams | 69cccdf | 2012-04-02 19:11:49 -0700 | [diff] [blame] | 31 | sp<Allocation> ain = Allocation::createTyped(rs, t); |
| 32 | sp<Allocation> aout = Allocation::createTyped(rs, t); |
| 33 | printf("Allocation %p %p\n", ain.get(), aout.get()); |
Jason Sams | f1e6d22 | 2012-02-24 14:24:56 -0800 | [diff] [blame] | 34 | |
Jason Sams | 69cccdf | 2012-04-02 19:11:49 -0700 | [diff] [blame] | 35 | sp<ScriptC_mono> sc = new ScriptC_mono(rs, NULL, 0); |
Jason Sams | f1e6d22 | 2012-02-24 14:24:56 -0800 | [diff] [blame] | 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 | |
Jason Sams | f1e6d22 | 2012-02-24 14:24:56 -0800 | [diff] [blame] | 45 | sc->forEach_root(ain, aout); |
| 46 | printf("for each done\n"); |
Jason Sams | 221a4b1 | 2012-02-22 15:22:41 -0800 | [diff] [blame] | 47 | |
Jason Sams | 221a4b1 | 2012-02-22 15:22:41 -0800 | [diff] [blame] | 48 | printf("Deleting stuff\n"); |
Jason Sams | 69cccdf | 2012-04-02 19:11:49 -0700 | [diff] [blame] | 49 | sc.clear(); |
| 50 | t.clear(); |
| 51 | a1.clear(); |
| 52 | e.clear(); |
Tim Murray | 16b9512 | 2012-10-31 16:02:59 -0700 | [diff] [blame] | 53 | ain.clear(); |
| 54 | aout.clear(); |
Tim Murray | 8d8fb3e | 2012-11-02 17:02:32 -0700 | [diff] [blame^] | 55 | // delete rs; |
Jason Sams | 221a4b1 | 2012-02-22 15:22:41 -0800 | [diff] [blame] | 56 | printf("Delete OK\n"); |
| 57 | } |