171 Commits

Author SHA1 Message Date
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
Seigo Nonaka
7cc3ee7091 Adjust font texture cache based on device density.
The main purpose of this CL is reducing font cache size of
low-density device.

The memory usage for the small RGBA texture will be
Nexus 6P: 7,928,856 bytes (1408x1408)
Nexus 5X: 4,734,976 bytes (1088x1088)
These used to be 4,194,304 bytes

Test: manually checked
Bug: 64400885
Change-Id: Ied064a6d59909ad7fbeff74332973206436fbd34
2017-08-15 10:53:20 -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
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
Derek Sollenberger
b29b16e542 Remove clipRegion from the public API.
This API is difficult to support for printing and has other negative
effects as it does not respect the current matrix/clip.

Test: compile
Bug: 14650725
Change-Id: I71f9bd687d446c7ce8910d755421aad8e09458db
2017-01-04 14:57:43 -05: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
sergeyv
dcbc0e9e25 resolve merge conflicts of 0ec2fd7 to master
Change-Id: I113ede26ab42e3f9a36a52a756c38d365731e16d
2016-09-14 09:15:15 -07: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
sergeyv
baf29e7cf4 HWUI: calculate used memory in FontCache for gfxinfo
bug:30427106
Change-Id: I653571d6a4e974e975fb0dc03fc2364eecbf2f84
2016-09-08 14:50:50 -07:00
Chris Craik
5e00c7ce06 Delete old rendering pipeline
fixes: 30002246

Change-Id: I45df0e924708526cee045b14c291bd23aa1a92db
2016-07-07 15:53:50 -07:00
Chris Craik
f3754a8428 Fix shadow radius too large for RS
bug:28276925

Change-Id: I3d962ace75be7bbf49f5a95320390d8f5a9bf951
2016-04-19 18:15:51 -07:00
Chris Craik
e8c3c813b0 Fix TextDropShadowCacheTests and glyph_t everywhere
Change-Id: I943eae4e9408c77bdfba6304ba7ee3e862351a41
2016-02-08 22:45:22 +00:00
John Reck
2de7771740 Normalize GL_UNPACK_ALIGNMENT
Several places were setting GL_UNPACK_ALIGNMENT
unneccessarily, whereas other places were assuming an
unpack alignment of 1. Since we never actually
do explicit row-alignment, set GL_UNPACK_ALIGNMENT
to 1 at context creation time and never change it

Bug: 26584230

Also turns on aggressive glGetError checking to
better catch potential problem zones

Change-Id: I190c8f0f0494a7f046d5ed769405c75d363be59a
2016-01-20 13:16:24 -08:00
Chris Craik
5430ab220b Avoid unneeded rect params
Change-Id: I2d8dcf6b09fdc554a403ac74763bf856b5f5d9fa
2015-12-10 16:29:01 -08:00
Chris Craik
f09ff5aa57 Add bitmapmesh, rect, and patch rendering
bug:22480459

Change-Id: Id9e9146997dd018b3e4e785c2bc13689e3cf7c3c
2015-12-09 16:06:09 -08:00
Chris Craik
15c3f19a44 Merged op dispatch in OpReorderer
bug:22480459

Also switches std::functions to function pointers on OpReorderer, and
switches AssetAtlas' entry getter methods to using pixelRef pointers,
so it's clear they're the keys.

Change-Id: I3040ce5ff4e178a8364e0fd7ab0876ada7d4de05
2015-12-07 12:34:46 -08:00
Chris Craik
9e7fcfda28 Move BakedOpDispatcher to separate file
Change-Id: If7aad6db6b7e54a33eac9b9eddbe8cd844207282
2015-11-25 13:27:33 -08:00
Chris Craik
a1717271ca Initial text support in new reorderer/renderer
Removes obsolete drawPosText codepath, and unifies text decoration behavior.

Change-Id: I9c563249ab688a3394445a0e7fe1b9d0661f6f7c
2015-11-20 11:03:18 -08:00
Stephen Hines
0fe8ea2096 am 697e3dd6: am ee144b1e: resolved conflicts for bd57dac5 to stage-aosp-master
* commit '697e3dd6b9a8be4451e19ab7c03ced310602b92a':
  Don't unregister Fonts from renderer at destruction
2015-10-03 00:52:32 +00:00
Stephen Hines
ee144b1e60 resolved conflicts for bd57dac5 to stage-aosp-master
Change-Id: I5107af13712d7cc908d8699e5c15a002f0a3ec85
2015-10-02 17:34:05 -07:00
Chris Craik
148c78f825 Don't unregister Fonts from renderer at destruction
bug:24584749

Fonts are only destroyed when the renderer is destroyed, this prevents
modifying the FontRenderer's LruCache while it's being iterated through
in FontRenderer::~FontRenderer.

Change-Id: I0e2c9f87981bfa50454ec8689df05851839e288e
2015-10-02 14:21:46 -07:00
Chris Craik
c08820f587 Remove lookup3 gamma code
Also clean up gamma / glyph cache properties

Change-Id: I75b1ac0cb55638bf787ffd3cf457483ae314f03b
2015-09-22 14:40:35 -07:00
Chris Craik
9db58c031f Remove MathUtils::min/max
bug:22202895

Change-Id: Ia115d86871314e3819f684ea7307356aed13a28e
2015-08-19 15:53:01 -07:00
huanhuan.x.wang
a46ca5ec73 Make the value for shadowRadius less than 1.0 work
bug:22806069

Shadow effect is not visible if the shadowRadius is set
between 0.1 and 1.0.

Cherry-pick of 8d9b5fbd from AOSP

Change-Id: Ifff71f44d66ba604bd751bb1df96a9904ae7998e
2015-08-14 22:47:47 +00:00
Andreas Gampe
fea85a33b7 Hwui: Remove unused variables
For build-system CFLAGS clean-up, remove unused variables.

Bug: 18632512

(cherry picked from commit cb4af9b10ab17187288d8f5ccb4cc1e465be9a51)

Change-Id: Ic58bedc84234325512193991fc64315e3aad6f9e
2015-08-12 16:30:32 -07:00
John Reck
272a685f17 Replace most usages of utils/Vector.h
Change-Id: I540d1b3523244d6c71fc52d6fb30555271c25644
2015-07-30 09:51:52 -07:00
Andreas Gampe
cb4af9b10a Hwui: Remove unused variables
For build-system CFLAGS clean-up, remove unused variables.

Bug: 18632512
Change-Id: Ic58bedc84234325512193991fc64315e3aad6f9e
2015-07-27 18:22:08 -07:00
Chris Craik
e6a15ee3d0 Remove all usage of fmin and fmax
bug:22208220

Removes needless call, and upconversion to doubles in multiple places.

Change-Id: I1b949fa5f206446ac34de800154c0147d6bd8034
2015-07-07 18:42:42 -07:00
Chris Craik
53e51e4aa9 Handle shader matrix correctly when ignoring canvas transform
bug:20063841

Restores old SkShader matrix behavior from before the Glop refactor.

Many drawing operations draw without sending the canvas transform to
the GL shader. In such cases, we need to adapt the matrix sent to the
SkShader logic to invert the canvas transform that's built into
the mesh.

Change-Id: I42b6f59df36ce46436322b95bf9ad2140795ee58
2015-06-02 16:28:39 -07:00
huanhuan.x.wang
8d9b5fbdf0 Make the value for shadowRadius less than 1.0 work
Shadow effect is not visible if the shadowRadius is set
between 0.1 and 1.0.

Change-Id: Ifff71f44d66ba604bd751bb1df96a9904ae7998e
2015-04-14 16:25:46 +02:00
John Reck
cdd3021936 am 18ae2a02: am 32eafe9b: am a08f6a66: Merge "Fix GL_INVALID_OPERATION in font renderer when font cache is limited."
* commit '18ae2a020d3c720f8b6125b9f4567e953f04c7b0':
  Fix GL_INVALID_OPERATION in font renderer when font cache is limited.
2015-04-10 16:06:04 +00:00
John Reck
a08f6a66e9 Merge "Fix GL_INVALID_OPERATION in font renderer when font cache is limited." 2015-04-10 15:32:01 +00:00
Chris Craik
828407356d Delete pre-glop path
bug:19014311

Change-Id: I06376b6f625455892d8eafe2727b78025a64c4bf
2015-04-03 13:01:18 -07:00
Chris Craik
c6128bae43 Fix clang build
Change-Id: I5336ac347123671a18401121c5f001c8f7caf54d
2015-03-19 10:00:56 -07:00
Chris Craik
e2bb380bc2 Use glops for text rendering
Change-Id: I5e155c8baf3149f0ff231ec3c89dbff6bb8eae92
2015-03-18 16:10:24 -07:00
Chris Craik
083e733e82 Cleanup of FontRenderer
Remove invalid and over complicated buffer unbinding
optimization, and simplify constructor.

Change-Id: I3dd90528de4f377e972bbd7967e7e232875387e4
2015-02-27 17:09:02 -08:00
Chris Craik
6c15ffa196 Refactoring of Program ownership/lifecycle, and WIP Glop rendering path
Change-Id: I2549032790bddbc048b0bccc224ed8f386b4517c
2015-02-02 14:08:57 -08:00
Chris Craik
44eb2c0086 Refactor blending and texture gl state
Change-Id: Ia6b3c8b2afd3dfcee7f3ce401d846b789612054a
2015-01-30 10:49:05 -08:00
Chris Craik
96a5c4c7ba Move more GL state management to RenderState and its directory
Change-Id: Ic68584e1c08dc64be2ad43450cb6caa1de834fdc
2015-01-28 16:32:39 -08:00
Chris Craik
d41c4d8c73 Add overrides and switch to nullptr keyword for all files
Adds remaining missing overrides and nullptr usages, missed due to
an extreme failure in tool usage.

Change-Id: I56abd72975a3999ad13330003c348db40f59aebf
2015-01-05 16:49:13 -08:00
Chris Craik
51d6a3db97 Cleanup various clang warnings, use unique_ptrs in several places
Change-Id: I347904b25e51fcc7de14b1e72f1acd0f6ba26f3f
2014-12-23 16:53:56 -08:00
Andreas Gampe
64bb413a66 Revert "resolved conflicts for merge of 220c3f4f to master"
Reverted as hwui doesn't agree.

This reverts commit 8a902d9f24e83c87b054adb5836b4a5b8a257be9.

Change-Id: I109e7b02bee2921e2155ded6df36f52e6f574b5a
2014-11-22 00:35:09 +00:00
John Reck
8b59a528b5 Revert "Frameworks/base: Unused parameters in hwui"
This reverts commit 42ddc18d108f789705ad4eb697ce9599ad322507.

Change-Id: I3574a936a39a96314db6437d0a1eb58d260d893d
2014-11-22 00:10:02 +00:00
Andreas Gampe
42ddc18d10 Frameworks/base: Unused parameters in hwui
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-11-21 10:39:21 -08:00
Andreas Gampe
1e19674107 Frameworks/base: Wall Werror in libs/hwui
Turn on -Wall -Werror in libs/hwui. Fix errors.

Change-Id: I74962d08c889712dacbd0d86d6760fc10802b6bd
2014-11-10 15:58:04 -08:00
chaochen
1f61b1911e Fix GL_INVALID_OPERATION in font renderer when font cache is limited.
b/17332126 

This patch is to fix a false logic in FontRenderer when
flashAllAndInValidate() happens. The flashAllAndInvalidate
will trigger an issueDrawCommand which will set mDrawn to
true even though there is no texture drawn. So that the
step of unbinding buffer in GL is skipped. And when the
second time issueDrawCommand get called, the
glVertexAttribPointer will be trigger with GL_ARRAY_BUFFER
wrongly bound and then finally lead to a GL_INVALID_OPERATION when
glDrawElements() in FontRenderer:issueDrawCommand get
called the second time.

Change-Id: I1a996354a84db911ace0e7b39ca77cd0dd3d1555

Signed-off-by: Raj Mamadgi <r.mamadgi@samsung.com>
2014-08-29 20:29:01 +00:00
Chris Craik
59744b79ec Add hack for custom re-rasterization buckets
bug:14083128

Moves all of the font transform management into
OpenGLRenderer::findBestFontTransform(), and now simply passes down
final rasterization transforms into the FontRenderer.

Change-Id: Ie02752e6af863347b142367c7d628db5f9fc2998
2014-07-07 19:14:55 +00:00
Derek Sollenberger
c33fb2b5c0 Merge "Pass the radius as a float deeper into HWUI allowing RS to generate more accurate blurs." 2014-05-23 15:51:20 +00:00
Leon Scroggins III
d1ad5e62fd Inspect SkShader to determine hw shader.
Instead of duplicating internal info about SkShader, inspect the
SkShader installed on the SkPaint.

core/java/android/view/GLES20Canvas.java:
Remove setupModifiers, nResetModifiers, and nSetupShader.

core/jni/android/graphics/Shader.cpp:
Remove calls to create/destroy the (previously) attached SkiaShader.

core/jni/android_view_GLES20Canvas.cpp:
Remove native code for setupShader and resetModifiers.

graphics/java/android/graphics/BitmapShader.java:
graphics/java/android/graphics/ComposeShader.java:
graphics/java/android/graphics/LinearGradient.java:
graphics/java/android/graphics/RadialGradient.java:
graphics/java/android/graphics/Shader.java:
graphics/java/android/graphics/SweepGradient.java:
Remove code keeping track of native SkiaShader.

libs/hwui/Caches.h:
Include Extensions.h.

libs/hwui/DeferredDisplayList.cpp:
Compare shaders on the paint, instead of on DrawModifiers.

libs/hwui/DisplayList.cpp:
libs/hwui/DisplayList.h:
Remove vector of SkiaShaders.

libs/hwui/DisplayListOp.h:
Access the SkShader on mPaint.
Remove SetupShaderOp and ResetShaderOp.

libs/hwui/DisplayListRenderer.cpp:
libs/hwui/DisplayListRenderer.h:
Remove resetShader, setupShader, refShader, and mShaderMap.

libs/hwui/FontRenderer.cpp:
Pass SkShader to setupDrawShader and setupDrawShaderUniforms.

libs/hwui/OpenGLRenderer.cpp:
libs/hwui/OpenGLRenderer.h:
Add LayerShader, a class inheriting from SkShader, to mimic the
behavior of SkiaLayerShader. Unlike SkiaLayerShader, it can be set on
the SkPaint so it can be inspected later.
Set a LayerShader instead of a SkiaLayerShader.
setupDrawShader and setupDrawShaderUniforms now inspect an SkShader
passed in.
Inspect SkShader instead of mDrawModifiers.mShader.
Remove resetShader and setupShader.
setupDrawColorUniforms now takes a boolean indicating whether there is
a shader.
Add an inline function for accessing the SkShader on an SkPaint.
In setupDrawBlending(Layer*, bool), do not check the shader (which will
never be set), but do check whether the color filter may change the
alpha (newly fixed behavior).
In setupDrawBlending(SkPaint, ...), check the SkShader and whether the
color filter affects alpha (the latter is new behavior).

libs/hwui/Renderer.h:
Remove pure virtual functions setupShader and resetShader.

libs/hwui/ResourceCache.cpp:
libs/hwui/ResourceCache.h:
Remove functions for refing/unrefing shaders.

libs/hwui/SkiaShader.cpp:
libs/hwui/SkiaShader.h:
Much of this code was redundant and has been removed.
Convert structs into class with nothing but static functions for
calling describe/setupProgram.

libs/hwui/TextureCache.cpp:
libs/hwui/TextureCache.h:
Use the SkPixelRef as the key to the bitmap Lru cache, since shader
inspection will provide a different SkBitmap pointer (though it will
hold the correct SkPixelRef with the correct generation ID).

tests/CanvasCompare/src/com/android/test/hwuicompare/DisplayModifier.java:
tests/CanvasCompare/src/com/android/test/hwuicompare/ResourceModifiers.java:
Update manual test to have more shaders: radial, sweep, compose,
invalid compose.

BUG:10650594

Change-Id: Iaa7189178bda1c55f96da044d2a9fa602ba36034
2014-05-22 14:46:59 -04:00
Derek Sollenberger
e392c81f6b Pass the radius as a float deeper into HWUI allowing RS to generate more accurate blurs.
Also, when converting radius to an integer value snap to the appropriate integer boundaries.

bug: 10650594
Change-Id: Icca4bc17d88162bbcbc6035d4f81bd1d98a4de2d
2014-05-21 13:27:10 -04:00