55 Commits

Author SHA1 Message Date
Lucas Dupin
00af5271da Adding force-dark support to RippleDrawable
Add force-dark support to RippleDrawable by modifying the ink color.

Test: manual
Test: atest CanvasOp
Fixes: 186130682
Change-Id: I89eaaf3afa5ec53a74d2d08de8cff6484e55a912
2021-05-06 15:17:02 -07:00
Lucas Dupin
6d1601a740 Move sparkle animation to RenderThread
The sparkle loop animation was happening on the UI thread and is poses
some interesting challengers:
- Animations freezes when UI thread is busy, for example when
  startActivity is called.
- onDraw calls add unnecessary work to the UI thread, leading to jank
  in some cases, like PIP

Test: manual
Fixes: 184760248
Change-Id: Ie2840c767da61476678839eaac215dc3aff95b5c
2021-04-15 15:26:32 -07:00
Nader Jawad
2dc632aee3 Holepunch layers for SurfaceView
Update RenderNodeDrawable to hole punch areas into
layers created for SurfaceView

Bug: 184297961
Test: Added CTS test to SurfaceViewTests
Change-Id: I1f03a4fe34c5a8b7411ebe728ea3d4195fcd1fac
2021-04-06 22:03:00 -07:00
Mike Reed
bb4cb48800 Simplify paint filtering
Removes complication of copy-on-write intermediate class, and
allows for shaing a single applyLooper() function.

Test: make

Bug: 178700363
Change-Id: Ia74cb8e7c650e469b8429de1d7cf9204821d8f11
2021-02-23 12:49:22 -05:00
Mike Reed
0f9dce7ed5 Custom looper code for Android
Test: make

Bug: 178700363
Change-Id: I1d328275ab5e0c9b6b9171ef075f71274e50a3f5
2021-02-17 11:30:21 -05:00
John Reck
0acf0dade3 Merge "Remove DisplayList.h dependency from Canvas.h" 2021-01-20 04:52:14 +00:00
John Reck
2e48df3705 Remove DisplayList.h dependency from Canvas.h
Canvas is included in a lot of places, reduce include
dependencies

Test: make
Change-Id: Iab513de8d4bc3eb18220307acc124859dbf44030
2021-01-19 21:58:40 -05:00
TreeHugger Robot
106f1b33b4 Merge "Refactor RuntimeShader to support easier assignment of uniforms." 2021-01-15 20:16:55 +00:00
Derek Sollenberger
783e5aeb2e Refactor RuntimeShader to support easier assignment of uniforms.
uniforms are no longer set as single block of bytes where the caller
has to know the offset, but instead by the string identfier in the
shader.  This CL only supports floats, but future expansions of this
will provide helpers for ints, colors, and byte[].

Also by storing the shaders and uniforms in the RuntimeShaderBuilder
we can more easily copy them.  This enables Canvas.drawRipple to not
just copy the compiled SkSL effect, but also all the uniforms and
other input shaders set on the RuntimeShader.

Bug: 177051137
Test: HwAccelerationTest
Change-Id: I4733f42ba662546be6bebc37f0b89832778e66ce
2021-01-15 13:03:25 -05:00
John Reck
f0b5b1a076 Merge changes I1d7806aa,Ie906e628,Idf5a4acc
* changes:
  Convert DisplayList to a value-type wrapper
  Remove forward-decleration of SkiaDisplayList
  Avoid DisplayList* hitting the JNI layer
2021-01-14 18:02:57 +00:00
John Reck
be67195c44 Convert DisplayList to a value-type wrapper
Make DisplayList its own type instead of an alias,
pushing the Skia aspect behind it mostly. Removes a bunch
of manual memory management and opens the door to DisplayList
being a union type with multiple implementations

Test: builds (somehow), boots, hwuiunit passes, CtsUiRendering passes
Change-Id: I1d7806aa3afc5d9ece08b06959920078a5814c59
2021-01-14 03:55:58 +00:00
TreeHugger Robot
a6a7ea7ed2 Merge "Initial framework needed to draw circle with RuntimeShader." 2021-01-08 15:42:48 +00:00
Derek Sollenberger
df301aaa54 Initial framework needed to draw circle with RuntimeShader.
This also adds the ability for RenderThread to animate a few
predefined shader uniforms.

Bug: 177051137
Test: demo in ag/13296877
Change-Id: I6e58e671ad1242a07ecb1cf4cdb48031f85c2088
2021-01-08 12:47:31 +00:00
Mike Reed
2d1279f3a9 Adopt sampling parameter
Test: make

Change-Id: Ie5c1897cf9108db3795a5d65b8c095e0b0280520
2021-01-05 14:24:58 -05:00
John Reck
a00eef21de Remove SaveFlags from saveLayer(Alpha)
This has been hardcoded as ALL_SAVE_FLAGS for a couple releases now.

Since it's now permanent behavior, remove the last bit of plumbing
for SaveFlags on saveLayer

Test: builds & boots
Change-Id: Iec92f27199d0b4781c2293dcdcfd45a1562a1b4e
2020-11-16 18:26:08 -05:00
Seigo Nonaka
63af7ba42f Remove bounding box retrieval from Canvas which is not used.
The bounding box information is not used for drawing glyphs, so
removing them from Canvas.

Bug: 169114687
Test: hwui_unit_tests
Change-Id: I512717cd00fe56e5b74fcc32fbdf2319e273074e
2020-09-22 16:24:34 +00:00
John Reck
aa4c982294 Remove legacy callDrawGlFunction2 from HWUI
Bug: 151439970
Test: CtsUiRenderingTestCases passes

Change-Id: I1c29df17bb6e8b078467edf73cb3547db6948cdd
2020-06-26 13:49:05 -07:00
Leon Scroggins III
0f53e10c07 Switch Java calls to enableZ and disableZ; remove isRecordingFor
Bug: 155422223
Test: make

insertInOrderBarrier and insertReorderBarrier are @hide and deprecated.
Remove them and update all callers to enableZ and disableZ, which are
already public.

Update native code to refer to enableZ instead of insertReorderBarrier.

In addition, remove @hide Canvas#isRecordingFor. This method was
originally used to prevent a single RenderNode from being in two display
lists. This is now supported, so there's no reason to avoid it. The one
caller used it to determine whether to reorder drawing its child Views
(which, as the comment says, makes sense to determine based on whether
the Canvas isHardwareAccelerated) and whether to call
insertReorderBarrier/insertInOrderBarrier (now enableZ/disableZ). In the
latter case, there is no need for a conditional, since enableZ/disableZ
only work on a hardware Canvas.

Change-Id: Ib216a19d6aeff40b2e23532bacd62d1795c2ab27
2020-05-06 09:38:39 -04:00
John Reck
2afc3b0a00 Remove a dead option
Test: builds & text still works
Change-Id: Ia9c678f258834d7cc5e65027db8be4c37fb6b4db
2019-10-28 15:51:25 -07:00
Mike Reed
c2dbc03acc pass Paint not SkPaint to Canvas
Test: cts

Change-Id: I9a3314bc3f221b6e884c8c84d7b0241f7c5be600
2019-07-29 13:38:35 -04:00
John Reck
894e85a34d Remove final usage of asSkCanvas
Bug: 137581257
Test: builds
Change-Id: Ib38f85c11be332e6cd784f8bbf55f58cde72ac09
2019-07-15 16:16:44 -07:00
Jerome Gaillard
21e7e2d9b1 Build native android graphics library for desktop
The purpose of this is to be able to use the native graphics code from
the Android platform directly in Android Studio (running on desktop) to
do layout rendering.

This creates a host library that is a subset of libandroid_runtime
including only the JNI files relevant to Android graphics. It also
includes LayoutlibLoader.cpp which is used to load the JNI when using
it as part of layoutlib (the graphics library for Android Studio).

This also creates libhwui-host, a host library that is a subset of
libhwui.

Bug: 117921091
Test: lunch sdk && m libandroid_runtime
Change-Id: I3850020d2d4c13c85e377476bc463d3eb6a01c6d
2019-05-29 15:48:53 +01:00
Derek Sollenberger
6b045a0b14 Merge "Fix fading edge effect from impacting neighboring pixels" 2019-05-09 18:25:30 +00:00
Derek Sollenberger
ac33a48751 Fix fading edge effect from impacting neighboring pixels
Bug: 129117085
Test: skia unit tests and test cases described in the bug
Change-Id: Ieaa7c831dd6298ac0565e6f1837b1c1dbd4545da
2019-05-02 13:04:20 -04:00
Ben Wagner
5a31997b0e Remove SkCanvas::filterBitmap declaration.
It doesn't look like this even has an implementation anymore.

Test: This just removes dead code.
Change-Id: I126ad7f653e80973e0d79966a5885f486e2aa9f2
2019-04-26 10:39:37 -04:00
Mike Reed
2dfd55d199 don't toggle between Paint and SkPaint
Test: make

Change-Id: Id5864591db0577a24833bbb90036b9554ce130d4
2019-01-08 16:19:22 -05:00
Derek Sollenberger
24fc901e5f Improve performance of unclipped save layers.
Instead of allocating a separate renderTarget and switching
between them on each draw the new implementation follows the same
pattern that the old HWUI renderer used. The area of the layer is
now copied to a buffer on the GPU, the area is then cleared, rendered
as normal, and finally the texture is redrawn using dst_over blending.

This results in no render target switches and is considerably faster
on some hardware.

Test: CtsGraphicsTestCases, CtsUiRenderingTestCases
Bug: 119222339
Change-Id: I716aac1fc31e4c7a171373d37dee82034c01cf18
2018-12-20 10:04:46 -05:00
Derek Sollenberger
d01b5916d8 Set the color space to sRGB on the Surface and remove colorFilter.
Also for a canvas wrapping a bitmap the colorspace of the bitmap
will be used to correctly blend content.

Test: CtsUiRenderingTestCases
Bug: 111436479
Change-Id: I63ad7a30605a7f725cc0ef4716d42ea978fb03e3
2018-11-07 20:56:28 +00:00
Nader Jawad
adfe1d991b Added support for Canvas#drawDoubleRoundRect in application Canvas API
Exposed Skia's underlying drawDRRect method used to draw a double
rounded rectangle

Bug: 117181396
Test: Added test case to verify Canvas#drawDRRect and re-ran CanvasTests
Change-Id: I4e1954c8ffc82811dc541488d1df9b37309faf51
2018-10-02 17:12:15 -07:00
Ben Wagner
0ed10bedbb Replace SkDrawFilter with PaintFilter.
Skia is removing SkDrawFilter.

Test: refactoring CL. Existing unit tests still pass.
Change-Id: If81c1a2feabf7d377ae1d7bcb3e8cf0f599ad3ce
2018-07-11 12:07:22 -04:00
Derek Sollenberger
2d14213849 Initial implmentation of AnimatedImageDrawables on the RenderThread.
The current implementation schedules the next frame of the images
to be decoded after the current frame completes but potentially
schedules tasks that will result in a no-op execution if a new
frame is not yet needed.

Test: HwAccelerationTest
Change-Id: I0510cb5a1b801abd651327e924deb586af0306d6
2018-01-24 13:11:39 +00:00
Leon Scroggins III
671cce2605 Make ImageDecoder return animated Drawables
Bug: 63909536
Bug: 63908092
Test: TODO

If ImageDecoder.decodeDrawable is called with an animated image Source
(currently GIF or WebP), return an object of a new (hidden) Drawable
subclass. The new Drawable animates, and it implements Animatable (TODO:
implement Animatable2) so users have some control over the animation.

In addition to the normal features of Drawable, this new one supports
many of the features of ImageDecoder, including scaling, cropping and
PostProcess, which enables circle masks/rounded corners and other
arbitrary after-effects. It does *not* support decoding directly to a
Hardware Bitmap, since it cycles through frames and reuses the same
bitmap memory. But it could be made to use shared memory (TODO?).

TODO: Use a better number for the native allocation registry
TODO: Use the RenderThread to drive the animation, and remove decoding
on the UI thread.
TODO: Add support for modifying the loop count

Android.bp:
- build new AnimatedImageDrawable.cpp

AndroidRuntime.cpp:
- register new native methods

AnimatedImageDrawable.java
AnimatedImageDrawable.cpp:
- new Drawable that handles animated images

Canvas.h, SkiaCanvas.h/.cpp
- New virtual method and implementation for drawing SkAnimatedImages

RecordingCanvas.h/.cpp
- Stub implementation of drawing SkAnimatedImages

ImageDecoder.h/cpp
- Allow code sharing with AnimatedImageDrawable.cpp
  - postProcess
  - access the ImageDecoder struct

Depends on https://skia-review.googlesource.com/c/skia/+/94660 in Skia.

Change-Id: Ie2ec98d9c52deda4d439c6ef8e5dea2861bb93a3
2018-01-17 17:06:57 -05: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
938e884a1f Avoid setting high contrast in every view draw
Test: high contrast text still works
Change-Id: I6674d1aca8dddf7eb9725a5346aed12ef1dbc195
2017-08-24 16:15:58 -07:00
Derek Sollenberger
fa3e340431 Use colorFilters when rendering to an sRGB bitmap.
Bug: 62347704
Test: CtsUiRenderingTestCases, CtsGraphicsTestCases, hwui_unit_tests
Change-Id: I3e237b64cd92217b02d4995bdd695a28d3f393ee
2017-08-07 08:43:23 -04:00
Derek Sollenberger
a7f6af2c51 Revert "Use colorFilters when rendering to an sRGB bitmap."
This reverts commit b851b197497783f894b72edcaed8f93d035ddea0.

Change-Id: I5bb8fe9bf9f5d411674e289c467b3f569f7bb068
2017-08-02 21:57:42 +00:00
Derek Sollenberger
b851b19749 Use colorFilters when rendering to an sRGB bitmap.
Bug: 62347704
Test: CtsUiRenderingTestCases, CtsGraphicsTestCases
Change-Id: I55a574ffd9305588b82345a598da7818952a131d
2017-08-02 11:37:46 -04:00
Matt Sarett
d0814db633 Add SkiaCanvas::captureCanvasState()
Test: Verified bug is fixed.  Wrote unit test.

Bug: 37268771

Change-Id: I9deb7db353cd2129ad245e7f65419670463bb717
2017-04-13 14:23:38 -04:00
Matt Sarett
7c9fb6076e Merge "Xform bitmaps to sRGB on SW and PDF canvases" into oc-dev am: c29dffed16
am: fd5d5425ee

Change-Id: If960ccd900ebc2b841c2f13ca4f25820a48a950f
2017-04-06 22:16:49 +00:00
Matt Sarett
ea70d22dc8 Xform bitmaps to sRGB on SW and PDF canvases
For picture-backed canvases, we will defer the xform
until playback.

Test: Unit tests and cts test.
Bug: 32984164
Change-Id: Ib74663bcb688b74b6ba8792b403b0475126732af
2017-04-06 15:14:00 +00:00
Mike Reed
826deefda5 switch over to SkVertices object, and stop using deprecated methods.
This allows Skia to remove
  SK_SUPPORT_LEGACY_CANVAS_VERTICES
  SK_SUPPORT_LEGACY_BITMAP_SETPIXELREF
  SK_SUPPORT_LEGACY_PIXELREFFACTORY

Test: Existing CTS cover these changes

Running CtsGraphicsTestCases, there were 6 failures w/ and w/o this CL.
None of the 6 seems related to this CL.

Change-Id: I724082357d9f6cb699770df3c0b9ef555b957697
2017-04-05 14:20:38 +00:00
Stan Iliev
0b58d99283 Optimize Canvas::drawGlyphs
Avoid one memcpy in Canvas::drawGlyphs for all pipelines.

Test: CTS passed with exception of SweepTests#testBasicDraws
shadowtext, which fails with and without this CL.
Change-Id: I0841232dc7a6173eb3b03f939dbde15a84186296
2017-04-04 15:43:12 -04: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
Mike Reed
6e49c9f007 switch over clip calls to use SkClipOp instead of SkRegion::Op
Change-Id: I67d23c487b5249bc31d96e3b2393f693c0b2bcff
2016-12-07 10:34:39 -05:00
Mike Reed
6acfe16b56 SkCanvas is no longer reference-counted
Change-Id: Ie821efe7c0a7d1301715e303aaf4d7ec86ac35e7
2016-11-28 15:11:22 -05: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
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
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
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