blob: 241b73eb7a3a3e624a52a385b18c557e393bf9ac [file] [log] [blame]
Romain Guy694b5192010-07-21 21:33:20 -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_FONT_RENDERER_H
18#define ANDROID_HWUI_FONT_RENDERER_H
Romain Guy694b5192010-07-21 21:33:20 -070019
20#include <utils/String8.h>
Alex Sakhartchouk65ef9092010-07-26 11:09:33 -070021#include <utils/String16.h>
Romain Guy694b5192010-07-21 21:33:20 -070022#include <utils/Vector.h>
23#include <utils/KeyedVector.h>
24
25#include <SkScalerContext.h>
26#include <SkPaint.h>
Romain Guy97771732012-02-28 18:17:02 -080027#include <SkPathMeasure.h>
28#include <SkPoint.h>
Romain Guy694b5192010-07-21 21:33:20 -070029
30#include <GLES2/gl2.h>
31
Romain Guy09147fb2010-07-22 13:08:20 -070032#include "Rect.h"
Romain Guy51769a62010-07-23 00:28:00 -070033#include "Properties.h"
Romain Guy09147fb2010-07-22 13:08:20 -070034
Romain Guy694b5192010-07-21 21:33:20 -070035namespace android {
36namespace uirenderer {
37
Romain Guy726aeba2011-06-01 14:52:00 -070038///////////////////////////////////////////////////////////////////////////////
39// Defines
40///////////////////////////////////////////////////////////////////////////////
41
42#if RENDER_TEXT_AS_GLYPHS
43 typedef uint16_t glyph_t;
Romain Guyae91c4c2012-05-14 14:00:27 -070044 #define TO_GLYPH(g) g
Romain Guy726aeba2011-06-01 14:52:00 -070045 #define GET_METRICS(paint, glyph) paint->getGlyphMetrics(glyph)
46 #define GET_GLYPH(text) nextGlyph((const uint16_t**) &text)
47 #define IS_END_OF_STRING(glyph) false
48#else
49 typedef SkUnichar glyph_t;
Romain Guyae91c4c2012-05-14 14:00:27 -070050 #define TO_GLYPH(g) ((SkUnichar) g)
Romain Guy726aeba2011-06-01 14:52:00 -070051 #define GET_METRICS(paint, glyph) paint->getUnicharMetrics(glyph)
52 #define GET_GLYPH(text) SkUTF16_NextUnichar((const uint16_t**) &text)
53 #define IS_END_OF_STRING(glyph) glyph < 0
54#endif
55
Chet Haasee816bae2012-08-09 13:39:02 -070056#define TEXTURE_BORDER_SIZE 1
57
Romain Guy726aeba2011-06-01 14:52:00 -070058///////////////////////////////////////////////////////////////////////////////
59// Declarations
60///////////////////////////////////////////////////////////////////////////////
61
Romain Guy694b5192010-07-21 21:33:20 -070062class FontRenderer;
63
Chet Haasee816bae2012-08-09 13:39:02 -070064/**
Chet Haase378e9192012-08-15 15:54:54 -070065 * CacheBlock is a node in a linked list of current free space areas in a CacheTexture.
66 * Using CacheBlocks enables us to pack the cache from top to bottom as well as left to right.
Chet Haasee816bae2012-08-09 13:39:02 -070067 * When we add a glyph to the cache, we see if it fits within one of the existing columns that
68 * have already been started (this is the case if the glyph fits vertically as well as
69 * horizontally, and if its width is sufficiently close to the column width to avoid
70 * sub-optimal packing of small glyphs into wide columns). If there is no column in which the
Chet Haase378e9192012-08-15 15:54:54 -070071 * glyph fits, we check the final node, which is the remaining space in the cache, creating
Chet Haasee816bae2012-08-09 13:39:02 -070072 * a new column as appropriate.
73 *
74 * As columns fill up, we remove their CacheBlock from the list to avoid having to check
75 * small blocks in the future.
76 */
77struct CacheBlock {
78 uint16_t mX;
79 uint16_t mY;
80 uint16_t mWidth;
81 uint16_t mHeight;
82 CacheBlock* mNext;
83 CacheBlock* mPrev;
84
85 CacheBlock(uint16_t x, uint16_t y, uint16_t width, uint16_t height, bool empty = false):
86 mX(x), mY(y), mWidth(width), mHeight(height), mNext(NULL), mPrev(NULL)
87 {
88 }
89
90 static CacheBlock* insertBlock(CacheBlock* head, CacheBlock *newBlock);
91
92 static CacheBlock* removeBlock(CacheBlock* head, CacheBlock *blockToRemove);
93
94 void output() {
95 CacheBlock *currBlock = this;
96 while (currBlock) {
97 ALOGD("Block: this, x, y, w, h = %p, %d, %d, %d, %d",
98 currBlock, currBlock->mX, currBlock->mY, currBlock->mWidth, currBlock->mHeight);
99 currBlock = currBlock->mNext;
100 }
101 }
102};
103
Chet Haase378e9192012-08-15 15:54:54 -0700104class CacheTexture {
Chet Haase7de0cb12011-12-05 16:35:38 -0800105public:
Chet Haase378e9192012-08-15 15:54:54 -0700106 CacheTexture(uint16_t width, uint16_t height) :
107 mTexture(NULL), mTextureId(0), mWidth(width), mHeight(height),
108 mLinearFiltering(false), mDirty(false), mNumGlyphs(0) {
Chet Haasee816bae2012-08-09 13:39:02 -0700109 mCacheBlocks = new CacheBlock(TEXTURE_BORDER_SIZE, TEXTURE_BORDER_SIZE,
Chet Haase378e9192012-08-15 15:54:54 -0700110 mWidth - TEXTURE_BORDER_SIZE, mHeight - TEXTURE_BORDER_SIZE, true);
Chet Haasee816bae2012-08-09 13:39:02 -0700111 }
112
Chet Haase378e9192012-08-15 15:54:54 -0700113 ~CacheTexture() {
114 if (mTexture) {
115 delete[] mTexture;
116 }
117 if (mTextureId) {
118 glDeleteTextures(1, &mTextureId);
119 }
Chet Haasee816bae2012-08-09 13:39:02 -0700120 reset();
121 }
122
123 void reset() {
124 // Delete existing cache blocks
125 while (mCacheBlocks != NULL) {
126 CacheBlock* tmpBlock = mCacheBlocks;
127 mCacheBlocks = mCacheBlocks->mNext;
128 delete tmpBlock;
129 }
130 mNumGlyphs = 0;
131 }
132
133 void init() {
134 // reset, then create a new remainder space to start again
135 reset();
136 mCacheBlocks = new CacheBlock(TEXTURE_BORDER_SIZE, TEXTURE_BORDER_SIZE,
Chet Haase378e9192012-08-15 15:54:54 -0700137 mWidth - TEXTURE_BORDER_SIZE, mHeight - TEXTURE_BORDER_SIZE, true);
Chet Haase7de0cb12011-12-05 16:35:38 -0800138 }
139
140 bool fitBitmap(const SkGlyph& glyph, uint32_t *retOriginX, uint32_t *retOriginY);
141
Chet Haase378e9192012-08-15 15:54:54 -0700142 uint8_t* mTexture;
143 GLuint mTextureId;
144 uint16_t mWidth;
145 uint16_t mHeight;
146 bool mLinearFiltering;
Chet Haase7de0cb12011-12-05 16:35:38 -0800147 bool mDirty;
Chet Haasee816bae2012-08-09 13:39:02 -0700148 uint16_t mNumGlyphs;
Chet Haasee816bae2012-08-09 13:39:02 -0700149 CacheBlock* mCacheBlocks;
Chet Haase7de0cb12011-12-05 16:35:38 -0800150};
151
152struct CachedGlyphInfo {
153 // Has the cache been invalidated?
154 bool mIsValid;
155 // Location of the cached glyph in the bitmap
156 // in case we need to resize the texture or
157 // render to bitmap
158 uint32_t mStartX;
159 uint32_t mStartY;
160 uint32_t mBitmapWidth;
161 uint32_t mBitmapHeight;
162 // Also cache texture coords for the quad
163 float mBitmapMinU;
164 float mBitmapMinV;
165 float mBitmapMaxU;
166 float mBitmapMaxV;
167 // Minimize how much we call freetype
168 uint32_t mGlyphIndex;
169 uint32_t mAdvanceX;
170 uint32_t mAdvanceY;
171 // Values below contain a glyph's origin in the bitmap
172 int32_t mBitmapLeft;
173 int32_t mBitmapTop;
174 // Auto-kerning
175 SkFixed mLsbDelta;
176 SkFixed mRsbDelta;
Chet Haase378e9192012-08-15 15:54:54 -0700177 CacheTexture* mCacheTexture;
Chet Haase7de0cb12011-12-05 16:35:38 -0800178};
179
180
Romain Guy726aeba2011-06-01 14:52:00 -0700181///////////////////////////////////////////////////////////////////////////////
182// Font
183///////////////////////////////////////////////////////////////////////////////
184
Romain Guy51769a62010-07-23 00:28:00 -0700185/**
186 * Represents a font, defined by a Skia font id and a font size. A font is used
187 * to generate glyphs and cache them in the FontState.
188 */
Romain Guy694b5192010-07-21 21:33:20 -0700189class Font {
190public:
Romain Guy325a0f92011-01-05 15:26:55 -0800191 enum Style {
Romain Guyc7b25be2011-03-23 14:59:20 -0700192 kFakeBold = 1
Romain Guy325a0f92011-01-05 15:26:55 -0800193 };
194
Romain Guy694b5192010-07-21 21:33:20 -0700195 ~Font();
196
Romain Guy51769a62010-07-23 00:28:00 -0700197 /**
198 * Renders the specified string of text.
Alex Sakhartchoukf18136c2010-08-06 14:49:04 -0700199 * If bitmap is specified, it will be used as the render target
Romain Guy51769a62010-07-23 00:28:00 -0700200 */
Romain Guy726aeba2011-06-01 14:52:00 -0700201 void render(SkPaint* paint, const char *text, uint32_t start, uint32_t len,
202 int numGlyphs, int x, int y, uint8_t *bitmap = NULL,
203 uint32_t bitmapW = 0, uint32_t bitmapH = 0);
Romain Guy671d6cf2012-01-18 12:39:17 -0800204
205 void render(SkPaint* paint, const char *text, uint32_t start, uint32_t len,
206 int numGlyphs, int x, int y, const float* positions);
207
Romain Guy97771732012-02-28 18:17:02 -0800208 void render(SkPaint* paint, const char *text, uint32_t start, uint32_t len,
209 int numGlyphs, SkPath* path, float hOffset, float vOffset);
210
Romain Guy51769a62010-07-23 00:28:00 -0700211 /**
212 * Creates a new font associated with the specified font state.
213 */
Romain Guy2577db12011-01-18 13:02:38 -0800214 static Font* create(FontRenderer* state, uint32_t fontId, float fontSize,
Romain Guybd496bc2011-08-02 17:32:41 -0700215 int flags, uint32_t italicStyle, uint32_t scaleX, SkPaint::Style style,
216 uint32_t strokeWidth);
Romain Guy694b5192010-07-21 21:33:20 -0700217
218protected:
Romain Guy694b5192010-07-21 21:33:20 -0700219 friend class FontRenderer;
Romain Guy671d6cf2012-01-18 12:39:17 -0800220 typedef void (Font::*RenderGlyph)(CachedGlyphInfo*, int, int, uint8_t*,
221 uint32_t, uint32_t, Rect*, const float*);
Romain Guy694b5192010-07-21 21:33:20 -0700222
Alex Sakhartchoukf18136c2010-08-06 14:49:04 -0700223 enum RenderMode {
224 FRAMEBUFFER,
225 BITMAP,
226 MEASURE,
227 };
228
Chet Haasee816bae2012-08-09 13:39:02 -0700229 void precache(SkPaint* paint, const char* text, int numGlyphs);
230
Romain Guy726aeba2011-06-01 14:52:00 -0700231 void render(SkPaint* paint, const char *text, uint32_t start, uint32_t len,
232 int numGlyphs, int x, int y, RenderMode mode, uint8_t *bitmap,
Romain Guy671d6cf2012-01-18 12:39:17 -0800233 uint32_t bitmapW, uint32_t bitmapH, Rect *bounds, const float* positions);
Alex Sakhartchoukf18136c2010-08-06 14:49:04 -0700234
Romain Guy726aeba2011-06-01 14:52:00 -0700235 void measure(SkPaint* paint, const char* text, uint32_t start, uint32_t len,
Raph Levien416a8472012-07-19 22:48:17 -0700236 int numGlyphs, Rect *bounds, const float* positions);
Alex Sakhartchoukf18136c2010-08-06 14:49:04 -0700237
Chet Haase8668f8a2011-03-02 13:51:36 -0800238 Font(FontRenderer* state, uint32_t fontId, float fontSize, int flags, uint32_t italicStyle,
Romain Guybd496bc2011-08-02 17:32:41 -0700239 uint32_t scaleX, SkPaint::Style style, uint32_t strokeWidth);
Romain Guy694b5192010-07-21 21:33:20 -0700240
Romain Guy726aeba2011-06-01 14:52:00 -0700241 // Cache of glyphs
242 DefaultKeyedVector<glyph_t, CachedGlyphInfo*> mCachedGlyphs;
Romain Guy694b5192010-07-21 21:33:20 -0700243
Chet Haase378e9192012-08-15 15:54:54 -0700244 void invalidateTextureCache(CacheTexture *cacheTexture = NULL);
Romain Guybd0e6aa2010-07-22 18:50:12 -0700245
Chet Haasef942cf12012-08-30 09:06:46 -0700246 CachedGlyphInfo* cacheGlyph(SkPaint* paint, glyph_t glyph, bool precaching);
247 void updateGlyphCache(SkPaint* paint, const SkGlyph& skiaGlyph, CachedGlyphInfo* glyph,
248 bool precaching);
Romain Guy671d6cf2012-01-18 12:39:17 -0800249
250 void measureCachedGlyph(CachedGlyphInfo* glyph, int x, int y,
251 uint8_t *bitmap, uint32_t bitmapW, uint32_t bitmapH,
252 Rect* bounds, const float* pos);
253 void drawCachedGlyph(CachedGlyphInfo* glyph, int x, int y,
254 uint8_t *bitmap, uint32_t bitmapW, uint32_t bitmapH,
255 Rect* bounds, const float* pos);
256 void drawCachedGlyphBitmap(CachedGlyphInfo* glyph, int x, int y,
257 uint8_t *bitmap, uint32_t bitmapW, uint32_t bitmapH,
258 Rect* bounds, const float* pos);
Romain Guy97771732012-02-28 18:17:02 -0800259 void drawCachedGlyph(CachedGlyphInfo* glyph, float x, float hOffset, float vOffset,
260 SkPathMeasure& measure, SkPoint* position, SkVector* tangent);
Romain Guybd0e6aa2010-07-22 18:50:12 -0700261
Chet Haasef942cf12012-08-30 09:06:46 -0700262 CachedGlyphInfo* getCachedGlyph(SkPaint* paint, glyph_t textUnit, bool precaching = false);
Romain Guy726aeba2011-06-01 14:52:00 -0700263
264 static glyph_t nextGlyph(const uint16_t** srcPtr) {
265 const uint16_t* src = *srcPtr;
266 glyph_t g = *src++;
267 *srcPtr = src;
268 return g;
269 }
Alex Sakhartchouk65ef9092010-07-26 11:09:33 -0700270
Romain Guybd0e6aa2010-07-22 18:50:12 -0700271 FontRenderer* mState;
272 uint32_t mFontId;
273 float mFontSize;
Romain Guy325a0f92011-01-05 15:26:55 -0800274 int mFlags;
Romain Guy2577db12011-01-18 13:02:38 -0800275 uint32_t mItalicStyle;
Chet Haase8668f8a2011-03-02 13:51:36 -0800276 uint32_t mScaleX;
Romain Guybd496bc2011-08-02 17:32:41 -0700277 SkPaint::Style mStyle;
278 uint32_t mStrokeWidth;
Romain Guy694b5192010-07-21 21:33:20 -0700279};
280
Romain Guy726aeba2011-06-01 14:52:00 -0700281///////////////////////////////////////////////////////////////////////////////
282// Renderer
283///////////////////////////////////////////////////////////////////////////////
284
Romain Guy694b5192010-07-21 21:33:20 -0700285class FontRenderer {
286public:
287 FontRenderer();
288 ~FontRenderer();
289
Chet Haase9a824562011-12-16 15:44:59 -0800290 void flushLargeCaches();
Romain Guy694b5192010-07-21 21:33:20 -0700291
Romain Guyb45c0c92010-08-26 20:35:23 -0700292 void setGammaTable(const uint8_t* gammaTable) {
293 mGammaTable = gammaTable;
294 }
295
Alex Sakhartchouk65ef9092010-07-26 11:09:33 -0700296 void setFont(SkPaint* paint, uint32_t fontId, float fontSize);
Chet Haasee816bae2012-08-09 13:39:02 -0700297
298 void precache(SkPaint* paint, const char* text, int numGlyphs);
299
Romain Guy671d6cf2012-01-18 12:39:17 -0800300 // bounds is an out parameter
Romain Guy5b3b3522010-10-27 18:57:51 -0700301 bool renderText(SkPaint* paint, const Rect* clip, const char *text, uint32_t startIndex,
302 uint32_t len, int numGlyphs, int x, int y, Rect* bounds);
Romain Guy671d6cf2012-01-18 12:39:17 -0800303 // bounds is an out parameter
304 bool renderPosText(SkPaint* paint, const Rect* clip, const char *text, uint32_t startIndex,
305 uint32_t len, int numGlyphs, int x, int y, const float* positions, Rect* bounds);
Romain Guy97771732012-02-28 18:17:02 -0800306 // bounds is an out parameter
307 bool renderTextOnPath(SkPaint* paint, const Rect* clip, const char *text, uint32_t startIndex,
308 uint32_t len, int numGlyphs, SkPath* path, float hOffset, float vOffset, Rect* bounds);
Romain Guy694b5192010-07-21 21:33:20 -0700309
Alex Sakhartchoukf18136c2010-08-06 14:49:04 -0700310 struct DropShadow {
Romain Guy1e45aae2010-08-13 19:39:53 -0700311 DropShadow() { };
312
313 DropShadow(const DropShadow& dropShadow):
314 width(dropShadow.width), height(dropShadow.height),
315 image(dropShadow.image), penX(dropShadow.penX),
316 penY(dropShadow.penY) {
317 }
318
Alex Sakhartchoukf18136c2010-08-06 14:49:04 -0700319 uint32_t width;
320 uint32_t height;
321 uint8_t* image;
322 int32_t penX;
323 int32_t penY;
324 };
325
326 // After renderDropShadow returns, the called owns the memory in DropShadow.image
327 // and is responsible for releasing it when it's done with it
328 DropShadow renderDropShadow(SkPaint* paint, const char *text, uint32_t startIndex,
Raph Levien416a8472012-07-19 22:48:17 -0700329 uint32_t len, int numGlyphs, uint32_t radius, const float* positions);
Alex Sakhartchoukf18136c2010-08-06 14:49:04 -0700330
Romain Guye8cb9c142010-10-04 14:14:11 -0700331 GLuint getTexture(bool linearFiltering = false) {
Romain Guy694b5192010-07-21 21:33:20 -0700332 checkInit();
Romain Guyae91c4c2012-05-14 14:00:27 -0700333
Chet Haase2a47c142011-12-14 15:22:56 -0800334 if (linearFiltering != mCurrentCacheTexture->mLinearFiltering) {
335 mCurrentCacheTexture->mLinearFiltering = linearFiltering;
Romain Guye8cb9c142010-10-04 14:14:11 -0700336 mLinearFiltering = linearFiltering;
337 const GLenum filtering = linearFiltering ? GL_LINEAR : GL_NEAREST;
338
Chet Haase7de0cb12011-12-05 16:35:38 -0800339 glBindTexture(GL_TEXTURE_2D, mCurrentCacheTexture->mTextureId);
Romain Guye8cb9c142010-10-04 14:14:11 -0700340 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, filtering);
341 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, filtering);
342 }
Romain Guyae91c4c2012-05-14 14:00:27 -0700343
Chet Haase7de0cb12011-12-05 16:35:38 -0800344 return mCurrentCacheTexture->mTextureId;
Romain Guy694b5192010-07-21 21:33:20 -0700345 }
346
Chet Haase7de0cb12011-12-05 16:35:38 -0800347 uint32_t getCacheSize() const {
348 uint32_t size = 0;
Chet Haase378e9192012-08-15 15:54:54 -0700349 for (uint32_t i = 0; i < mCacheTextures.size(); i++) {
350 CacheTexture* cacheTexture = mCacheTextures[i];
351 if (cacheTexture != NULL && cacheTexture->mTexture != NULL) {
352 size += cacheTexture->mWidth * cacheTexture->mHeight;
353 }
Chet Haase7de0cb12011-12-05 16:35:38 -0800354 }
355 return size;
Romain Guyc15008e2010-11-10 11:59:15 -0800356 }
357
Romain Guy694b5192010-07-21 21:33:20 -0700358protected:
359 friend class Font;
360
Romain Guyb45c0c92010-08-26 20:35:23 -0700361 const uint8_t* mGammaTable;
362
Chet Haase2a47c142011-12-14 15:22:56 -0800363 void allocateTextureMemory(CacheTexture* cacheTexture);
Chet Haase9a824562011-12-16 15:44:59 -0800364 void deallocateTextureMemory(CacheTexture* cacheTexture);
Chet Haase7de0cb12011-12-05 16:35:38 -0800365 void initTextTexture();
Romain Guy97771732012-02-28 18:17:02 -0800366 CacheTexture* createCacheTexture(int width, int height, bool allocate);
Chet Haase7de0cb12011-12-05 16:35:38 -0800367 void cacheBitmap(const SkGlyph& glyph, CachedGlyphInfo* cachedGlyph,
Chet Haasef942cf12012-08-30 09:06:46 -0700368 uint32_t *retOriginX, uint32_t *retOriginY, bool precaching);
Chet Haase378e9192012-08-15 15:54:54 -0700369 CacheTexture* cacheBitmapInTexture(const SkGlyph& glyph, uint32_t* startX, uint32_t* startY);
Romain Guy694b5192010-07-21 21:33:20 -0700370
371 void flushAllAndInvalidate();
372 void initVertexArrayBuffers();
373
374 void checkInit();
Romain Guy671d6cf2012-01-18 12:39:17 -0800375 void initRender(const Rect* clip, Rect* bounds);
376 void finishRender();
Romain Guy694b5192010-07-21 21:33:20 -0700377
378 void issueDrawCommand();
Romain Guy97771732012-02-28 18:17:02 -0800379 void appendMeshQuadNoClip(float x1, float y1, float u1, float v1,
380 float x2, float y2, float u2, float v2,
381 float x3, float y3, float u3, float v3,
382 float x4, float y4, float u4, float v4, CacheTexture* texture);
Romain Guyd71dd362011-12-12 19:03:35 -0800383 void appendMeshQuad(float x1, float y1, float u1, float v1,
384 float x2, float y2, float u2, float v2,
385 float x3, float y3, float u3, float v3,
Chet Haase7de0cb12011-12-05 16:35:38 -0800386 float x4, float y4, float u4, float v4, CacheTexture* texture);
Romain Guy97771732012-02-28 18:17:02 -0800387 void appendRotatedMeshQuad(float x1, float y1, float u1, float v1,
388 float x2, float y2, float u2, float v2,
389 float x3, float y3, float u3, float v3,
390 float x4, float y4, float u4, float v4, CacheTexture* texture);
Romain Guy694b5192010-07-21 21:33:20 -0700391
Chet Haase7de0cb12011-12-05 16:35:38 -0800392 uint32_t mSmallCacheWidth;
393 uint32_t mSmallCacheHeight;
Chet Haaseeb32a492012-08-31 13:54:03 -0700394 uint32_t mLargeCacheWidth;
395 uint32_t mLargeCacheHeight;
Romain Guy694b5192010-07-21 21:33:20 -0700396
Chet Haase378e9192012-08-15 15:54:54 -0700397 Vector<CacheTexture*> mCacheTextures;
Romain Guy694b5192010-07-21 21:33:20 -0700398
Romain Guy09147fb2010-07-22 13:08:20 -0700399 Font* mCurrentFont;
Romain Guy694b5192010-07-21 21:33:20 -0700400 Vector<Font*> mActiveFonts;
401
Chet Haase7de0cb12011-12-05 16:35:38 -0800402 CacheTexture* mCurrentCacheTexture;
403 CacheTexture* mLastCacheTexture;
Chet Haase7de0cb12011-12-05 16:35:38 -0800404
Alex Sakhartchouk9b9902d2010-07-23 14:45:49 -0700405 void checkTextureUpdate();
Romain Guy694b5192010-07-21 21:33:20 -0700406 bool mUploadTexture;
407
408 // Pointer to vertex data to speed up frame to frame work
409 float *mTextMeshPtr;
410 uint32_t mCurrentQuadIndex;
411 uint32_t mMaxNumberOfQuads;
412
413 uint32_t mIndexBufferID;
414
Romain Guy09147fb2010-07-22 13:08:20 -0700415 const Rect* mClip;
Romain Guy5b3b3522010-10-27 18:57:51 -0700416 Rect* mBounds;
417 bool mDrawn;
Romain Guy09147fb2010-07-22 13:08:20 -0700418
Romain Guy694b5192010-07-21 21:33:20 -0700419 bool mInitialized;
Alex Sakhartchouk89a524a2010-08-02 17:52:30 -0700420
Romain Guye8cb9c142010-10-04 14:14:11 -0700421 bool mLinearFiltering;
422
Alex Sakhartchouk89a524a2010-08-02 17:52:30 -0700423 void computeGaussianWeights(float* weights, int32_t radius);
424 void horizontalBlur(float* weights, int32_t radius, const uint8_t *source, uint8_t *dest,
Romain Guy1e45aae2010-08-13 19:39:53 -0700425 int32_t width, int32_t height);
Alex Sakhartchouk89a524a2010-08-02 17:52:30 -0700426 void verticalBlur(float* weights, int32_t radius, const uint8_t *source, uint8_t *dest,
Romain Guy1e45aae2010-08-13 19:39:53 -0700427 int32_t width, int32_t height);
Alex Sakhartchouk89a524a2010-08-02 17:52:30 -0700428 void blurImage(uint8_t* image, int32_t width, int32_t height, int32_t radius);
Romain Guy694b5192010-07-21 21:33:20 -0700429};
430
431}; // namespace uirenderer
432}; // namespace android
433
Romain Guy5b3b3522010-10-27 18:57:51 -0700434#endif // ANDROID_HWUI_FONT_RENDERER_H