blob: bd27a1a720609d3348e830cc82e4933eaad3c6e7 [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"
Romain Guy41210632012-07-16 17:04:24 -070021#include "Program.h"
Romain Guyb45c0c92010-08-26 20:35:23 -070022
Chris Craikc08820f2015-09-22 14:22:29 -070023#include <SkPaint.h>
24
sergeyvbaf29e72016-09-08 11:09:34 -070025#include <utils/String8.h>
26
Romain Guyb45c0c92010-08-26 20:35:23 -070027namespace android {
28namespace uirenderer {
29
Romain Guyb1d0a4e2012-07-13 18:25:35 -070030class GammaFontRenderer {
31public:
Romain Guyb1d0a4e2012-07-13 18:25:35 -070032 GammaFontRenderer();
33
Chris Craikc08820f2015-09-22 14:22:29 -070034 void clear() {
John Reckf636e632015-12-11 14:55:22 -080035 mRenderer.reset(nullptr);
Romain Guy6e25e382012-07-18 15:50:29 -070036 }
37
Chris Craikc08820f2015-09-22 14:22:29 -070038 void flush() {
Romain Guy6e25e382012-07-18 15:50:29 -070039 if (mRenderer) {
40 mRenderer->flushLargeCaches();
41 }
42 }
43
Chris Craikc08820f2015-09-22 14:22:29 -070044 FontRenderer& getFontRenderer() {
Romain Guy6e25e382012-07-18 15:50:29 -070045 if (!mRenderer) {
Chris Craikc08820f2015-09-22 14:22:29 -070046 mRenderer.reset(new FontRenderer(&mGammaTable[0]));
Romain Guy6e25e382012-07-18 15:50:29 -070047 }
48 return *mRenderer;
49 }
50
sergeyvbaf29e72016-09-08 11:09:34 -070051 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;
Romain Guy6e25e382012-07-18 15:50:29 -070061 }
62
Chris Craikc08820f2015-09-22 14:22:29 -070063 void endPrecaching();
Romain Guycf51a412013-04-08 19:40:31 -070064
Romain Guy6e25e382012-07-18 15:50:29 -070065private:
Chris Craikc08820f2015-09-22 14:22:29 -070066 std::unique_ptr<FontRenderer> mRenderer;
Romain Guy6e25e382012-07-18 15:50:29 -070067 uint8_t mGammaTable[256];
Romain Guyb45c0c92010-08-26 20:35:23 -070068};
69
70}; // namespace uirenderer
71}; // namespace android
72
Romain Guy5b3b3522010-10-27 18:57:51 -070073#endif // ANDROID_HWUI_GAMMA_FONT_RENDERER_H