Romain Guy | 694b519 | 2010-07-21 21:33:20 -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_FONT_RENDERER_H |
| 18 | #define ANDROID_HWUI_FONT_RENDERER_H |
Romain Guy | 694b519 | 2010-07-21 21:33:20 -0700 | [diff] [blame] | 19 | |
| 20 | #include <utils/String8.h> |
Alex Sakhartchouk | 65ef909 | 2010-07-26 11:09:33 -0700 | [diff] [blame] | 21 | #include <utils/String16.h> |
Romain Guy | 694b519 | 2010-07-21 21:33:20 -0700 | [diff] [blame] | 22 | #include <utils/Vector.h> |
| 23 | #include <utils/KeyedVector.h> |
| 24 | |
| 25 | #include <SkScalerContext.h> |
| 26 | #include <SkPaint.h> |
| 27 | |
| 28 | #include <GLES2/gl2.h> |
| 29 | |
Romain Guy | 09147fb | 2010-07-22 13:08:20 -0700 | [diff] [blame] | 30 | #include "Rect.h" |
Romain Guy | 51769a6 | 2010-07-23 00:28:00 -0700 | [diff] [blame] | 31 | #include "Properties.h" |
Romain Guy | 09147fb | 2010-07-22 13:08:20 -0700 | [diff] [blame] | 32 | |
Romain Guy | 694b519 | 2010-07-21 21:33:20 -0700 | [diff] [blame] | 33 | namespace android { |
| 34 | namespace uirenderer { |
| 35 | |
Romain Guy | 726aeba | 2011-06-01 14:52:00 -0700 | [diff] [blame] | 36 | /////////////////////////////////////////////////////////////////////////////// |
| 37 | // Defines |
| 38 | /////////////////////////////////////////////////////////////////////////////// |
| 39 | |
| 40 | #if RENDER_TEXT_AS_GLYPHS |
| 41 | typedef uint16_t glyph_t; |
| 42 | #define GET_METRICS(paint, glyph) paint->getGlyphMetrics(glyph) |
| 43 | #define GET_GLYPH(text) nextGlyph((const uint16_t**) &text) |
| 44 | #define IS_END_OF_STRING(glyph) false |
| 45 | #else |
| 46 | typedef SkUnichar glyph_t; |
| 47 | #define GET_METRICS(paint, glyph) paint->getUnicharMetrics(glyph) |
| 48 | #define GET_GLYPH(text) SkUTF16_NextUnichar((const uint16_t**) &text) |
| 49 | #define IS_END_OF_STRING(glyph) glyph < 0 |
| 50 | #endif |
| 51 | |
| 52 | /////////////////////////////////////////////////////////////////////////////// |
| 53 | // Declarations |
| 54 | /////////////////////////////////////////////////////////////////////////////// |
| 55 | |
Romain Guy | 694b519 | 2010-07-21 21:33:20 -0700 | [diff] [blame] | 56 | class FontRenderer; |
| 57 | |
Chet Haase | 7de0cb1 | 2011-12-05 16:35:38 -0800 | [diff] [blame] | 58 | class CacheTexture { |
| 59 | public: |
| 60 | CacheTexture(){} |
| 61 | CacheTexture(uint8_t* texture, GLuint textureId, uint16_t width, uint16_t height) : |
Chet Haase | 2a47c14 | 2011-12-14 15:22:56 -0800 | [diff] [blame] | 62 | mTexture(texture), mTextureId(textureId), mWidth(width), mHeight(height), |
| 63 | mLinearFiltering(false) {} |
Chet Haase | 7de0cb1 | 2011-12-05 16:35:38 -0800 | [diff] [blame] | 64 | ~CacheTexture() { |
| 65 | if (mTexture != NULL) { |
| 66 | delete[] mTexture; |
| 67 | } |
| 68 | if (mTextureId != 0) { |
| 69 | glDeleteTextures(1, &mTextureId); |
| 70 | } |
| 71 | } |
| 72 | |
| 73 | uint8_t* mTexture; |
| 74 | GLuint mTextureId; |
| 75 | uint16_t mWidth; |
| 76 | uint16_t mHeight; |
Chet Haase | 2a47c14 | 2011-12-14 15:22:56 -0800 | [diff] [blame] | 77 | bool mLinearFiltering; |
Chet Haase | 7de0cb1 | 2011-12-05 16:35:38 -0800 | [diff] [blame] | 78 | }; |
| 79 | |
| 80 | class CacheTextureLine { |
| 81 | public: |
| 82 | CacheTextureLine(uint16_t maxWidth, uint16_t maxHeight, uint32_t currentRow, |
| 83 | uint32_t currentCol, CacheTexture* cacheTexture): |
| 84 | mMaxHeight(maxHeight), |
| 85 | mMaxWidth(maxWidth), |
| 86 | mCurrentRow(currentRow), |
| 87 | mCurrentCol(currentCol), |
| 88 | mDirty(false), |
| 89 | mCacheTexture(cacheTexture){ |
| 90 | } |
| 91 | |
| 92 | bool fitBitmap(const SkGlyph& glyph, uint32_t *retOriginX, uint32_t *retOriginY); |
| 93 | |
| 94 | uint16_t mMaxHeight; |
| 95 | uint16_t mMaxWidth; |
| 96 | uint32_t mCurrentRow; |
| 97 | uint32_t mCurrentCol; |
| 98 | bool mDirty; |
| 99 | CacheTexture *mCacheTexture; |
| 100 | }; |
| 101 | |
| 102 | struct CachedGlyphInfo { |
| 103 | // Has the cache been invalidated? |
| 104 | bool mIsValid; |
| 105 | // Location of the cached glyph in the bitmap |
| 106 | // in case we need to resize the texture or |
| 107 | // render to bitmap |
| 108 | uint32_t mStartX; |
| 109 | uint32_t mStartY; |
| 110 | uint32_t mBitmapWidth; |
| 111 | uint32_t mBitmapHeight; |
| 112 | // Also cache texture coords for the quad |
| 113 | float mBitmapMinU; |
| 114 | float mBitmapMinV; |
| 115 | float mBitmapMaxU; |
| 116 | float mBitmapMaxV; |
| 117 | // Minimize how much we call freetype |
| 118 | uint32_t mGlyphIndex; |
| 119 | uint32_t mAdvanceX; |
| 120 | uint32_t mAdvanceY; |
| 121 | // Values below contain a glyph's origin in the bitmap |
| 122 | int32_t mBitmapLeft; |
| 123 | int32_t mBitmapTop; |
| 124 | // Auto-kerning |
| 125 | SkFixed mLsbDelta; |
| 126 | SkFixed mRsbDelta; |
| 127 | CacheTextureLine* mCachedTextureLine; |
| 128 | }; |
| 129 | |
| 130 | |
Romain Guy | 726aeba | 2011-06-01 14:52:00 -0700 | [diff] [blame] | 131 | /////////////////////////////////////////////////////////////////////////////// |
| 132 | // Font |
| 133 | /////////////////////////////////////////////////////////////////////////////// |
| 134 | |
Romain Guy | 51769a6 | 2010-07-23 00:28:00 -0700 | [diff] [blame] | 135 | /** |
| 136 | * Represents a font, defined by a Skia font id and a font size. A font is used |
| 137 | * to generate glyphs and cache them in the FontState. |
| 138 | */ |
Romain Guy | 694b519 | 2010-07-21 21:33:20 -0700 | [diff] [blame] | 139 | class Font { |
| 140 | public: |
Romain Guy | 325a0f9 | 2011-01-05 15:26:55 -0800 | [diff] [blame] | 141 | enum Style { |
Romain Guy | c7b25be | 2011-03-23 14:59:20 -0700 | [diff] [blame] | 142 | kFakeBold = 1 |
Romain Guy | 325a0f9 | 2011-01-05 15:26:55 -0800 | [diff] [blame] | 143 | }; |
| 144 | |
Romain Guy | 694b519 | 2010-07-21 21:33:20 -0700 | [diff] [blame] | 145 | ~Font(); |
| 146 | |
Romain Guy | 51769a6 | 2010-07-23 00:28:00 -0700 | [diff] [blame] | 147 | /** |
| 148 | * Renders the specified string of text. |
Alex Sakhartchouk | f18136c | 2010-08-06 14:49:04 -0700 | [diff] [blame] | 149 | * If bitmap is specified, it will be used as the render target |
Romain Guy | 51769a6 | 2010-07-23 00:28:00 -0700 | [diff] [blame] | 150 | */ |
Romain Guy | 726aeba | 2011-06-01 14:52:00 -0700 | [diff] [blame] | 151 | void render(SkPaint* paint, const char *text, uint32_t start, uint32_t len, |
| 152 | int numGlyphs, int x, int y, uint8_t *bitmap = NULL, |
| 153 | uint32_t bitmapW = 0, uint32_t bitmapH = 0); |
Romain Guy | 51769a6 | 2010-07-23 00:28:00 -0700 | [diff] [blame] | 154 | /** |
| 155 | * Creates a new font associated with the specified font state. |
| 156 | */ |
Romain Guy | 2577db1 | 2011-01-18 13:02:38 -0800 | [diff] [blame] | 157 | static Font* create(FontRenderer* state, uint32_t fontId, float fontSize, |
Romain Guy | bd496bc | 2011-08-02 17:32:41 -0700 | [diff] [blame] | 158 | int flags, uint32_t italicStyle, uint32_t scaleX, SkPaint::Style style, |
| 159 | uint32_t strokeWidth); |
Romain Guy | 694b519 | 2010-07-21 21:33:20 -0700 | [diff] [blame] | 160 | |
| 161 | protected: |
Romain Guy | 694b519 | 2010-07-21 21:33:20 -0700 | [diff] [blame] | 162 | friend class FontRenderer; |
| 163 | |
Alex Sakhartchouk | f18136c | 2010-08-06 14:49:04 -0700 | [diff] [blame] | 164 | enum RenderMode { |
| 165 | FRAMEBUFFER, |
| 166 | BITMAP, |
| 167 | MEASURE, |
| 168 | }; |
| 169 | |
Romain Guy | 726aeba | 2011-06-01 14:52:00 -0700 | [diff] [blame] | 170 | void render(SkPaint* paint, const char *text, uint32_t start, uint32_t len, |
| 171 | int numGlyphs, int x, int y, RenderMode mode, uint8_t *bitmap, |
| 172 | uint32_t bitmapW, uint32_t bitmapH, Rect *bounds); |
Alex Sakhartchouk | f18136c | 2010-08-06 14:49:04 -0700 | [diff] [blame] | 173 | |
Romain Guy | 726aeba | 2011-06-01 14:52:00 -0700 | [diff] [blame] | 174 | void measure(SkPaint* paint, const char* text, uint32_t start, uint32_t len, |
| 175 | int numGlyphs, Rect *bounds); |
Alex Sakhartchouk | f18136c | 2010-08-06 14:49:04 -0700 | [diff] [blame] | 176 | |
Chet Haase | 8668f8a | 2011-03-02 13:51:36 -0800 | [diff] [blame] | 177 | Font(FontRenderer* state, uint32_t fontId, float fontSize, int flags, uint32_t italicStyle, |
Romain Guy | bd496bc | 2011-08-02 17:32:41 -0700 | [diff] [blame] | 178 | uint32_t scaleX, SkPaint::Style style, uint32_t strokeWidth); |
Romain Guy | 694b519 | 2010-07-21 21:33:20 -0700 | [diff] [blame] | 179 | |
Romain Guy | 726aeba | 2011-06-01 14:52:00 -0700 | [diff] [blame] | 180 | // Cache of glyphs |
| 181 | DefaultKeyedVector<glyph_t, CachedGlyphInfo*> mCachedGlyphs; |
Romain Guy | 694b519 | 2010-07-21 21:33:20 -0700 | [diff] [blame] | 182 | |
Chet Haase | 9a82456 | 2011-12-16 15:44:59 -0800 | [diff] [blame^] | 183 | void invalidateTextureCache(CacheTextureLine *cacheLine = NULL); |
Romain Guy | bd0e6aa | 2010-07-22 18:50:12 -0700 | [diff] [blame] | 184 | |
Romain Guy | 726aeba | 2011-06-01 14:52:00 -0700 | [diff] [blame] | 185 | CachedGlyphInfo* cacheGlyph(SkPaint* paint, glyph_t glyph); |
Romain Guy | 694b519 | 2010-07-21 21:33:20 -0700 | [diff] [blame] | 186 | void updateGlyphCache(SkPaint* paint, const SkGlyph& skiaGlyph, CachedGlyphInfo *glyph); |
Alex Sakhartchouk | f18136c | 2010-08-06 14:49:04 -0700 | [diff] [blame] | 187 | void measureCachedGlyph(CachedGlyphInfo *glyph, int x, int y, Rect *bounds); |
Romain Guy | 694b519 | 2010-07-21 21:33:20 -0700 | [diff] [blame] | 188 | void drawCachedGlyph(CachedGlyphInfo *glyph, int x, int y); |
Alex Sakhartchouk | 89a524a | 2010-08-02 17:52:30 -0700 | [diff] [blame] | 189 | void drawCachedGlyph(CachedGlyphInfo *glyph, int x, int y, |
Romain Guy | 726aeba | 2011-06-01 14:52:00 -0700 | [diff] [blame] | 190 | uint8_t *bitmap, uint32_t bitmapW, uint32_t bitmapH); |
Romain Guy | bd0e6aa | 2010-07-22 18:50:12 -0700 | [diff] [blame] | 191 | |
Romain Guy | 726aeba | 2011-06-01 14:52:00 -0700 | [diff] [blame] | 192 | CachedGlyphInfo* getCachedGlyph(SkPaint* paint, glyph_t textUnit); |
| 193 | |
| 194 | static glyph_t nextGlyph(const uint16_t** srcPtr) { |
| 195 | const uint16_t* src = *srcPtr; |
| 196 | glyph_t g = *src++; |
| 197 | *srcPtr = src; |
| 198 | return g; |
| 199 | } |
Alex Sakhartchouk | 65ef909 | 2010-07-26 11:09:33 -0700 | [diff] [blame] | 200 | |
Romain Guy | bd0e6aa | 2010-07-22 18:50:12 -0700 | [diff] [blame] | 201 | FontRenderer* mState; |
| 202 | uint32_t mFontId; |
| 203 | float mFontSize; |
Romain Guy | 325a0f9 | 2011-01-05 15:26:55 -0800 | [diff] [blame] | 204 | int mFlags; |
Romain Guy | 2577db1 | 2011-01-18 13:02:38 -0800 | [diff] [blame] | 205 | uint32_t mItalicStyle; |
Chet Haase | 8668f8a | 2011-03-02 13:51:36 -0800 | [diff] [blame] | 206 | uint32_t mScaleX; |
Romain Guy | bd496bc | 2011-08-02 17:32:41 -0700 | [diff] [blame] | 207 | SkPaint::Style mStyle; |
| 208 | uint32_t mStrokeWidth; |
Romain Guy | 694b519 | 2010-07-21 21:33:20 -0700 | [diff] [blame] | 209 | }; |
| 210 | |
Romain Guy | 726aeba | 2011-06-01 14:52:00 -0700 | [diff] [blame] | 211 | /////////////////////////////////////////////////////////////////////////////// |
| 212 | // Renderer |
| 213 | /////////////////////////////////////////////////////////////////////////////// |
| 214 | |
Romain Guy | 694b519 | 2010-07-21 21:33:20 -0700 | [diff] [blame] | 215 | class FontRenderer { |
| 216 | public: |
| 217 | FontRenderer(); |
| 218 | ~FontRenderer(); |
| 219 | |
| 220 | void init(); |
| 221 | void deinit(); |
Chet Haase | 9a82456 | 2011-12-16 15:44:59 -0800 | [diff] [blame^] | 222 | void flushLargeCaches(); |
Romain Guy | 694b519 | 2010-07-21 21:33:20 -0700 | [diff] [blame] | 223 | |
Romain Guy | b45c0c9 | 2010-08-26 20:35:23 -0700 | [diff] [blame] | 224 | void setGammaTable(const uint8_t* gammaTable) { |
| 225 | mGammaTable = gammaTable; |
| 226 | } |
| 227 | |
Alex Sakhartchouk | 65ef909 | 2010-07-26 11:09:33 -0700 | [diff] [blame] | 228 | void setFont(SkPaint* paint, uint32_t fontId, float fontSize); |
Romain Guy | 5b3b352 | 2010-10-27 18:57:51 -0700 | [diff] [blame] | 229 | bool renderText(SkPaint* paint, const Rect* clip, const char *text, uint32_t startIndex, |
| 230 | uint32_t len, int numGlyphs, int x, int y, Rect* bounds); |
Romain Guy | 694b519 | 2010-07-21 21:33:20 -0700 | [diff] [blame] | 231 | |
Alex Sakhartchouk | f18136c | 2010-08-06 14:49:04 -0700 | [diff] [blame] | 232 | struct DropShadow { |
Romain Guy | 1e45aae | 2010-08-13 19:39:53 -0700 | [diff] [blame] | 233 | DropShadow() { }; |
| 234 | |
| 235 | DropShadow(const DropShadow& dropShadow): |
| 236 | width(dropShadow.width), height(dropShadow.height), |
| 237 | image(dropShadow.image), penX(dropShadow.penX), |
| 238 | penY(dropShadow.penY) { |
| 239 | } |
| 240 | |
Alex Sakhartchouk | f18136c | 2010-08-06 14:49:04 -0700 | [diff] [blame] | 241 | uint32_t width; |
| 242 | uint32_t height; |
| 243 | uint8_t* image; |
| 244 | int32_t penX; |
| 245 | int32_t penY; |
| 246 | }; |
| 247 | |
| 248 | // After renderDropShadow returns, the called owns the memory in DropShadow.image |
| 249 | // and is responsible for releasing it when it's done with it |
| 250 | DropShadow renderDropShadow(SkPaint* paint, const char *text, uint32_t startIndex, |
Romain Guy | 1e45aae | 2010-08-13 19:39:53 -0700 | [diff] [blame] | 251 | uint32_t len, int numGlyphs, uint32_t radius); |
Alex Sakhartchouk | f18136c | 2010-08-06 14:49:04 -0700 | [diff] [blame] | 252 | |
Romain Guy | e8cb9c14 | 2010-10-04 14:14:11 -0700 | [diff] [blame] | 253 | GLuint getTexture(bool linearFiltering = false) { |
Romain Guy | 694b519 | 2010-07-21 21:33:20 -0700 | [diff] [blame] | 254 | checkInit(); |
Chet Haase | 2a47c14 | 2011-12-14 15:22:56 -0800 | [diff] [blame] | 255 | if (linearFiltering != mCurrentCacheTexture->mLinearFiltering) { |
| 256 | mCurrentCacheTexture->mLinearFiltering = linearFiltering; |
Romain Guy | e8cb9c14 | 2010-10-04 14:14:11 -0700 | [diff] [blame] | 257 | mLinearFiltering = linearFiltering; |
| 258 | const GLenum filtering = linearFiltering ? GL_LINEAR : GL_NEAREST; |
| 259 | |
Chet Haase | 7de0cb1 | 2011-12-05 16:35:38 -0800 | [diff] [blame] | 260 | glBindTexture(GL_TEXTURE_2D, mCurrentCacheTexture->mTextureId); |
Romain Guy | e8cb9c14 | 2010-10-04 14:14:11 -0700 | [diff] [blame] | 261 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, filtering); |
| 262 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, filtering); |
| 263 | } |
Chet Haase | 7de0cb1 | 2011-12-05 16:35:38 -0800 | [diff] [blame] | 264 | return mCurrentCacheTexture->mTextureId; |
Romain Guy | 694b519 | 2010-07-21 21:33:20 -0700 | [diff] [blame] | 265 | } |
| 266 | |
Chet Haase | 7de0cb1 | 2011-12-05 16:35:38 -0800 | [diff] [blame] | 267 | uint32_t getCacheSize() const { |
| 268 | uint32_t size = 0; |
| 269 | if (mCacheTextureSmall != NULL && mCacheTextureSmall->mTexture != NULL) { |
| 270 | size += mCacheTextureSmall->mWidth * mCacheTextureSmall->mHeight; |
| 271 | } |
| 272 | if (mCacheTexture128 != NULL && mCacheTexture128->mTexture != NULL) { |
| 273 | size += mCacheTexture128->mWidth * mCacheTexture128->mHeight; |
| 274 | } |
| 275 | if (mCacheTexture256 != NULL && mCacheTexture256->mTexture != NULL) { |
| 276 | size += mCacheTexture256->mWidth * mCacheTexture256->mHeight; |
| 277 | } |
| 278 | if (mCacheTexture512 != NULL && mCacheTexture512->mTexture != NULL) { |
| 279 | size += mCacheTexture512->mWidth * mCacheTexture512->mHeight; |
| 280 | } |
| 281 | return size; |
Romain Guy | c15008e | 2010-11-10 11:59:15 -0800 | [diff] [blame] | 282 | } |
| 283 | |
Romain Guy | 694b519 | 2010-07-21 21:33:20 -0700 | [diff] [blame] | 284 | protected: |
| 285 | friend class Font; |
| 286 | |
Romain Guy | b45c0c9 | 2010-08-26 20:35:23 -0700 | [diff] [blame] | 287 | const uint8_t* mGammaTable; |
| 288 | |
Chet Haase | 2a47c14 | 2011-12-14 15:22:56 -0800 | [diff] [blame] | 289 | void allocateTextureMemory(CacheTexture* cacheTexture); |
Chet Haase | 9a82456 | 2011-12-16 15:44:59 -0800 | [diff] [blame^] | 290 | void deallocateTextureMemory(CacheTexture* cacheTexture); |
Chet Haase | 7de0cb1 | 2011-12-05 16:35:38 -0800 | [diff] [blame] | 291 | void initTextTexture(); |
| 292 | CacheTexture *createCacheTexture(int width, int height, bool allocate); |
| 293 | void cacheBitmap(const SkGlyph& glyph, CachedGlyphInfo* cachedGlyph, |
| 294 | uint32_t *retOriginX, uint32_t *retOriginY); |
Romain Guy | 694b519 | 2010-07-21 21:33:20 -0700 | [diff] [blame] | 295 | |
| 296 | void flushAllAndInvalidate(); |
| 297 | void initVertexArrayBuffers(); |
| 298 | |
| 299 | void checkInit(); |
| 300 | |
Alex Sakhartchouk | 65ef909 | 2010-07-26 11:09:33 -0700 | [diff] [blame] | 301 | String16 mLatinPrecache; |
| 302 | void precacheLatin(SkPaint* paint); |
| 303 | |
Romain Guy | 694b519 | 2010-07-21 21:33:20 -0700 | [diff] [blame] | 304 | void issueDrawCommand(); |
Romain Guy | d71dd36 | 2011-12-12 19:03:35 -0800 | [diff] [blame] | 305 | void appendMeshQuad(float x1, float y1, float u1, float v1, |
| 306 | float x2, float y2, float u2, float v2, |
| 307 | float x3, float y3, float u3, float v3, |
Chet Haase | 7de0cb1 | 2011-12-05 16:35:38 -0800 | [diff] [blame] | 308 | float x4, float y4, float u4, float v4, CacheTexture* texture); |
Romain Guy | 694b519 | 2010-07-21 21:33:20 -0700 | [diff] [blame] | 309 | |
Chet Haase | 7de0cb1 | 2011-12-05 16:35:38 -0800 | [diff] [blame] | 310 | uint32_t mSmallCacheWidth; |
| 311 | uint32_t mSmallCacheHeight; |
Romain Guy | 694b519 | 2010-07-21 21:33:20 -0700 | [diff] [blame] | 312 | |
Romain Guy | 694b519 | 2010-07-21 21:33:20 -0700 | [diff] [blame] | 313 | Vector<CacheTextureLine*> mCacheLines; |
Alex Sakhartchouk | 65ef909 | 2010-07-26 11:09:33 -0700 | [diff] [blame] | 314 | uint32_t getRemainingCacheCapacity(); |
Romain Guy | 694b519 | 2010-07-21 21:33:20 -0700 | [diff] [blame] | 315 | |
Romain Guy | 09147fb | 2010-07-22 13:08:20 -0700 | [diff] [blame] | 316 | Font* mCurrentFont; |
Romain Guy | 694b519 | 2010-07-21 21:33:20 -0700 | [diff] [blame] | 317 | Vector<Font*> mActiveFonts; |
| 318 | |
Chet Haase | 7de0cb1 | 2011-12-05 16:35:38 -0800 | [diff] [blame] | 319 | CacheTexture* mCurrentCacheTexture; |
| 320 | CacheTexture* mLastCacheTexture; |
| 321 | CacheTexture* mCacheTextureSmall; |
| 322 | CacheTexture* mCacheTexture128; |
| 323 | CacheTexture* mCacheTexture256; |
| 324 | CacheTexture* mCacheTexture512; |
| 325 | |
Alex Sakhartchouk | 9b9902d | 2010-07-23 14:45:49 -0700 | [diff] [blame] | 326 | void checkTextureUpdate(); |
Romain Guy | 694b519 | 2010-07-21 21:33:20 -0700 | [diff] [blame] | 327 | bool mUploadTexture; |
| 328 | |
| 329 | // Pointer to vertex data to speed up frame to frame work |
| 330 | float *mTextMeshPtr; |
| 331 | uint32_t mCurrentQuadIndex; |
| 332 | uint32_t mMaxNumberOfQuads; |
| 333 | |
| 334 | uint32_t mIndexBufferID; |
| 335 | |
Romain Guy | 09147fb | 2010-07-22 13:08:20 -0700 | [diff] [blame] | 336 | const Rect* mClip; |
Romain Guy | 5b3b352 | 2010-10-27 18:57:51 -0700 | [diff] [blame] | 337 | Rect* mBounds; |
| 338 | bool mDrawn; |
Romain Guy | 09147fb | 2010-07-22 13:08:20 -0700 | [diff] [blame] | 339 | |
Romain Guy | 694b519 | 2010-07-21 21:33:20 -0700 | [diff] [blame] | 340 | bool mInitialized; |
Alex Sakhartchouk | 89a524a | 2010-08-02 17:52:30 -0700 | [diff] [blame] | 341 | |
Romain Guy | e8cb9c14 | 2010-10-04 14:14:11 -0700 | [diff] [blame] | 342 | bool mLinearFiltering; |
| 343 | |
Alex Sakhartchouk | 89a524a | 2010-08-02 17:52:30 -0700 | [diff] [blame] | 344 | void computeGaussianWeights(float* weights, int32_t radius); |
| 345 | void horizontalBlur(float* weights, int32_t radius, const uint8_t *source, uint8_t *dest, |
Romain Guy | 1e45aae | 2010-08-13 19:39:53 -0700 | [diff] [blame] | 346 | int32_t width, int32_t height); |
Alex Sakhartchouk | 89a524a | 2010-08-02 17:52:30 -0700 | [diff] [blame] | 347 | void verticalBlur(float* weights, int32_t radius, const uint8_t *source, uint8_t *dest, |
Romain Guy | 1e45aae | 2010-08-13 19:39:53 -0700 | [diff] [blame] | 348 | int32_t width, int32_t height); |
Alex Sakhartchouk | 89a524a | 2010-08-02 17:52:30 -0700 | [diff] [blame] | 349 | void blurImage(uint8_t* image, int32_t width, int32_t height, int32_t radius); |
Romain Guy | 694b519 | 2010-07-21 21:33:20 -0700 | [diff] [blame] | 350 | }; |
| 351 | |
| 352 | }; // namespace uirenderer |
| 353 | }; // namespace android |
| 354 | |
Romain Guy | 5b3b352 | 2010-10-27 18:57:51 -0700 | [diff] [blame] | 355 | #endif // ANDROID_HWUI_FONT_RENDERER_H |