1 /* 2 * Copyright (C) 2010 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 ANDROID_HWUI_GAMMA_FONT_RENDERER_H 18 #define ANDROID_HWUI_GAMMA_FONT_RENDERER_H 19 20 #include <SkPaint.h> 21 22 #include "FontRenderer.h" 23 24 namespace android { 25 namespace uirenderer { 26 27 struct GammaFontRenderer { 28 GammaFontRenderer(); 29 ~GammaFontRenderer(); 30 31 enum Gamma { 32 kGammaDefault = 0, 33 kGammaBlack = 1, 34 kGammaWhite = 2, 35 kGammaCount = 3 36 }; 37 38 void clear(); 39 void flush(); 40 41 FontRenderer& getFontRenderer(const SkPaint* paint); 42 43 uint32_t getFontRendererCount() const { 44 return kGammaCount; 45 } 46 47 uint32_t getFontRendererSize(uint32_t fontRenderer) const { 48 if (fontRenderer >= kGammaCount) return 0; 49 50 FontRenderer* renderer = mRenderers[fontRenderer]; 51 if (!renderer) return 0; 52 53 return renderer->getCacheHeight() * renderer->getCacheWidth(); 54 } 55 56 private: 57 FontRenderer* getRenderer(Gamma gamma); 58 59 uint32_t mRenderersUsageCount[kGammaCount]; 60 FontRenderer* mRenderers[kGammaCount]; 61 62 int mBlackThreshold; 63 int mWhiteThreshold; 64 65 uint8_t mGammaTable[256 * kGammaCount]; 66 }; 67 68 }; // namespace uirenderer 69 }; // namespace android 70 71 #endif // ANDROID_HWUI_GAMMA_FONT_RENDERER_H 72