PageRenderTime 18ms CodeModel.GetById 16ms app.highlight 1ms RepoModel.GetById 1ms app.codeStats 0ms

/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
Possible License(s): LGPL-2.1, MPL-2.0-no-copyleft-exception, CC0-1.0, BitTorrent-1.0, BSD-3-Clause
 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
27namespace android {
28namespace uirenderer {
29
30class GammaFontRenderer {
31public:
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
65private:
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