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 17c9855a53edfac818dc68714557185977556f849dRomain Guy#include "Debug.h" 18b45c0c9774bd19a9dbe77d149abae4e124b08bf6Romain Guy#include "GammaFontRenderer.h" 19b45c0c9774bd19a9dbe77d149abae4e124b08bf6Romain Guy#include "Properties.h" 20b45c0c9774bd19a9dbe77d149abae4e124b08bf6Romain Guy 21b45c0c9774bd19a9dbe77d149abae4e124b08bf6Romain Guynamespace android { 22b45c0c9774bd19a9dbe77d149abae4e124b08bf6Romain Guynamespace uirenderer { 23b45c0c9774bd19a9dbe77d149abae4e124b08bf6Romain Guy 24b1d0a4ed21168fefcb82232c8f22cb95d60acb85Romain GuyGammaFontRenderer::GammaFontRenderer() { 25b1d0a4ed21168fefcb82232c8f22cb95d60acb85Romain Guy INIT_LOGD("Creating lookup gamma font renderer"); 26b45c0c9774bd19a9dbe77d149abae4e124b08bf6Romain Guy 27b45c0c9774bd19a9dbe77d149abae4e124b08bf6Romain Guy // Compute the gamma tables 28c08820f587ad94698691a6657e87712de07e484cChris Craik const float gamma = 1.0f / Properties::textGamma; 296e25e38e43f9e7f71397dfab7ed32c81c7bf7d46Romain Guy 306e25e38e43f9e7f71397dfab7ed32c81c7bf7d46Romain Guy for (uint32_t i = 0; i <= 255; i++) { 316e25e38e43f9e7f71397dfab7ed32c81c7bf7d46Romain Guy mGammaTable[i] = uint8_t((float)::floor(pow(i / 255.0f, gamma) * 255.0f + 0.5f)); 326e25e38e43f9e7f71397dfab7ed32c81c7bf7d46Romain Guy } 336e25e38e43f9e7f71397dfab7ed32c81c7bf7d46Romain Guy} 346e25e38e43f9e7f71397dfab7ed32c81c7bf7d46Romain Guy 35c08820f587ad94698691a6657e87712de07e484cChris Craikvoid GammaFontRenderer::endPrecaching() { 36cf51a4199835e9604aa4c8b3854306f8fbabbf33Romain Guy if (mRenderer) { 37cf51a4199835e9604aa4c8b3854306f8fbabbf33Romain Guy mRenderer->endPrecaching(); 38cf51a4199835e9604aa4c8b3854306f8fbabbf33Romain Guy } 39cf51a4199835e9604aa4c8b3854306f8fbabbf33Romain Guy} 40cf51a4199835e9604aa4c8b3854306f8fbabbf33Romain Guy 41b45c0c9774bd19a9dbe77d149abae4e124b08bf6Romain Guy}; // namespace uirenderer 42b45c0c9774bd19a9dbe77d149abae4e124b08bf6Romain Guy}; // namespace android 43