blob: c9cf69bc7d9f3fcca42c4bc6c1ef11d48ca100e6 [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
Chris Craikc08820f2015-09-22 14:22:29 -070029 void clear() {
John Reckf636e632015-12-11 14:55:22 -080030 mRenderer.reset(nullptr);
Romain Guy6e25e382012-07-18 15:50:29 -070031 }
32
Chris Craikc08820f2015-09-22 14:22:29 -070033 void flush() {
Romain Guy6e25e382012-07-18 15:50:29 -070034 if (mRenderer) {
35 mRenderer->flushLargeCaches();
36 }
37 }
38
Chris Craikc08820f2015-09-22 14:22:29 -070039 FontRenderer& getFontRenderer() {
Romain Guy6e25e382012-07-18 15:50:29 -070040 if (!mRenderer) {
Romain Guy253f2c22016-09-28 17:34:42 -070041 const uint8_t* table = nullptr;
42#ifndef ANDROID_ENABLE_LINEAR_BLENDING
43 table = &mGammaTable[0];
44#endif
45 mRenderer.reset(new FontRenderer(table));
Romain Guy6e25e382012-07-18 15:50:29 -070046 }
47 return *mRenderer;
48 }
49
sergeyvbaf29e72016-09-08 11:09:34 -070050 void dumpMemoryUsage(String8& log) const {
51 if (mRenderer) {
52 mRenderer->dumpMemoryUsage(log);
53 } else {
54 log.appendFormat("FontRenderer doesn't exist.\n");
55 }
56 }
57
58 uint32_t getSize() const {
59 return mRenderer ? mRenderer->getSize() : 0;
Romain Guy6e25e382012-07-18 15:50:29 -070060 }
61
Chris Craikc08820f2015-09-22 14:22:29 -070062 void endPrecaching();
Romain Guycf51a412013-04-08 19:40:31 -070063
Romain Guy6e25e382012-07-18 15:50:29 -070064private:
Chris Craikc08820f2015-09-22 14:22:29 -070065 std::unique_ptr<FontRenderer> mRenderer;
Romain Guy253f2c22016-09-28 17:34:42 -070066#ifndef ANDROID_ENABLE_LINEAR_BLENDING
Romain Guy6e25e382012-07-18 15:50:29 -070067 uint8_t mGammaTable[256];
Romain Guy253f2c22016-09-28 17:34:42 -070068#endif
Romain Guyb45c0c92010-08-26 20:35:23 -070069};
70
71}; // namespace uirenderer
72}; // namespace android
73
Romain Guy5b3b3522010-10-27 18:57:51 -070074#endif // ANDROID_HWUI_GAMMA_FONT_RENDERER_H