GammaFontRenderer.h revision c15008e72ec00ca20a271c3006dac649fd07533b
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 <SkPaint.h>
21
22#include "FontRenderer.h"
23
24namespace android {
25namespace uirenderer {
26
27struct GammaFontRenderer {
28    GammaFontRenderer();
29
30    FontRenderer& getFontRenderer(const SkPaint* paint);
31
32    uint32_t getFontRendererCount() const {
33        return 3;
34    }
35
36    uint32_t getFontRendererSize(uint32_t fontRenderer) const {
37        switch (fontRenderer) {
38            case 0:
39                return mDefaultRenderer.getCacheHeight() * mDefaultRenderer.getCacheWidth();
40            case 1:
41                return mBlackGammaRenderer.getCacheHeight() * mBlackGammaRenderer.getCacheWidth();
42            case 2:
43                return mWhiteGammaRenderer.getCacheHeight() * mWhiteGammaRenderer.getCacheWidth();
44        }
45        return 0;
46    }
47
48private:
49    FontRenderer mDefaultRenderer;
50    FontRenderer mBlackGammaRenderer;
51    FontRenderer mWhiteGammaRenderer;
52
53    int mBlackThreshold;
54    int mWhiteThreshold;
55
56    uint8_t mDefault[256];
57    uint8_t mBlackGamma[256];
58    uint8_t mWhiteGamma[256];
59};
60
61}; // namespace uirenderer
62}; // namespace android
63
64#endif // ANDROID_HWUI_GAMMA_FONT_RENDERER_H
65