1 2 /* 3 * Copyright 2008 The Android Open Source Project 4 * 5 * Use of this source code is governed by a BSD-style license that can be 6 * found in the LICENSE file. 7 */ 8 9 10 #ifndef SkKernel33MaskFilter_DEFINED 11 #define SkKernel33MaskFilter_DEFINED 12 13 #include "SkMaskFilter.h" 14 15 class SkKernel33ProcMaskFilter : public SkMaskFilter { 16 public: 17 SkKernel33ProcMaskFilter(unsigned percent256 = 256) fPercent256(percent256)18 : fPercent256(percent256) {} 19 20 virtual uint8_t computeValue(uint8_t* const* srcRows) = 0; 21 22 // overrides from SkMaskFilter 23 virtual SkMask::Format getFormat(); 24 virtual bool filterMask(SkMask*, const SkMask&, const SkMatrix&, SkIPoint*); 25 26 // overrides from SkFlattenable 27 virtual void flatten(SkFlattenableWriteBuffer& wb); 28 29 protected: 30 SkKernel33ProcMaskFilter(SkFlattenableReadBuffer& rb); 31 32 private: 33 int fPercent256; 34 35 typedef SkMaskFilter INHERITED; 36 }; 37 38 /////////////////////////////////////////////////////////////////////////////// 39 40 class SkKernel33MaskFilter : public SkKernel33ProcMaskFilter { 41 public: 42 SkKernel33MaskFilter(const int coeff[3][3], int shift, int percent256 = 256) SkKernel33ProcMaskFilter(percent256)43 : SkKernel33ProcMaskFilter(percent256) { 44 memcpy(fKernel, coeff, 9 * sizeof(int)); 45 fShift = shift; 46 } 47 48 // override from SkKernel33ProcMaskFilter 49 virtual uint8_t computeValue(uint8_t* const* srcRows); 50 51 // overrides from SkFlattenable 52 virtual void flatten(SkFlattenableWriteBuffer& wb); 53 virtual Factory getFactory(); 54 55 private: 56 int fKernel[3][3]; 57 int fShift; 58 59 SkKernel33MaskFilter(SkFlattenableReadBuffer& rb); 60 static SkFlattenable* Create(SkFlattenableReadBuffer& rb); 61 62 typedef SkKernel33ProcMaskFilter INHERITED; 63 }; 64 65 #endif 66