CrossProcess.java revision 572a5031a5d8602db0bec0b253428a034bd4dd59
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 17package com.android.rs.imagejb; 18 19import java.lang.Math; 20 21import android.renderscript.Allocation; 22import android.renderscript.Element; 23import android.renderscript.RenderScript; 24import android.renderscript.ScriptIntrinsicLUT; 25import android.util.Log; 26 27public class CrossProcess extends TestBase { 28 private ScriptIntrinsicLUT mIntrinsic; 29 30 public void createTest(android.content.res.Resources res) { 31 mIntrinsic = ScriptIntrinsicLUT.create(mRS, Element.U8_4(mRS)); 32 for (int ct=0; ct < 256; ct++) { 33 float f = ((float)ct) / 255.f; 34 35 float r = f; 36 if (r < 0.5f) { 37 r = 4.0f * r * r * r; 38 } else { 39 r = 1.0f - r; 40 r = 1.0f - (4.0f * r * r * r); 41 } 42 mIntrinsic.setRed(ct, (int)(r * 255.f + 0.5f)); 43 44 float g = f; 45 if (g < 0.5f) { 46 g = 2.0f * g * g; 47 } else { 48 g = 1.0f - g; 49 g = 1.0f - (2.0f * g * g); 50 } 51 mIntrinsic.setGreen(ct, (int)(g * 255.f + 0.5f)); 52 53 float b = f * 0.5f + 0.25f; 54 mIntrinsic.setBlue(ct, (int)(b * 255.f + 0.5f)); 55 } 56 57 } 58 59 public void runTest() { 60 mIntrinsic.forEach(mInPixelsAllocation, mOutPixelsAllocation); 61 } 62 63} 64