/libs/hwui/GammaFontRenderer.h

http://github.com/CyanogenMod/android_frameworks_base · C Header · 73 lines · 43 code · 15 blank · 15 comment · 4 complexity · 295212f9366a3bd712bf5f6a3c97c196 MD5 · raw file

  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. #ifndef ANDROID_HWUI_GAMMA_FONT_RENDERER_H
  17. #define ANDROID_HWUI_GAMMA_FONT_RENDERER_H
  18. #include "FontRenderer.h"
  19. #include "Program.h"
  20. #include <SkPaint.h>
  21. #include <utils/String8.h>
  22. namespace android {
  23. namespace uirenderer {
  24. class GammaFontRenderer {
  25. public:
  26. GammaFontRenderer();
  27. void clear() {
  28. mRenderer.reset(nullptr);
  29. }
  30. void flush() {
  31. if (mRenderer) {
  32. mRenderer->flushLargeCaches();
  33. }
  34. }
  35. FontRenderer& getFontRenderer() {
  36. if (!mRenderer) {
  37. mRenderer.reset(new FontRenderer(&mGammaTable[0]));
  38. }
  39. return *mRenderer;
  40. }
  41. void dumpMemoryUsage(String8& log) const {
  42. if (mRenderer) {
  43. mRenderer->dumpMemoryUsage(log);
  44. } else {
  45. log.appendFormat("FontRenderer doesn't exist.\n");
  46. }
  47. }
  48. uint32_t getSize() const {
  49. return mRenderer ? mRenderer->getSize() : 0;
  50. }
  51. void endPrecaching();
  52. private:
  53. std::unique_ptr<FontRenderer> mRenderer;
  54. uint8_t mGammaTable[256];
  55. };
  56. }; // namespace uirenderer
  57. }; // namespace android
  58. #endif // ANDROID_HWUI_GAMMA_FONT_RENDERER_H