| /* |
| * Licensed to the Apache Software Foundation (ASF) under one or more |
| * contributor license agreements. See the NOTICE file distributed with |
| * this work for additional information regarding copyright ownership. |
| * The ASF licenses this file to You under the Apache License, Version 2.0 |
| * (the "License"); you may not use this file except in compliance with |
| * the License. You may obtain a copy of the License at |
| * |
| * http://www.apache.org/licenses/LICENSE-2.0 |
| * |
| * Unless required by applicable law or agreed to in writing, software |
| * distributed under the License is distributed on an "AS IS" BASIS, |
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| * See the License for the specific language governing permissions and |
| * limitations under the License. |
| */ |
| <languageVersion : 1.0;> |
| |
| kernel Int4 |
| < namespace : "testing"; |
| vendor : "Apache"; |
| version : 1; |
| description : "Int4 with default."; |
| > |
| { |
| input image4 src; |
| output pixel4 dst; |
| |
| parameter int4 theInt |
| < |
| minValue:int4(0,0,0,0); |
| maxValue:int4(7,7,7,7); |
| defaultValue:int4(0,0,0,0); |
| >; |
| |
| void |
| evaluatePixel() |
| { |
| float2 pos = outCoord(); |
| float x = pos.x; |
| float y = pos.y; |
| |
| // Booleans are not supported in hydra byte code, so we'll use an int's 1 and 0. |
| int int1bit1 = (theInt.x == 1 || theInt.x == 3 || theInt.x == 5 || theInt.x == 7) ? 1 : 0; |
| int int1bit2 = (theInt.x == 2 || theInt.x == 3 || theInt.x == 6 || theInt.x == 7) ? 1 : 0; |
| int int1bit3 = (theInt.x >= 4) ? 1 : 0; |
| |
| float4 int1bit1Bounds; |
| float4 int1bit2Bounds; |
| float4 int1bit3Bounds; |
| |
| // Booleans are not supported in hydra byte code, so we'll use an int's 1 and 0. |
| int int2bit1 = (theInt.y == 1 || theInt.y == 3 || theInt.y == 5 || theInt.y == 7) ? 1 : 0; |
| int int2bit2 = (theInt.y == 2 || theInt.y == 3 || theInt.y == 6 || theInt.y == 7) ? 1 : 0; |
| int int2bit3 = (theInt.y >= 4) ? 1 : 0; |
| |
| float4 int2bit1Bounds; |
| float4 int2bit2Bounds; |
| float4 int2bit3Bounds; |
| |
| // Booleans are not supported in hydra byte code, so we'll use an int's 1 and 0. |
| int int3bit1 = (theInt.z == 1 || theInt.z == 3 || theInt.z == 5 || theInt.z == 7) ? 1 : 0; |
| int int3bit2 = (theInt.z == 2 || theInt.z == 3 || theInt.z == 6 || theInt.z == 7) ? 1 : 0; |
| int int3bit3 = (theInt.z >= 4) ? 1 : 0; |
| |
| float4 int3bit1Bounds; |
| float4 int3bit2Bounds; |
| float4 int3bit3Bounds; |
| |
| // Booleans are not supported in hydra byte code, so we'll use an int's 1 and 0. |
| int int4bit1 = (theInt.w == 1 || theInt.w == 3 || theInt.w == 5 || theInt.w == 7) ? 1 : 0; |
| int int4bit2 = (theInt.w == 2 || theInt.w == 3 || theInt.w == 6 || theInt.w == 7) ? 1 : 0; |
| int int4bit3 = (theInt.w >= 4) ? 1 : 0; |
| |
| float4 int4bit1Bounds; |
| float4 int4bit2Bounds; |
| float4 int4bit3Bounds; |
| |
| int1bit1Bounds.x = float(67); //minX |
| int1bit1Bounds.y = float(100); //maxX |
| int1bit1Bounds.z = float(0); //minY |
| int1bit1Bounds.w = float(25); //maxY |
| |
| int1bit2Bounds.x = float(34); |
| int1bit2Bounds.y = float(66); |
| int1bit2Bounds.z = float(0); |
| int1bit2Bounds.w = float(25); |
| |
| int1bit3Bounds.x = float(0); |
| int1bit3Bounds.y = float(33); |
| int1bit3Bounds.z = float(0); |
| int1bit3Bounds.w = float(25); |
| |
| int2bit1Bounds.x = float(67); //minX |
| int2bit1Bounds.y = float(100); //maxX |
| int2bit1Bounds.z = float(26); //minY |
| int2bit1Bounds.w = float(50); //maxY |
| |
| int2bit2Bounds.x = float(34); |
| int2bit2Bounds.y = float(66); |
| int2bit2Bounds.z = float(26); |
| int2bit2Bounds.w = float(50); |
| |
| int2bit3Bounds.x = float(0); |
| int2bit3Bounds.y = float(33); |
| int2bit3Bounds.z = float(26); |
| int2bit3Bounds.w = float(50); |
| |
| int3bit1Bounds.x = float(67); //minX |
| int3bit1Bounds.y = float(100); //maxX |
| int3bit1Bounds.z = float(51); //minY |
| int3bit1Bounds.w = float(75); //maxY |
| |
| int3bit2Bounds.x = float(34); |
| int3bit2Bounds.y = float(66); |
| int3bit2Bounds.z = float(51); |
| int3bit2Bounds.w = float(75); |
| |
| int3bit3Bounds.x = float(0); |
| int3bit3Bounds.y = float(33); |
| int3bit3Bounds.z = float(51); |
| int3bit3Bounds.w = float(75); |
| |
| int4bit1Bounds.x = float(67); //minX |
| int4bit1Bounds.y = float(100); //maxX |
| int4bit1Bounds.z = float(76); //minY |
| int4bit1Bounds.w = float(100); //maxY |
| |
| int4bit2Bounds.x = float(34); |
| int4bit2Bounds.y = float(66); |
| int4bit2Bounds.z = float(76); |
| int4bit2Bounds.w = float(100); |
| |
| int4bit3Bounds.x = float(0); |
| int4bit3Bounds.y = float(33); |
| int4bit3Bounds.z = float(76); |
| int4bit3Bounds.w = float(100); |
| |
| if( |
| ((int1bit1 > 0)&& x >= int1bit1Bounds.x && y <= int1bit1Bounds.w)|| |
| ((int1bit2 > 0) && x >= int1bit2Bounds.x && x <= int1bit2Bounds.y && y >= int1bit2Bounds.z && y <= int1bit2Bounds.w) || |
| ((int1bit3 > 0) && x >= int1bit3Bounds.x && x <= int1bit3Bounds.y && y >= int1bit3Bounds.z && y <= int1bit3Bounds.w) || |
| |
| ((int2bit1 > 0) && x >= int2bit1Bounds.x && x <= int2bit1Bounds.y && y >= int2bit1Bounds.z && y <= int2bit1Bounds.w)|| |
| ((int2bit2 > 0) && x >= int2bit2Bounds.x && x <= int2bit2Bounds.y && y >= int2bit2Bounds.z && y <= int2bit2Bounds.w) || |
| ((int2bit3 > 0) && x >= int2bit3Bounds.x && x <= int2bit3Bounds.y && y >= int2bit3Bounds.z && y <= int2bit3Bounds.w) || |
| |
| ((int3bit1 > 0) && x >= int3bit1Bounds.x && x <= int3bit1Bounds.y && y >= int3bit1Bounds.z && y <= int3bit1Bounds.w)|| |
| ((int3bit2 > 0) && x >= int3bit2Bounds.x && x <= int3bit2Bounds.y && y >= int3bit2Bounds.z && y <= int3bit2Bounds.w) || |
| ((int3bit3 > 0) && x >= int3bit3Bounds.x && x <= int3bit3Bounds.y && y >= int3bit3Bounds.z && y <= int3bit3Bounds.w) || |
| |
| ((int4bit1 > 0) && x >= int4bit1Bounds.x && x <= int4bit1Bounds.y && y >= int4bit1Bounds.z && y <= int4bit1Bounds.w)|| |
| ((int4bit2 > 0) && x >= int4bit2Bounds.x && x <= int4bit2Bounds.y && y >= int4bit2Bounds.z && y <= int4bit2Bounds.w) || |
| ((int4bit3 > 0) && x >= int4bit3Bounds.x && x <= int4bit3Bounds.y && y >= int4bit3Bounds.z && y <= int4bit3Bounds.w) |
| ) |
| { |
| dst.r = float(0); |
| dst.g = float(0); |
| dst.b = float(0); |
| }else{ |
| dst.r = float(0.5); |
| dst.g = float(0.5); |
| dst.b = float(0.5); |
| } |
| |
| dst.a = sampleNearest(src, outCoord()).a; |
| } |
| } |