blob: 471b10aa272c33bce65e10a3ee53def3ea7a9e99 [file] [log] [blame]
Jason Sams221a4b12012-02-22 15:22:41 -08001
2#include "RenderScript.h"
Jason Sams221a4b12012-02-22 15:22:41 -08003
Jason Samsf1e6d222012-02-24 14:24:56 -08004#include "ScriptC_mono.h"
5
Jason Sams69cccdf2012-04-02 19:11:49 -07006using namespace android;
Tim Murray9eb7f4b2012-11-16 14:02:18 -08007using namespace RSC;
Jason Sams69cccdf2012-04-02 19:11:49 -07008
Jason Sams221a4b12012-02-22 15:22:41 -08009int main(int argc, char** argv)
10{
11
Tim Murray8d8fb3e2012-11-02 17:02:32 -070012 sp<RS> rs = new RS();
13 printf("New RS %p\n", rs.get());
Jason Sams221a4b12012-02-22 15:22:41 -080014
Tim Murray8d8fb3e2012-11-02 17:02:32 -070015 bool r = rs->init();
Jason Sams221a4b12012-02-22 15:22:41 -080016 printf("Init returned %i\n", r);
17
Jason Sams69cccdf2012-04-02 19:11:49 -070018 sp<const Element> e = Element::RGBA_8888(rs);
19 printf("Element %p\n", e.get());
Jason Sams221a4b12012-02-22 15:22:41 -080020
21 Type::Builder tb(rs, e);
22 tb.setX(128);
23 tb.setY(128);
Jason Sams69cccdf2012-04-02 19:11:49 -070024 sp<const Type> t = tb.create();
25 printf("Type %p\n", t.get());
Jason Sams221a4b12012-02-22 15:22:41 -080026
27
Jason Sams69cccdf2012-04-02 19:11:49 -070028 sp<Allocation> a1 = Allocation::createSized(rs, e, 1000);
29 printf("Allocation %p\n", a1.get());
Jason Sams221a4b12012-02-22 15:22:41 -080030
Jason Sams69cccdf2012-04-02 19:11:49 -070031 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 Samsf1e6d222012-02-24 14:24:56 -080034
Jason Sams69cccdf2012-04-02 19:11:49 -070035 sp<ScriptC_mono> sc = new ScriptC_mono(rs, NULL, 0);
Jason Samsf1e6d222012-02-24 14:24:56 -080036 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 }
Tim Murray0b93e302012-11-15 14:56:54 -080042 ain->copy1DRangeFrom(0, t->getCount(), buf);
Jason Samsf1e6d222012-02-24 14:24:56 -080043
Jason Samsf1e6d222012-02-24 14:24:56 -080044 sc->forEach_root(ain, aout);
45 printf("for each done\n");
Jason Sams221a4b12012-02-22 15:22:41 -080046
Jason Sams221a4b12012-02-22 15:22:41 -080047 printf("Deleting stuff\n");
Jason Sams69cccdf2012-04-02 19:11:49 -070048 sc.clear();
49 t.clear();
50 a1.clear();
51 e.clear();
Tim Murray16b95122012-10-31 16:02:59 -070052 ain.clear();
53 aout.clear();
Tim Murray8d8fb3e2012-11-02 17:02:32 -070054 // delete rs;
Jason Sams221a4b12012-02-22 15:22:41 -080055 printf("Delete OK\n");
56}