120 Commits

Author SHA1 Message Date
Derek Sollenberger
28a4d9935c Refactor RenderState and remove unused functionality.
Test: hwui_unit_tests still pass
Change-Id: Ie943671535ab8c5da1bac05985e815e0cb842dc1
2018-09-20 14:47:08 -04:00
Derek Sollenberger
5a5a648b69 Fix crash when EGLSurface is no longer valid.
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
2018-09-20 13:35:19 -04:00
Stan Iliev
564ca3e2c9 Reland "TextureView Vulkan support and optimized OpenGL draw"
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
2018-09-05 01:58:34 +00:00
Stan Iliev
a683eb3945 Revert "Revert "Revert "TextureView Vulkan support and optimized OpenGL draw"""
This reverts commit 85f9096b5272c9a39e592e2e97cbbe6cb0e767ab.

Reason for revert: lensblur broken.

Change-Id: I83ac163159fc537bc15936a0f8597a7512ca9d6e
2018-09-04 15:42:18 +00:00
Stan Iliev
85f9096b52 Revert "Revert "TextureView Vulkan support and optimized OpenGL draw""
This reverts commit 867c43de0544217d26c3ee18f4d6603bb2ea97ce.

Reason for revert: Fixed issue with unsupported hardware buffer formats by landing https://skia-review.googlesource.com/c/skia/+/150470 "Support more hardware buffer formats"

Bug: 113673613
Change-Id: I1f7c528f138e290160e75833c8d989d9535002ee
2018-08-31 22:13:15 +00:00
John Reck
867c43de05 Revert "TextureView Vulkan support and optimized OpenGL draw"
This reverts commit c8e22a653297837da9a80b0ba65f6854c8986c96.

Reason for revert: broke camera, b/113555199

Bug: 113555199
Change-Id: Iae9b462694d5de0cd99427afead63b567fb4d71d
2018-08-30 18:42:08 +00:00
Stan Iliev
c8e22a6532 TextureView Vulkan support and optimized OpenGL draw
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
2018-08-29 10:22:03 -04:00
John Reck
e4c1e6c5a1 Remove dead code
Test: builds
Change-Id: I57cf72ca460115463d7759097d5ba598b5ec1775
2018-05-30 16:40:07 -07:00
Mike Reed
932caf0668 remove obsolete Glop, Tessellators, Programs, and SkiaShader
Test: make

Change-Id: I92f36335830dfc37be72468546637d9986f0baf1
2018-05-08 20:47:45 +00:00
Mike Reed
e7f688bd01 remove BakedOps and much of renderstate
Test: make

Change-Id: If070b7436b848c6840abfac5f051b0f5b6cb17ce
2018-05-04 15:21:49 -04:00
android-build-team Robot
2214272f1c Merge "remove shadow related references" 2018-05-04 18:04:24 +00:00
Mike Reed
4ad8f5329f remove shadow related references
Test: make

Change-Id: I1fc387ee442ca9120ff4f80248cc2395e93128f6
2018-05-04 13:12:16 -04:00
John Reck
d9d7f127b5 Delete a bunch of code
This removes the duality of DisplayList, removing a small amount of
overhead

Test: buids & hwuiunit passes

Change-Id: I8bb3a20e9ead1caec4b4a8a3e9f2c08f717a7096
2018-05-03 15:25:19 -07:00
Mike Reed
8cafcc628f remove (dead) caches from hwui
Test: make

Change-Id: I18bfe51896672272ce7d471eaead69b651399368
2018-05-03 13:23:40 -04:00
John Reck
1bcacfdcab Format the world (or just HWUI)
Test: No code changes, just ran through clang-format
Change-Id: Id23aa4ec7eebc0446fe3a30260f33e7fd455bb8c
2017-11-03 10:57:44 -07:00
John Reck
f8441e6552 Switch to a fancy new queue
Test: unit tests & benchmarks pass/faster

Change-Id: I9521432172d6dd6039c5280b1265479a36a86247
2017-10-27 13:39:55 -07:00
Derek Sollenberger
7a4216bb73 Don't clear a layerPool that is never initialized.
Test: device now boots in Vulkan without crash
Change-Id: Ib0a3d8253a49fbcdb75e9f4edda0c32d06903669
2017-10-25 09:52:23 -04:00
Chris Craik
01ed792ade Add test for first draw blend behavior in HWUI pipeline
Bug: 65077146
Test: BakedOpRendererTests
Change-Id: Ia3139a01fe25344a19f2b947069bd686303b9fd5
2017-09-01 14:39:18 -07:00
Arun
530a2b44d9 Disable hwui blending for first draw to main FBO
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
2017-08-18 16:52:55 -07:00
John Reck
642ebea6e1 Delete all ro.hwui.* props
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)
2017-08-10 17:22:43 +00:00
George Burgess IV
09c00f25af Fix use-after-free
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
2017-07-18 17:00:06 -07:00
Romain Guy
07ae505d40 Use RGBA16F layers when wide color gamut rendering is on
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
2017-06-14 13:44:08 -07:00
Derek Sollenberger
f9e45d1d81 Implement CacheManager for the Skia pipelines.
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
2017-06-06 14:19:37 -04:00
Arun
11e44273dc Merge "Optimised hwui rounded corners shader" am: d7287c96eb am: ed7bdd6549
am: 92ef0a59f8

Change-Id: I9f5e6ef057ba6049804226d65f2f2f06594efc69
2017-06-01 23:42:06 +00:00
Arun
06e9f324ef Optimised hwui rounded corners shader
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-06-01 13:42:12 -07:00
John Reck
1f7f8bfddb Merge "Fix null deref crash" into oc-dev
am: c1affe14c2

Change-Id: Ib8e4c34fb38400dc748b463c5ab965d57e260fd0
2017-05-24 00:48:30 +00:00
John Reck
36393c3e8d Fix null deref crash
Change-Id: Ic1a64e926b5faa2f4cf8d079a2b67e0261dcecd7
Fixes: 62035692
Test: manual
2017-05-23 15:32:08 -07:00
John Reck
9d08fca62f Merge "Improve time to texture destruction" into oc-dev
am: 1bc0286ef8

Change-Id: I93daab53961a018a2cf8d4e2d4d8300b84bb917e
2017-05-23 17:51:28 +00:00
John Reck
9a814875c4 Improve time to texture destruction
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
2017-05-22 17:17:05 -07:00
Arun
93cafba790 Merge "Reduce hwui CPU time by using glDrawRangeElements" am: 057c7c3164 am: 94f4f5e45f
am: b5facc7516

Change-Id: I9e96bf83ae5ebd4237fc4d78a58e83793de86aad
2017-05-05 19:10:21 +00:00
Arun
b0a9477c8e Reduce hwui CPU time by using glDrawRangeElements
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
2017-05-05 15:11:27 +00:00
Romain Guy
caaaa66e57 Convert bitmaps to sRGB/scRGB when they have a color profile
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-28 18:35:49 -07:00
Romain Guy
efb4b06493 Add ColorSpace information on Bitmap
This is the first step toward interpreting color spaces at render time.

Bug: 32984164
Test: BitmapColorSpaceTest in CtsGraphicsTestCases

Change-Id: I0164a18f1ed74a745874fe5229168042afe27a04
2017-03-06 19:33:25 -08:00
sergeyv
c3f1316961 Clean up deferredLayers only onGpuContextDestroyed.
Test: manual
bug:34919311
Change-Id: I5488b0845ec3922424f5893943e4f42675dfc9fd
2017-02-06 11:45:14 -08:00
sergeyv
3e9999bd86 Explicitly destroy Layer in DeferredLayerUpdater on destroyHardwareResources()
Change-Id: I0987104eabda9a2a302b9e765213aad48f93aea4
Test: refactoring CL. Existing tests still pass
bug:33753499
2017-01-30 16:42:41 -08:00
Greg Daniel
45ec62ba72 Add support for dummy draws for Vulkan webview and texture views.
Test: manual testing
Change-Id: Iaec8c3a34367673c281665ff6c6e97d1ce532265
2017-01-10 15:54:14 -05:00
Greg Daniel
8cd3edfa15 Break Layer class into Gl and Vulkan subclasses
Test: manual testing
Change-Id: Ibd2beed39de3ac6da7448e96496253cfe427dfbb
2017-01-10 15:05:07 -05:00
sergeyv
2a38c42e92 Add target to texture
Test: refactoring cl.
bug:32413624

Change-Id: I94b1c31cd4e0712dfcfd7777a0012424c1bf0dca
2016-10-26 14:01:09 -07:00
Mike Reed
260ab72648 use SkBlendMode instead of SkXfermode
use sk_sp versions of paint setters/getters

Change-Id: I86591a0a8ec92e6039776cbf00424ea24f585b28
2016-10-13 17:14:52 -04:00
Romain Guy
253f2c213f 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
2016-10-11 17:47:58 -07:00
Chih-hung Hsieh
25c9f6cede Merge "Fix google-explicit-constructor warnings in libs/hwui." am: 7207562ff7 am: d7a69e04eb am: 842f1e48e7
am: 1f50f80aab

Change-Id: I713bd07fee150cc684e630045e02872b23062a5a
2016-09-01 01:26:40 +00:00
Chih-Hung Hsieh
a619ec70cf Fix google-explicit-constructor warnings in libs/hwui.
* Add explicit keyword to conversion constructors,
  or add NOLINT for implicit converters.
Bug: 28341362
Test: build with WITH_TIDY=1

Change-Id: Id8ca42433a4fc3652e4cb13787c4cb169f20d9a9
2016-08-29 14:56:58 -07:00
Chih-Hung Hsieh
ed935c32f4 resolve merge conflicts of 76ce8e5 to stage-aosp-master
Change-Id: I4b4ca9906373a95776d2da8ba2fa39a4a78e2a30
2016-08-11 16:48:46 -07:00
Chih-Hung Hsieh
f35c939cd7 Fix clang-tidy warnings in libs/hwui.
* 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
Merged-In: Iab3e6636f60a70cb124f29dc19f20f842fa8dfda
2016-08-10 23:26:59 +00:00
Chih-Hung Hsieh
49796451cb Fix clang-tidy warnings in libs/hwui.
* 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
2016-08-10 16:01:29 -07:00
Chris Craik
5e00c7ce06 Delete old rendering pipeline
fixes: 30002246

Change-Id: I45df0e924708526cee045b14c291bd23aa1a92db
2016-07-07 15:53:50 -07:00
Chris Craik
f6856b0f34 Merge "Fix hw layer overdraw/update visualization" into nyc-dev am: 189e3e5ec5 am: bd2edfca03
am: f075b05d5a

* commit 'f075b05d5a8516ff98d9c25c1b5ac307fdfc234a':
  Fix hw layer overdraw/update visualization

Change-Id: I70968a90dbc3ea13654b7dbb8065d5a577a0f9ae
2016-05-17 00:17:42 +00:00
Chris Craik
bd2edfca03 Merge "Fix hw layer overdraw/update visualization" into nyc-dev
am: 189e3e5ec5

* commit '189e3e5ec5b698f1062fb98692fa75d3750148e0':
  Fix hw layer overdraw/update visualization

Change-Id: Ic4c49b25e0d1709d34974adb828c3ab4644415e5
2016-05-17 00:08:14 +00:00
Chris Craik
3741328947 Fix hw layer overdraw/update visualization
Fixes: 28748255

Change-Id: I83b531cdf5e4407fd17edd72d96e6189924926fa
2016-05-16 13:54:02 -07:00
sergeyv
fd3744b7d8 Move gl calls from PatchCache to MeshState
bug:27358166
Change-Id: I5f544f497e9480e64faa2ddd369eb16318e82dc3
2016-05-11 23:53:39 +00:00