summaryrefslogtreecommitdiffstats
path: root/libs/hwui/FontRenderer.h
Commit message (Collapse)AuthorAgeFilesLines
* Handle updates to RS C++ API.Tim Murray2013-08-021-3/+5
| | | | Change-Id: I73127fc7369643b94d4a49f31a516b50c74b54ac
* Support RGBA fonts and bitmap fonts (and RGBA bitmap fonts)Victoria Lease2013-07-311-6/+44
| | | | | | | | | | | | | | | | | | | | | | | | | | | Quite a few things going on in this commit: - Enable bitmap strikes by default in Paint objects. The SkPaint parameter that enables bitmap strikes was not previously included in DEFAULT_PAINT_FLAGS. This effectively disabled bitmap fonts. Oops! It's for the best, though, as additional work was needed in Skia to make bitmap fonts work anyway. - Complain if TEXTURE_BORDER_SIZE is not 1. Our glyph cache code does not currently handle any value other than 1 here, including zero. I've added a little C preprocessor check to prevent future engineers (including especially future-me) from thinking that they can change this value without updating the related code. - Add GL_RGBA support to hwui's FontRenderer and friends This also happened to involve some refactoring for convenience and cleanliness. Bug: 9577689 Change-Id: I0abd1e5a0d6623106247fb6421787e2c2f2ea19c
* Share Caches' index buffer with FontRendererRomain Guy2013-06-181-5/+0
| | | | | | | | | This reduces state changes when we draw 9patches and text together, which happens *a lot*. Also disable the NV profiling extension by default since it doesn't play nice with display lists deferrals. To enable it set debug.hwui.nv_profiling to true. Change-Id: I518b44b7d294e5def10c78911ceb9f01ae401609
* libutils clean-upMathias Agopian2013-05-071-0/+1
| | | | Change-Id: I11ee943da23a66828455a9770fc3c5ceb4bbcaa9
* am 55b883b0: am 30c990c3: Merge "Draw Operation merging" into jb-mr2-devChris Craik2013-04-151-2/+4
|\ | | | | | | | | * commit '55b883b0a960b37aa453253f3ccb614dd95c221c': Draw Operation merging
| * Draw Operation mergingChris Craik2013-04-151-2/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Merge simple bitmap draw operations and text operations to avoid issuing individual gl draws for each operation. Merging other ops to be done eventually. The methods are different - the bitmap merging generates a single mesh for reused, unclipped images (esp. repeated images in a listview) The text approach queries just defers the normal font rendering until the last drawText in the sequence that can share the same shader. Patches are sorted and merged, but don't yet have a multiDraw implementation. For now, the pretending-to-merge gives better sorting behavior by keeping similar patches together. Change-Id: Ic300cdab0a53814cf7b09c58bf54b1bf0f58ccd6
* | resolved conflicts for merge of 886e1204 to masterRomain Guy2013-04-121-10/+2
|\ \ | |/ | | | | Change-Id: Id002d2ae799c6946672335f122ecbfa07d9c0bc1
| * Introduce PixelBuffer API to enable PBOsRomain Guy2013-04-111-10/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | PBOs (Pixel Buffer Objects) can be used on OpenGL ES 3.0 to perform asynchronous texture uploads to free up the CPU. This change does not enable the use of PBOs unless a specific property is set (Adreno drivers have issues with PBOs at the moment, Mali drivers work just fine.) This change also cleans up Font/FontRenderer a little bit and improves performance of drop shadows generations by using memcpy() instead of a manual byte-by-byte copy. On GL ES 2.0 devices, or when PBOs are disabled, a PixelBuffer instance behaves like a simple byte array. The extra APIs introduced for PBOs (map/unmap and bind/unbind) are pretty much no-ops for CPU pixel buffers and won't introduce any significant overhead. This change also fixes a bug with text drop shadows: if the drop shadow is larger than the max texture size, the renderer would leave the GL context in a bad state and generate 0x501 errors. This change simply skips drop shadows if they are too large. Change-Id: I2700aadb0c6093431dc5dee3d587d689190c4e23
* | Phase 1 of refactoring SystemServer.Dan Morrill2013-04-041-0/+4
|/ | | | | | | | | | SystemServer is currently a monolithic class that brings up key system services. This change is the first phase of refactoring it to be more configurable. Specifically, it adds a set of on/off switches used to control startup of individual services. Future plans include finer grained controls and a more explicit and consistent startup sequence for these services. Change-Id: I7299f5ce7d7b74a34eb56dffb788366fbc058532
* Optimize text GL setupRomain Guy2013-03-201-8/+7
| | | | | | | | Only performs the GL setup steps when at least one glyph is drawn. This change also skips various draw operations when the specified paint draws with alpha = 0. Change-Id: I9eda148b0503acffc552ee19196f5d52e958a1a2
* Reduce number of glDraw calls when drawing textRomain Guy2013-03-191-33/+0
| | | | | | | | This change moves the mesh buffer from FontRenderer to CacheTexture to help reduce the number of texture binds and glDraw calls when drawing text that spans across multiple textures. Change-Id: I7de574d88313ca3672879ca878c253ff5f131fc1
* Minimize texture binds when drawing textRomain Guy2013-03-191-3/+27
| | | | | | | | | | | When several CacheTextures are used to draw text, sort the draw batches by texture ID to minimize state changes in the driver. This change also tweaks the font cache size and renames a property that was too long to be set using setprop. Change-Id: I0a36dfffe58c9e75dd7384592d3343c192d042b1
* Revert "Revert "Use RenderScript for large text blurs""Chris Craik2013-02-131-2/+14
| | | | | | This reverts commit bf5703e52e3304246cbf0e73f6976f7d7312d238. Change-Id: Ic6f991277dec9e80a6fed93db91499726b30ab2a
* Revert "Use RenderScript for large text blurs"Chris Craik2013-02-131-14/+2
| | | | | | This reverts commit 3f76e65d251ead65fe8ff98e3bd4c7623fbaac07 Change-Id: Ia81cd485e5ca696bb284c419dc8a1d2f3247100e
* Use RenderScript for large text blursChris Craik2013-02-121-2/+14
| | | | | | Still fall back to simple path for small tasks Change-Id: I492f1b3f7d6fec1738f3e45cbfb15864bd23a392
* Add plumbing for better text scalingRomain Guy2013-01-081-6/+5
| | | | | | | | Fonts are now described by a transform matrix. This lead to switching from a vector to a hashmap. This change therefore adds new comparators and hash computations to Font. Change-Id: I2daffa7d6287c18554c606b8bfa06640d28b4530
* Another optimization of glyph cache uploadsSangkyu Lee2012-11-281-1/+6
| | | | | | | | | | | | Previously, cache textures were updated whenever mCurrentCacheTexuture was changed. Since updating cache textures needs glTexSubImage2D call, frequent changing of mCurrentCacheTexture (which can easily happen when an app uses lots of unique glyphs even with precaching) caused many glTexSubImage2D calls and bad framerates. This patch optimized isssueDrawCommand function. Consequently, changing mCurrentCacheTexture doesn't cause glTexSubImage2D call any more and it will improve font rendering performance. Change-Id: Id19d959fa0e69eeb2a39f83a57e311d7394586b2 Signed-off-by: Sangkyu Lee <geteuid@gmail.com>
* Code cleanup in FontRendererRomain Guy2012-09-041-12/+5
| | | | Change-Id: Ic788721c224a77f0a76f4cd6d9817b62e390a5a7
* Small code cleanup in FontRendererRomain Guy2012-09-041-7/+15
| | | | Change-Id: I09c00debe9b0b4f45b232cae402ed19bdaeabfe4
* Refactor FontRenderer.cppRomain Guy2012-09-041-250/+4
| | | | | | | | FontRenderer.h defined several classes and structures that now live in the font/ folder. This will make the code easier to read and maintain. Change-Id: I3dc044e9bde1d6515f8704f5c72462877d279fe2
* Paramaterize and adjust the glyph cache sizesChet Haase2012-08-311-0/+2
| | | | | | | | | Add new parameters for the texture size used for the larger, fallback caches. Bump up the defaults in some situations. Issue #7045164 Adjust cache sizes for manta Change-Id: I562118ce785d7f8b6e445178878672e9709d25f2
* Avoid thrashing the glyph cache during the precache phaseChet Haase2012-08-301-4/+5
| | | | | | | | | | | | | | | | | | | It is unlikely, but possible, to draw so many glyphs in a frame (especially of the glyphs are quite large) that the cache starts flushing itself to fit the later glyphs in. This causes unnecessary thrashing, because when we actually draw the frame, we will again need to flush to fit the earlier glyphs in, and then flush again to fit the later ones in. It is better to avoid thrashing the cache at the precache phase, and wait until we actually draw the glyphs that do not fit to do any eviction of the earlier glyphs. This change simply notes when we are in the preaching phase, and avoids flushing the cache when a glyph does not fit. Issue #7081725 avoid thrashing cache during DisplayList recording Change-Id: I230410ab5b478091b1032fa99dc1752acf868bbe
* Remove CacheTextureLine structure from FontRendererChet Haase2012-08-161-58/+30
| | | | | | | | | | | | | | | | | CacheTextureLine was useful before we were packing the glyph textures; it allowed simple packing of any particular texture according to how many lines there were in a texture, and how tall those lines were. Now that we are packing more efficiently (both horizontally and vertically in any given texture line), it is more efficient to have open space in every texture, removing the need for CacheTextureLine (which now gets in the way since it limits how much can be stored in each line). This change removes CacheTextureLine and just uses CacheTexture directly, allowing caching of glyphs anywhere in the open space of each texture. As before, the packing of these glyphs is determined by the CacheBlock structure, which is a linked list of open spaces in each CacheTexture. Change-Id: Id6f628170df0f676f8743ac7de76f2377fc6a012
* Optimize interactions with glyph cacheChet Haase2012-08-141-6/+74
| | | | | | | | | | | | | | | | | There are two fixes here: - precaching: instead of caching-then-drawing whenever there is a new glyph, we cache at DisplayList record time. Then when we finally draw that DisplayList, we just upload the affected texture(s) once, instead of once per change. This is a huge savings in upload time, especially when there are larger glyphs being used by the app. - packing: Previously, glyphs would line up horizontally on each cache line, leaving potentially tons of space vertically, especially when smaller glyphs got put into cache lines intended for large glyphs (which can happen when an app uses lots of unique glyphs, a common case with, for example, chinese/japanese/korean languages). The new approach packs glyphs vertically as well as horizontally to use the space more efficiently and provide space for more glyphs in these situations. Change-Id: I84338aa25db208c7bf13f3f92b4d05ed40c33527
* Merge "Add drop shadow for drawPosText in hwui renderer."Raph Levien2012-07-201-2/+2
|\
| * Add drop shadow for drawPosText in hwui renderer.Raph Levien2012-07-201-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch adds support for drop shadows (setShadowLayer) for drawPosText in the hwui renderer. In and of itself, it's not very important, but it's on the critical path for correct mark positioning, tracked as bug 5443796. The change itself is fairly straightforward - it basically just adds an extra "positions" argument to all draw and measure methods on the code path for drawing drop shadowed text, as well as to the cache key for cached shadow textures. Change-Id: Ic1cb63299ba61ccbef31779459ecb82aa4a5e672
* | Fix crash with new LookupGammaFontRendererRomain Guy2012-07-201-3/+2
|/ | | | | | Bug #6853934 Change-Id: I15e6ca73bfe00eff1a37c4b9d2f7f709ee018eb6
* Forget the name of a texture after freeingRomain Guy2012-05-141-2/+2
| | | | | | | | | | | | | | | | | Bug #6408362 FontRenderer allocates large font textures when more room is needed to store all the glyphs used by an application. Thse large textures are the first to be freed when memory needs to be reclaimed by the system. When freeing a texture, the renderer would however not set the texture name to an invalid name, leading future allocations to be performed on the same texture name. That name could have by then be recycled by the driver and returned by a call to glGenTexture and used to create an entirely different texture. This would cause the font renderer to point to the wrong texture, thus leading to the "corruptions." Change-Id: I8a1e80e5b79e8f21d1baf5320c090df4f2066cd4
* Fix two memory leaksRomain Guy2012-05-141-6/+6
| | | | | | Bug #6408362 Change-Id: I58543938e7b64d83504e11e97b0dd21ef8ebf3b6
* Properly pre-cache latin glyphsRomain Guy2012-05-141-4/+5
| | | | | | Bug #6408362 Change-Id: Ie11644c5a9e2d87d3b851b7e619e5f04b60a7e02
* Full implementation of Canvas.drawPath()Romain Guy2012-02-291-1/+19
| | | | Change-Id: I23223b89770a0cd2b4762365bead9bfddb094290
* Full support for Canvas.drawPosTextRomain Guy2012-01-181-6/+24
| | | | | | This also introduces a small optimization when rendering text. Change-Id: Iff620ac97bf878eaac406bccc6daa07052c93890
* De-allocate caches for large glyphs when trimming memoryChet Haase2011-12-161-1/+3
| | | | | | | | | | | | | Currently, font renderers eliminate some texture caches when memory is trimmed. This change makes it go further by eliminating the large-glyph caches for all font renderers. These caches are only allocated as needed, but continue to consume large amounts of memory (CPU and GPU) after that allocation. De-allocating this memory on a trim operation should prevent background apps from holding onto this memory in the possible case that they have allocated it by drawing large glyphs. Change-Id: Id7a3ab49b244e036b442d87252fb40aeca8fdb26
* Fix issues from recent glyph caching changeChet Haase2011-12-151-4/+6
| | | | | | | | | | | | | There were 2 issues remaining after a recent change to support glyph caching from multiple textures: - memory in the GPU for all textures was being allocated automatically. This is now lazy, being allocated only when those textures are first needed. - filtering (applied when a rendered object is transformed) was ignoring the new multiple-texture structure. Filtering should be applied correctly whenever we change textures. Change-Id: I5c8eb8d46c73cd01782a353fc79b11cacc2146ab
* Merge "Make glyph cache more flexible"Chet Haase2011-12-131-79/+104
|\
| * Make glyph cache more flexibleChet Haase2011-12-131-79/+104
| | | | | | | | | | | | | | | | | | | | Some GPU architectures could not handle the previous implementation of our glyph cache. Frequent uploads would cause memory problems in the GPU and eventually a crash due to these memory issues. The solution is to move to a system of several, smaller caches instead of one monolythic cache for all glyphs. Change-Id: I0fc7a323360940d16d5a33eeb33abfab194c5920
* | Reduce the number of GL commands generated by the UIRomain Guy2011-12-131-9/+0
|/ | | | | | | | This optimization along with the previous one lets us render an application like Gmail using only 30% of the number of GL commands previously required Change-Id: Ifee63edaf495e04490b5abd5433bb9a07bc327a8
* Optimize state changesRomain Guy2011-12-121-6/+7
| | | | Change-Id: Iae59bc8dfd6427d0967472462cc1994987092827
* Minimize the amount of data uploaded to draw textRomain Guy2011-12-121-3/+4
| | | | Change-Id: I6313ac039291c9cd93aadafe3566ad9d60cab42d
* Paint style and stroke width affect text rendering.Romain Guy2011-08-021-2/+5
| | | | | | Bug #5112207 Change-Id: Ic34037ace21a5058ba23dd15e51aae58c998454d
* Add support to OpenGLRendere to draw BiDi text.Romain Guy2011-06-011-13/+48
| | | | | | Bug #4350336 Change-Id: I1cf31693f7ca9653fa3a41b5b91c27ef288d680f
* Enable large font rendering with GPU accelerationChet Haase2011-05-191-1/+1
| | | | Change-Id: I7b022100fb0762613f9cf7753dbb0217e1e75f8d
* Take fake bold font property into account.Romain Guy2011-03-231-1/+1
| | | | | | | | Bug #4159731 For real this time! Change-Id: I9cb6d70e68d2b57eb9a6d9a6bca8176967192421
* Fix problem with glyph cache and textScaleX propertyChet Haase2011-03-021-2/+4
| | | | | | | | | | Glyphs drawn with paints that had different textScaleX values were not being recognized as different, so the glyph cache was being used regardless of different scaleX values. This change adds the scaleX attribute to the native Font object to allow the cache to distinguish between this difference and cache accordingly. Change-Id: I5d8fc26d47460b27dc8e373a473d46b2f1b8dc30
* Fixing font renderer attribute slot locations.Alex Sakhartchouk2011-02-171-0/+8
| | | | Change-Id: I6377bb641df7d8372d873c00790189f9a190afd6
* Add support for Paint::setTextSkewX in OpenGLRenderer.Romain Guy2011-01-181-2/+4
| | | | | | Bug #3360888 Change-Id: I42e81a1f10bf7b9ae1c63ca8add1878fd59a1e8a
* The font cache should respect the fake bold flag.Romain Guy2011-01-051-2/+7
| | | | Change-Id: Ie4edc9ba46610edde831b55e769944e9a19bdcb5
* Move all debug flags in a single place.Romain Guy2010-11-101-8/+8
| | | | | | | | | | | | | | | | | | | | | | | | This change also adds a new memory usage flag. When turned on, the following is printed after every frame: D/OpenGLRenderer( 3723): Current memory usage / total memory usage (bytes): D/OpenGLRenderer( 3723): TextureCache 3766680 / 20971520 D/OpenGLRenderer( 3723): LayerCache 3538944 / 8388608 D/OpenGLRenderer( 3723): GradientCache 135168 / 524288 D/OpenGLRenderer( 3723): PathCache 41180 / 4194304 D/OpenGLRenderer( 3723): TextDropShadowCache 0 / 2097152 D/OpenGLRenderer( 3723): FontRenderer 0 262144 / 262144 D/OpenGLRenderer( 3723): FontRenderer 1 262144 / 262144 D/OpenGLRenderer( 3723): FontRenderer 2 262144 / 262144 D/OpenGLRenderer( 3723): Other: D/OpenGLRenderer( 3723): FboCache 2 / 12 D/OpenGLRenderer( 3723): PatchCache 31 / 512 D/OpenGLRenderer( 3723): Total memory usage: D/OpenGLRenderer( 3723): 8268404 bytes, 7.89 MB This should help tracking possibe memory issues. Change-Id: I83f483ca1d2dbef904829bce368e33fe5503e8d6
* Optimize FBO drawing with regions.Romain Guy2010-11-021-5/+7
| | | | | | | | | This optimization is currently disabled until Launcher is modified to take advantage of it. The optimization can be enabled by turning on RENDER_LAYERS_AS_REGIONS in the OpenGLRenderer.h file. Change-Id: I2fdf59d0f4dc690a3d7f712173ab8db3848b27b1
* Apply bilinear filtering on text only when necessary.Romain Guy2010-10-041-1/+11
| | | | Change-Id: Ic903f4b5d30e9c92528c6291941896efe4729ee3