summaryrefslogtreecommitdiff
path: root/tests/lldb/cpp/MultipleRSFiles/MultipleRSFiles.cpp
blob: 98a1b825e6011df44230f751444d4f9ed82c9cf8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#include <RenderScript.h>

#include "ScriptC_first.h"
#include "ScriptC_second.h"

int main()
{
    static const int size = 64;
    sp<RS> rs = new RS();

    rs->init("/data/rscache", RS_INIT_LOW_LATENCY | RS_INIT_WAIT_FOR_ATTACH);

    auto e = Element::RGBA_8888(rs);
    Type::Builder tb(rs, e);
    tb.setX(size);
    tb.setY(size);
    auto t = tb.create();

    auto a = Allocation::createTyped(rs, t);
    auto b = Allocation::createTyped(rs, t);

    // Script is executed once, then the data is copied back when finished
    sp<ScriptC_first> s1 = new ScriptC_first(rs);
    sp<ScriptC_second> s2 = new ScriptC_second(rs);

    s1->forEach_first_kernel(a, b);
    uint32_t * output = new uint32_t[size*size];
    b->copy2DRangeTo(0, 0, size, size, output);
    delete [] output;

    s2->forEach_second_kernel(a, b);

    rs->finish();
    return 0;
}