Commit Graph

111 Commits

Author SHA1 Message Date
Michael Ludwig
70cf50c24a Emulate replace clip ops using SkAndroidFrameworkUtils::ResetClip
At the JNI bridge, Region::Op::kReplace_Op is detected and sent
to new functions on Canvas.h -> emulateReplaceClip[Rect|Path].
The SkiaCanvas implementation calls
SkAndroidFrameworkUtils::ResetClip to turn the SkCanvas' clip
wide open (modulo the device clip restriction), followed by
an intersect op with the actual clip geometry.

SkiaCanvas is also updated to record the replace ops in its
Clip struct for partial saves.

This should result in no visible behavioral change at the Java
Canvas level, but allows the removal of the
SK_SUPPORT_DEPRECATED_CLIPOPS flag.

Test: Updated SkiaPipeline.clip_replace unit test to use the new
  emulateReplaceClipRect function instead of SkClipOp::kReplace.
  Builds and recently added CTS tests for clip ops pass.
Bug: b/151725198
Bug: b/143352151
Change-Id: I8fb8765b4ead92bbe8eceadb52710a5673b6cf6b
2021-08-03 15:46:04 +00:00
Mike Reed
a6cb58a924 Store filterbitmap on Paint
Update Paint and SkiaCanvas now that SkFilterQuality is no longer
part of Skia's API.

1. Store mFilterBitmap:bool directly in Paint (matching java side)

2. Change Looper construct to operate on Paint rather than SkPaint
... so it can access mFilterBitmap.

3. Update PaintFilter to take Paint instead of SkPaint

As before, when we do have to call SkCanvas, we convert Paint's
mFilterBitmap into SkSamplingOptions as needed.

Test: make

Bug: 178700363
Change-Id: I7fccf17657d4e255f2453b4bfc513215503597b2
2021-07-12 09:29:59 -04:00
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
Minkyoung Kim
0c15baeb4d Fix bug on High Contrast Text : where DarkTheme is enabled &&
ForceDarkAllowed is true.

In this condition, text seems be bold so far.
From now, in this case, text would have black outline, white inline
color.

this is related to
https://partnerissuetracker.corp.google.com/u/1/issues/175363190.

Test: Repro steps in bug; make
Bug: 175363190

Change-Id: Icf0048ef8d55c2e29676944c24c2050f531616d5
2021-02-18 21:49:24 +00:00
Mike Reed
27bf51dc50 Pass sampling or nothing to surface.draw
Test: make

Bug: 178700363
Change-Id: I144c0a1bc2376259640d1a6920d9df4edd652849
2021-02-01 17:15:00 -05:00
Mike Reed
7994a3120b Modernize calls to drawImage
1. drawBitmap --> drawImage
2. drawImage now always requires sampling parameter

Bug:178700363

Test: make

Change-Id: I96f610a180b3774ba955cc334949fd62b1cf4d69
2021-01-29 11:46:48 -05:00
Alec Mouri
1f5830e66f Additional clipping logic for vk webview
Bug: 172857687
Bug: 176834621
Test: WebView test app
Change-Id: I6885e0078f6ff6a90a5a2a9e616adb41deee12db
2021-01-14 15:20:22 -08:00
Mike Reed
2d1279f3a9 Adopt sampling parameter
Test: make

Change-Id: Ie5c1897cf9108db3795a5d65b8c095e0b0280520
2021-01-05 14:24:58 -05:00
Mike Reed
4efe0bed46 onDrawImageNine is no longer used
nine-patch draws now route through onDrawImageLattice, and canvas no
longer ever calls onDrawImageNine.

Test: make

Change-Id: Ie1d5b0c72690a4986e97efa1feeb736ef704a079
2021-01-04 02:08:15 +00:00
Mike Reed
6525763ff3 Use new canvas virtuals for m44
Test: make

Change-Id: I83b71fc69515458946b90e96db612c11ba963e98
2020-11-27 09:55:23 -05:00
John Reck
c34597c42d Abort if realloc failed
Bug: 162942933
Test: none
Change-Id: Ic5c1d2da3e496c3eb790a40b7945f58d8afeb977
2020-08-21 10:47:59 -07:00
Mike Reed
a92bdbb5b9 remove (unsupported) clipmask
Test: make

Change-Id: I633e80fe80365e59636f55f7f8db65b40a11a02c
2020-06-13 12:59:08 -04:00
Mike Reed
57f23bf31b opt into m44 concat
Test: make

Change-Id: I2b19ba2192d8dc3dfe47186a397c038d33122a71
2020-04-18 11:26:06 -04:00
Mike Reed
ef06a087ed concat44 is deprecated -- use concat
Test: make

Change-Id: If92f8c1c1d2cd5d5aeb6e2b4e44a25d361cce97b
2020-04-06 17:09:22 -04:00
Mike Reed
ab34214dd9 onDrawBitmap* virtual are no longer called
Test: make

Change-Id: I53e73fb13ae38c4dfbb7ce874f678510434daa40
2020-03-17 18:15:18 -04:00
Mike Reed
719b95efd7 onDrawBitmap[Nine,Latice] are never called
Test: make

Change-Id: Ie9dc8058076a17bdfc60c29f222f5da8108539dc
2020-03-13 08:29:20 -04:00
Mike Reed
08606656ae move to new virtual for drawVertices
Test: make

Change-Id: I390859fcd65738511a6a4a943f86cddb652d4848
2020-03-03 16:54:04 -05:00
Mike Reed
56cb2d260b opt into public SkM44
Landing this allows Skia to remove include/private/SkM44.h

Test: make

Change-Id: I05881e6ae7844231a6f092aaf67c14ca46244b0f
2020-02-22 16:01:43 +00:00
Mike Reed
a4973d8436 extend recordingcanvas overrides for mat4
Note: SkCanvas now tracks a real 4x4, so android could consider using it

Test: make

Change-Id: I6e201f2feec4fb4663f5d3e62fe0ffef5ef9a33f
2020-01-22 20:06:26 +00:00
Stan Iliev
ff2c36b7de Fix VkFunctorDrawable crash
Fix WebView crash, which is specific for Vulkan pipeline
introduced by ag/8550137.
VkFunctorDrawable expects SkDrawable::onSnapGpuDrawHandler
callback instead of SkDrawable::onDraw.
This CL invokes SkCanvas::drawDrawable/SkGpuDevice::drawDrawable,
which has the logic to invoke onSnapGpuDrawHandler.

Test: Don't crash WebView with Vulkan pipeline, pass CTS
Change-Id: Ia98f159511f4ad2dbdbe0d53f0aec2f8c6db263b
2019-08-27 17:39:33 -04:00
Nathaniel Nifong
31fee3a244 Resolve drawable when playing back DisplayListData in the RenderThread.
Drawables are mutable, and not expected to produce the same content if retained for longer than the
duration of the frame. This becomes relevant when recording multi-frame SKPs because the
serialization step forces drawables to be played back long after the frame completed. By resolving
the drawable when we are drawing the frame we avoid ref'ing the SkDrawable and do not extend its
lifetime beyond the frame.

Bug: skia:9234
Test: Captured SKPs on a Pixel 3
Change-Id: I5d317dd14e20be9d5e18675df8667327bd05aff0
2019-07-12 15:14:06 -04: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
Stan Iliev
f09ee58eb7 Put Vulkan WebViews on a HW layer if stencil clip
Put WebViews in a HW layer, if the clip is a non-rect.
This CL reuses logic implemented by ag/705975. This used
to be the way GL WebViews were drawn in Android M.
Implement complex clip detection at recording
time, which was not previously supported by the canvas.
Vulkan WebViews using GL interop are already drawn
in a layer, but this CL will be useful when WebView
supports new Vulkan interop.

Test: WebView CTS pass for Vulkan and GL
Bug: 115613038
Change-Id: I9b02c6f4de8efd504a7507633f3d849004215a16
2019-01-30 13:43:12 -05:00
Mike Reed
3905e83b20 All non-blob variants of drawText are deprecated
Test: make

Change-Id: Iff8cb6a7e2c4f47dcd56db311bc73e0ab12ac8f3
2019-01-02 16:25:04 +00:00
Mike Reed
3682251dfd remove overrides of (dead) onDrawTextRSXform
Test: make

Change-Id: Id943d36e76a837ec8e86de6f28e999a442cc489b
2018-12-21 09:33:49 -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
Mike Reed
05f1d5c04b remove overrides of onDrawText -- no longer called
Skia now routes drawText, drawPosText, drawPosTextH to textblobs, so
these virtuals are no longer needed/called.

Test: make

Change-Id: Ia9d98d6c4ac72cea4ed9ed938b5fd29dbfe8bf49
2018-12-07 08:27:18 -05:00
Chris Blume
7b8a808b7d Remove ; from closing namespaces in libs/hwui
When closing a namespace a } is sufficient. It doesn't need to be };
like closing a class or enum.

Within frameworks/base/libs/hwui there is a mix between } and }; when
closing a namespace. There are even mixes between a .h and the
corresponding .cpp files.

In a separate CL I was asked to not close with };. That was a good
comment. I adopted the style from nearby code. This CL cleans up the
nearby code.

Test: I made sure the code still built as expected.
Change-Id: Ieb314a4f48d6e33752463f3be4361fdc9be97482
2018-12-03 16:05:14 -08:00
John Reck
3b4510cd77 Auto-dark NinePatches & launcher
Support palette for ninepatches (fixes popupwindow)

Crude heuristic tweak to treat any RenderNode that fully
contains other nodes as background nodes.

Test: all apps is now readable, and so is chrome's menu
Change-Id: I9926973c0be1dbf0088fa2d61e4ee2a414b19a97
2018-10-02 11:19:55 -07:00
John Reck
08ee815625 Support auto-dark for VectorDrawable
Also fixes a bug where non-animatable properties (colorfilter)
weren't captured at record-time

Test: poked around, quick settings doesn't look awful
Change-Id: I57312dd5eb70f477814a4d898963ee010153c243
2018-09-21 09:56:42 -07:00
John Reck
f3c724fd7c Make auto-dark a bit better
Handles transform of basic bitmaps
Tweak to always treat text as foreground

Test: builds, poked around with force_dark
Change-Id: I733d39e05067438335da5a7eac06111f66f1228d
2018-09-20 13:41:56 -07:00
Greg Kaiser
5dda003e68 RecordingCanvas: Avoid accessing moved variable
We explicitly use the "image" class member, instead of the function
parameter, since we've already used move() on the function
parameter.

Test: TreeHugger
Change-Id: I631517ca7cbf7cc59f75f8a66b125be4ee391944
2018-08-30 06:45:03 -07:00
John Reck
8f45d4afd9 New DisplayList v2
First step of many

* Pulls SkLiteDL and SkLiteRecorder into HWUI

* forceDark shifted to be a sync-time transformation
instead of record time. No meaningful behavior change,
but much more flexible heuristics are possible this
way.

Test: build, poked around with forceDark on

Change-Id: I7b7cec5b7fd7c2b18823b4d92d821cf5898f9b88
2018-08-29 13:53:36 -07: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
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
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
792fb3252f Use SkPaint.nothingToDraw instead of PaintUtils helper.
The PaintUtils helper is now shared between all pipelines and was
missing a quick reject test for drawLoopers which are used in
view.setShadowLayer and supported in the Skia pipelines.

Bug: 35809097
Test: added hwui unit test and verified in DocumentsUI app
Change-Id: I3c4a988f1c42b7f421f78ac3659af1daee910ea2
2017-03-03 14:24:58 -05: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
8cd3edfa15 Break Layer class into Gl and Vulkan subclasses
Test: manual testing
Change-Id: Ibd2beed39de3ac6da7448e96496253cfe427dfbb
2017-01-10 15:05:07 -05: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
sergeyv
98fa4f9e7b Use Bitmap in Texture.upload
Test: refactoring cl.
bug:32216791

Change-Id: Ib0b16c878d8371e0471e9a502f55626ec5999c60
2016-10-26 13:57:38 -07: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
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
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
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