300 Commits

Author SHA1 Message Date
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
Roozbeh Pournader
46c6f4c5ea Frameworks support for hyphenation for various complex cases
This adds better support for Arabic script languages, Armenian,
Catalan, Hebrew, Kannada, Malayalam, Polish, Tamil, and Telugu by
adding various hyphenation types and edits appropriate for the
locales.

The actual implementations are in Minikin. This CL takes care of the
changes needed in frameworks, to support different end-of-line and
start-of-line hyphen edits.

Two bugs in TextLine.java are also fixed:

1. Where hyphen edits on non-spanned texts were not eliminated in
handleRun() when they should have. This had manifested itself in
double hyphenation in some bidi paragraphs.

2. Some no op assignments and comparions around the change for the
above bug are removed.

Test: thorough manual testing for various cases
Bug: 19756624
Bug: 19950445
Bug: 19955011
Bug: 25623243
Bug: 26154469
Bug: 26154471
Bug: 33387871
Bug: 33560754
Bug: 33752592
Bug: 33754204
Change-Id: I48c047d1f6a75c39a78a6ea38a0a3282f63326ec
2017-03-03 15:34:42 -08:00
John Reck
df1742ed47 Overhaul GraphicsStatsService
* LRU cache of recently-used is dead, replaced
  disk storage
* ASHMEM size is read from native by the system service,
  no longer requires keeping a sizeof() in sync with a
  constant in Java
* Supports dumping in proto format by passing --proto
* Rotates logs on a daily basis
* Keeps a history of the most recent 3 days

Bug: 33705836
Test: Manual. Verified log rotating works by setting it up to
rotate every minute instead of day. Confirmed /data/system/graphicsstats
only has the most recent 3 entries after several minutes

Change-Id: Ib84bafb26c58701cc86f123236de4fff01aaa4aa
2017-02-21 09:49:10 -08:00
Po-Chien Hsueh
c5ae595e6f Remove build flag ANDROID_ENABLE_RENDERSCRIPT
remove this flag and consider renderscript is always enabled

Bug: 34693640
Test: compile
Change-Id: I22464e1d64f2a55a60ba9f8ab1510f2811605552
2017-02-09 15:00:09 +08:00
Miao Wang
1d5b9778bb Merge "Remove uncessary dependency of libhwui" 2017-02-06 19:54:42 +00:00
sergeyv
83809fec68 Properly clear textures for Hardware Bitmaps
Test: manual  (Description in the bug)
bug:34858530
Change-Id: I13eb89077c43ca28436509a7af5b7c11374446c4
2017-02-01 12:44:28 -08:00
Miao Wang
629fd3d48b Remove uncessary dependency of libhwui
- libRS.so is not directly used. It is accessed by libRScpp.so.

Test: mm, and boot-up test on sailfish
Change-Id: I5742d2ee3b34ef09bcb997524408affce1ace8fd
2017-01-31 17:26:52 -08:00
John Reck
b5544d0308 Temporarily enable GL validation
Bug: 34206215
Test: none
Change-Id: Ifc2855ca399f4ae42376349dd5c660f60b327c04
2017-01-25 15:09:37 -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
TreeHugger Robot
7a7c921e18 Merge "Add more Skia pipeline unit tests." 2016-12-12 20:59:45 +00:00
Stan Iliev
52771272f4 Add more Skia pipeline unit tests.
Add more Skia pipeline unit tests and fix an issue
in backdrop/content bounds clip logic.

Test: built and run angler-eng and HWUI unit tests.
Change-Id: Ie41f80ff7ce9802a4d76e8b14f1695dbc9771a2b
2016-12-12 14:13:16 -05:00
TreeHugger Robot
8600928705 Merge "Make HWUI makefile include external/skia/src/utils" 2016-12-12 17:35:46 +00:00
Leon Scroggins III
82c581dac3 Make HWUI makefile include external/skia/src/utils
Test: none. No new code; this just makes it explicit that HWUI is
depending on headers in Skia's src/utils directory.

This is needed for SkTextureCompressor.h, which itself is pulled in
transitively through SkGlyphCache.h. Adding this here means that Skia
need not list src/utils as an exported include dir.

Change-Id: I3f2b022504486b7a640236fb98a497b599b42a6b
2016-12-12 16:15:49 +00:00
Greg Daniel
cd55852fcd Make buffer age work in Vulkan
Test: manual testing in skiavk mode

Change-Id: I5b9d8af7d9cecf2f022ef104ec33a5b7477e9e0c
2016-12-09 15:45:15 +00:00
TreeHugger Robot
e9bf7c8436 Merge "Introduce PathInterpolator to native animators" 2016-12-01 20:21:13 +00:00
Doris Liu
9e9eeeeb78 Introduce PathInterpolator to native animators
For interpolators defined with a path, PathInterpolator is more accurate
and likely less costly for longer animations than what are currently
using as a substiute - LUTInterpolator.

Test: manual test and added a unit test
BUG: 32830741
Change-Id: I867c7a28e4261392cce9c45a2992ab4fd120c496
2016-11-30 16:03:23 -08:00
sergeyv
71c4477bee Add hwui test for correct refcounting of SkColorTable in Bitmap
Test: BitmapTests.colorTableRefCounting
bug:32561595
Change-Id: I505c735feffbac18d406b6b2f9dff51d81700cd8
2016-11-30 13:42:52 -08:00
Stan Iliev
db45a4bfaf Fix Skia render node projection to match HWUI
Fix Skia render node projection to match HWUI. Port
FrameBuilderTests_projectionReorder test for Skia pipeline.
Add new tests in both HWUI and Skia to cover more projection
use cases.

Test: built and run on angler-eng
Change-Id: Ibf27af211452ae95d595aca7723ea63f48b0b282
2016-11-22 16:38:20 -05:00
Derek Sollenberger
c4fbada76a Support Surface and Layer Readback in the SkiaPipelines.
Test: CTS TextureViewTests and UIRendering
Change-Id: I2969c8f5a975bfd9aebcbb585c64d1fcbb2487c2
2016-11-16 13:30:00 -05:00
Derek Sollenberger
0e3cba3146 Handle vulkan windowing directly in SkiaVulkanPipeline
Test: manual testing in skiavk mode
Change-Id: I2fab80bae2787bfdacbc70d0402e98450e59406d
2016-11-09 11:58:36 -05:00
Matt Sarett
cf2c05c652 Add SkiaProfileRenderer to draw visual debugging info
This adds support for debug.hwui.profile and
debug.hwui.show_dirty_regions to the Skia pipelines.

There still may be some follow up work for profiling
with visual bars.  The speed at which the renderer
is able to draw the rects in the graph is having a
noticeable effect on the actual data in the graphs.

Test: Verified that the features work as expected.

BUG:32370375

Change-Id: I24430da2bab3eb54f6a771f9c984f8ae0008a5a7
2016-11-03 21:42:58 -04:00
TreeHugger Robot
40800725d2 Merge "Implement Skia pipelines for OpenGL and Vulkan." 2016-11-03 19:59:46 +00:00
Stan Iliev
500a0c30d4 Implement Skia pipelines for OpenGL and Vulkan.
Implement Skia pipelines for OpenGL and Vulkan:
base SkiaPipeline, SkiaOpenGLPipeline and SkiaVulkanPipeline.
Write unit tests for SkiaPipeline.

Test: Built and run manually on angler-eng.
Change-Id: Ie02583426cb3547541ad9bf91700602a6163ff58
2016-11-03 13:28:49 -04:00
John Reck
f0503b0b6f Merge "Add benchmarks for View inflation" 2016-11-03 17:14:57 +00:00
John Reck
3acf0382da Add benchmarks for View inflation
Also speed up RenderNode creation:

Use finalizer() instead of NativeAllocationRegistry, this
shaves ~3us off of creation currently

Avoid instanceof, instead have SurfaceView explicitly ask
for updates.

Remove unused method call.

Test: ran benchmarks
Change-Id: I3117fdf72313a4e6a9965baca9f2a8b855c19b34
2016-11-02 14:49:51 -07:00
Stan Iliev
021693b967 Implement SkiaRecordingCanvas, RenderNodeDrawable and other drawables.
Implement SkiaRecordingCanvas, RenderNodeDrawable, GLFunctorDrawable,
LayerDrawable, StartReorderBarrierDrawable, EndReorderBarrierDrawable.
Move AnimatedRoundRect and AnimatedCircle in a separate file.
All Skia pipeline files are moved in hwui/pipeline/skia folder.
Add unit tests for RenderNodeDrawable, StartReorderBarrierDrawable,
EndReorderBarrierDrawable and SkiaRecordingCanvas.

Test: I tested manually on 6P devices and did run the unit tests.
Change-Id: If2a347bd1fc4689953822294ce5bf98c7f3f57c7
2016-10-31 14:27:02 -04:00
TreeHugger Robot
c024377dcf Merge "Implement getTransparentRegion() using SkLatticeIter" 2016-10-27 14:13:19 +00:00
Matt Sarett
7de7385897 Implement getTransparentRegion() using SkLatticeIter
This allows us to delete utils/NinePatchImpl.cpp and
utils/NinePatch.h

Test: Passed cts tests - DrawableTest, NinePatchTest,
NinePatchDrawableTest.

Change-Id: I6b5d09fa3479e758d8b931fa0e977c25f4435a7c
2016-10-27 08:22:38 -04:00
Derek Sollenberger
daf7229047 Move OpenGL specific details behind renderPipeline interface.
Test: new and existing unit tests still pass.
Change-Id: I6164f30f45ebe450788ed8d949eca5af9a44e585
2016-10-26 12:46:57 +00:00
Matt Sarett
de97307362 Make FrameInfoVisualizer use an IRenderPipeline to draw
Removing the direct uses of the BakedOpRenderer should make
it easier for the SkiaGL pipeline to take advantage of these
debugging features.

Test: Verified that debug.hwui.show_dirty_regions and
debug.hwui.profile still behave as expected.

BUG:32370375

Change-Id: I2818bda4a18ec183c9c39ca080ad34a4dc89b5cd
2016-10-25 17:44:55 -04:00
sergeyv
c1c54062f8 Rename hwui/PixelRef to hwui/Bitmap
Test: refactoring cl.
bug:32216791

Change-Id: I26de43f71027bccb43a5011f84080ab4631b2883
2016-10-20 09:48:02 -07:00
Derek Sollenberger
6e68bedacc Merge "Initial refactoring to enable the addition of the SkiaOpenGLPipeline." 2016-10-13 16:53:14 +00:00
Romain Guy
21986f2ae7 Merge "Linear blending, step 1" 2016-10-12 15:52:14 +00: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
Sergei Vasilinetc
e9eefce9f8 Merge "Move PixelRef to hwui Test: refactoring cl. bug:27762775" 2016-10-11 18:08:56 +00:00
sergeyv
0728f0872f resolve merge conflicts of e830f35 to master
Change-Id: I4d2b10a6a2ac983986775f1f925c4a09734bb70d
2016-10-10 18:20:04 -07:00
sergeyv
e830f351e1 Turn off additional logging in text rendering am: 5bb5626599
am: 4778f6a43e

Change-Id: If031a1d480d8c2e75e9f6268d15c8ccc098a0268
2016-10-11 00:54:34 +00:00
sergeyv
5bb5626599 Turn off additional logging in text rendering
Change-Id: If5f11489c05e320e4436fb57680857b29228a755
b:30427106
2016-10-10 12:25:06 -07:00
sergeyv
163f88140e Move PixelRef to hwui
Test: refactoring cl.
bug:27762775

Change-Id: Idd13b865ce22d4c51ced9b0fe3e9174452e87c6e
2016-10-07 17:01:41 -07:00
Derek Sollenberger
0df6209a02 Initial refactoring to enable the addition of the SkiaOpenGLPipeline.
Test: existing and new HWUI unit tests all pass.
Change-Id: I4f5c1dc839a2ed15d8b0f6245fe030684501b083
2016-10-05 15:28:27 -04:00
sergeyv
dcbc0e9e25 resolve merge conflicts of 0ec2fd7 to master
Change-Id: I113ede26ab42e3f9a36a52a756c38d365731e16d
2016-09-14 09:15:15 -07:00
sergeyv
0ec2fd7bc5 HWUI: track upload & recent usage in font cache am: af102bee51
am: 42c01cf62f

Change-Id: Ieb80108d520aa629c54a40d7c533bf74a71849c4
2016-09-13 02:01:28 +00:00
sergeyv
af102bee51 HWUI: track upload & recent usage in font cache
FontCacheHistoryTracker should be turned off before shipping: b/31438876

bug:30427106
Change-Id: Ic26b25e790d4ee69e484ca0cb23dc9cc522b2ed3
2016-09-12 15:45:26 -07:00
Hugo Benichi
63d8aa930f Merge \\\"Fix missing IpConnectivity metrics\\\" into nyc-mr1-dev am: 66e7752ad1 am: b2db402899
am: fb5c675b7e

Change-Id: Iba1f81a892acd9f541b9dd564203bfebc56c9c73
2016-07-31 02:13:00 +00:00
John Reck
fb5c675b7e resolve merge conflicts of 67daab6 to nyc-mr1-dev-plus-aosp
Change-Id: I35f867b8d6408a7eae9cf5643f0908259de90cb1
2016-07-29 10:08:16 -07:00
John Reck
2d5b8d7392 Teach JankTracker about new swap behaviors
Bug: 30440166

If we are using HWC2, there's a change in timing
when in triple buffering with the pipelined offsets.
This changes JankTracker to recognize that and silently
erase that from the total duration

Change-Id: Ib1fd4209070f17dbd2baed707c8cf73fb11c3cf2
2016-07-29 07:56:02 -07:00
Derek Sollenberger
56ad6ec42f Remove LayerRenderer.
There is only one caller each for the static functions here so this
CL moves the logic to the caller.  Also by moving some of the code
into the pipeline it makes it easier for future changes to configure
how a pipeline handles a layer.

Change-Id: Ib735b5154325cbb658fd151f7a19dbf434ab44b7
2016-07-26 13:05:13 -04:00
Sergei Vasilinetc
f1b0e07e7f Merge "Move hwuimacro to common native benchmark infrastructure" 2016-07-19 21:33:23 +00:00
Stan Iliev
768e39335b Refactor CanvasContext: move OpenGL specific code
Move OpenGL specific code from CanvasContext into a new class
OpenGLPipeline.

Change-Id: I4363053f890701a4235927b59ec588861488ea8f
2016-07-13 14:14:12 -04:00