GammaFontRenderer.h revision eca0ca2424afc1e98912405906edfc32f7733e16
1b45c0c9774bd19a9dbe77d149abae4e124b08bf6Romain Guy/* 2b45c0c9774bd19a9dbe77d149abae4e124b08bf6Romain Guy * Copyright (C) 2010 The Android Open Source Project 3b45c0c9774bd19a9dbe77d149abae4e124b08bf6Romain Guy * 4b45c0c9774bd19a9dbe77d149abae4e124b08bf6Romain Guy * Licensed under the Apache License, Version 2.0 (the "License"); 5b45c0c9774bd19a9dbe77d149abae4e124b08bf6Romain Guy * you may not use this file except in compliance with the License. 6b45c0c9774bd19a9dbe77d149abae4e124b08bf6Romain Guy * You may obtain a copy of the License at 7b45c0c9774bd19a9dbe77d149abae4e124b08bf6Romain Guy * 8b45c0c9774bd19a9dbe77d149abae4e124b08bf6Romain Guy * http://www.apache.org/licenses/LICENSE-2.0 9b45c0c9774bd19a9dbe77d149abae4e124b08bf6Romain Guy * 10b45c0c9774bd19a9dbe77d149abae4e124b08bf6Romain Guy * Unless required by applicable law or agreed to in writing, software 11b45c0c9774bd19a9dbe77d149abae4e124b08bf6Romain Guy * distributed under the License is distributed on an "AS IS" BASIS, 12b45c0c9774bd19a9dbe77d149abae4e124b08bf6Romain Guy * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13b45c0c9774bd19a9dbe77d149abae4e124b08bf6Romain Guy * See the License for the specific language governing permissions and 14b45c0c9774bd19a9dbe77d149abae4e124b08bf6Romain Guy * limitations under the License. 15b45c0c9774bd19a9dbe77d149abae4e124b08bf6Romain Guy */ 16b45c0c9774bd19a9dbe77d149abae4e124b08bf6Romain Guy 175b3b35296e8b2c8d3f07d32bb645d5414db41a1dRomain Guy#ifndef ANDROID_HWUI_GAMMA_FONT_RENDERER_H 185b3b35296e8b2c8d3f07d32bb645d5414db41a1dRomain Guy#define ANDROID_HWUI_GAMMA_FONT_RENDERER_H 19b45c0c9774bd19a9dbe77d149abae4e124b08bf6Romain Guy 20b45c0c9774bd19a9dbe77d149abae4e124b08bf6Romain Guy#include <SkPaint.h> 21b45c0c9774bd19a9dbe77d149abae4e124b08bf6Romain Guy 22b45c0c9774bd19a9dbe77d149abae4e124b08bf6Romain Guy#include "FontRenderer.h" 23b45c0c9774bd19a9dbe77d149abae4e124b08bf6Romain Guy 24b45c0c9774bd19a9dbe77d149abae4e124b08bf6Romain Guynamespace android { 25b45c0c9774bd19a9dbe77d149abae4e124b08bf6Romain Guynamespace uirenderer { 26b45c0c9774bd19a9dbe77d149abae4e124b08bf6Romain Guy 27b45c0c9774bd19a9dbe77d149abae4e124b08bf6Romain Guystruct GammaFontRenderer { 28b45c0c9774bd19a9dbe77d149abae4e124b08bf6Romain Guy GammaFontRenderer(); 29eca0ca2424afc1e98912405906edfc32f7733e16Romain Guy ~GammaFontRenderer(); 30eca0ca2424afc1e98912405906edfc32f7733e16Romain Guy 31eca0ca2424afc1e98912405906edfc32f7733e16Romain Guy enum Gamma { 32eca0ca2424afc1e98912405906edfc32f7733e16Romain Guy kGammaDefault = 0, 33eca0ca2424afc1e98912405906edfc32f7733e16Romain Guy kGammaBlack = 1, 34eca0ca2424afc1e98912405906edfc32f7733e16Romain Guy kGammaWhite = 2, 35eca0ca2424afc1e98912405906edfc32f7733e16Romain Guy kGammaCount = 3 36eca0ca2424afc1e98912405906edfc32f7733e16Romain Guy }; 37eca0ca2424afc1e98912405906edfc32f7733e16Romain Guy 38eca0ca2424afc1e98912405906edfc32f7733e16Romain Guy void clear(); 39eca0ca2424afc1e98912405906edfc32f7733e16Romain Guy void flush(); 40b45c0c9774bd19a9dbe77d149abae4e124b08bf6Romain Guy 41b45c0c9774bd19a9dbe77d149abae4e124b08bf6Romain Guy FontRenderer& getFontRenderer(const SkPaint* paint); 42b45c0c9774bd19a9dbe77d149abae4e124b08bf6Romain Guy 43c15008e72ec00ca20a271c3006dac649fd07533bRomain Guy uint32_t getFontRendererCount() const { 44eca0ca2424afc1e98912405906edfc32f7733e16Romain Guy return kGammaCount; 45c15008e72ec00ca20a271c3006dac649fd07533bRomain Guy } 46c15008e72ec00ca20a271c3006dac649fd07533bRomain Guy 47c15008e72ec00ca20a271c3006dac649fd07533bRomain Guy uint32_t getFontRendererSize(uint32_t fontRenderer) const { 48eca0ca2424afc1e98912405906edfc32f7733e16Romain Guy if (fontRenderer >= kGammaCount) return 0; 49eca0ca2424afc1e98912405906edfc32f7733e16Romain Guy 50eca0ca2424afc1e98912405906edfc32f7733e16Romain Guy FontRenderer* renderer = mRenderers[fontRenderer]; 51eca0ca2424afc1e98912405906edfc32f7733e16Romain Guy if (!renderer) return 0; 52eca0ca2424afc1e98912405906edfc32f7733e16Romain Guy 53eca0ca2424afc1e98912405906edfc32f7733e16Romain Guy return renderer->getCacheHeight() * renderer->getCacheWidth(); 54c15008e72ec00ca20a271c3006dac649fd07533bRomain Guy } 55c15008e72ec00ca20a271c3006dac649fd07533bRomain Guy 56b45c0c9774bd19a9dbe77d149abae4e124b08bf6Romain Guyprivate: 57eca0ca2424afc1e98912405906edfc32f7733e16Romain Guy FontRenderer* getRenderer(Gamma gamma); 58eca0ca2424afc1e98912405906edfc32f7733e16Romain Guy 59eca0ca2424afc1e98912405906edfc32f7733e16Romain Guy uint32_t mRenderersUsageCount[kGammaCount]; 60eca0ca2424afc1e98912405906edfc32f7733e16Romain Guy FontRenderer* mRenderers[kGammaCount]; 61b45c0c9774bd19a9dbe77d149abae4e124b08bf6Romain Guy 62b45c0c9774bd19a9dbe77d149abae4e124b08bf6Romain Guy int mBlackThreshold; 63b45c0c9774bd19a9dbe77d149abae4e124b08bf6Romain Guy int mWhiteThreshold; 64b45c0c9774bd19a9dbe77d149abae4e124b08bf6Romain Guy 65eca0ca2424afc1e98912405906edfc32f7733e16Romain Guy uint8_t mGammaTable[256 * kGammaCount]; 66b45c0c9774bd19a9dbe77d149abae4e124b08bf6Romain Guy}; 67b45c0c9774bd19a9dbe77d149abae4e124b08bf6Romain Guy 68b45c0c9774bd19a9dbe77d149abae4e124b08bf6Romain Guy}; // namespace uirenderer 69b45c0c9774bd19a9dbe77d149abae4e124b08bf6Romain Guy}; // namespace android 70b45c0c9774bd19a9dbe77d149abae4e124b08bf6Romain Guy 715b3b35296e8b2c8d3f07d32bb645d5414db41a1dRomain Guy#endif // ANDROID_HWUI_GAMMA_FONT_RENDERER_H 72