History log of /frameworks/base/libs/hwui/font/CacheTexture.cpp
Revision Date Author Comments (<<< Hide modified files) (Show modified files >>>)
253f2c213f6ecda63b6872aee77bd30d5ec07c82 29-Sep-2016 Romain Guy <romainguy@google.com> Linear blending, step 1

NOTE: Linear blending is currently disabled in this CL as the
feature is still a work in progress

Android currently performs all blending (any kind of linear math
on colors really) on gamma-encoded colors. Since Android assumes
that the default color space is sRGB, all bitmaps and colors
are encoded with the sRGB Opto-Electronic Conversion Function
(OECF, which can be approximated with a power function). Since
the power curve is not linear, our linear math is incorrect.
The result is that we generate colors that tend to be too dark;
this affects blending but also anti-aliasing, gradients, blurs,
etc.

The solution is to convert gamma-encoded colors back to linear
space before doing any math on them, using the sRGB Electo-Optical
Conversion Function (EOCF). This is achieved in different
ways in different parts of the pipeline:

- Using hardware conversions when sampling from OpenGL textures
or writing into OpenGL frame buffers
- Using software conversion functions, to translate app-supplied
colors to and from sRGB
- Using Skia's color spaces

Any type of processing on colors must roughly ollow these steps:

[sRGB input]->EOCF->[linear data]->[processing]->OECF->[sRGB output]

For the sRGB color space, the conversion functions are defined as
follows:

OECF(linear) :=
linear <= 0.0031308 ? linear * 12.92 : (pow(linear, 1/2.4) * 1.055) - 0.055

EOCF(srgb) :=
srgb <= 0.04045 ? srgb / 12.92 : pow((srgb + 0.055) / 1.055, 2.4)

The EOCF is simply the reciprocal of the OECF.
While it is highly recommended to use the exact sRGB conversion
functions everywhere possible, it is sometimes useful or beneficial
to rely on approximations:

- pow(x,2.2) and pow(x,1/2.2)
- x^2 and sqrt(x)

The latter is particularly useful in fragment shaders (for instance
to apply dithering in sRGB space), especially if the sqrt() can be
replaced with an inversesqrt().

Here is a fairly exhaustive list of modifications implemented
in this CL:

- Set TARGET_ENABLE_LINEAR_BLENDING := false in BoardConfig.mk
to disable linear blending. This is only for GLES 2.0 GPUs
with no hardware sRGB support. This flag is currently assumed
to be false (see note above)
- sRGB writes are disabled when entering a functor (WebView).
This will need to be fixed at some point
- Skia bitmaps are created with the sRGB color space
- Bitmaps using a 565 config are expanded to 888
- Linear blending is disabled when entering a functor
- External textures are not properly sampled (see below)
- Gradients are interpolated in linear space
- Texture-based dithering was replaced with analytical dithering
- Dithering is done in the quantization color space, which is
why we must do EOCF(OECF(color)+dither)
- Text is now gamma corrected differently depending on the luminance
of the source pixel. The asumption is that a bright pixel will be
blended on a dark background and the other way around. The source
alpha is gamma corrected to thicken dark on bright and thin
bright on dark to match the intended design of fonts. This also
matches the behavior of popular design/drawing applications
- Removed the asset atlas. It did not contain anything useful and
could not be sampled in sRGB without a yet-to-be-defined GL
extension
- The last column of color matrices is converted to linear space
because its value are added to linear colors

Missing features:
- Resource qualifier?
- Regeneration of goldeng images for automated tests
- Handle alpha8/grey8 properly
- Disable sRGB write for layers with external textures

Test: Manual testing while work in progress
Bug: 29940137

Change-Id: I6a07b15ab49b554377cd33a36b6d9971a15e9a0b
/frameworks/base/libs/hwui/font/CacheTexture.cpp
ee6aca55bd4d0e785823c672c557af5c477d5058 13-Sep-2016 sergeyv <sergeyv@google.com> HWUI: calculate used memory in FontCache for gfxinfo am: baf29e7cf4
am: c60abfb739

Change-Id: I3f8202348a97c69d080b69329b23e388aec06f17
baf29e7cf433624687c9d6b3bac180d33add8e0f 08-Sep-2016 sergeyv <sergeyv@google.com> HWUI: calculate used memory in FontCache for gfxinfo

bug:30427106
Change-Id: I653571d6a4e974e975fb0dc03fc2364eecbf2f84
/frameworks/base/libs/hwui/font/CacheTexture.cpp
ec45adde7096e9e4a69d62e21d67d6062fc43a75 16-Jun-2016 ywen <ywen@codeaurora.org> Merge \"Performance Optimization: Align texture dirty rect\"
am: 4e6a73c16a

Change-Id: I2bafdfadd3d6ff88be44475f77158236015acfde
229cad0ab219289adf34a8f40c3237b688b6a764 15-Feb-2016 ywen <ywen@codeaurora.org> Performance Optimization: Align texture dirty rect

Align x offset and width to 32, y offset and height to 4.
It improves the font texture upload performance.

Change-Id: I967eeed90658f2ce1eb08cb2740d5dc34c72f40b
/frameworks/base/libs/hwui/font/CacheTexture.cpp
38e0c32852e3b9d8ca4a9d3791577f52536419cb 10-Nov-2015 John Reck <jreck@google.com> Track texture memory globally

Also mostly consolidates texture creation

Change-Id: Ifea01303afda531dcec99b8fe2a0f64cf2f24420
/frameworks/base/libs/hwui/font/CacheTexture.cpp
e6a15ee3d0c78eb3f2551d73a7d238c3d8d2f075 08-Jul-2015 Chris Craik <ccraik@google.com> Remove all usage of fmin and fmax

bug:22208220

Removes needless call, and upconversion to doubles in multiple places.

Change-Id: I1b949fa5f206446ac34de800154c0147d6bd8034
/frameworks/base/libs/hwui/font/CacheTexture.cpp
e2bb380bc26749782c873e5488cfdf4e42b27346 13-Mar-2015 Chris Craik <ccraik@google.com> Use glops for text rendering

Change-Id: I5e155c8baf3149f0ff231ec3c89dbff6bb8eae92
/frameworks/base/libs/hwui/font/CacheTexture.cpp
117bdbcfa3e8306dad21e7e01fa71b00cdfa7265 05-Feb-2015 Chris Craik <ccraik@google.com> Glop ColorFilter & VertexBuffer support, initial enable

Enables Glop rendering for supported Rects and VertexBuffers
Also removes unused Query object

Change-Id: Ibe227bc362685a153159f75077664f0947764e06
/frameworks/base/libs/hwui/font/CacheTexture.cpp
44eb2c00861098dd3e2950d923646814b4cc57c2 29-Jan-2015 Chris Craik <ccraik@google.com> Refactor blending and texture gl state

Change-Id: Ia6b3c8b2afd3dfcee7f3ce401d846b789612054a
/frameworks/base/libs/hwui/font/CacheTexture.cpp
d41c4d8c732095ae99c955b6b82f7306633004b1 06-Jan-2015 Chris Craik <ccraik@google.com> Add overrides and switch to nullptr keyword for all files

Adds remaining missing overrides and nullptr usages, missed due to
an extreme failure in tool usage.

Change-Id: I56abd72975a3999ad13330003c348db40f59aebf
/frameworks/base/libs/hwui/font/CacheTexture.cpp
2dc236b2bae13b9a0ed9b3f7320502aecd7983b3 15-Oct-2014 Tom Hudson <tomhudson@google.com> Clean up physical coupling

Narrow the use of #include directives in hwui, replacing with forward
declarations where straightforward. Speeds compiles; doesn't do any
restructuring of code.

Change-Id: Icac2baffb5896f55d8c6718e9bd9d4bfa02d3ca0
/frameworks/base/libs/hwui/font/CacheTexture.cpp
e63f7c622a2086aefa80983c6f41b74fb166bb42 17-Oct-2013 Chris Craik <ccraik@google.com> Clean unused parameters, disable warnings

Change-Id: Iddb872f53075dd022eeef45265594d1c6a9e2bc0
/frameworks/base/libs/hwui/font/CacheTexture.cpp
318ae7bb92869d99a05388c598ad105e7aa4cdbd 25-Sep-2013 Romain Guy <romainguy@google.com> Take SkBitmap's stride into account when uploading textures
Bug #10151807

Change-Id: I7ba4804fa3619088fea70eb55f10519fff0bf5f0
/frameworks/base/libs/hwui/font/CacheTexture.cpp
723b2feb929b96b1dde40a865c49ea18bc42f055 12-Aug-2013 Victoria Lease <violets@google.com> fix kBW_Format glyphs

Oops! kBW_Format was omitted from a couple of switch statements,
resulting in glyphs in that format being invisible.

Bug: 10206452
Change-Id: Ib2aa52250aeeecc0de1b1b78e3d0f568f368c73e
/frameworks/base/libs/hwui/font/CacheTexture.cpp
1e546815bbb736c50679a8aefc25f48561026fc5 25-Jun-2013 Victoria Lease <violets@google.com> Support RGBA fonts and bitmap fonts (and RGBA bitmap fonts)

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
/frameworks/base/libs/hwui/font/CacheTexture.cpp
be1b127c7bec252e0c6ab0e06ed6babed07d496f 06-Jun-2013 Romain Guy <romainguy@google.com> Assume a texture is unbound after deleting it
Bug #9316260

The GL specification indicates that deleting a bound texture has
the side effect of binding the default texture (name=0). This change
replaces all calls to glDeleteTextures() by Caches::deleteTexture()
to properly keep track of texture bindings.

Change-Id: Ifbc60ef433e0f9776a668dd5bd5f0adbc65a77a0
/frameworks/base/libs/hwui/font/CacheTexture.cpp
8aa195d7081b889f3a7b1f426cbd8556377aae5e 05-Jun-2013 Romain Guy <romainguy@google.com> Introduce Caches::bindTexture() to reduce glBindTexture calls

Change-Id: Ic345422567c020c0a9035ff51dcf2ae2a1fc59f4
/frameworks/base/libs/hwui/font/CacheTexture.cpp
cf51a4199835e9604aa4c8b3854306f8fbabbf33 09-Apr-2013 Romain Guy <romainguy@google.com> Introduce PixelBuffer API to enable PBOs

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
/frameworks/base/libs/hwui/font/CacheTexture.cpp
0908764b2b3cf5075df4178a5f0a8547dcb7b317 04-Apr-2013 Romain Guy <romainguy@google.com> First OpenGL ES 3.0 based optimization

This change uses a new OpenGL ES 3.0 feature to upload less data when
the font cache needs to be update. This can result in significant
performance improvements on device with large textures or with locales
that use a lot of glyphs (CJK for instance.)

This change also fixes various unpack alignment issues. The unpack
alignment, as well as the unpack row length, is not texture specific
but a global state that affect all glTex/SubImage2D calls. Some of
them were missing the appropriate glPixelStorei() call. This could
result in corrupted textures.

Change-Id: Iefb429d4d0d0b4e0faeadf27daafee6d30a21d85
/frameworks/base/libs/hwui/font/CacheTexture.cpp
661a87ec28a49458f1faf533783abf2ab9927cab 19-Mar-2013 Romain Guy <romainguy@google.com> Reduce number of glDraw calls when drawing text

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
/frameworks/base/libs/hwui/font/CacheTexture.cpp
ca79cf69d09efa0c327e9b1237d86a119aea5da7 14-Aug-2012 Derek Sollenberger <djsollen@google.com> Update framework to support r5967 of Skia.

bug: 6906025
Change-Id: Iefdb830ec3aa2ab3472c1c142484a7aa21788a15
/frameworks/base/libs/hwui/font/CacheTexture.cpp
b92d8f7979c29c7c09932578a11b2f8d6eec1d90 21-Sep-2012 Chet Haase <chet@google.com> Optimize glyph cache texture uploads

Only upload the changed area of the glyph cache, not the entire
bitmap. Note that we can't do the full-on optimization here of copying a sub-rect
of the bitmap because of GL ES 2 limitations, but we can at least copy the
horizontal stripe containing the dirty rect, which can still be a big
savings over uploading the entire bitmap.

Issue #7158326 Bad framerates on MR1 (Mako, Manta, Prime)

Change-Id: Iab38d53202650f757ead4658cf4287bdad2b3cb9
/frameworks/base/libs/hwui/font/CacheTexture.cpp
e43f785b7ff3fdf75f6d1c92282ebca6db191f2f 05-Sep-2012 Romain Guy <romainguy@google.com> Correctly check the height of a glyph prior to caching it

Change-Id: Iaf3977afc20fcde65bfda7b9e092b3e723241684
/frameworks/base/libs/hwui/font/CacheTexture.cpp
9b1204baf4740b4d443e72157dea98571cf84e1f 05-Sep-2012 Romain Guy <romainguy@google.com> Small code cleanup in FontRenderer

Change-Id: I09c00debe9b0b4f45b232cae402ed19bdaeabfe4
/frameworks/base/libs/hwui/font/CacheTexture.cpp
9f5dab3fc228fa11c32b483e6101ec086895a32b 04-Sep-2012 Romain Guy <romainguy@google.com> Refactor FontRenderer.cpp

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
/frameworks/base/libs/hwui/font/CacheTexture.cpp