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 | |
Romain Guy | b45c0c9 | 2010-08-26 20:35:23 -0700 | [diff] [blame] | 20 | #include "FontRenderer.h" |
sergeyv | baf29e7 | 2016-09-08 11:09:34 -0700 | [diff] [blame] | 21 | |
Romain Guy | b45c0c9 | 2010-08-26 20:35:23 -0700 | [diff] [blame] | 22 | namespace android { |
| 23 | namespace uirenderer { |
| 24 | |
Romain Guy | b1d0a4e | 2012-07-13 18:25:35 -0700 | [diff] [blame] | 25 | class GammaFontRenderer { |
| 26 | public: |
Romain Guy | b1d0a4e | 2012-07-13 18:25:35 -0700 | [diff] [blame] | 27 | GammaFontRenderer(); |
| 28 | |
Chris Craik | c08820f | 2015-09-22 14:22:29 -0700 | [diff] [blame] | 29 | void clear() { |
John Reck | f636e63 | 2015-12-11 14:55:22 -0800 | [diff] [blame] | 30 | mRenderer.reset(nullptr); |
Romain Guy | 6e25e38 | 2012-07-18 15:50:29 -0700 | [diff] [blame] | 31 | } |
| 32 | |
Chris Craik | c08820f | 2015-09-22 14:22:29 -0700 | [diff] [blame] | 33 | void flush() { |
Romain Guy | 6e25e38 | 2012-07-18 15:50:29 -0700 | [diff] [blame] | 34 | if (mRenderer) { |
| 35 | mRenderer->flushLargeCaches(); |
| 36 | } |
| 37 | } |
| 38 | |
Chris Craik | c08820f | 2015-09-22 14:22:29 -0700 | [diff] [blame] | 39 | FontRenderer& getFontRenderer() { |
Romain Guy | 6e25e38 | 2012-07-18 15:50:29 -0700 | [diff] [blame] | 40 | if (!mRenderer) { |
Romain Guy | 253f2c2 | 2016-09-28 17:34:42 -0700 | [diff] [blame] | 41 | const uint8_t* table = nullptr; |
| 42 | #ifndef ANDROID_ENABLE_LINEAR_BLENDING |
| 43 | table = &mGammaTable[0]; |
| 44 | #endif |
| 45 | mRenderer.reset(new FontRenderer(table)); |
Romain Guy | 6e25e38 | 2012-07-18 15:50:29 -0700 | [diff] [blame] | 46 | } |
| 47 | return *mRenderer; |
| 48 | } |
| 49 | |
sergeyv | baf29e7 | 2016-09-08 11:09:34 -0700 | [diff] [blame] | 50 | void dumpMemoryUsage(String8& log) const { |
| 51 | if (mRenderer) { |
| 52 | mRenderer->dumpMemoryUsage(log); |
| 53 | } else { |
| 54 | log.appendFormat("FontRenderer doesn't exist.\n"); |
| 55 | } |
| 56 | } |
| 57 | |
| 58 | uint32_t getSize() const { |
| 59 | return mRenderer ? mRenderer->getSize() : 0; |
Romain Guy | 6e25e38 | 2012-07-18 15:50:29 -0700 | [diff] [blame] | 60 | } |
| 61 | |
Chris Craik | c08820f | 2015-09-22 14:22:29 -0700 | [diff] [blame] | 62 | void endPrecaching(); |
Romain Guy | cf51a41 | 2013-04-08 19:40:31 -0700 | [diff] [blame] | 63 | |
Romain Guy | 6e25e38 | 2012-07-18 15:50:29 -0700 | [diff] [blame] | 64 | private: |
Chris Craik | c08820f | 2015-09-22 14:22:29 -0700 | [diff] [blame] | 65 | std::unique_ptr<FontRenderer> mRenderer; |
Romain Guy | 253f2c2 | 2016-09-28 17:34:42 -0700 | [diff] [blame] | 66 | #ifndef ANDROID_ENABLE_LINEAR_BLENDING |
Romain Guy | 6e25e38 | 2012-07-18 15:50:29 -0700 | [diff] [blame] | 67 | uint8_t mGammaTable[256]; |
Romain Guy | 253f2c2 | 2016-09-28 17:34:42 -0700 | [diff] [blame] | 68 | #endif |
Romain Guy | b45c0c9 | 2010-08-26 20:35:23 -0700 | [diff] [blame] | 69 | }; |
| 70 | |
| 71 | }; // namespace uirenderer |
| 72 | }; // namespace android |
| 73 | |
Romain Guy | 5b3b352 | 2010-10-27 18:57:51 -0700 | [diff] [blame] | 74 | #endif // ANDROID_HWUI_GAMMA_FONT_RENDERER_H |