Romain Guy | b45c0c9 | 2010-08-26 20:35:23 -0700 | [diff] [blame] | 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 | |
Romain Guy | 5b3b352 | 2010-10-27 18:57:51 -0700 | [diff] [blame] | 17 | #ifndef ANDROID_HWUI_GAMMA_FONT_RENDERER_H |
| 18 | #define ANDROID_HWUI_GAMMA_FONT_RENDERER_H |
Romain Guy | b45c0c9 | 2010-08-26 20:35:23 -0700 | [diff] [blame] | 19 | |
| 20 | #include <SkPaint.h> |
| 21 | |
| 22 | #include "FontRenderer.h" |
| 23 | |
| 24 | namespace android { |
| 25 | namespace uirenderer { |
| 26 | |
| 27 | struct GammaFontRenderer { |
| 28 | GammaFontRenderer(); |
Romain Guy | eca0ca2 | 2011-11-04 15:12:29 -0700 | [diff] [blame] | 29 | ~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 Guy | b45c0c9 | 2010-08-26 20:35:23 -0700 | [diff] [blame] | 40 | |
| 41 | FontRenderer& getFontRenderer(const SkPaint* paint); |
| 42 | |
Romain Guy | c15008e | 2010-11-10 11:59:15 -0800 | [diff] [blame] | 43 | uint32_t getFontRendererCount() const { |
Romain Guy | eca0ca2 | 2011-11-04 15:12:29 -0700 | [diff] [blame] | 44 | return kGammaCount; |
Romain Guy | c15008e | 2010-11-10 11:59:15 -0800 | [diff] [blame] | 45 | } |
| 46 | |
| 47 | uint32_t getFontRendererSize(uint32_t fontRenderer) const { |
Romain Guy | eca0ca2 | 2011-11-04 15:12:29 -0700 | [diff] [blame] | 48 | if (fontRenderer >= kGammaCount) return 0; |
| 49 | |
| 50 | FontRenderer* renderer = mRenderers[fontRenderer]; |
| 51 | if (!renderer) return 0; |
| 52 | |
Chet Haase | 7de0cb1 | 2011-12-05 16:35:38 -0800 | [diff] [blame] | 53 | return renderer->getCacheSize(); |
Romain Guy | c15008e | 2010-11-10 11:59:15 -0800 | [diff] [blame] | 54 | } |
| 55 | |
Romain Guy | b45c0c9 | 2010-08-26 20:35:23 -0700 | [diff] [blame] | 56 | private: |
Romain Guy | eca0ca2 | 2011-11-04 15:12:29 -0700 | [diff] [blame] | 57 | FontRenderer* getRenderer(Gamma gamma); |
| 58 | |
| 59 | uint32_t mRenderersUsageCount[kGammaCount]; |
| 60 | FontRenderer* mRenderers[kGammaCount]; |
Romain Guy | b45c0c9 | 2010-08-26 20:35:23 -0700 | [diff] [blame] | 61 | |
| 62 | int mBlackThreshold; |
| 63 | int mWhiteThreshold; |
| 64 | |
Romain Guy | eca0ca2 | 2011-11-04 15:12:29 -0700 | [diff] [blame] | 65 | uint8_t mGammaTable[256 * kGammaCount]; |
Romain Guy | b45c0c9 | 2010-08-26 20:35:23 -0700 | [diff] [blame] | 66 | }; |
| 67 | |
| 68 | }; // namespace uirenderer |
| 69 | }; // namespace android |
| 70 | |
Romain Guy | 5b3b352 | 2010-10-27 18:57:51 -0700 | [diff] [blame] | 71 | #endif // ANDROID_HWUI_GAMMA_FONT_RENDERER_H |