Romain Guy | 9f5dab3 | 2012-09-04 12:55:44 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2012 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_FONT_UTIL_H |
| 18 | #define ANDROID_HWUI_FONT_UTIL_H |
| 19 | |
| 20 | #include <SkUtils.h> |
| 21 | |
| 22 | #include "Properties.h" |
| 23 | |
| 24 | /////////////////////////////////////////////////////////////////////////////// |
| 25 | // Defines |
| 26 | /////////////////////////////////////////////////////////////////////////////// |
| 27 | |
| 28 | #define DEFAULT_TEXT_SMALL_CACHE_WIDTH 1024 |
Romain Guy | 115096f | 2013-03-19 11:32:41 -0700 | [diff] [blame] | 29 | #define DEFAULT_TEXT_SMALL_CACHE_HEIGHT 512 |
Romain Guy | 9f5dab3 | 2012-09-04 12:55:44 -0700 | [diff] [blame] | 30 | #define DEFAULT_TEXT_LARGE_CACHE_WIDTH 2048 |
| 31 | #define DEFAULT_TEXT_LARGE_CACHE_HEIGHT 512 |
| 32 | |
| 33 | #define TEXTURE_BORDER_SIZE 1 |
Victoria Lease | 1e54681 | 2013-06-25 14:25:17 -0700 | [diff] [blame^] | 34 | #if TEXTURE_BORDER_SIZE != 1 |
| 35 | # error TEXTURE_BORDER_SIZE other than 1 is not currently supported |
| 36 | #endif |
Romain Guy | 9f5dab3 | 2012-09-04 12:55:44 -0700 | [diff] [blame] | 37 | |
| 38 | #define CACHE_BLOCK_ROUNDING_SIZE 4 |
| 39 | |
| 40 | #if RENDER_TEXT_AS_GLYPHS |
| 41 | typedef uint16_t glyph_t; |
| 42 | #define TO_GLYPH(g) g |
Romain Guy | e3a9b24 | 2013-01-08 11:15:30 -0800 | [diff] [blame] | 43 | #define GET_METRICS(paint, glyph, matrix) paint->getGlyphMetrics(glyph, matrix) |
Romain Guy | 9f5dab3 | 2012-09-04 12:55:44 -0700 | [diff] [blame] | 44 | #define GET_GLYPH(text) nextGlyph((const uint16_t**) &text) |
| 45 | #define IS_END_OF_STRING(glyph) false |
| 46 | |
| 47 | static glyph_t nextGlyph(const uint16_t** srcPtr) { |
| 48 | const uint16_t* src = *srcPtr; |
| 49 | glyph_t g = *src++; |
| 50 | *srcPtr = src; |
| 51 | return g; |
| 52 | } |
| 53 | #else |
| 54 | typedef SkUnichar glyph_t; |
| 55 | #define TO_GLYPH(g) ((SkUnichar) g) |
Romain Guy | e3a9b24 | 2013-01-08 11:15:30 -0800 | [diff] [blame] | 56 | #define GET_METRICS(paint, glyph, matrix) paint->getUnicharMetrics(glyph, matrix) |
Romain Guy | 9f5dab3 | 2012-09-04 12:55:44 -0700 | [diff] [blame] | 57 | #define GET_GLYPH(text) SkUTF16_NextUnichar((const uint16_t**) &text) |
| 58 | #define IS_END_OF_STRING(glyph) glyph < 0 |
| 59 | #endif |
| 60 | |
| 61 | #define AUTO_KERN(prev, next) (((next) - (prev) + 32) >> 6 << 16) |
| 62 | |
| 63 | #endif // ANDROID_HWUI_FONT_UTIL_H |