summaryrefslogtreecommitdiff
path: root/libs/hwui/GradientCache.cpp
AgeCommit message (Collapse)Author
2018-05-03remove (dead) caches from hwuiMike Reed
Test: make Change-Id: I18bfe51896672272ce7d471eaead69b651399368
2017-11-03Format the world (or just HWUI)John Reck
Test: No code changes, just ran through clang-format Change-Id: Id23aa4ec7eebc0446fe3a30260f33e7fd455bb8c
2017-07-19Delete all ro.hwui.* propsJohn Reck
Remove all ro.hwui.* tuning props and instead calculate them from the screen resolution. Or just hardcode them to what all devices were hardcoding them to anyway. Bug: 63741221 Test: Check cache size results on sailfish Change-Id: I8b0d210572a246f4fefb076935cf5156a70c274c
2017-04-04Fix HWUI/Skia Gradients to premultiply the colors prior to interpolationDerek Sollenberger
This is fixed in Skia by passing the appropriate flag when the shader is generated. The fix in HWUI is to reverse the premultiplication and interpolation steps. Test: bit CtsUiRenderingTestCases:.testclasses.ShaderTests Bug: 34323783 Change-Id: I3417141949f62fcc696b6d8213a4b446d7d0cbf8
2017-03-16Bowing my head in shame, going back to gamma interpolated gradientsRomain Guy
Frankengradients (linearly interpolated RGB, gamma interpolated alpha) look fantastic but unfortunately create sligh compatibility issues. For instance, a gradient from 0xffea1030 to 0x00ea1030 (opaque to alpha, with a single color) blended on top of 0xff101010 would not look the same as a single opaque gradient from 0xffea1030 to 0xff101010. The difference is hardly noticeable on simple gradients but it could cause confusion amongst app developers. Their life is hard enough as it is, let's be good to them. My crusade against the gamma world is not over and one day I shall be the victor. I am patience. Bug: 35485208 Test: UiRendering.ShaderTests, UiRendering.GradientTests, manual testing Change-Id: I8204e60cdf0a6b12dfe22638d30ca9622687000e
2017-03-06Add ColorSpace information on BitmapRomain Guy
This is the first step toward interpreting color spaces at render time. Bug: 32984164 Test: BitmapColorSpaceTest in CtsGraphicsTestCases Change-Id: I0164a18f1ed74a745874fe5229168042afe27a04
2017-02-03Gradients are now an absurd ChimeraRomain Guy
As of O, gradients are interpolated in linear space. This unfortunately affects applications that were expecting a certain behavior for the alpha ramp. This change attempts to get the best of both world: better color interpolation (in linear space) and the old alpha interpolation (in gamma space). This is achieved by applying the electro-optical transfer function to the alpha channel; an idea so wrong it would make any graphics programmer worth his salt weep in disgust. As abhorrent this idea might be to me, it also acts as a faint beacon of hope admist the unfathomable darkness that is Android's color management. And if you allow me another misguided metaphor, this change represents the flotsam I can cling onto in the hope to one day reach the bountiful shores of linear blending and accurate color management. Would this change not fix the distress caused by its predecessors, I will have no choice but bow my head in shame until the day I can finally devise an infallible plan. Bug: 33010587 Test: CtsUiRenderingTestCases Change-Id: I5397fefd7944413f2c820e613a5cba50579d4dd5
2016-12-12Pre-multiply gradient colors the right wayRomain Guy
Alpha pre-multiplication must be done after applying the opto-electronic transfer function when linear blending is disabled. The correct way would be to pre-multiply before gamma encoding but this leads to improper blending which cannot be corrected without using sRGB frame buffers and texture sampling. Bug: 33010587 Test: cts-tradefed run singleCommand cts-dev --module CtsUiRenderingTestCases --test android.uirendering.cts.testclasses.GradientTests Change-Id: I5f04bda4cb9f63674537aef5931621c14d601884
2016-10-12Don't apply the OECF twice to multi-stop gradientsRomain Guy
Test: Manual Change-Id: Icd65d906df2f0a059373edb8c6d55fe378c92f92
2016-10-12Various fixes for linear blending and gradientsRomain Guy
With linear blending turned off some textures were still created as sRGB textures instead of linear textures. Multi-stop gradients were not behaving properly on devices with no support for float textures. Gradients are now always interpolated in linear space even if linear blending is off. New functions to always force sRGB->linear->sRGB conversions. Test: Manual testing Bug: 29940137 Change-Id: Ie2f84ee2a65fd85570e88af813e841e0e625df6c
2016-10-11Linear blending, step 1Romain Guy
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
2016-02-11Fix buildJohn Reck
Change-Id: Id793d3a824902ab794b5d5a4cdf4c77a72c52add
2016-02-11Fix bpp mismatchJohn Reck
Bug: 26980851 GL_RGBA16F was being incorrectly calculated as 4 bpp instead of 16 in Texture's objectSize(), leading to a mismatch in cache size tracking in GradientCache Change-Id: I533c52fcdf9910d7a7d14bbd80965b8cbef8e147
2016-02-06Merge "Move several property queries to Properties class"Chris Craik
2016-02-05Move several property queries to Properties classChris Craik
bug:17478770 This removes a lot of redundant property query code, and puts the queries all in one place, so defining them automatically will be simpler in the future. Change-Id: I0428550e6081f07bc6554ffdf73b22284325abb8
2016-02-05Add a debug assert to track down infinite loopJohn Reck
Bug: 26980851 Change-Id: I326983ab367782048311b6cf06d800f72837e38e
2016-01-20Normalize GL_UNPACK_ALIGNMENTJohn Reck
Several places were setting GL_UNPACK_ALIGNMENT unneccessarily, whereas other places were assuming an unpack alignment of 1. Since we never actually do explicit row-alignment, set GL_UNPACK_ALIGNMENT to 1 at context creation time and never change it Bug: 26584230 Also turns on aggressive glGetError checking to better catch potential problem zones Change-Id: I190c8f0f0494a7f046d5ed769405c75d363be59a
2016-01-19Fix ordering of texture->upload argumentsJohn Reck
Caught by scatter-shotting GL_CHECKPOINTS which seem generally useful to have Bug: 26609444 Change-Id: Ie31d9297d8dae56405126720f338b4256c8bae77
2016-01-14Track texture memory globallyJohn Reck
Also mostly consolidates texture creation Change-Id: Ifea01303afda531dcec99b8fe2a0f64cf2f24420
2015-11-03Remove almost-all android::Singleton usersJohn Reck
Bug: 25426213 Change-Id: I88e6206e8915cce95c3a8a8a82a4bb8fbf668141
2015-07-14Clean up unncessary definesChris Craik
LOG_TAG and TRACE_TAG are already defined in the makefile Change-Id: I9e53e3dacbe018441edd74cb7c8c90846defee74
2015-02-23Simplify Texture member initializationChris Craik
Change-Id: Iaaa6dd20e64a0a075d732b101e3c4278cad44047
2015-02-06Glop ColorFilter & VertexBuffer support, initial enableChris Craik
Enables Glop rendering for supported Rects and VertexBuffers Also removes unused Query object Change-Id: Ibe227bc362685a153159f75077664f0947764e06
2015-01-30Refactor blending and texture gl stateChris Craik
Change-Id: Ia6b3c8b2afd3dfcee7f3ce401d846b789612054a
2015-01-05Add overrides and switch to nullptr keyword for all filesChris Craik
Adds remaining missing overrides and nullptr usages, missed due to an extreme failure in tool usage. Change-Id: I56abd72975a3999ad13330003c348db40f59aebf
2014-12-23Cleanup various clang warnings, use unique_ptrs in several placesChris Craik
Change-Id: I347904b25e51fcc7de14b1e72f1acd0f6ba26f3f
2013-10-17Clean unused parameters, disable warningsChris Craik
Change-Id: Iddb872f53075dd022eeef45265594d1c6a9e2bc0
2013-06-13Add new Query class for debuggingRomain Guy
This class can be used to perform occlusion queries. An occlusion query can be used to test whether an object is entirely hidden or not. Change-Id: Ida456df81dbe008a64d3ff4cb7879340785c6abf
2013-06-06Assume a texture is unbound after deleting itRomain Guy
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
2013-06-04Introduce Caches::bindTexture() to reduce glBindTexture callsRomain Guy
Change-Id: Ic345422567c020c0a9035ff51dcf2ae2a1fc59f4
2013-04-12Properly computer gradient textures widthRomain Guy
Only on devices that do not have the npot extension Change-Id: I472a13dc707d2abaf5fcc06f99c9da343b333558
2013-04-05Use float textures to render gradients when possibleRomain Guy
Float textures offer better precision for dithering. In addition this change removes two uniforms from gradient shaders. These uniforms were used to dither gradients but their value is a build time constant. Instead we hardcode the value directly in the shader source at compile time. Change-Id: I05e9fd3eef93771843bbd91b453274452dfaefee
2013-03-11Precache paths from a worker threadRomain Guy
Change-Id: I3e7b53d67e0e03e403beaf55c39350ead7f1e309
2013-02-07Add a RenderBuffer object to store stencil buffers.Romain Guy
Bug #7146141 This change is needed to add a render buffer cache to avoid creating and destroying stencil buffers on every frame. This change also allows the renderer to use a 1 bit or 4 bit stencil buffer whenever possible. Finally this change fixes a bug introduced by a previous CL which causes the stencil buffer to not be updated in certain conditions. The fix relies on a new optional parameter in drawColorRects() that can be used to avoid performing a quickReject on rectangles generated by the clip region. Change-Id: I2f55a8e807009887b276a83cde9f53fd5c01199f
2013-01-03Remove unnecessary & uninitialized variableRomain Guy
Bug #7728929 The uninitialized variable was taken into account to compute the hash of gradient cache entries, thus causing cache corruptions and sometimes infinite loops (it would also cause the cache to fill up.) Change-Id: Ic807a9bf901888b121a6a781a81dafc33075ed2a
2012-11-29Use LruCache instead of GenerationCache in libhwuiRomain Guy
Change-Id: Ic26ddc7151eb5462bcd243b21daf7187ed6d3bec
2012-08-31Revert "Add more support for transformed clip rects and paths"Mathias Agopian
this introduced a dead lock in GradientCache's ctor. This reverts commit dfe082f63e94cde9aee271c94d13de5e7217e036. Bug: 7096001 Change-Id: I57b8bbab11fb7cb502fa58e3bbf5d19864db874f
2012-08-31Add more support for transformed clip rects and pathsRomain Guy
Change-Id: I41791b1e1bffef77d503dc9e52428395d2309688
2012-08-29Pre-multiply color components for 2-stop gradientsRomain Guy
Bug #7033344 Change-Id: Ia168501f1dc56ba7a1bb0c55078320432309a66a
2012-08-08Reduce gradients textures size whenever possibleRomain Guy
Change-Id: Ifd58625ee62edac3b5d20b77553cb98b6fa2b46e
2012-07-31Improve gradientsRomain Guy
Avoid using textures for common gradients (two stops from 0.0 to 1.0) Change-Id: Iff55d21b126c8cfc4cfb701669f2339c8f6b131a
2012-07-20Make gradients look slightly betterRomain Guy
Change-Id: Ib12c628a88b9ec6af1214ce6e5cb14cfde40485e
2012-07-20Clamp gradient textures to max GL texture sizeRomain Guy
Change-Id: I8ce4e50988f5194fe5ce4bde7945ec01673af3cd
2012-07-18Optimize gradient texturesRomain Guy
Compute the size of the backing textures based on the maximum possible number of shades in the gradient. Change-Id: I2d7f20477d31b81e9735f2c1d83ebdd0dbcbe340
2012-01-08Rename (IF_)LOGE(_IF) to (IF_)ALOGE(_IF) DO NOT MERGESteve Block
See https://android-git.corp.google.com/g/#/c/157220 Bug: 5449033 Change-Id: Ic9c19d30693bd56755f55906127cd6bd7126096c
2011-12-12Various OpenGL optimizationsRomain Guy
Change-Id: Ib0742c96f10f5f50e7e5148b742c31b6c232d127
2011-08-01Reduce the amount of data cached by the gradients cache.Romain Guy
Change-Id: I8546f5a5ecf38031c9a40bdcc434d4c7f22da63d
2011-07-25Improve rendering performance on some GPUsRomain Guy
This change sets textures filtering to GL_NEAREST by default. GL_LINEAR filtering is only used when textures are transformed with a scale or a rotation. This helps save a couple of fps on some GPUs. Change-Id: I1efaa452c2c79905f00238e54d886a37203a2ac1
2011-01-21Log only 1 line per process when using OpenGLRenderer.Romain Guy
Change-Id: Idbdd6b84f31301e58ed53e0d50fd61fece192dfa
2010-11-11Free resources only from the GL context thread.Romain Guy
Bug #3179882 Resources were freed following garbage collections on a worker thread. This worker thread had no EGL context, which would cause the renderer to incorrectly assume that the memory was liberated. Change-Id: Ifdb51f94ddf42641e8654522787bfac532976c7c