Home | History | Annotate | Download | only in graphics
      1 /*
      2  * Copyright (C) 2006 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 package android.graphics;
     18 
     19 /**
     20  * This takes a mask, and blurs its edge by the specified radius. Whether or
     21  * or not to include the original mask, and whether the blur goes outside,
     22  * inside, or straddles, the original mask's border, is controlled by the
     23  * Blur enum.
     24  */
     25 public class BlurMaskFilter extends MaskFilter {
     26 
     27     public enum Blur {
     28         /**
     29          * Blur inside and outside the original border.
     30          */
     31         NORMAL(0),
     32 
     33         /**
     34          * Draw solid inside the border, blur outside.
     35          */
     36         SOLID(1),
     37 
     38         /**
     39          * Draw nothing inside the border, blur outside.
     40          */
     41         OUTER(2),
     42 
     43         /**
     44          * Blur inside the border, draw nothing outside.
     45          */
     46         INNER(3);
     47 
     48         Blur(int value) {
     49             native_int = value;
     50         }
     51         final int native_int;
     52     }
     53 
     54     /**
     55      * Create a blur maskfilter.
     56      *
     57      * @param radius The radius to extend the blur from the original mask. Must be > 0.
     58      * @param style  The Blur to use
     59      * @return       The new blur maskfilter
     60      */
     61     public BlurMaskFilter(float radius, Blur style) {
     62         native_instance = nativeConstructor(radius, style.native_int);
     63     }
     64 
     65     private static native long nativeConstructor(float radius, int style);
     66 }
     67