blob: 99f08f032769b66adf7dde059de183fff2819905 [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
20#include <SkPaint.h>
21
22#include "FontRenderer.h"
23
24namespace android {
25namespace uirenderer {
26
27struct GammaFontRenderer {
28 GammaFontRenderer();
Romain Guyeca0ca22011-11-04 15:12:29 -070029 ~GammaFontRenderer();
30
31 enum Gamma {
32 kGammaDefault = 0,
33 kGammaBlack = 1,
34 kGammaWhite = 2,
35 kGammaCount = 3
36 };
37
38 void clear();
39 void flush();
Romain Guyb45c0c92010-08-26 20:35:23 -070040
41 FontRenderer& getFontRenderer(const SkPaint* paint);
42
Romain Guyc15008e2010-11-10 11:59:15 -080043 uint32_t getFontRendererCount() const {
Romain Guyeca0ca22011-11-04 15:12:29 -070044 return kGammaCount;
Romain Guyc15008e2010-11-10 11:59:15 -080045 }
46
47 uint32_t getFontRendererSize(uint32_t fontRenderer) const {
Romain Guyeca0ca22011-11-04 15:12:29 -070048 if (fontRenderer >= kGammaCount) return 0;
49
50 FontRenderer* renderer = mRenderers[fontRenderer];
51 if (!renderer) return 0;
52
Chet Haase7de0cb12011-12-05 16:35:38 -080053 return renderer->getCacheSize();
Romain Guyc15008e2010-11-10 11:59:15 -080054 }
55
Romain Guyb45c0c92010-08-26 20:35:23 -070056private:
Romain Guyeca0ca22011-11-04 15:12:29 -070057 FontRenderer* getRenderer(Gamma gamma);
58
59 uint32_t mRenderersUsageCount[kGammaCount];
60 FontRenderer* mRenderers[kGammaCount];
Romain Guyb45c0c92010-08-26 20:35:23 -070061
62 int mBlackThreshold;
63 int mWhiteThreshold;
64
Romain Guyeca0ca22011-11-04 15:12:29 -070065 uint8_t mGammaTable[256 * kGammaCount];
Romain Guyb45c0c92010-08-26 20:35:23 -070066};
67
68}; // namespace uirenderer
69}; // namespace android
70
Romain Guy5b3b3522010-10-27 18:57:51 -070071#endif // ANDROID_HWUI_GAMMA_FONT_RENDERER_H