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