FontRenderer.h revision e816baea651476aca4407200d4a5e629b9ab8dfa
1694b519ac647fe998fd396fe0784cc8e179aadc4Romain Guy/* 2694b519ac647fe998fd396fe0784cc8e179aadc4Romain Guy * Copyright (C) 2010 The Android Open Source Project 3694b519ac647fe998fd396fe0784cc8e179aadc4Romain Guy * 4694b519ac647fe998fd396fe0784cc8e179aadc4Romain Guy * Licensed under the Apache License, Version 2.0 (the "License"); 5694b519ac647fe998fd396fe0784cc8e179aadc4Romain Guy * you may not use this file except in compliance with the License. 6694b519ac647fe998fd396fe0784cc8e179aadc4Romain Guy * You may obtain a copy of the License at 7694b519ac647fe998fd396fe0784cc8e179aadc4Romain Guy * 8694b519ac647fe998fd396fe0784cc8e179aadc4Romain Guy * http://www.apache.org/licenses/LICENSE-2.0 9694b519ac647fe998fd396fe0784cc8e179aadc4Romain Guy * 10694b519ac647fe998fd396fe0784cc8e179aadc4Romain Guy * Unless required by applicable law or agreed to in writing, software 11694b519ac647fe998fd396fe0784cc8e179aadc4Romain Guy * distributed under the License is distributed on an "AS IS" BASIS, 12694b519ac647fe998fd396fe0784cc8e179aadc4Romain Guy * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13694b519ac647fe998fd396fe0784cc8e179aadc4Romain Guy * See the License for the specific language governing permissions and 14694b519ac647fe998fd396fe0784cc8e179aadc4Romain Guy * limitations under the License. 15694b519ac647fe998fd396fe0784cc8e179aadc4Romain Guy */ 16694b519ac647fe998fd396fe0784cc8e179aadc4Romain Guy 175b3b35296e8b2c8d3f07d32bb645d5414db41a1dRomain Guy#ifndef ANDROID_HWUI_FONT_RENDERER_H 185b3b35296e8b2c8d3f07d32bb645d5414db41a1dRomain Guy#define ANDROID_HWUI_FONT_RENDERER_H 19694b519ac647fe998fd396fe0784cc8e179aadc4Romain Guy 20694b519ac647fe998fd396fe0784cc8e179aadc4Romain Guy#include <utils/String8.h> 2165ef909776c03417d8b597738da54ca211e37e4fAlex Sakhartchouk#include <utils/String16.h> 22694b519ac647fe998fd396fe0784cc8e179aadc4Romain Guy#include <utils/Vector.h> 23694b519ac647fe998fd396fe0784cc8e179aadc4Romain Guy#include <utils/KeyedVector.h> 24694b519ac647fe998fd396fe0784cc8e179aadc4Romain Guy 25694b519ac647fe998fd396fe0784cc8e179aadc4Romain Guy#include <SkScalerContext.h> 26694b519ac647fe998fd396fe0784cc8e179aadc4Romain Guy#include <SkPaint.h> 279777173eb6c9eb97c7921c8288ebc65e3ab3ce6fRomain Guy#include <SkPathMeasure.h> 289777173eb6c9eb97c7921c8288ebc65e3ab3ce6fRomain Guy#include <SkPoint.h> 29694b519ac647fe998fd396fe0784cc8e179aadc4Romain Guy 30694b519ac647fe998fd396fe0784cc8e179aadc4Romain Guy#include <GLES2/gl2.h> 31694b519ac647fe998fd396fe0784cc8e179aadc4Romain Guy 3209147fbdc8206a0cac78bfe9083e7e15b3c5689cRomain Guy#include "Rect.h" 3351769a68a5cb34e9564740c6a854fcb93018789dRomain Guy#include "Properties.h" 3409147fbdc8206a0cac78bfe9083e7e15b3c5689cRomain Guy 35694b519ac647fe998fd396fe0784cc8e179aadc4Romain Guynamespace android { 36694b519ac647fe998fd396fe0784cc8e179aadc4Romain Guynamespace uirenderer { 37694b519ac647fe998fd396fe0784cc8e179aadc4Romain Guy 38726aeba80ffc6778a9bc3e0ee957b8d644183505Romain Guy/////////////////////////////////////////////////////////////////////////////// 39726aeba80ffc6778a9bc3e0ee957b8d644183505Romain Guy// Defines 40726aeba80ffc6778a9bc3e0ee957b8d644183505Romain Guy/////////////////////////////////////////////////////////////////////////////// 41726aeba80ffc6778a9bc3e0ee957b8d644183505Romain Guy 42726aeba80ffc6778a9bc3e0ee957b8d644183505Romain Guy#if RENDER_TEXT_AS_GLYPHS 43726aeba80ffc6778a9bc3e0ee957b8d644183505Romain Guy typedef uint16_t glyph_t; 44ae91c4cbc79ea910753be65e2f1d7899abcb4da2Romain Guy #define TO_GLYPH(g) g 45726aeba80ffc6778a9bc3e0ee957b8d644183505Romain Guy #define GET_METRICS(paint, glyph) paint->getGlyphMetrics(glyph) 46726aeba80ffc6778a9bc3e0ee957b8d644183505Romain Guy #define GET_GLYPH(text) nextGlyph((const uint16_t**) &text) 47726aeba80ffc6778a9bc3e0ee957b8d644183505Romain Guy #define IS_END_OF_STRING(glyph) false 48726aeba80ffc6778a9bc3e0ee957b8d644183505Romain Guy#else 49726aeba80ffc6778a9bc3e0ee957b8d644183505Romain Guy typedef SkUnichar glyph_t; 50ae91c4cbc79ea910753be65e2f1d7899abcb4da2Romain Guy #define TO_GLYPH(g) ((SkUnichar) g) 51726aeba80ffc6778a9bc3e0ee957b8d644183505Romain Guy #define GET_METRICS(paint, glyph) paint->getUnicharMetrics(glyph) 52726aeba80ffc6778a9bc3e0ee957b8d644183505Romain Guy #define GET_GLYPH(text) SkUTF16_NextUnichar((const uint16_t**) &text) 53726aeba80ffc6778a9bc3e0ee957b8d644183505Romain Guy #define IS_END_OF_STRING(glyph) glyph < 0 54726aeba80ffc6778a9bc3e0ee957b8d644183505Romain Guy#endif 55726aeba80ffc6778a9bc3e0ee957b8d644183505Romain Guy 56e816baea651476aca4407200d4a5e629b9ab8dfaChet Haase#define TEXTURE_BORDER_SIZE 1 57e816baea651476aca4407200d4a5e629b9ab8dfaChet Haase 58726aeba80ffc6778a9bc3e0ee957b8d644183505Romain Guy/////////////////////////////////////////////////////////////////////////////// 59726aeba80ffc6778a9bc3e0ee957b8d644183505Romain Guy// Declarations 60726aeba80ffc6778a9bc3e0ee957b8d644183505Romain Guy/////////////////////////////////////////////////////////////////////////////// 61726aeba80ffc6778a9bc3e0ee957b8d644183505Romain Guy 62694b519ac647fe998fd396fe0784cc8e179aadc4Romain Guyclass FontRenderer; 63694b519ac647fe998fd396fe0784cc8e179aadc4Romain Guy 647de0cb12d0e5fd64811da0b5d1ae0c0d58b86f86Chet Haaseclass CacheTexture { 657de0cb12d0e5fd64811da0b5d1ae0c0d58b86f86Chet Haasepublic: 660aa87bbfc41e8b5f52de701ac17b4e66a7a7b609Romain Guy CacheTexture(uint16_t width, uint16_t height) : 670aa87bbfc41e8b5f52de701ac17b4e66a7a7b609Romain Guy mTexture(NULL), mTextureId(0), mWidth(width), mHeight(height), 689d9758ae30a59dcf594e0d26ba5d4ee153a3e44aRomain Guy mLinearFiltering(false) { } 697de0cb12d0e5fd64811da0b5d1ae0c0d58b86f86Chet Haase ~CacheTexture() { 709d9758ae30a59dcf594e0d26ba5d4ee153a3e44aRomain Guy if (mTexture) { 717de0cb12d0e5fd64811da0b5d1ae0c0d58b86f86Chet Haase delete[] mTexture; 727de0cb12d0e5fd64811da0b5d1ae0c0d58b86f86Chet Haase } 739d9758ae30a59dcf594e0d26ba5d4ee153a3e44aRomain Guy if (mTextureId) { 747de0cb12d0e5fd64811da0b5d1ae0c0d58b86f86Chet Haase glDeleteTextures(1, &mTextureId); 757de0cb12d0e5fd64811da0b5d1ae0c0d58b86f86Chet Haase } 767de0cb12d0e5fd64811da0b5d1ae0c0d58b86f86Chet Haase } 777de0cb12d0e5fd64811da0b5d1ae0c0d58b86f86Chet Haase 787de0cb12d0e5fd64811da0b5d1ae0c0d58b86f86Chet Haase uint8_t* mTexture; 797de0cb12d0e5fd64811da0b5d1ae0c0d58b86f86Chet Haase GLuint mTextureId; 807de0cb12d0e5fd64811da0b5d1ae0c0d58b86f86Chet Haase uint16_t mWidth; 817de0cb12d0e5fd64811da0b5d1ae0c0d58b86f86Chet Haase uint16_t mHeight; 822a47c14e2a6f152496b43104bc785c488583fd59Chet Haase bool mLinearFiltering; 837de0cb12d0e5fd64811da0b5d1ae0c0d58b86f86Chet Haase}; 847de0cb12d0e5fd64811da0b5d1ae0c0d58b86f86Chet Haase 85e816baea651476aca4407200d4a5e629b9ab8dfaChet Haase/** 86e816baea651476aca4407200d4a5e629b9ab8dfaChet Haase * CacheBlock is a noce in a linked list of current free space areas in a CacheTextureLine. 87e816baea651476aca4407200d4a5e629b9ab8dfaChet Haase * Using CacheBlocks enables us to pack the cache line from top to bottom as well as left to right. 88e816baea651476aca4407200d4a5e629b9ab8dfaChet Haase * When we add a glyph to the cache, we see if it fits within one of the existing columns that 89e816baea651476aca4407200d4a5e629b9ab8dfaChet Haase * have already been started (this is the case if the glyph fits vertically as well as 90e816baea651476aca4407200d4a5e629b9ab8dfaChet Haase * horizontally, and if its width is sufficiently close to the column width to avoid 91e816baea651476aca4407200d4a5e629b9ab8dfaChet Haase * sub-optimal packing of small glyphs into wide columns). If there is no column in which the 92e816baea651476aca4407200d4a5e629b9ab8dfaChet Haase * glyph fits, we check the final node, which is the remaining space in the cache line, creating 93e816baea651476aca4407200d4a5e629b9ab8dfaChet Haase * a new column as appropriate. 94e816baea651476aca4407200d4a5e629b9ab8dfaChet Haase * 95e816baea651476aca4407200d4a5e629b9ab8dfaChet Haase * As columns fill up, we remove their CacheBlock from the list to avoid having to check 96e816baea651476aca4407200d4a5e629b9ab8dfaChet Haase * small blocks in the future. 97e816baea651476aca4407200d4a5e629b9ab8dfaChet Haase */ 98e816baea651476aca4407200d4a5e629b9ab8dfaChet Haasestruct CacheBlock { 99e816baea651476aca4407200d4a5e629b9ab8dfaChet Haase uint16_t mX; 100e816baea651476aca4407200d4a5e629b9ab8dfaChet Haase uint16_t mY; 101e816baea651476aca4407200d4a5e629b9ab8dfaChet Haase uint16_t mWidth; 102e816baea651476aca4407200d4a5e629b9ab8dfaChet Haase uint16_t mHeight; 103e816baea651476aca4407200d4a5e629b9ab8dfaChet Haase CacheBlock* mNext; 104e816baea651476aca4407200d4a5e629b9ab8dfaChet Haase CacheBlock* mPrev; 105e816baea651476aca4407200d4a5e629b9ab8dfaChet Haase 106e816baea651476aca4407200d4a5e629b9ab8dfaChet Haase CacheBlock(uint16_t x, uint16_t y, uint16_t width, uint16_t height, bool empty = false): 107e816baea651476aca4407200d4a5e629b9ab8dfaChet Haase mX(x), mY(y), mWidth(width), mHeight(height), mNext(NULL), mPrev(NULL) 108e816baea651476aca4407200d4a5e629b9ab8dfaChet Haase { 109e816baea651476aca4407200d4a5e629b9ab8dfaChet Haase } 110e816baea651476aca4407200d4a5e629b9ab8dfaChet Haase 111e816baea651476aca4407200d4a5e629b9ab8dfaChet Haase static CacheBlock* insertBlock(CacheBlock* head, CacheBlock *newBlock); 112e816baea651476aca4407200d4a5e629b9ab8dfaChet Haase 113e816baea651476aca4407200d4a5e629b9ab8dfaChet Haase static CacheBlock* removeBlock(CacheBlock* head, CacheBlock *blockToRemove); 114e816baea651476aca4407200d4a5e629b9ab8dfaChet Haase 115e816baea651476aca4407200d4a5e629b9ab8dfaChet Haase void output() { 116e816baea651476aca4407200d4a5e629b9ab8dfaChet Haase CacheBlock *currBlock = this; 117e816baea651476aca4407200d4a5e629b9ab8dfaChet Haase while (currBlock) { 118e816baea651476aca4407200d4a5e629b9ab8dfaChet Haase ALOGD("Block: this, x, y, w, h = %p, %d, %d, %d, %d", 119e816baea651476aca4407200d4a5e629b9ab8dfaChet Haase currBlock, currBlock->mX, currBlock->mY, currBlock->mWidth, currBlock->mHeight); 120e816baea651476aca4407200d4a5e629b9ab8dfaChet Haase currBlock = currBlock->mNext; 121e816baea651476aca4407200d4a5e629b9ab8dfaChet Haase } 122e816baea651476aca4407200d4a5e629b9ab8dfaChet Haase } 123e816baea651476aca4407200d4a5e629b9ab8dfaChet Haase}; 124e816baea651476aca4407200d4a5e629b9ab8dfaChet Haase 1257de0cb12d0e5fd64811da0b5d1ae0c0d58b86f86Chet Haaseclass CacheTextureLine { 1267de0cb12d0e5fd64811da0b5d1ae0c0d58b86f86Chet Haasepublic: 1277de0cb12d0e5fd64811da0b5d1ae0c0d58b86f86Chet Haase CacheTextureLine(uint16_t maxWidth, uint16_t maxHeight, uint32_t currentRow, 128e816baea651476aca4407200d4a5e629b9ab8dfaChet Haase CacheTexture* cacheTexture): 1297de0cb12d0e5fd64811da0b5d1ae0c0d58b86f86Chet Haase mMaxHeight(maxHeight), 1307de0cb12d0e5fd64811da0b5d1ae0c0d58b86f86Chet Haase mMaxWidth(maxWidth), 1317de0cb12d0e5fd64811da0b5d1ae0c0d58b86f86Chet Haase mCurrentRow(currentRow), 1327de0cb12d0e5fd64811da0b5d1ae0c0d58b86f86Chet Haase mDirty(false), 133e816baea651476aca4407200d4a5e629b9ab8dfaChet Haase mNumGlyphs(0), 1349d9758ae30a59dcf594e0d26ba5d4ee153a3e44aRomain Guy mCacheTexture(cacheTexture) { 135e816baea651476aca4407200d4a5e629b9ab8dfaChet Haase mCacheBlocks = new CacheBlock(TEXTURE_BORDER_SIZE, TEXTURE_BORDER_SIZE, 136e816baea651476aca4407200d4a5e629b9ab8dfaChet Haase maxWidth - TEXTURE_BORDER_SIZE, maxHeight - TEXTURE_BORDER_SIZE, true); 137e816baea651476aca4407200d4a5e629b9ab8dfaChet Haase } 138e816baea651476aca4407200d4a5e629b9ab8dfaChet Haase 139e816baea651476aca4407200d4a5e629b9ab8dfaChet Haase ~CacheTextureLine() { 140e816baea651476aca4407200d4a5e629b9ab8dfaChet Haase reset(); 141e816baea651476aca4407200d4a5e629b9ab8dfaChet Haase } 142e816baea651476aca4407200d4a5e629b9ab8dfaChet Haase 143e816baea651476aca4407200d4a5e629b9ab8dfaChet Haase void reset() { 144e816baea651476aca4407200d4a5e629b9ab8dfaChet Haase // Delete existing cache blocks 145e816baea651476aca4407200d4a5e629b9ab8dfaChet Haase while (mCacheBlocks != NULL) { 146e816baea651476aca4407200d4a5e629b9ab8dfaChet Haase CacheBlock* tmpBlock = mCacheBlocks; 147e816baea651476aca4407200d4a5e629b9ab8dfaChet Haase mCacheBlocks = mCacheBlocks->mNext; 148e816baea651476aca4407200d4a5e629b9ab8dfaChet Haase delete tmpBlock; 149e816baea651476aca4407200d4a5e629b9ab8dfaChet Haase } 150e816baea651476aca4407200d4a5e629b9ab8dfaChet Haase mNumGlyphs = 0; 151e816baea651476aca4407200d4a5e629b9ab8dfaChet Haase } 152e816baea651476aca4407200d4a5e629b9ab8dfaChet Haase 153e816baea651476aca4407200d4a5e629b9ab8dfaChet Haase void init() { 154e816baea651476aca4407200d4a5e629b9ab8dfaChet Haase // reset, then create a new remainder space to start again 155e816baea651476aca4407200d4a5e629b9ab8dfaChet Haase reset(); 156e816baea651476aca4407200d4a5e629b9ab8dfaChet Haase mCacheBlocks = new CacheBlock(TEXTURE_BORDER_SIZE, TEXTURE_BORDER_SIZE, 157e816baea651476aca4407200d4a5e629b9ab8dfaChet Haase mMaxWidth - TEXTURE_BORDER_SIZE, mMaxHeight - TEXTURE_BORDER_SIZE, true); 1587de0cb12d0e5fd64811da0b5d1ae0c0d58b86f86Chet Haase } 1597de0cb12d0e5fd64811da0b5d1ae0c0d58b86f86Chet Haase 1607de0cb12d0e5fd64811da0b5d1ae0c0d58b86f86Chet Haase bool fitBitmap(const SkGlyph& glyph, uint32_t *retOriginX, uint32_t *retOriginY); 1617de0cb12d0e5fd64811da0b5d1ae0c0d58b86f86Chet Haase 1627de0cb12d0e5fd64811da0b5d1ae0c0d58b86f86Chet Haase uint16_t mMaxHeight; 1637de0cb12d0e5fd64811da0b5d1ae0c0d58b86f86Chet Haase uint16_t mMaxWidth; 1647de0cb12d0e5fd64811da0b5d1ae0c0d58b86f86Chet Haase uint32_t mCurrentRow; 1657de0cb12d0e5fd64811da0b5d1ae0c0d58b86f86Chet Haase bool mDirty; 166e816baea651476aca4407200d4a5e629b9ab8dfaChet Haase uint16_t mNumGlyphs; 167ae91c4cbc79ea910753be65e2f1d7899abcb4da2Romain Guy CacheTexture* mCacheTexture; 168e816baea651476aca4407200d4a5e629b9ab8dfaChet Haase CacheBlock* mCacheBlocks; 1697de0cb12d0e5fd64811da0b5d1ae0c0d58b86f86Chet Haase}; 1707de0cb12d0e5fd64811da0b5d1ae0c0d58b86f86Chet Haase 1717de0cb12d0e5fd64811da0b5d1ae0c0d58b86f86Chet Haasestruct CachedGlyphInfo { 1727de0cb12d0e5fd64811da0b5d1ae0c0d58b86f86Chet Haase // Has the cache been invalidated? 1737de0cb12d0e5fd64811da0b5d1ae0c0d58b86f86Chet Haase bool mIsValid; 1747de0cb12d0e5fd64811da0b5d1ae0c0d58b86f86Chet Haase // Location of the cached glyph in the bitmap 1757de0cb12d0e5fd64811da0b5d1ae0c0d58b86f86Chet Haase // in case we need to resize the texture or 1767de0cb12d0e5fd64811da0b5d1ae0c0d58b86f86Chet Haase // render to bitmap 1777de0cb12d0e5fd64811da0b5d1ae0c0d58b86f86Chet Haase uint32_t mStartX; 1787de0cb12d0e5fd64811da0b5d1ae0c0d58b86f86Chet Haase uint32_t mStartY; 1797de0cb12d0e5fd64811da0b5d1ae0c0d58b86f86Chet Haase uint32_t mBitmapWidth; 1807de0cb12d0e5fd64811da0b5d1ae0c0d58b86f86Chet Haase uint32_t mBitmapHeight; 1817de0cb12d0e5fd64811da0b5d1ae0c0d58b86f86Chet Haase // Also cache texture coords for the quad 1827de0cb12d0e5fd64811da0b5d1ae0c0d58b86f86Chet Haase float mBitmapMinU; 1837de0cb12d0e5fd64811da0b5d1ae0c0d58b86f86Chet Haase float mBitmapMinV; 1847de0cb12d0e5fd64811da0b5d1ae0c0d58b86f86Chet Haase float mBitmapMaxU; 1857de0cb12d0e5fd64811da0b5d1ae0c0d58b86f86Chet Haase float mBitmapMaxV; 1867de0cb12d0e5fd64811da0b5d1ae0c0d58b86f86Chet Haase // Minimize how much we call freetype 1877de0cb12d0e5fd64811da0b5d1ae0c0d58b86f86Chet Haase uint32_t mGlyphIndex; 1887de0cb12d0e5fd64811da0b5d1ae0c0d58b86f86Chet Haase uint32_t mAdvanceX; 1897de0cb12d0e5fd64811da0b5d1ae0c0d58b86f86Chet Haase uint32_t mAdvanceY; 1907de0cb12d0e5fd64811da0b5d1ae0c0d58b86f86Chet Haase // Values below contain a glyph's origin in the bitmap 1917de0cb12d0e5fd64811da0b5d1ae0c0d58b86f86Chet Haase int32_t mBitmapLeft; 1927de0cb12d0e5fd64811da0b5d1ae0c0d58b86f86Chet Haase int32_t mBitmapTop; 1937de0cb12d0e5fd64811da0b5d1ae0c0d58b86f86Chet Haase // Auto-kerning 1947de0cb12d0e5fd64811da0b5d1ae0c0d58b86f86Chet Haase SkFixed mLsbDelta; 1957de0cb12d0e5fd64811da0b5d1ae0c0d58b86f86Chet Haase SkFixed mRsbDelta; 1967de0cb12d0e5fd64811da0b5d1ae0c0d58b86f86Chet Haase CacheTextureLine* mCachedTextureLine; 1977de0cb12d0e5fd64811da0b5d1ae0c0d58b86f86Chet Haase}; 1987de0cb12d0e5fd64811da0b5d1ae0c0d58b86f86Chet Haase 1997de0cb12d0e5fd64811da0b5d1ae0c0d58b86f86Chet Haase 200726aeba80ffc6778a9bc3e0ee957b8d644183505Romain Guy/////////////////////////////////////////////////////////////////////////////// 201726aeba80ffc6778a9bc3e0ee957b8d644183505Romain Guy// Font 202726aeba80ffc6778a9bc3e0ee957b8d644183505Romain Guy/////////////////////////////////////////////////////////////////////////////// 203726aeba80ffc6778a9bc3e0ee957b8d644183505Romain Guy 20451769a68a5cb34e9564740c6a854fcb93018789dRomain Guy/** 20551769a68a5cb34e9564740c6a854fcb93018789dRomain Guy * Represents a font, defined by a Skia font id and a font size. A font is used 20651769a68a5cb34e9564740c6a854fcb93018789dRomain Guy * to generate glyphs and cache them in the FontState. 20751769a68a5cb34e9564740c6a854fcb93018789dRomain Guy */ 208694b519ac647fe998fd396fe0784cc8e179aadc4Romain Guyclass Font { 209694b519ac647fe998fd396fe0784cc8e179aadc4Romain Guypublic: 210325a0f969c1d803d7e39a9caee8cc3d400350659Romain Guy enum Style { 211c7b25be64f679e78dfa79080b44be18c9974004cRomain Guy kFakeBold = 1 212325a0f969c1d803d7e39a9caee8cc3d400350659Romain Guy }; 213325a0f969c1d803d7e39a9caee8cc3d400350659Romain Guy 214694b519ac647fe998fd396fe0784cc8e179aadc4Romain Guy ~Font(); 215694b519ac647fe998fd396fe0784cc8e179aadc4Romain Guy 21651769a68a5cb34e9564740c6a854fcb93018789dRomain Guy /** 21751769a68a5cb34e9564740c6a854fcb93018789dRomain Guy * Renders the specified string of text. 218f18136cb3c881a9d16c1a4f0f341732c276936bfAlex Sakhartchouk * If bitmap is specified, it will be used as the render target 21951769a68a5cb34e9564740c6a854fcb93018789dRomain Guy */ 220726aeba80ffc6778a9bc3e0ee957b8d644183505Romain Guy void render(SkPaint* paint, const char *text, uint32_t start, uint32_t len, 221726aeba80ffc6778a9bc3e0ee957b8d644183505Romain Guy int numGlyphs, int x, int y, uint8_t *bitmap = NULL, 222726aeba80ffc6778a9bc3e0ee957b8d644183505Romain Guy uint32_t bitmapW = 0, uint32_t bitmapH = 0); 223671d6cf460531825a321edb200523d0faa7792c9Romain Guy 224671d6cf460531825a321edb200523d0faa7792c9Romain Guy void render(SkPaint* paint, const char *text, uint32_t start, uint32_t len, 225671d6cf460531825a321edb200523d0faa7792c9Romain Guy int numGlyphs, int x, int y, const float* positions); 226671d6cf460531825a321edb200523d0faa7792c9Romain Guy 2279777173eb6c9eb97c7921c8288ebc65e3ab3ce6fRomain Guy void render(SkPaint* paint, const char *text, uint32_t start, uint32_t len, 2289777173eb6c9eb97c7921c8288ebc65e3ab3ce6fRomain Guy int numGlyphs, SkPath* path, float hOffset, float vOffset); 2299777173eb6c9eb97c7921c8288ebc65e3ab3ce6fRomain Guy 23051769a68a5cb34e9564740c6a854fcb93018789dRomain Guy /** 23151769a68a5cb34e9564740c6a854fcb93018789dRomain Guy * Creates a new font associated with the specified font state. 23251769a68a5cb34e9564740c6a854fcb93018789dRomain Guy */ 2332577db1ec135a1470a2c42139772ec97a6c30e78Romain Guy static Font* create(FontRenderer* state, uint32_t fontId, float fontSize, 234bd496bc3d481f9cfc39007d22372d3a1a8809f96Romain Guy int flags, uint32_t italicStyle, uint32_t scaleX, SkPaint::Style style, 235bd496bc3d481f9cfc39007d22372d3a1a8809f96Romain Guy uint32_t strokeWidth); 236694b519ac647fe998fd396fe0784cc8e179aadc4Romain Guy 237694b519ac647fe998fd396fe0784cc8e179aadc4Romain Guyprotected: 238694b519ac647fe998fd396fe0784cc8e179aadc4Romain Guy friend class FontRenderer; 239671d6cf460531825a321edb200523d0faa7792c9Romain Guy typedef void (Font::*RenderGlyph)(CachedGlyphInfo*, int, int, uint8_t*, 240671d6cf460531825a321edb200523d0faa7792c9Romain Guy uint32_t, uint32_t, Rect*, const float*); 241694b519ac647fe998fd396fe0784cc8e179aadc4Romain Guy 242f18136cb3c881a9d16c1a4f0f341732c276936bfAlex Sakhartchouk enum RenderMode { 243f18136cb3c881a9d16c1a4f0f341732c276936bfAlex Sakhartchouk FRAMEBUFFER, 244f18136cb3c881a9d16c1a4f0f341732c276936bfAlex Sakhartchouk BITMAP, 245f18136cb3c881a9d16c1a4f0f341732c276936bfAlex Sakhartchouk MEASURE, 246f18136cb3c881a9d16c1a4f0f341732c276936bfAlex Sakhartchouk }; 247f18136cb3c881a9d16c1a4f0f341732c276936bfAlex Sakhartchouk 248e816baea651476aca4407200d4a5e629b9ab8dfaChet Haase void precache(SkPaint* paint, const char* text, int numGlyphs); 249e816baea651476aca4407200d4a5e629b9ab8dfaChet Haase 250726aeba80ffc6778a9bc3e0ee957b8d644183505Romain Guy void render(SkPaint* paint, const char *text, uint32_t start, uint32_t len, 251726aeba80ffc6778a9bc3e0ee957b8d644183505Romain Guy int numGlyphs, int x, int y, RenderMode mode, uint8_t *bitmap, 252671d6cf460531825a321edb200523d0faa7792c9Romain Guy uint32_t bitmapW, uint32_t bitmapH, Rect *bounds, const float* positions); 253f18136cb3c881a9d16c1a4f0f341732c276936bfAlex Sakhartchouk 254726aeba80ffc6778a9bc3e0ee957b8d644183505Romain Guy void measure(SkPaint* paint, const char* text, uint32_t start, uint32_t len, 255416a847633680d94efb926837efdc18726d54918Raph Levien int numGlyphs, Rect *bounds, const float* positions); 256f18136cb3c881a9d16c1a4f0f341732c276936bfAlex Sakhartchouk 2578668f8a633d9299091556c3b2e5ae07be8dce360Chet Haase Font(FontRenderer* state, uint32_t fontId, float fontSize, int flags, uint32_t italicStyle, 258bd496bc3d481f9cfc39007d22372d3a1a8809f96Romain Guy uint32_t scaleX, SkPaint::Style style, uint32_t strokeWidth); 259694b519ac647fe998fd396fe0784cc8e179aadc4Romain Guy 260726aeba80ffc6778a9bc3e0ee957b8d644183505Romain Guy // Cache of glyphs 261726aeba80ffc6778a9bc3e0ee957b8d644183505Romain Guy DefaultKeyedVector<glyph_t, CachedGlyphInfo*> mCachedGlyphs; 262694b519ac647fe998fd396fe0784cc8e179aadc4Romain Guy 2639a8245629d69d81e0b62e52970feaf9c02580e75Chet Haase void invalidateTextureCache(CacheTextureLine *cacheLine = NULL); 264bd0e6aa0ff0bd8b376772c3e23513a6021bdda87Romain Guy 265726aeba80ffc6778a9bc3e0ee957b8d644183505Romain Guy CachedGlyphInfo* cacheGlyph(SkPaint* paint, glyph_t glyph); 266671d6cf460531825a321edb200523d0faa7792c9Romain Guy void updateGlyphCache(SkPaint* paint, const SkGlyph& skiaGlyph, CachedGlyphInfo* glyph); 267671d6cf460531825a321edb200523d0faa7792c9Romain Guy 268671d6cf460531825a321edb200523d0faa7792c9Romain Guy void measureCachedGlyph(CachedGlyphInfo* glyph, int x, int y, 269671d6cf460531825a321edb200523d0faa7792c9Romain Guy uint8_t *bitmap, uint32_t bitmapW, uint32_t bitmapH, 270671d6cf460531825a321edb200523d0faa7792c9Romain Guy Rect* bounds, const float* pos); 271671d6cf460531825a321edb200523d0faa7792c9Romain Guy void drawCachedGlyph(CachedGlyphInfo* glyph, int x, int y, 272671d6cf460531825a321edb200523d0faa7792c9Romain Guy uint8_t *bitmap, uint32_t bitmapW, uint32_t bitmapH, 273671d6cf460531825a321edb200523d0faa7792c9Romain Guy Rect* bounds, const float* pos); 274671d6cf460531825a321edb200523d0faa7792c9Romain Guy void drawCachedGlyphBitmap(CachedGlyphInfo* glyph, int x, int y, 275671d6cf460531825a321edb200523d0faa7792c9Romain Guy uint8_t *bitmap, uint32_t bitmapW, uint32_t bitmapH, 276671d6cf460531825a321edb200523d0faa7792c9Romain Guy Rect* bounds, const float* pos); 2779777173eb6c9eb97c7921c8288ebc65e3ab3ce6fRomain Guy void drawCachedGlyph(CachedGlyphInfo* glyph, float x, float hOffset, float vOffset, 2789777173eb6c9eb97c7921c8288ebc65e3ab3ce6fRomain Guy SkPathMeasure& measure, SkPoint* position, SkVector* tangent); 279bd0e6aa0ff0bd8b376772c3e23513a6021bdda87Romain Guy 280726aeba80ffc6778a9bc3e0ee957b8d644183505Romain Guy CachedGlyphInfo* getCachedGlyph(SkPaint* paint, glyph_t textUnit); 281726aeba80ffc6778a9bc3e0ee957b8d644183505Romain Guy 282726aeba80ffc6778a9bc3e0ee957b8d644183505Romain Guy static glyph_t nextGlyph(const uint16_t** srcPtr) { 283726aeba80ffc6778a9bc3e0ee957b8d644183505Romain Guy const uint16_t* src = *srcPtr; 284726aeba80ffc6778a9bc3e0ee957b8d644183505Romain Guy glyph_t g = *src++; 285726aeba80ffc6778a9bc3e0ee957b8d644183505Romain Guy *srcPtr = src; 286726aeba80ffc6778a9bc3e0ee957b8d644183505Romain Guy return g; 287726aeba80ffc6778a9bc3e0ee957b8d644183505Romain Guy } 28865ef909776c03417d8b597738da54ca211e37e4fAlex Sakhartchouk 289bd0e6aa0ff0bd8b376772c3e23513a6021bdda87Romain Guy FontRenderer* mState; 290bd0e6aa0ff0bd8b376772c3e23513a6021bdda87Romain Guy uint32_t mFontId; 291bd0e6aa0ff0bd8b376772c3e23513a6021bdda87Romain Guy float mFontSize; 292325a0f969c1d803d7e39a9caee8cc3d400350659Romain Guy int mFlags; 2932577db1ec135a1470a2c42139772ec97a6c30e78Romain Guy uint32_t mItalicStyle; 2948668f8a633d9299091556c3b2e5ae07be8dce360Chet Haase uint32_t mScaleX; 295bd496bc3d481f9cfc39007d22372d3a1a8809f96Romain Guy SkPaint::Style mStyle; 296bd496bc3d481f9cfc39007d22372d3a1a8809f96Romain Guy uint32_t mStrokeWidth; 297694b519ac647fe998fd396fe0784cc8e179aadc4Romain Guy}; 298694b519ac647fe998fd396fe0784cc8e179aadc4Romain Guy 299726aeba80ffc6778a9bc3e0ee957b8d644183505Romain Guy/////////////////////////////////////////////////////////////////////////////// 300726aeba80ffc6778a9bc3e0ee957b8d644183505Romain Guy// Renderer 301726aeba80ffc6778a9bc3e0ee957b8d644183505Romain Guy/////////////////////////////////////////////////////////////////////////////// 302726aeba80ffc6778a9bc3e0ee957b8d644183505Romain Guy 303694b519ac647fe998fd396fe0784cc8e179aadc4Romain Guyclass FontRenderer { 304694b519ac647fe998fd396fe0784cc8e179aadc4Romain Guypublic: 305694b519ac647fe998fd396fe0784cc8e179aadc4Romain Guy FontRenderer(); 306694b519ac647fe998fd396fe0784cc8e179aadc4Romain Guy ~FontRenderer(); 307694b519ac647fe998fd396fe0784cc8e179aadc4Romain Guy 3089a8245629d69d81e0b62e52970feaf9c02580e75Chet Haase void flushLargeCaches(); 309694b519ac647fe998fd396fe0784cc8e179aadc4Romain Guy 310b45c0c9774bd19a9dbe77d149abae4e124b08bf6Romain Guy void setGammaTable(const uint8_t* gammaTable) { 311b45c0c9774bd19a9dbe77d149abae4e124b08bf6Romain Guy mGammaTable = gammaTable; 312b45c0c9774bd19a9dbe77d149abae4e124b08bf6Romain Guy } 313b45c0c9774bd19a9dbe77d149abae4e124b08bf6Romain Guy 31465ef909776c03417d8b597738da54ca211e37e4fAlex Sakhartchouk void setFont(SkPaint* paint, uint32_t fontId, float fontSize); 315e816baea651476aca4407200d4a5e629b9ab8dfaChet Haase 316e816baea651476aca4407200d4a5e629b9ab8dfaChet Haase void precache(SkPaint* paint, const char* text, int numGlyphs); 317e816baea651476aca4407200d4a5e629b9ab8dfaChet Haase 318671d6cf460531825a321edb200523d0faa7792c9Romain Guy // bounds is an out parameter 3195b3b35296e8b2c8d3f07d32bb645d5414db41a1dRomain Guy bool renderText(SkPaint* paint, const Rect* clip, const char *text, uint32_t startIndex, 3205b3b35296e8b2c8d3f07d32bb645d5414db41a1dRomain Guy uint32_t len, int numGlyphs, int x, int y, Rect* bounds); 321671d6cf460531825a321edb200523d0faa7792c9Romain Guy // bounds is an out parameter 322671d6cf460531825a321edb200523d0faa7792c9Romain Guy bool renderPosText(SkPaint* paint, const Rect* clip, const char *text, uint32_t startIndex, 323671d6cf460531825a321edb200523d0faa7792c9Romain Guy uint32_t len, int numGlyphs, int x, int y, const float* positions, Rect* bounds); 3249777173eb6c9eb97c7921c8288ebc65e3ab3ce6fRomain Guy // bounds is an out parameter 3259777173eb6c9eb97c7921c8288ebc65e3ab3ce6fRomain Guy bool renderTextOnPath(SkPaint* paint, const Rect* clip, const char *text, uint32_t startIndex, 3269777173eb6c9eb97c7921c8288ebc65e3ab3ce6fRomain Guy uint32_t len, int numGlyphs, SkPath* path, float hOffset, float vOffset, Rect* bounds); 327694b519ac647fe998fd396fe0784cc8e179aadc4Romain Guy 328f18136cb3c881a9d16c1a4f0f341732c276936bfAlex Sakhartchouk struct DropShadow { 3291e45aae5de003657e5d18f74d34998f5de5db5b7Romain Guy DropShadow() { }; 3301e45aae5de003657e5d18f74d34998f5de5db5b7Romain Guy 3311e45aae5de003657e5d18f74d34998f5de5db5b7Romain Guy DropShadow(const DropShadow& dropShadow): 3321e45aae5de003657e5d18f74d34998f5de5db5b7Romain Guy width(dropShadow.width), height(dropShadow.height), 3331e45aae5de003657e5d18f74d34998f5de5db5b7Romain Guy image(dropShadow.image), penX(dropShadow.penX), 3341e45aae5de003657e5d18f74d34998f5de5db5b7Romain Guy penY(dropShadow.penY) { 3351e45aae5de003657e5d18f74d34998f5de5db5b7Romain Guy } 3361e45aae5de003657e5d18f74d34998f5de5db5b7Romain Guy 337f18136cb3c881a9d16c1a4f0f341732c276936bfAlex Sakhartchouk uint32_t width; 338f18136cb3c881a9d16c1a4f0f341732c276936bfAlex Sakhartchouk uint32_t height; 339f18136cb3c881a9d16c1a4f0f341732c276936bfAlex Sakhartchouk uint8_t* image; 340f18136cb3c881a9d16c1a4f0f341732c276936bfAlex Sakhartchouk int32_t penX; 341f18136cb3c881a9d16c1a4f0f341732c276936bfAlex Sakhartchouk int32_t penY; 342f18136cb3c881a9d16c1a4f0f341732c276936bfAlex Sakhartchouk }; 343f18136cb3c881a9d16c1a4f0f341732c276936bfAlex Sakhartchouk 344f18136cb3c881a9d16c1a4f0f341732c276936bfAlex Sakhartchouk // After renderDropShadow returns, the called owns the memory in DropShadow.image 345f18136cb3c881a9d16c1a4f0f341732c276936bfAlex Sakhartchouk // and is responsible for releasing it when it's done with it 346f18136cb3c881a9d16c1a4f0f341732c276936bfAlex Sakhartchouk DropShadow renderDropShadow(SkPaint* paint, const char *text, uint32_t startIndex, 347416a847633680d94efb926837efdc18726d54918Raph Levien uint32_t len, int numGlyphs, uint32_t radius, const float* positions); 348f18136cb3c881a9d16c1a4f0f341732c276936bfAlex Sakhartchouk 349e8cb9c14309b0f01c0159efdf9a7198f44a62642Romain Guy GLuint getTexture(bool linearFiltering = false) { 350694b519ac647fe998fd396fe0784cc8e179aadc4Romain Guy checkInit(); 351ae91c4cbc79ea910753be65e2f1d7899abcb4da2Romain Guy 3522a47c14e2a6f152496b43104bc785c488583fd59Chet Haase if (linearFiltering != mCurrentCacheTexture->mLinearFiltering) { 3532a47c14e2a6f152496b43104bc785c488583fd59Chet Haase mCurrentCacheTexture->mLinearFiltering = linearFiltering; 354e8cb9c14309b0f01c0159efdf9a7198f44a62642Romain Guy mLinearFiltering = linearFiltering; 355e8cb9c14309b0f01c0159efdf9a7198f44a62642Romain Guy const GLenum filtering = linearFiltering ? GL_LINEAR : GL_NEAREST; 356e8cb9c14309b0f01c0159efdf9a7198f44a62642Romain Guy 3577de0cb12d0e5fd64811da0b5d1ae0c0d58b86f86Chet Haase glBindTexture(GL_TEXTURE_2D, mCurrentCacheTexture->mTextureId); 358e8cb9c14309b0f01c0159efdf9a7198f44a62642Romain Guy glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, filtering); 359e8cb9c14309b0f01c0159efdf9a7198f44a62642Romain Guy glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, filtering); 360e8cb9c14309b0f01c0159efdf9a7198f44a62642Romain Guy } 361ae91c4cbc79ea910753be65e2f1d7899abcb4da2Romain Guy 3627de0cb12d0e5fd64811da0b5d1ae0c0d58b86f86Chet Haase return mCurrentCacheTexture->mTextureId; 363c15008e72ec00ca20a271c3006dac649fd07533bRomain Guy } 364c15008e72ec00ca20a271c3006dac649fd07533bRomain Guy 3657de0cb12d0e5fd64811da0b5d1ae0c0d58b86f86Chet Haase uint32_t getCacheSize() const { 3667de0cb12d0e5fd64811da0b5d1ae0c0d58b86f86Chet Haase uint32_t size = 0; 3677de0cb12d0e5fd64811da0b5d1ae0c0d58b86f86Chet Haase if (mCacheTextureSmall != NULL && mCacheTextureSmall->mTexture != NULL) { 3687de0cb12d0e5fd64811da0b5d1ae0c0d58b86f86Chet Haase size += mCacheTextureSmall->mWidth * mCacheTextureSmall->mHeight; 3697de0cb12d0e5fd64811da0b5d1ae0c0d58b86f86Chet Haase } 3707de0cb12d0e5fd64811da0b5d1ae0c0d58b86f86Chet Haase if (mCacheTexture128 != NULL && mCacheTexture128->mTexture != NULL) { 3717de0cb12d0e5fd64811da0b5d1ae0c0d58b86f86Chet Haase size += mCacheTexture128->mWidth * mCacheTexture128->mHeight; 3727de0cb12d0e5fd64811da0b5d1ae0c0d58b86f86Chet Haase } 3737de0cb12d0e5fd64811da0b5d1ae0c0d58b86f86Chet Haase if (mCacheTexture256 != NULL && mCacheTexture256->mTexture != NULL) { 3747de0cb12d0e5fd64811da0b5d1ae0c0d58b86f86Chet Haase size += mCacheTexture256->mWidth * mCacheTexture256->mHeight; 3757de0cb12d0e5fd64811da0b5d1ae0c0d58b86f86Chet Haase } 3767de0cb12d0e5fd64811da0b5d1ae0c0d58b86f86Chet Haase if (mCacheTexture512 != NULL && mCacheTexture512->mTexture != NULL) { 3777de0cb12d0e5fd64811da0b5d1ae0c0d58b86f86Chet Haase size += mCacheTexture512->mWidth * mCacheTexture512->mHeight; 3787de0cb12d0e5fd64811da0b5d1ae0c0d58b86f86Chet Haase } 3797de0cb12d0e5fd64811da0b5d1ae0c0d58b86f86Chet Haase return size; 380c15008e72ec00ca20a271c3006dac649fd07533bRomain Guy } 381c15008e72ec00ca20a271c3006dac649fd07533bRomain Guy 382694b519ac647fe998fd396fe0784cc8e179aadc4Romain Guyprotected: 383694b519ac647fe998fd396fe0784cc8e179aadc4Romain Guy friend class Font; 384694b519ac647fe998fd396fe0784cc8e179aadc4Romain Guy 385b45c0c9774bd19a9dbe77d149abae4e124b08bf6Romain Guy const uint8_t* mGammaTable; 386b45c0c9774bd19a9dbe77d149abae4e124b08bf6Romain Guy 3872a47c14e2a6f152496b43104bc785c488583fd59Chet Haase void allocateTextureMemory(CacheTexture* cacheTexture); 3889a8245629d69d81e0b62e52970feaf9c02580e75Chet Haase void deallocateTextureMemory(CacheTexture* cacheTexture); 3897de0cb12d0e5fd64811da0b5d1ae0c0d58b86f86Chet Haase void initTextTexture(); 3909777173eb6c9eb97c7921c8288ebc65e3ab3ce6fRomain Guy CacheTexture* createCacheTexture(int width, int height, bool allocate); 3917de0cb12d0e5fd64811da0b5d1ae0c0d58b86f86Chet Haase void cacheBitmap(const SkGlyph& glyph, CachedGlyphInfo* cachedGlyph, 3927de0cb12d0e5fd64811da0b5d1ae0c0d58b86f86Chet Haase uint32_t *retOriginX, uint32_t *retOriginY); 393694b519ac647fe998fd396fe0784cc8e179aadc4Romain Guy 394694b519ac647fe998fd396fe0784cc8e179aadc4Romain Guy void flushAllAndInvalidate(); 395694b519ac647fe998fd396fe0784cc8e179aadc4Romain Guy void initVertexArrayBuffers(); 396694b519ac647fe998fd396fe0784cc8e179aadc4Romain Guy 397694b519ac647fe998fd396fe0784cc8e179aadc4Romain Guy void checkInit(); 398671d6cf460531825a321edb200523d0faa7792c9Romain Guy void initRender(const Rect* clip, Rect* bounds); 399671d6cf460531825a321edb200523d0faa7792c9Romain Guy void finishRender(); 400694b519ac647fe998fd396fe0784cc8e179aadc4Romain Guy 401694b519ac647fe998fd396fe0784cc8e179aadc4Romain Guy void issueDrawCommand(); 4029777173eb6c9eb97c7921c8288ebc65e3ab3ce6fRomain Guy void appendMeshQuadNoClip(float x1, float y1, float u1, float v1, 4039777173eb6c9eb97c7921c8288ebc65e3ab3ce6fRomain Guy float x2, float y2, float u2, float v2, 4049777173eb6c9eb97c7921c8288ebc65e3ab3ce6fRomain Guy float x3, float y3, float u3, float v3, 4059777173eb6c9eb97c7921c8288ebc65e3ab3ce6fRomain Guy float x4, float y4, float u4, float v4, CacheTexture* texture); 406d71dd367af604571c7d00ca473184a1b9240eca2Romain Guy void appendMeshQuad(float x1, float y1, float u1, float v1, 407d71dd367af604571c7d00ca473184a1b9240eca2Romain Guy float x2, float y2, float u2, float v2, 408d71dd367af604571c7d00ca473184a1b9240eca2Romain Guy float x3, float y3, float u3, float v3, 4097de0cb12d0e5fd64811da0b5d1ae0c0d58b86f86Chet Haase float x4, float y4, float u4, float v4, CacheTexture* texture); 4109777173eb6c9eb97c7921c8288ebc65e3ab3ce6fRomain Guy void appendRotatedMeshQuad(float x1, float y1, float u1, float v1, 4119777173eb6c9eb97c7921c8288ebc65e3ab3ce6fRomain Guy float x2, float y2, float u2, float v2, 4129777173eb6c9eb97c7921c8288ebc65e3ab3ce6fRomain Guy float x3, float y3, float u3, float v3, 4139777173eb6c9eb97c7921c8288ebc65e3ab3ce6fRomain Guy float x4, float y4, float u4, float v4, CacheTexture* texture); 414694b519ac647fe998fd396fe0784cc8e179aadc4Romain Guy 4157de0cb12d0e5fd64811da0b5d1ae0c0d58b86f86Chet Haase uint32_t mSmallCacheWidth; 4167de0cb12d0e5fd64811da0b5d1ae0c0d58b86f86Chet Haase uint32_t mSmallCacheHeight; 417694b519ac647fe998fd396fe0784cc8e179aadc4Romain Guy 418694b519ac647fe998fd396fe0784cc8e179aadc4Romain Guy Vector<CacheTextureLine*> mCacheLines; 419694b519ac647fe998fd396fe0784cc8e179aadc4Romain Guy 42009147fbdc8206a0cac78bfe9083e7e15b3c5689cRomain Guy Font* mCurrentFont; 421694b519ac647fe998fd396fe0784cc8e179aadc4Romain Guy Vector<Font*> mActiveFonts; 422694b519ac647fe998fd396fe0784cc8e179aadc4Romain Guy 4237de0cb12d0e5fd64811da0b5d1ae0c0d58b86f86Chet Haase CacheTexture* mCurrentCacheTexture; 4247de0cb12d0e5fd64811da0b5d1ae0c0d58b86f86Chet Haase CacheTexture* mLastCacheTexture; 4257de0cb12d0e5fd64811da0b5d1ae0c0d58b86f86Chet Haase CacheTexture* mCacheTextureSmall; 4267de0cb12d0e5fd64811da0b5d1ae0c0d58b86f86Chet Haase CacheTexture* mCacheTexture128; 4277de0cb12d0e5fd64811da0b5d1ae0c0d58b86f86Chet Haase CacheTexture* mCacheTexture256; 4287de0cb12d0e5fd64811da0b5d1ae0c0d58b86f86Chet Haase CacheTexture* mCacheTexture512; 4297de0cb12d0e5fd64811da0b5d1ae0c0d58b86f86Chet Haase 4309b9902ddbb01548f4a0199087b7035e7c10b2ae7Alex Sakhartchouk void checkTextureUpdate(); 431694b519ac647fe998fd396fe0784cc8e179aadc4Romain Guy bool mUploadTexture; 432694b519ac647fe998fd396fe0784cc8e179aadc4Romain Guy 433694b519ac647fe998fd396fe0784cc8e179aadc4Romain Guy // Pointer to vertex data to speed up frame to frame work 434694b519ac647fe998fd396fe0784cc8e179aadc4Romain Guy float *mTextMeshPtr; 435694b519ac647fe998fd396fe0784cc8e179aadc4Romain Guy uint32_t mCurrentQuadIndex; 436694b519ac647fe998fd396fe0784cc8e179aadc4Romain Guy uint32_t mMaxNumberOfQuads; 437694b519ac647fe998fd396fe0784cc8e179aadc4Romain Guy 438694b519ac647fe998fd396fe0784cc8e179aadc4Romain Guy uint32_t mIndexBufferID; 439694b519ac647fe998fd396fe0784cc8e179aadc4Romain Guy 44009147fbdc8206a0cac78bfe9083e7e15b3c5689cRomain Guy const Rect* mClip; 4415b3b35296e8b2c8d3f07d32bb645d5414db41a1dRomain Guy Rect* mBounds; 4425b3b35296e8b2c8d3f07d32bb645d5414db41a1dRomain Guy bool mDrawn; 44309147fbdc8206a0cac78bfe9083e7e15b3c5689cRomain Guy 444694b519ac647fe998fd396fe0784cc8e179aadc4Romain Guy bool mInitialized; 44589a524ac2d4a36739e51b01b336c0bade77e2ee0Alex Sakhartchouk 446e8cb9c14309b0f01c0159efdf9a7198f44a62642Romain Guy bool mLinearFiltering; 447e8cb9c14309b0f01c0159efdf9a7198f44a62642Romain Guy 44889a524ac2d4a36739e51b01b336c0bade77e2ee0Alex Sakhartchouk void computeGaussianWeights(float* weights, int32_t radius); 44989a524ac2d4a36739e51b01b336c0bade77e2ee0Alex Sakhartchouk void horizontalBlur(float* weights, int32_t radius, const uint8_t *source, uint8_t *dest, 4501e45aae5de003657e5d18f74d34998f5de5db5b7Romain Guy int32_t width, int32_t height); 45189a524ac2d4a36739e51b01b336c0bade77e2ee0Alex Sakhartchouk void verticalBlur(float* weights, int32_t radius, const uint8_t *source, uint8_t *dest, 4521e45aae5de003657e5d18f74d34998f5de5db5b7Romain Guy int32_t width, int32_t height); 45389a524ac2d4a36739e51b01b336c0bade77e2ee0Alex Sakhartchouk void blurImage(uint8_t* image, int32_t width, int32_t height, int32_t radius); 454694b519ac647fe998fd396fe0784cc8e179aadc4Romain Guy}; 455694b519ac647fe998fd396fe0784cc8e179aadc4Romain Guy 456694b519ac647fe998fd396fe0784cc8e179aadc4Romain Guy}; // namespace uirenderer 457694b519ac647fe998fd396fe0784cc8e179aadc4Romain Guy}; // namespace android 458694b519ac647fe998fd396fe0784cc8e179aadc4Romain Guy 4595b3b35296e8b2c8d3f07d32bb645d5414db41a1dRomain Guy#endif // ANDROID_HWUI_FONT_RENDERER_H 460