Home | History | Annotate | Download | only in effects
      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 #ifndef SkEmbossMaskFilter_DEFINED
     18 #define SkEmbossMaskFilter_DEFINED
     19 
     20 #include "SkMaskFilter.h"
     21 
     22 /** \class SkEmbossMaskFilter
     23 
     24     This mask filter creates a 3D emboss look, by specifying a light and blur amount.
     25 */
     26 class SkEmbossMaskFilter : public SkMaskFilter {
     27 public:
     28     struct Light {
     29         SkScalar    fDirection[3];  // x,y,z
     30         uint16_t    fPad;
     31         uint8_t     fAmbient;
     32         uint8_t     fSpecular;      // exponent, 4.4 right now
     33     };
     34 
     35     SkEmbossMaskFilter(const Light& light, SkScalar blurRadius);
     36 
     37     // overrides from SkMaskFilter
     38     //  This method is not exported to java.
     39     virtual SkMask::Format getFormat();
     40     //  This method is not exported to java.
     41     virtual bool filterMask(SkMask* dst, const SkMask& src, const SkMatrix&,
     42                             SkIPoint* margin);
     43 
     44     // overrides from SkFlattenable
     45 
     46     //  This method is not exported to java.
     47     virtual Factory getFactory();
     48     //  This method is not exported to java.
     49     virtual void flatten(SkFlattenableWriteBuffer&);
     50 
     51 protected:
     52     SkEmbossMaskFilter(SkFlattenableReadBuffer&);
     53 
     54 private:
     55     Light       fLight;
     56     SkScalar    fBlurRadius;
     57 
     58     static SkFlattenable* CreateProc(SkFlattenableReadBuffer&);
     59 
     60     typedef SkMaskFilter INHERITED;
     61 };
     62 
     63 #endif
     64 
     65