00001 /* 00002 * Copyright (C) 2006 The Android Open Source Project 00003 * 00004 * Licensed under the Apache License, Version 2.0 (the "License"); 00005 * you may not use this file except in compliance with the License. 00006 * You may obtain a copy of the License at 00007 * 00008 * http://www.apache.org/licenses/LICENSE-2.0 00009 * 00010 * Unless required by applicable law or agreed to in writing, software 00011 * distributed under the License is distributed on an "AS IS" BASIS, 00012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00013 * See the License for the specific language governing permissions and 00014 * limitations under the License. 00015 */ 00016 00017 #ifndef SkMaskFilter_DEFINED 00018 #define SkMaskFilter_DEFINED 00019 00020 #include "SkFlattenable.h" 00021 #include "SkMask.h" 00022 00023 class SkBlitter; 00024 class SkBounder; 00025 class SkMatrix; 00026 class SkPath; 00027 class SkRegion; 00028 00040 class SkMaskFilter : public SkFlattenable { 00041 public: 00042 SkMaskFilter() {} 00043 00047 virtual SkMask::Format getFormat() = 0; 00048 00062 virtual bool filterMask(SkMask* dst, const SkMask& src, const SkMatrix&, SkIPoint* margin); 00063 00069 bool filterPath(const SkPath& devPath, const SkMatrix& devMatrix, 00070 const SkRegion& devClip, SkBounder*, SkBlitter* blitter); 00071 00072 virtual void flatten(SkFlattenableWriteBuffer& ) {} 00073 protected: 00074 // empty for now, but lets get our subclass to remember to init us for the future 00075 SkMaskFilter(SkFlattenableReadBuffer&) {} 00076 }; 00077 00083 class SkAutoMaskImage { 00084 public: 00085 SkAutoMaskImage(SkMask* mask, bool alloc) 00086 { 00087 if (alloc) 00088 mask->fImage = SkMask::AllocImage(mask->computeImageSize()); 00089 fImage = mask->fImage; 00090 } 00091 ~SkAutoMaskImage() 00092 { 00093 SkMask::FreeImage(fImage); 00094 } 00095 private: 00096 uint8_t* fImage; 00097 }; 00098 00099 #endif 00100