3798 Commits

Author SHA1 Message Date
Sergei Vasilinetc
fda66672fe Merge changes I94b1c31c,Ib0b16c87
* changes:
  Add target to texture
  Use Bitmap in Texture.upload
2016-10-28 01:31:00 +00: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
Seigo Nonaka
e2179925df Make sure the Typeface is loaded before calling measureText.
This is a clean up CL by resolving TODO in hwui/Typeface.cpp

Usually Typeface is listed in preloaded-classes and loaded during Zygote
initialization. However, on some devices, class preloading is disabled.
Paint.measureText can not be called before Typeface static initializer
and it may not load Typeface class.

To ensure that the font preloading happens in ZygoteInit even on such
devices, refer Typeface.DEFAULT static field in TextView.preloadFontCache
in TextView which also happens during zygote initialization.

Bug: 32374752
Test: Manually done
Change-Id: I773c154671c170bebad3aa0f9c04eee5a664b849
2016-10-27 18:18:49 +09:00
sergeyv
2a38c42e92 Add target to texture
Test: refactoring cl.
bug:32413624

Change-Id: I94b1c31cd4e0712dfcfd7777a0012424c1bf0dca
2016-10-26 14:01:09 -07:00
sergeyv
98fa4f9e7b Use Bitmap in Texture.upload
Test: refactoring cl.
bug:32216791

Change-Id: Ib0b16c878d8371e0471e9a502f55626ec5999c60
2016-10-26 13:57:38 -07: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
Derek Sollenberger
be9a73063c Merge "Store GrContext on RenderThread for use by Skia-based renderers." 2016-10-26 12:46:30 +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
Derek Sollenberger
98f75d53db Store GrContext on RenderThread for use by Skia-based renderers.
Test: built and booted on device
Change-Id: I4c1060ec72bc67e54e6b2d25b1f2c13aaa513f89
2016-10-25 19:43:00 +00:00
Seigo Nonaka
6af8c0968e Merge "Revert "Remove obsolete interface GetTable."" 2016-10-25 03:58:02 +00:00
Seigo Nonaka
436f8ac786 Revert "Remove obsolete interface GetTable."
This reverts commit 9cd73b6828e4e7475ab430c373efa2cd6dc69cea.

This causes a crash on Android Auto.
Bug: 32374752

Change-Id: I7fd0a52eb2458772ff50f246ca1c7d3397554133
2016-10-25 00:49:14 +00:00
Stan Iliev
f50806afb8 Merge SkiaCanvas changes from master-skia to master branch.
Most changes are taken from ag/1407698, ag/1336660, ag/1488900.

Test: Built and run manually on angler-eng.
Change-Id: Id4e464b9a83c62b6bc7ea31a30e5ca6cd53b659d
2016-10-24 12:16:13 -04:00
Sergei Vasilinetc
0dd9902595 Merge changes I1d8a9a6e,I5adcd59d
* changes:
  Use Bitmap in DisplayList & RecordedOps instead of SkBitmap Test: refactoring cl. bug:32216791
  Pass Bitmap instead of SkBitmap in drawNinePatch & drawBitmapMesh Test: refactoring cl. bug:32216791
2016-10-21 21:11:49 +00:00
sergeyv
ec4a4b13ea Use Bitmap in DisplayList & RecordedOps instead of SkBitmap
Test: refactoring cl.
bug:32216791

Change-Id: I1d8a9a6e772e2176b6c2409409a910478b45f8db
2016-10-21 12:11:44 -07:00
Sergei Vasilinetc
cc97d86da8 Merge "Pass Bitmap instead of SkBitmap for bitmap rect operation Test: refactoring cl. bug:32216791" 2016-10-20 23:05:05 +00:00
sergeyv
5fd2a1cb27 Pass Bitmap instead of SkBitmap in drawNinePatch & drawBitmapMesh
Test: refactoring cl.
bug:32216791

Change-Id: I5adcd59daf752d36012456b0a9960c59d07e2e3d
2016-10-20 15:04:28 -07:00
sergeyv
fc9999505a Pass Bitmap instead of SkBitmap for bitmap rect operation
Test: refactoring cl.
bug:32216791

Change-Id: I66d19194c57b3aa2c400aa87acffc774a533776a
2016-10-20 14:04:35 -07:00
Sergei Vasilinetc
4d2a1dc01f Merge "Pass Bitmap instead of SkBitmap in canvas.drawBitmap(Bitmap, float,float,Paint) Test: refactoring cl. bug:32216791" 2016-10-20 19:35:59 +00:00
Sergei Vasilinetc
638afc8b0f Merge "Rename hwui/PixelRef to hwui/Bitmap Test: refactoring cl. bug:32216791" 2016-10-20 19:35:31 +00:00
sergeyv
aed7f58fb0 Pass Bitmap instead of SkBitmap in canvas.drawBitmap(Bitmap, float,float,Paint)
Test: refactoring cl.
bug:32216791

Change-Id: If9f9fbc19e683b14cce6c3c268258bd832d495d2
2016-10-20 09:50:49 -07: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
Seigo Nonaka
ebeb817966 Merge "Remove obsolete interface GetTable." 2016-10-20 08:05:35 +00:00
TreeHugger Robot
0154feef22 Merge "Initial refactoring to enable reuse of SkiaDisplayList on a per RenderNode basis. With Skia renderer we see 30% speed improvement in Invalidate Tree UI Jank test, when SkiaDisplayList objects are reused." 2016-10-19 20:36:00 +00:00
Sergei Vasilinetc
7ca5ad1d06 Merge "Move allocatePixelRef methods to hwui. This patch also makes tests to use SkBitmap backed by hwui/PixelRef, Test: refactoring cl. bug:27762775" 2016-10-19 20:30:24 +00:00
Mike Reed
ca9b1ed9f0 Merge "use SkBlendMode instead of SkXfermode use sk_sp versions of paint setters/getters" 2016-10-18 13:57:13 +00:00
Seigo Nonaka
9cd73b6828 Remove obsolete interface GetTable.
Test: Manually done.

Change-Id: Ib9f50610454a6ddd7179c40d5f31c74916bcff84
2016-10-18 15:10:21 +09:00
TreeHugger Robot
52528d7629 Merge "Fix complex clipping on mergeable ops" 2016-10-17 22:11:46 +00:00
Mark Salyzyn
21c2e9e60c Merge "missing includes" am: 78929f3ee0 am: 6a8f0d70b0
am: 6e60ab12e7

Change-Id: I1b5c6f49d2ae565ebd59c6ce8d590512ab306487
2016-10-17 21:38:33 +00:00
Mark Salyzyn
6e60ab12e7 Merge "missing includes" am: 78929f3ee0
am: 6a8f0d70b0

Change-Id: I40ff974f4333aaa714a63d5436b822491b9d78d6
2016-10-17 21:31:35 +00:00
Mark Salyzyn
6a8f0d70b0 Merge "missing includes"
am: 78929f3ee0

Change-Id: I3e7a25ded484d516fab453abe434c2e53cf0f27e
2016-10-17 21:25:59 +00:00
Chris Craik
f8f56cbb20 Fix complex clipping on mergeable ops
Fixes: 32106003
Test: unit tests passing (and one added)

Change-Id: I519bc38a1fa8c25c9ae317ffdb7e59e5a0824f59
2016-10-17 13:40:32 -07:00
Stan Iliev
c0e7a90f1f Initial refactoring to enable reuse of SkiaDisplayList
on a per RenderNode basis. With Skia renderer we
see 30% speed improvement in Invalidate Tree UI Jank test,
when SkiaDisplayList objects are reused.

Test: manually built and run on angler-eng.
Change-Id: Ie4ec50ddb2015150e3ec678dde7ebed0c8d90067
2016-10-17 16:30:28 -04:00
Chris Craik
dfe4a1b6ee Fix complex clipping on mergeable ops DO NOT MERGE am: d183e0b988
am: a6bfd8d12c

Change-Id: I5af8d0fac1e47e7bf831ca2f387fe550acf4165c
2016-10-17 19:59:32 +00:00
Mark Salyzyn
4d6c372eae missing includes
Assumptions are made about header side effects

Test: compile
Bug: 30465923
Change-Id: Icc9415aed5e54b2bc00b70aa0da6df4148f30654
2016-10-17 12:32:54 -07:00
Chris Craik
d183e0b988 Fix complex clipping on mergeable ops DO NOT MERGE
Fixes: 32106003

Change-Id: I519bc38a1fa8c25c9ae317ffdb7e59e5a0824f59
2016-10-17 10:51:11 -07:00
sergeyv
c36bd6c16d Move allocatePixelRef methods to hwui.
This patch also makes tests to use SkBitmap backed by hwui/PixelRef,
Test: refactoring cl.
bug:27762775

Change-Id: Ib936e81877790849118420f5e565fc8f4466c1be
2016-10-13 18:22:04 -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
Derek Sollenberger
6e68bedacc Merge "Initial refactoring to enable the addition of the SkiaOpenGLPipeline." 2016-10-13 16:53:14 +00:00
TreeHugger Robot
8e56eea48c Merge changes Icd65d906,I109cb9db
* changes:
  Don't apply the OECF twice to multi-stop gradients
  JNI does not use hwui_flags but LOCAL_CFLAGS
2016-10-13 03:27:21 +00:00
Romain Guy
f9037dabea Don't apply the OECF twice to multi-stop gradients
Test: Manual

Change-Id: Icd65d906df2f0a059373edb8c6d55fe378c92f92
2016-10-12 18:31:31 -07:00
TreeHugger Robot
a6abb1031f Merge "Fatal abort on invalid state" 2016-10-12 23:12:18 +00:00
Romain Guy
3b26c211e3 Merge "Various fixes for linear blending and gradients" 2016-10-12 22:17:10 +00:00
John Reck
cecec702eb Fatal abort on invalid state
Use mCaches.size() to track item count instead of trying
to do it manually on the side.

Bug: 31856965
Test: manual, minimal. Repro steps for bug are unknown, fix
is speculative as a result
Change-Id: Ic32f27262548a99be95440881420d224ede4db74
2016-10-12 14:18:17 -07:00
Doris Liu
4e230f4688 Fix SkShader leak for Gradient VectorDrawable and test am: fc9cf72339 am: c47199bb6a
am: 1ef744a3b8

Change-Id: Iee4f98f10a4e1b3947166777040918ab779ab023
2016-10-12 21:10:47 +00:00
Doris Liu
1ef744a3b8 Fix SkShader leak for Gradient VectorDrawable and test am: fc9cf72339
am: c47199bb6a

Change-Id: I261f8f3708f526c15ae93c51d24bdaee054354f6
2016-10-12 21:03:14 +00:00
Romain Guy
8762e332e3 Various fixes for linear blending and gradients
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-12 13:28:26 -07:00
Romain Guy
21986f2ae7 Merge "Linear blending, step 1" 2016-10-12 15:52:14 +00:00
Doris Liu
fc9cf72339 Fix SkShader leak for Gradient VectorDrawable and test
This CL fixes a SkShader leak in VD when applying local matrix
to the shader. Specifically, the usage of newWithLocalMatrix(...)
increments the shader's ref count in every draw() call for
Gradient VectorDrawable, whereas there's no balancing call to
decrement the ref count in draw(). In this CL, we assume
the ownership of the shader returned from newWithLocalMatrix(...)
to ensure the correct ref count management.

Also, add test to verify that shader is no longer being leaked

BUG: 32067647
Test: this CL

Change-Id: Ic15fe46cde06a73d81b44e2d3c56b51907344cc0
2016-10-12 01:22:11 +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