1*d57664e9SAndroid Build Coastguard Worker /* 2*d57664e9SAndroid Build Coastguard Worker * Copyright (C) 2013 The Android Open Source Project 3*d57664e9SAndroid Build Coastguard Worker * 4*d57664e9SAndroid Build Coastguard Worker * Licensed under the Apache License, Version 2.0 (the "License"); 5*d57664e9SAndroid Build Coastguard Worker * you may not use this file except in compliance with the License. 6*d57664e9SAndroid Build Coastguard Worker * You may obtain a copy of the License at 7*d57664e9SAndroid Build Coastguard Worker * 8*d57664e9SAndroid Build Coastguard Worker * http://www.apache.org/licenses/LICENSE-2.0 9*d57664e9SAndroid Build Coastguard Worker * 10*d57664e9SAndroid Build Coastguard Worker * Unless required by applicable law or agreed to in writing, software 11*d57664e9SAndroid Build Coastguard Worker * distributed under the License is distributed on an "AS IS" BASIS, 12*d57664e9SAndroid Build Coastguard Worker * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13*d57664e9SAndroid Build Coastguard Worker * See the License for the specific language governing permissions and 14*d57664e9SAndroid Build Coastguard Worker * limitations under the License. 15*d57664e9SAndroid Build Coastguard Worker */ 16*d57664e9SAndroid Build Coastguard Worker 17*d57664e9SAndroid Build Coastguard Worker #ifndef ANDROID_HWUI_BLUR_H 18*d57664e9SAndroid Build Coastguard Worker #define ANDROID_HWUI_BLUR_H 19*d57664e9SAndroid Build Coastguard Worker 20*d57664e9SAndroid Build Coastguard Worker #include <cutils/compiler.h> 21*d57664e9SAndroid Build Coastguard Worker #include <stdint.h> 22*d57664e9SAndroid Build Coastguard Worker 23*d57664e9SAndroid Build Coastguard Worker namespace android { 24*d57664e9SAndroid Build Coastguard Worker namespace uirenderer { 25*d57664e9SAndroid Build Coastguard Worker 26*d57664e9SAndroid Build Coastguard Worker class Blur { 27*d57664e9SAndroid Build Coastguard Worker public: 28*d57664e9SAndroid Build Coastguard Worker // If radius > 0, return the corresponding sigma, else return 0 29*d57664e9SAndroid Build Coastguard Worker static float convertRadiusToSigma(float radius); 30*d57664e9SAndroid Build Coastguard Worker // If sigma > 0.5, return the corresponding radius, else return 0 31*d57664e9SAndroid Build Coastguard Worker static float convertSigmaToRadius(float sigma); 32*d57664e9SAndroid Build Coastguard Worker // If the original radius was on an integer boundary then after the sigma to 33*d57664e9SAndroid Build Coastguard Worker // radius conversion a small rounding error may be introduced. This function 34*d57664e9SAndroid Build Coastguard Worker // accounts for that error and snaps to the appropriate integer boundary. 35*d57664e9SAndroid Build Coastguard Worker static uint32_t convertRadiusToInt(float radius); 36*d57664e9SAndroid Build Coastguard Worker 37*d57664e9SAndroid Build Coastguard Worker static void generateGaussianWeights(float* weights, float radius); 38*d57664e9SAndroid Build Coastguard Worker static void horizontal(float* weights, int32_t radius, const uint8_t* source, uint8_t* dest, 39*d57664e9SAndroid Build Coastguard Worker int32_t width, int32_t height); 40*d57664e9SAndroid Build Coastguard Worker static void vertical(float* weights, int32_t radius, const uint8_t* source, uint8_t* dest, 41*d57664e9SAndroid Build Coastguard Worker int32_t width, int32_t height); 42*d57664e9SAndroid Build Coastguard Worker }; 43*d57664e9SAndroid Build Coastguard Worker 44*d57664e9SAndroid Build Coastguard Worker } // namespace uirenderer 45*d57664e9SAndroid Build Coastguard Worker } // namespace android 46*d57664e9SAndroid Build Coastguard Worker 47*d57664e9SAndroid Build Coastguard Worker #endif // ANDROID_HWUI_BLUR_H 48