blob: e9002442c64fc6f3b7fd6d6b032cd90ec1f8defc [file] [log] [blame]
Romain Guyb45c0c92010-08-26 20:35:23 -07001/*
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
Romain Guy5b3b3522010-10-27 18:57:51 -070017#ifndef ANDROID_HWUI_GAMMA_FONT_RENDERER_H
18#define ANDROID_HWUI_GAMMA_FONT_RENDERER_H
Romain Guyb45c0c92010-08-26 20:35:23 -070019
Romain Guyb45c0c92010-08-26 20:35:23 -070020#include "FontRenderer.h"
sergeyvbaf29e72016-09-08 11:09:34 -070021
Romain Guyb45c0c92010-08-26 20:35:23 -070022namespace android {
23namespace uirenderer {
24
Romain Guyb1d0a4e2012-07-13 18:25:35 -070025class GammaFontRenderer {
26public:
Romain Guyb1d0a4e2012-07-13 18:25:35 -070027 GammaFontRenderer();
28
John Reck1bcacfd2017-11-03 10:12:19 -070029 void clear() { mRenderer.reset(nullptr); }
Romain Guy6e25e382012-07-18 15:50:29 -070030
Chris Craikc08820f2015-09-22 14:22:29 -070031 void flush() {
Romain Guy6e25e382012-07-18 15:50:29 -070032 if (mRenderer) {
33 mRenderer->flushLargeCaches();
34 }
35 }
36
Chris Craikc08820f2015-09-22 14:22:29 -070037 FontRenderer& getFontRenderer() {
Romain Guy6e25e382012-07-18 15:50:29 -070038 if (!mRenderer) {
Romain Guy253f2c22016-09-28 17:34:42 -070039 const uint8_t* table = nullptr;
40#ifndef ANDROID_ENABLE_LINEAR_BLENDING
41 table = &mGammaTable[0];
42#endif
43 mRenderer.reset(new FontRenderer(table));
Romain Guy6e25e382012-07-18 15:50:29 -070044 }
45 return *mRenderer;
46 }
47
sergeyvbaf29e72016-09-08 11:09:34 -070048 void dumpMemoryUsage(String8& log) const {
49 if (mRenderer) {
50 mRenderer->dumpMemoryUsage(log);
51 } else {
52 log.appendFormat("FontRenderer doesn't exist.\n");
53 }
54 }
55
John Reck1bcacfd2017-11-03 10:12:19 -070056 uint32_t getSize() const { return mRenderer ? mRenderer->getSize() : 0; }
Romain Guy6e25e382012-07-18 15:50:29 -070057
Chris Craikc08820f2015-09-22 14:22:29 -070058 void endPrecaching();
Romain Guycf51a412013-04-08 19:40:31 -070059
Romain Guy6e25e382012-07-18 15:50:29 -070060private:
Chris Craikc08820f2015-09-22 14:22:29 -070061 std::unique_ptr<FontRenderer> mRenderer;
Romain Guy253f2c22016-09-28 17:34:42 -070062#ifndef ANDROID_ENABLE_LINEAR_BLENDING
Romain Guy6e25e382012-07-18 15:50:29 -070063 uint8_t mGammaTable[256];
Romain Guy253f2c22016-09-28 17:34:42 -070064#endif
Romain Guyb45c0c92010-08-26 20:35:23 -070065};
66
John Reck1bcacfd2017-11-03 10:12:19 -070067}; // namespace uirenderer
68}; // namespace android
Romain Guyb45c0c92010-08-26 20:35:23 -070069
John Reck1bcacfd2017-11-03 10:12:19 -070070#endif // ANDROID_HWUI_GAMMA_FONT_RENDERER_H