Home | History | Annotate | Download | only in levels
      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.levels)
     19 
     20 float inBlack;
     21 float outBlack;
     22 float inWMinInB;
     23 float outWMinOutB;
     24 float overInWMinInB;
     25 float gamma;
     26 rs_matrix3x3 colorMat;
     27 
     28 void root(const uchar4 *in, uchar4 *out, uint32_t x, uint32_t y) {
     29     float3 pixel = convert_float4(in[0]).rgb;
     30     pixel = rsMatrixMultiply(&colorMat, pixel);
     31     pixel = clamp(pixel, 0.f, 255.f);
     32     pixel = (pixel - inBlack) * overInWMinInB;
     33     if (gamma != 1.0f)
     34         pixel = pow(pixel, (float3)gamma);
     35     pixel = pixel * outWMinOutB + outBlack;
     36     pixel = clamp(pixel, 0.f, 255.f);
     37     out->xyz = convert_uchar3(pixel);
     38     out->w = 0xff;
     39 }
     40 
     41