blob: 12247baa876adebb27882cde438c5898fb5c8ff7 [file] [log] [blame]
Romain Guy9f5dab32012-09-04 12:55:44 -07001/*
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
29#define DEFAULT_TEXT_SMALL_CACHE_HEIGHT 256
30#define DEFAULT_TEXT_LARGE_CACHE_WIDTH 2048
31#define DEFAULT_TEXT_LARGE_CACHE_HEIGHT 512
32
33#define TEXTURE_BORDER_SIZE 1
34
35#define CACHE_BLOCK_ROUNDING_SIZE 4
36
37#if RENDER_TEXT_AS_GLYPHS
38 typedef uint16_t glyph_t;
39 #define TO_GLYPH(g) g
40 #define GET_METRICS(paint, glyph) paint->getGlyphMetrics(glyph)
41 #define GET_GLYPH(text) nextGlyph((const uint16_t**) &text)
42 #define IS_END_OF_STRING(glyph) false
43
44 static glyph_t nextGlyph(const uint16_t** srcPtr) {
45 const uint16_t* src = *srcPtr;
46 glyph_t g = *src++;
47 *srcPtr = src;
48 return g;
49 }
50#else
51 typedef SkUnichar glyph_t;
52 #define TO_GLYPH(g) ((SkUnichar) g)
53 #define GET_METRICS(paint, glyph) paint->getUnicharMetrics(glyph)
54 #define GET_GLYPH(text) SkUTF16_NextUnichar((const uint16_t**) &text)
55 #define IS_END_OF_STRING(glyph) glyph < 0
56#endif
57
58#define AUTO_KERN(prev, next) (((next) - (prev) + 32) >> 6 << 16)
59
60#endif // ANDROID_HWUI_FONT_UTIL_H