00001 /* 00002 * Copyright (C) 2008 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 SkUnitMappers_DEFINED 00018 #define SkUnitMappers_DEFINED 00019 00020 #include "SkUnitMapper.h" 00021 00024 class SkDiscreteMapper : public SkUnitMapper { 00025 public: 00026 SkDiscreteMapper(int segments); 00027 // override from SkUnitMapper 00028 virtual uint16_t mapUnit16(uint16_t x); 00029 00030 protected: 00031 SkDiscreteMapper(SkFlattenableReadBuffer& ); 00032 // overrides from SkFlattenable 00033 virtual void flatten(SkFlattenableWriteBuffer& ); 00034 virtual Factory getFactory(); 00035 private: 00036 int fSegments; 00037 SkFract fScale; // computed from fSegments 00038 00039 static SkFlattenable* Create(SkFlattenableReadBuffer& buffer); 00040 00041 typedef SkUnitMapper INHERITED; 00042 }; 00043 00047 class SkCosineMapper : public SkUnitMapper { 00048 public: 00049 SkCosineMapper() {} 00050 // override from SkUnitMapper 00051 virtual uint16_t mapUnit16(uint16_t x); 00052 00053 protected: 00054 SkCosineMapper(SkFlattenableReadBuffer&); 00055 // overrides from SkFlattenable 00056 virtual Factory getFactory(); 00057 00058 private: 00059 static SkFlattenable* Create(SkFlattenableReadBuffer&); 00060 00061 typedef SkUnitMapper INHERITED; 00062 }; 00063 00064 #endif 00065