summaryrefslogtreecommitdiff
path: root/libs/hwui/ProgramCache.cpp
AgeCommit message (Collapse)Author
2018-05-03remove (dead) caches from hwuiMike Reed
Test: make Change-Id: I18bfe51896672272ce7d471eaead69b651399368
2018-03-28Change shader precision because of CTS Fail.dohyunia.kim
Change-Id: I5d8747ecf9091a251b56d3a9de4bdb8ab0260898
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-06-01Merge "Optimised hwui rounded corners shader" am: d7287c96eb am: ed7bdd6549Arun
am: 92ef0a59f8 Change-Id: I9f5e6ef057ba6049804226d65f2f2f06594efc69
2017-06-01Optimised hwui rounded corners shaderArun
This is a ~2x performance increase for the rounded corners shader which was previously shader limited even on many high-end GPUs. It simplifies the calculations by pre-dividing by the radius, which also allows to maintain mediump/FP16 precision (this improves performance and might improve image quality on GPUs that don't support highp e.g. Mali-400). It also uses a conditional in the shader to save much of the work on the vast majority of pixels which are not close to the corners. Test: manual - visual inspection on fugu (nexus player) Change-Id: I38f491cfb006e2991ef0b9d6b3d67d2c4d328d44
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-28Convert bitmaps to sRGB/scRGB when they have a color profileRomain Guy
This change also fixes an issue with RGBA16F bitmaps when modulated with a color (for instance by setting an alpha on the Paint object). The color space conversion is currently done entirely in the shader, by doing these operations in order: 1. Sample the texture 2. Un-premultiply alpha 3. Apply the EOTF 4. Multiply by the 3x3 color space matrix 5. Apply the OETF 6. Premultiply alpha Optimizations: - Steps 2 & 6 are skipped for opaque (common) bitmaps - Step 3 is skipped when the color space's EOTF is close to sRGB (Display P3 for instance). Instead, we use a hardware sRGB fetch (when the GPU supports it) - When step 3 is necessary, we use one of four standard EOTF implementations, to save cycles when possible: + Linear (doesn't do anything) + Full parametric (ICC parametric curve type 4 as defined in ICC.1:2004-10, section 10.15) + Limited parametric (ICC parametric curve type 3) + Gamma (ICC parametric curve type 0) Color space conversion could be done using texture samplers instead, for instance 3D LUTs, with or without transfer functions baked in, or 1D LUTs for transfer functions. This would result in dependent texture fetches which may or may not be an advantage over an ALU based implementation. The current solution favor the use of ALUs to save precious bandwidth. Test: CtsUiRenderingTests, CtsGraphicsTests Bug: 32984164 Change-Id: I10bc3db515e13973b45220f129c66b23f0f7f8fe
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-15Improve dithering of alpha gradientsRomain Guy
Bug: 32984164 Test: CtsUiRenderingTestCases Change-Id: Ic728725845befd3c52cc7b043d5c6f8e33fcfcd2
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-08Don't print shader sourceRomain Guy
Bug: 32984164 Test: compile & run Change-Id: If632e49b773ca44d4e09e3acb5979f4df15a8d77
2017-02-07Apply transfer function when rendering with linear texturesRomain Guy
RGBA16F bitmaps are always encoded in linear space, which means we must apply the opto-electronic transfer function before we can render them in the framebuffer. Since our linear bitmaps are assumed to be scRGB, values can be negative. The OETF is a slightly modified sRGB OETF: sign(x) * OETF_sRGB(abs(x)) This effectively mirrors the OETF over the negative domain. This CL also removes the "optimized" shader generation path. With current compilers, the optimized path doesn't do anything of value and makes ProgramCache difficult to maintain. Shader compilers inline everything and are really good at folding expressions and removing unused code. Bug: 32984164 Test: CtsUiRenderingTestCases Change-Id: Ieb458ad53574e3a8959aa6bccbbd2d1fe203cbc5
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-13Merge "HWUI: set correct sampler for external texture in shaders"Sergei Vasilinetc
2016-12-13HWUI: set correct sampler for external texture in shaderssergeyv
Test: hwuimacro hwbitmapcompositeshader bug:30999911 Change-Id: Ic63f7109a4a7069b62c0b21efae2d4ba7e6d64be
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-11-15Support hardware bitmaps in bitmap shaderssergeyv
Test: hwuimacro bitmapShaderEglImage --onscreen. bug:30999911 Change-Id: I9d16a1c217a4474841794cf27ce49e3f7823678e
2016-11-02use SkBlendModeMike Reed
skbug.com/5814 Test: compile only Change-Id: Ibbaff43df1117b2ca77fd8f917f03d88cc476330 (cherry picked from commit 26edbcba8a2ed4cb300e7f87e679e3b73cec2772)
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-05-03Use LUT for computing final shadow alphaChris Craik
bug:27415250 Significantly reduces shadow fragment shader computation. Change-Id: Ie9b3c712700754b3734d0ae9cda8751c298fc59e
2015-09-22Remove shader based gamma approachChris Craik
Also fixes some INIT_LOGD logs Change-Id: I212a71a1e7b366aea41f7c3c8cc169d509d6e4a2
2015-08-21Merge "Switch several enums to enum classes"Chris Craik
2015-08-21Switch several enums to enum classesChris Craik
Change-Id: I00ecd0b61657196b51704f70ca31a9d1c1ac254e
2015-08-19Define GLSL versionChris Craik
bug:21923805 Change-Id: Ie44fb9cf38ef5f19df957e4a639d9c7d47da391e
2015-07-14Clean up unncessary definesChris Craik
LOG_TAG and TRACE_TAG are already defined in the makefile Change-Id: I9e53e3dacbe018441edd74cb7c8c90846defee74
2015-04-09Update the shadow fall off function from cosine to gaussian.ztenghui
Also tune the parameters to match a better look designed by UX team. For ambient part, the acos transformed alpha is not needed any more. b/19370798 Change-Id: I20d2615d1be502eb900942ed756aecd1660dee48
2015-03-06SkPorterDuff Multiply mode maps to SkXfermode modulate.Derek Sollenberger
bug:19627342 Change-Id: I97f26ca1bc8abe2768f4a12cc70fb0fa5d905098
2015-03-06Avoid invalid shader creation for certain blend modesChris Craik
bug:19627342 Change-Id: I41e3c1ce8e6fa52f046ec492d19de7cab92b9ec5
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-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
2014-11-22Revert "resolved conflicts for merge of 220c3f4f to master"Andreas Gampe
Reverted as hwui doesn't agree. This reverts commit 8a902d9f24e83c87b054adb5836b4a5b8a257be9. Change-Id: I109e7b02bee2921e2155ded6df36f52e6f574b5a
2014-11-21resolved conflicts for merge of 99377df1 to lmp-mr1-dev-plus-aospAndreas Gampe
Change-Id: I3a98f55832ac447b1ed0dd129c7a93d088025943
2014-11-21Frameworks/base: Unused parameters in hwuiAndreas Gampe
Remove Clang cutout for unused parameters. Fix warnings. Remove Clang cutout for deprecated Skia function usage. Has been fixed in the L push. Change-Id: I7ea073ff67127cc1e14e798b655e2c50615fe8e7
2014-10-27Cleanup debug optionsJohn Reck
Bug: 18138852 Bug: 18065434 Change-Id: Ibb07b73b147c2a8b287fe8aee3f6624582f21b00
2014-09-17Handle premultiplication correctly for ColorMatrixColorFiltersChris Craik
bug:17405627 Previously, the input content to the color matrix computation was left premultiplied. Since the color matrix could reduce the alpha channel, the alpha was re-multiplied, but this was incomplete, and incorrect. Instead, apply the color matrix in unpremultiplied space. Change-Id: I87b8e03d2e228e6ded81f7bbfea952605d7a095c
2014-09-04Merge "Remove invalid premul step from HWUI's matrix color filter." into lmp-devDerek Sollenberger
2014-08-29Fix precision issues for roundrect clippingChris Craik
bug:16984008 Change-Id: I941232d569293717f6bcd249d9e01f72a7409d2e
2014-08-18Remove invalid premul step from HWUI's matrix color filter.Derek Sollenberger
bug: 16186699 Change-Id: Ia0b828e76ce4831ee9e3b4f54c697e6017f1604d
2014-08-12Switch to cos interpolation of shadow alphaChris Craik
bug:16852257 Updates default shadow opacities to compensate. Also, update variable/constant naming related to vertex alpha. Change-Id: I9055b4ac3c9ac305ca9d515f21b52d6aa6dc9c5c
2014-08-12Rework shadow interpolationChris Craik
bug:16852257 Use pow(alpha, 1.5) to avoid harsh edges on shadow alpha ramps. Also adjusts shadow constants to compensate. Change-Id: I5869956d7d292db2a8e496bc320084b6d64c3fb7
2014-08-05Fix large radius RR clipping issue on certain devicesChris Craik
bug:16804363 Since dist can be in the 1000s of pixels, and length() may square it in its current precision, scale the value down significantly first, since final precision isn't very important. Change-Id: Id20f7a49d6171355c8e242442c2b5083f746dca3
2014-05-15Round rect outline clippingChris Craik
Change-Id: Iee9cf4f719f6f1917507b69189ad114fa365917b
2014-02-07Removing SkiaColorFilter and inspecting the native object directly.Derek Sollenberger
bug: 10650594 Change-Id: I4fcf66d008765afa0e35d011f58bc792183cb74f
2013-05-14Add tessellation path for pointsChris Craik
bug:4351353 bug:8185479 Point tessellation is similar to line special case, except that we only tessellate one point (as a circle or rect) and duplicate it across other instances. Additionally: Fixes square caps for AA=false lines Cleanup in CanvasCompare, disabling interpolation on zoomed-in comparison view Change-Id: I0756fcc4b20f77878fed0d8057297c80e82ed9dc
2013-05-03Add an on-screen overdraw counterRomain Guy
The counter can be enabled by setting the system property called debug.hwui.overdraw to the string "count". If the string is set to "show", overdraw will be highlighted on screen instead of printing out a simple counter. Change-Id: I9a9c970d54bffab43138bbb7682f6c04bc2c40bd
2013-04-09Change the dither texture's swizzlingRomain Guy
This is a more elegant way to sample from a float alpha texture. Instead of sampling from the red channel in the fragment shader we can set the alpha channel swizzle to redirect it to the red channel. This lets us sample from the alpha channel in the fragment shader and get the correct value. Change-Id: I95bbf7a82964e1bf42c0fee1b782b6bdbbcef618
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