Home | History | Annotate | Download | only in tests
      1 
      2 #include "RenderScript.h"
      3 #include "Element.h"
      4 #include "Type.h"
      5 #include "Allocation.h"
      6 
      7 #include "ScriptC_mono.h"
      8 
      9 using namespace android;
     10 using namespace renderscriptCpp;
     11 
     12 int main(int argc, char** argv)
     13 {
     14 
     15     RenderScript *rs = new RenderScript();
     16     printf("New RS %p\n", rs);
     17 
     18     bool r = rs->init(16);
     19     printf("Init returned %i\n", r);
     20 
     21     sp<const Element> e = Element::RGBA_8888(rs);
     22     printf("Element %p\n", e.get());
     23 
     24     Type::Builder tb(rs, e);
     25     tb.setX(128);
     26     tb.setY(128);
     27     sp<const Type> t = tb.create();
     28     printf("Type %p\n", t.get());
     29 
     30 
     31     sp<Allocation> a1 = Allocation::createSized(rs, e, 1000);
     32     printf("Allocation %p\n", a1.get());
     33 
     34     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());
     37 
     38     sp<ScriptC_mono> sc = new ScriptC_mono(rs, NULL, 0);
     39     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");
     52 
     53 
     54     printf("Deleting stuff\n");
     55     sc.clear();
     56     t.clear();
     57     a1.clear();
     58     e.clear();
     59     delete rs;
     60     printf("Delete OK\n");
     61 }
     62