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& matrix, SkIPoint* margin);
     42 
     43     // overrides from SkFlattenable
     44 
     45     //  This method is not exported to java.
     46     virtual Factory getFactory();
     47     //  This method is not exported to java.
     48     virtual void flatten(SkFlattenableWriteBuffer&);
     49 
     50 protected:
     51     SkEmbossMaskFilter(SkFlattenableReadBuffer&);
     52 
     53 private:
     54     Light       fLight;
     55     SkScalar    fBlurRadius;
     56 
     57     static SkFlattenable* CreateProc(SkFlattenableReadBuffer&);
     58 
     59     typedef SkMaskFilter INHERITED;
     60 };
     61 
     62 #endif
     63 
     64