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.image) 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 void 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 52 void 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 59 void 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 68 int __attribute__((kernel)) kern1(int i, uint32_t x, uint32_t y) { 69 return i + 10 * x + 100 *y; 70 } 71 72 void __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 } 76 77