The EGLSurface stored in the pipeline can become obsolete if the
EglManager/RenderThread has to destroy the context. This CL enables the
RenderThread to notify all active pipelines that their surface is invalid.
Bug: 115290937
Test: hwui_unit_tests
Change-Id: Ib3054822273bc35406630b7442229a81b39a2c91
Fix an issue with incorrect texture matrix, when there is 90/270 rotation.
This happened, because after refactoring SkImage has buffer width/height,
instead of layer width/height.
This reverts commit a683eb3945320f592f58705c3c31b3c044f4bd72.
Bug: 113673613
Test: Ran TextureView CTS and lensblur in camera app
Change-Id: If3bcf9cd5195de09fd67a753708568a8e3ca3a9a
Render TextureView as hardware bitmaps, instead of GL textures.
Cache SkImage for each observed GraphicBuffer, which is faster
even for GL.
Implement C++ SurfaceTexture, which allows Java SurfaceTexture
to be used with Vulkan HWUI render thread and application GL.
threads. Delete GLLayer and VkLayer classes and texture code
from old HWUI pipeline.
Test: Ran skiagl and skiavk pipeline with a TextureView app.
Test: TextureView CTS tests pass for GL pipeline.
Test: Ran Android NDK Native codec sample app.
Change-Id: Idc94f864ce2d34fd6ceff4be4fc7d3327e99879c
This removes the duality of DisplayList, removing a small amount of
overhead
Test: buids & hwuiunit passes
Change-Id: I8bb3a20e9ead1caec4b4a8a3e9f2c08f717a7096
bug:34809371
In some applications, the first draw is not opaque - either because the
application is misbehaved, or because hwui is not able to reliably tell
whether the layer is opaque or translucent. This is undefined behaviour
in OpenGL ES and has a significant performance and bandwidth impact on
some tiler GPUs as it requires loading the previous frame's color data.
This change disables blending in that case and also for effectively
opaque blend modes (SRC=GL_ONE, DST=GL_ZERO). It increases performance
by ~10% for Leanback CTS on some low-end GPUs (gradient layer that hwui
incorrectly believes to be translucent).
Test: manual - visual inspection on fugu (nexus player)
Change-Id: I2cbf1c76678acae1a36923e72fd18ed55cd89dc2
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
Merged-In: I8b0d210572a246f4fefb076935cf5156a70c274c
(cherry picked from commit 8dc02f99d09130ace2ee738c2e689db1b3f33181)
Since putOrDelete may delete the layer, we shouldn't be accessing its
member after calling it.
Caught by the static analyzer:
frameworks/base/libs/hwui/renderstate/OffscreenBufferPool.cpp:183:44:
warning: Use of memory after it is freed
Bug: 27101951
Test: mma. Static analyzer warning is gone.
Change-Id: I25ee8b45ede608da52bf58d1d9f52ce3bb60d4cb
Layers created using View.setLayerType() or Canvas.saveLayer() need
to be RGBA16F/scRGB-nl when within a window that requested wide color
gamut rendering.
Bug: 29940137
Test: CtsUiRenderingTestCases, CtsGraphicsTestCases, hwui_unit_tests
Change-Id: I42fd6355448c92041491a7109e3ac8a153d38bf9
The core of the implementation is complete and provides heuristic
cache sizing based on the size of the surface being used. This CL
will also be used to add the following features in the future...
1) Support Vulkan pipeline reporting on the size of the surface.
2) Complete the VectorDrawableAtlas stub code
3) Automatic purging of stale resources for low memory devices.
Test: hwui_unit_tests (new test added) and CtsUiRendering
Bug: 62260637
Change-Id: Ib85159cca28b646fe249f2190b07f1b7e0f50d8f
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
Eliminate textureCache.mGarbage which is only cleared
in a trimMemory. Instead when we hit ~Bitmap post a
message to RenderThread to release the texture immediately
Bug: 38258699
Test: manual
Change-Id: I962ba275e89afb628ba02f74769287edbab9fed4
The CPU overhead of glDrawElements in the GPU driver is significant
with client-side vertex data (unique per draw call) as the driver has
to calculate the mininimum and maximum indices from the index buffer
in order to evaluate the range of vertex data required. This can be
avoided by keeping track of the min-max in hwui and passing it with
glDrawRangeElements. This requires OpenGL ES3.0 support (which is
already checked for elsewhere in hwui).
Test: manual - visual inspection on fugu (nexus player)
Change-Id: I57bb1ddd239a1032f74f1cd2683bbe0970e84bd9
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
This is the first step toward interpreting color spaces at render time.
Bug: 32984164
Test: BitmapColorSpaceTest in CtsGraphicsTestCases
Change-Id: I0164a18f1ed74a745874fe5229168042afe27a04
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
* Add explicit keyword to conversion constructors.
Bug: 28341362
* Use const reference type for read-only parameters.
Bug: 30407689
Test: build with WITH_TIDY=1
Change-Id: Iab3e6636f60a70cb124f29dc19f20f842fa8dfda