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 "FontRenderer.h" 21 #include "Program.h" 22 23 #include <SkPaint.h> 24 25 namespace android { 26 namespace uirenderer { 27 28 class GammaFontRenderer { 29 public: 30 GammaFontRenderer(); 31 clear()32 void clear() { 33 mRenderer.reset(nullptr); 34 } 35 flush()36 void flush() { 37 if (mRenderer) { 38 mRenderer->flushLargeCaches(); 39 } 40 } 41 getFontRenderer()42 FontRenderer& getFontRenderer() { 43 if (!mRenderer) { 44 mRenderer.reset(new FontRenderer(&mGammaTable[0])); 45 } 46 return *mRenderer; 47 } 48 getFontRendererSize(GLenum format)49 uint32_t getFontRendererSize(GLenum format) const { 50 return mRenderer ? mRenderer->getCacheSize(format) : 0; 51 } 52 53 void endPrecaching(); 54 55 private: 56 std::unique_ptr<FontRenderer> mRenderer; 57 uint8_t mGammaTable[256]; 58 }; 59 60 }; // namespace uirenderer 61 }; // namespace android 62 63 #endif // ANDROID_HWUI_GAMMA_FONT_RENDERER_H 64