1 /*
2  * Copyright (C) 2012 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #pragma version(1)
18 #pragma rs java_package_name(com.android.rs.cppbasic)
19 #pragma rs_fp_relaxed
20 
21 int g_i = 4;
22 
23 float g_f = 5.9;
24 
25 const static float3 gMonoMult = {0.299f, 0.587f, 0.114f};
26 
27 bool *failed;
28 
29 #define _RS_ASSERT(b) \
30 do { \
31     if (!(b)) { \
32         *failed = true; \
33         rsDebug(#b " FAILED", 0); \
34     } \
35 \
36 } while (0)
37 
38 struct myStruct {
39     int i;
40     int j;
41     float f;
42     char c[3];
43 };
44 
45 rs_allocation alloc;
46 rs_element elem;
47 rs_type type;
48 rs_sampler sampler;
49 rs_script script;
50 
51 void root(const uchar4 *v_in, uchar4 *v_out) {
52     float4 f4 = rsUnpackColor8888(*v_in);
53 
54     float3 mono = dot(f4.rgb, gMonoMult);
55     *v_out = rsPackColorTo8888(mono);
56 }
57 
58 void foo(int i, float f) {
59     rsDebug("g_i", g_i);
60     rsDebug("g_f", g_f);
61     rsDebug("i", i);
62     rsDebug("f", f);
63 }
64 
65 void bar(int i, int j, char k, int l, int m, int n) {
66     _RS_ASSERT(i == 47);
67     _RS_ASSERT(j == -3);
68     _RS_ASSERT(k == 'c');
69     _RS_ASSERT(l == -7);
70     _RS_ASSERT(m == 14);
71     _RS_ASSERT(n == -8);
72 }
73 
74 int RS_KERNEL kern1(int i, uint32_t x, uint32_t y) {
75     return i + 10 * x + 100 *y;
76 }
77 
78 void RS_KERNEL verify_kern1(int i, uint32_t x, uint32_t y) {
79     _RS_ASSERT(i == (5 + 10 * x + 100 * y));
80     rsDebug("i ", i);
81 }
82 
83