16e2004089305cf2cd958b52b234459a49a4e5c83Romain Guy/* 26e2004089305cf2cd958b52b234459a49a4e5c83Romain Guy * Copyright (C) 2013 The Android Open Source Project 36e2004089305cf2cd958b52b234459a49a4e5c83Romain Guy * 46e2004089305cf2cd958b52b234459a49a4e5c83Romain Guy * Licensed under the Apache License, Version 2.0 (the "License"); 56e2004089305cf2cd958b52b234459a49a4e5c83Romain Guy * you may not use this file except in compliance with the License. 66e2004089305cf2cd958b52b234459a49a4e5c83Romain Guy * You may obtain a copy of the License at 76e2004089305cf2cd958b52b234459a49a4e5c83Romain Guy * 86e2004089305cf2cd958b52b234459a49a4e5c83Romain Guy * http://www.apache.org/licenses/LICENSE-2.0 96e2004089305cf2cd958b52b234459a49a4e5c83Romain Guy * 106e2004089305cf2cd958b52b234459a49a4e5c83Romain Guy * Unless required by applicable law or agreed to in writing, software 116e2004089305cf2cd958b52b234459a49a4e5c83Romain Guy * distributed under the License is distributed on an "AS IS" BASIS, 126e2004089305cf2cd958b52b234459a49a4e5c83Romain Guy * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 136e2004089305cf2cd958b52b234459a49a4e5c83Romain Guy * See the License for the specific language governing permissions and 146e2004089305cf2cd958b52b234459a49a4e5c83Romain Guy * limitations under the License. 156e2004089305cf2cd958b52b234459a49a4e5c83Romain Guy */ 166e2004089305cf2cd958b52b234459a49a4e5c83Romain Guy 176e2004089305cf2cd958b52b234459a49a4e5c83Romain Guy#ifndef ANDROID_HWUI_BLUR_H 186e2004089305cf2cd958b52b234459a49a4e5c83Romain Guy#define ANDROID_HWUI_BLUR_H 196e2004089305cf2cd958b52b234459a49a4e5c83Romain Guy 206e2004089305cf2cd958b52b234459a49a4e5c83Romain Guy#include <stdint.h> 21c29a0a4664a4b9871fadd668b632469a0db240b9Derek Sollenberger#include <cutils/compiler.h> 226e2004089305cf2cd958b52b234459a49a4e5c83Romain Guy 236e2004089305cf2cd958b52b234459a49a4e5c83Romain Guynamespace android { 246e2004089305cf2cd958b52b234459a49a4e5c83Romain Guynamespace uirenderer { 256e2004089305cf2cd958b52b234459a49a4e5c83Romain Guy 266e2004089305cf2cd958b52b234459a49a4e5c83Romain Guyclass Blur { 276e2004089305cf2cd958b52b234459a49a4e5c83Romain Guypublic: 28c29a0a4664a4b9871fadd668b632469a0db240b9Derek Sollenberger // If radius > 0, return the corresponding sigma, else return 0 29c29a0a4664a4b9871fadd668b632469a0db240b9Derek Sollenberger ANDROID_API static float convertRadiusToSigma(float radius); 30e392c81f6b8f9ace0c0a48c9d4df117fda31fd13Derek Sollenberger // If sigma > 0.5, return the corresponding radius, else return 0 31c29a0a4664a4b9871fadd668b632469a0db240b9Derek Sollenberger ANDROID_API static float convertSigmaToRadius(float sigma); 32e392c81f6b8f9ace0c0a48c9d4df117fda31fd13Derek Sollenberger // If the original radius was on an integer boundary then after the sigma to 33e392c81f6b8f9ace0c0a48c9d4df117fda31fd13Derek Sollenberger // radius conversion a small rounding error may be introduced. This function 34e392c81f6b8f9ace0c0a48c9d4df117fda31fd13Derek Sollenberger // accounts for that error and snaps to the appropriate integer boundary. 35e392c81f6b8f9ace0c0a48c9d4df117fda31fd13Derek Sollenberger static uint32_t convertRadiusToInt(float radius); 36c29a0a4664a4b9871fadd668b632469a0db240b9Derek Sollenberger 37a46ca5ec732a884c78d3e98f8b4eb8de03bc23f8huanhuan.x.wang static void generateGaussianWeights(float* weights, float radius); 386e2004089305cf2cd958b52b234459a49a4e5c83Romain Guy static void horizontal(float* weights, int32_t radius, const uint8_t* source, 396e2004089305cf2cd958b52b234459a49a4e5c83Romain Guy uint8_t* dest, int32_t width, int32_t height); 406e2004089305cf2cd958b52b234459a49a4e5c83Romain Guy static void vertical(float* weights, int32_t radius, const uint8_t* source, 416e2004089305cf2cd958b52b234459a49a4e5c83Romain Guy uint8_t* dest, int32_t width, int32_t height); 426e2004089305cf2cd958b52b234459a49a4e5c83Romain Guy}; 436e2004089305cf2cd958b52b234459a49a4e5c83Romain Guy 446e2004089305cf2cd958b52b234459a49a4e5c83Romain Guy}; // namespace uirenderer 456e2004089305cf2cd958b52b234459a49a4e5c83Romain Guy}; // namespace android 466e2004089305cf2cd958b52b234459a49a4e5c83Romain Guy 476e2004089305cf2cd958b52b234459a49a4e5c83Romain Guy#endif // ANDROID_HWUI_BLUR_H 48