2 * Copyright (C) 2012 The Android Open Source Project
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
18 #pragma rs java_package_name(com.android.gallery3d.filtershow.filters)
23 const uchar4 *gPixels;
28 void root(const uchar4 *in, uchar4 *out, const void *usrData, uint32_t x, uint32_t y) {
29 uint32_t x1 = min((int32_t)x+1, gWidth-1);
30 uint32_t x2 = max((int32_t)x-1, 0);
31 uint32_t y1 = min((int32_t)y+1, gHeight-1);
32 uint32_t y2 = max((int32_t)y-1, 0);
34 float4 p00 = rsUnpackColor8888(gPixels[x1 + gWidth * y1]);
35 float4 p01 = rsUnpackColor8888(gPixels[x + gWidth * y1]);
36 float4 p02 = rsUnpackColor8888(gPixels[x2 + gWidth * y1]);
37 float4 p10 = rsUnpackColor8888(gPixels[x1 + gWidth * y]);
38 float4 p11 = rsUnpackColor8888(gPixels[x + gWidth * y]);
39 float4 p12 = rsUnpackColor8888(gPixels[x2 + gWidth * y]);
40 float4 p20 = rsUnpackColor8888(gPixels[x1 + gWidth * y2]);
41 float4 p21 = rsUnpackColor8888(gPixels[x + gWidth * y2]);
42 float4 p22 = rsUnpackColor8888(gPixels[x2 + gWidth * y2]);
65 p20 = clamp(p20, 0.f, 1.f);
66 *out = rsPackColorTo8888(p20.r, p20.g, p20.b);