blob: 8c390db7271553ae96787a173228b3837e1c1d03 [file] [log] [blame]
Jason Sams221a4b12012-02-22 15:22:41 -08001
2#include "RenderScript.h"
3#include "Element.h"
4#include "Type.h"
5#include "Allocation.h"
6
Jason Samsf1e6d222012-02-24 14:24:56 -08007#include "ScriptC_mono.h"
8
Jason Sams69cccdf2012-04-02 19:11:49 -07009using namespace android;
10using namespace renderscriptCpp;
11
Jason Sams221a4b12012-02-22 15:22:41 -080012int main(int argc, char** argv)
13{
14
15 RenderScript *rs = new RenderScript();
16 printf("New RS %p\n", rs);
17
Jason Sams221a4b12012-02-22 15:22:41 -080018 bool r = rs->init(16);
19 printf("Init returned %i\n", r);
20
Jason Sams69cccdf2012-04-02 19:11:49 -070021 sp<const Element> e = Element::RGBA_8888(rs);
22 printf("Element %p\n", e.get());
Jason Sams221a4b12012-02-22 15:22:41 -080023
24 Type::Builder tb(rs, e);
25 tb.setX(128);
26 tb.setY(128);
Jason Sams69cccdf2012-04-02 19:11:49 -070027 sp<const Type> t = tb.create();
28 printf("Type %p\n", t.get());
Jason Sams221a4b12012-02-22 15:22:41 -080029
30
Jason Sams69cccdf2012-04-02 19:11:49 -070031 sp<Allocation> a1 = Allocation::createSized(rs, e, 1000);
32 printf("Allocation %p\n", a1.get());
Jason Sams221a4b12012-02-22 15:22:41 -080033
Jason Sams69cccdf2012-04-02 19:11:49 -070034 sp<Allocation> ain = Allocation::createTyped(rs, t);
35 sp<Allocation> aout = Allocation::createTyped(rs, t);
36 printf("Allocation %p %p\n", ain.get(), aout.get());
Jason Samsf1e6d222012-02-24 14:24:56 -080037
Jason Sams69cccdf2012-04-02 19:11:49 -070038 sp<ScriptC_mono> sc = new ScriptC_mono(rs, NULL, 0);
Jason Samsf1e6d222012-02-24 14:24:56 -080039 printf("new script\n");
40
41 uint32_t *buf = new uint32_t[t->getCount()];
42 for (uint32_t ct=0; ct < t->getCount(); ct++) {
43 buf[ct] = ct | (ct << 16);
44 }
45 //ain->copy1DRangeFrom(0, 128*128, (int32_t *)buf, 128*128*4);
46 ain->copy1DRangeFromUnchecked(0, t->getCount(), buf, t->getCount()*4);
47
48
49
50 sc->forEach_root(ain, aout);
51 printf("for each done\n");
Jason Sams221a4b12012-02-22 15:22:41 -080052
Jason Sams221a4b12012-02-22 15:22:41 -080053
54 printf("Deleting stuff\n");
Jason Sams69cccdf2012-04-02 19:11:49 -070055 sc.clear();
56 t.clear();
57 a1.clear();
58 e.clear();
Tim Murray16b95122012-10-31 16:02:59 -070059 ain.clear();
60 aout.clear();
Jason Sams221a4b12012-02-22 15:22:41 -080061 delete rs;
62 printf("Delete OK\n");
63}