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 #include <utils/String8.h> 26 27 namespace android { 28 namespace uirenderer { 29 30 class GammaFontRenderer { 31 public: 32 GammaFontRenderer(); 33 34 void clear() { 35 mRenderer.reset(nullptr); 36 } 37 38 void flush() { 39 if (mRenderer) { 40 mRenderer->flushLargeCaches(); 41 } 42 } 43 44 FontRenderer& getFontRenderer() { 45 if (!mRenderer) { 46 mRenderer.reset(new FontRenderer(&mGammaTable[0])); 47 } 48 return *mRenderer; 49 } 50 51 void dumpMemoryUsage(String8& log) const { 52 if (mRenderer) { 53 mRenderer->dumpMemoryUsage(log); 54 } else { 55 log.appendFormat("FontRenderer doesn't exist.\n"); 56 } 57 } 58 59 uint32_t getSize() const { 60 return mRenderer ? mRenderer->getSize() : 0; 61 } 62 63 void endPrecaching(); 64 65 private: 66 std::unique_ptr<FontRenderer> mRenderer; 67 uint8_t mGammaTable[256]; 68 }; 69 70 }; // namespace uirenderer 71 }; // namespace android 72 73 #endif // ANDROID_HWUI_GAMMA_FONT_RENDERER_H 74