compute.cpp revision a4cbc2b0cf0f6fbdb21e84a3e17585eda1885e3e
1 2#include "RenderScript.h" 3 4#include "ScriptC_mono.h" 5 6using namespace android; 7using namespace renderscriptCpp; 8 9int main(int argc, char** argv) 10{ 11 12 sp<RS> rs = new RS(); 13 printf("New RS %p\n", rs.get()); 14 15 bool r = rs->init(); 16 printf("Init returned %i\n", r); 17 18 sp<const Element> e = Element::RGBA_8888(rs); 19 printf("Element %p\n", e.get()); 20 21 Type::Builder tb(rs, e); 22 tb.setX(128); 23 tb.setY(128); 24 sp<const Type> t = tb.create(); 25 printf("Type %p\n", t.get()); 26 27 28 sp<Allocation> a1 = Allocation::createSized(rs, e, 1000); 29 printf("Allocation %p\n", a1.get()); 30 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()); 34 35 sp<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, t->getCount(), buf, t->getCount()*4); 43 44 sc->forEach_root(ain, aout); 45 printf("for each done\n"); 46 47 printf("Deleting stuff\n"); 48 sc.clear(); 49 t.clear(); 50 a1.clear(); 51 e.clear(); 52 ain.clear(); 53 aout.clear(); 54 // delete rs; 55 printf("Delete OK\n"); 56} 57