blob: d49d0f7d87749a10a6e99542d3acb4205cc3ef5b [file] [log] [blame]
Tim Murray16b95122012-10-31 16:02:59 -07001/*
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.image)
19#pragma rs_fp_relaxed
20
Stephen Hines43514cd2012-11-16 14:33:47 -080021int g_i = 4;
22
23float g_f = 5.9;
24
Tim Murray16b95122012-10-31 16:02:59 -070025const static float3 gMonoMult = {0.299f, 0.587f, 0.114f};
26
Stephen Hines43514cd2012-11-16 14:33:47 -080027bool *failed;
28
29#define _RS_ASSERT(b) \
30do { \
31 if (!(b)) { \
32 *failed = true; \
33 rsDebug(#b " FAILED", 0); \
34 } \
35\
36} while (0)
37
38struct myStruct {
39 int i;
40 int j;
41 float f;
42 char c[3];
43};
44
Tim Murray16b95122012-10-31 16:02:59 -070045void root(const uchar4 *v_in, uchar4 *v_out) {
46 float4 f4 = rsUnpackColor8888(*v_in);
47
48 float3 mono = dot(f4.rgb, gMonoMult);
49 *v_out = rsPackColorTo8888(mono);
50}
51
Stephen Hines43514cd2012-11-16 14:33:47 -080052void foo(int i, float f) {
53 rsDebug("g_i", g_i);
54 rsDebug("g_f", g_f);
55 rsDebug("i", i);
56 rsDebug("f", f);
57}
58
59void bar(int i, int j, char k, int l, int m, int n) {
60 _RS_ASSERT(i == 47);
61 _RS_ASSERT(j == -3);
62 _RS_ASSERT(k == 'c');
63 _RS_ASSERT(l == -7);
64 _RS_ASSERT(m == 14);
65 _RS_ASSERT(n == -8);
66}
67
68int __attribute__((kernel)) kern1(int i, uint32_t x, uint32_t y) {
69 return i + 10 * x + 100 *y;
70}
71
72void __attribute__((kernel)) verify_kern1(int i, uint32_t x, uint32_t y) {
73 _RS_ASSERT(i == (10 * x + 100 * y));
74 rsDebug("i ", i);
75}
Tim Murray16b95122012-10-31 16:02:59 -070076