summaryrefslogtreecommitdiff
path: root/libs/hwui/SkiaCanvas.cpp
AgeCommit message (Collapse)Author
2021-05-06Adding force-dark support to RippleDrawableLucas Dupin
Add force-dark support to RippleDrawable by modifying the ink color. Test: manual Test: atest CanvasOp Fixes: 186130682 Change-Id: I89eaaf3afa5ec53a74d2d08de8cff6484e55a912
2021-04-15Move sparkle animation to RenderThreadLucas Dupin
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-06Holepunch layers for SurfaceViewNader Jawad
Update RenderNodeDrawable to hole punch areas into layers created for SurfaceView Bug: 184297961 Test: Added CTS test to SurfaceViewTests Change-Id: I1f03a4fe34c5a8b7411ebe728ea3d4195fcd1fac
2021-02-23Simplify paint filteringMike Reed
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-17Custom looper code for AndroidMike Reed
Test: make Bug: 178700363 Change-Id: I1d328275ab5e0c9b6b9171ef075f71274e50a3f5
2021-01-29Modernize calls to drawImageMike Reed
1. drawBitmap --> drawImage 2. drawImage now always requires sampling parameter Bug:178700363 Test: make Change-Id: I96f610a180b3774ba955cc334949fd62b1cf4d69
2021-01-28Pass filtering to drawLatticeMike Reed
Test: make Bug:178700363 Merged-In: I14541a21abb885c5291ca839d72ed6434c9accd1 Change-Id: I14541a21abb885c5291ca839d72ed6434c9accd1
2021-01-15Refactor RuntimeShader to support easier assignment of uniforms.Derek Sollenberger
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-08Initial framework needed to draw circle with RuntimeShader.Derek Sollenberger
This also adds the ability for RenderThread to animate a few predefined shader uniforms. Bug: 177051137 Test: demo in ag/13296877 Change-Id: I6e58e671ad1242a07ecb1cf4cdb48031f85c2088
2020-12-14Use SkSamplingOptions when creating image-shaderMike Reed
Test: make Change-Id: Ie979cdb10263a08ea3d8c817234b94c9b61abb76
2020-11-16Remove SaveFlags from saveLayer(Alpha)John Reck
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-09-30Revert "Create wrapper around Shader native implementation"Nader Jawad
This reverts commit fc42a99ea5712883c9872d34a523d972c26c9d6f. Because we are moving away from a wrapper class to delegate between SkImageFilter and SkShader and instead adding RenderEffect on RenderNode, this wrapper implementation is no longer necessary. There are some behavioral differences between SkShader and SkImageFilter that would lead to additional complexity in conversions between these objects and potential bugs. To simplify this, RenderEffect will be added directly to RenderNode to support better caching of rasterization layers that is necessary for various visual effects like blur. Test: N/A Change-Id: I65dc9f8bd26aed8761af13491ae3f6d583208377
2020-09-22Remove bounding box retrieval from Canvas which is not used.Seigo Nonaka
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-08-14Create wrapper around Shader native implementationNader Jawad
Created Shader classes to wrap existing shader classes in the framework in order to handle creation of either an SkShader or SkImageFilter. Updated native Paint implementation to optionally configure the currently configured SkShader or SkImageFilter Bug: 143468037 Test: re-ran CtsGraphicsTestCases and CtsUiRenderingTestCases Change-Id: I7663b92766c912ab3866cf4e39b268f6dcf5d8e2
2020-06-26Remove legacy callDrawGlFunction2 from HWUIJohn Reck
Bug: 151439970 Test: CtsUiRenderingTestCases passes Change-Id: I1c29df17bb6e8b078467edf73cb3547db6948cdd
2020-05-01Merge "Fix setShadowLayer + drawTextOnPath" into rvc-dev am: 7e17bc6496 am: ↵Leon Scroggins
e21afec2c5 am: 697eda359d am: 847725f66e Change-Id: I06729007ece72910f2b3f6d5af3f027489547315
2020-05-01Fix setShadowLayer + drawTextOnPathLeon Scroggins III
Bug: 140255441 Test: I49c468b0f4cc142e5d6b03f0aee917b3d85153f3 Fix two issues that prevented this combination from working: - make() the SkTextBlob once and reuse it for each iteration of the loop. This is necessary because make() resets the SkTextBlobBuilder, so a second call does nothing. - use the altered SkPaint, passed as a parameter to the lambda, rather than the Paint passed to apply_looper. Incidentally, reference mCanvas directly like the other methods, rather than calling asSkCanvas(), which returns mCanvas. Change-Id: I48ea1232b12df4f5f8afffc20c7dc8e5dc2bb511
2020-04-01Include SkVertices.h in SkiaCanvas.hBrian Osman
Test: Adding IWYU header. It still builds. Change-Id: I40df22a18fef960259b144d491f0c2f794d159b6
2020-01-15Merge "Added support for antialiased canvas clipping"Nader Jawad
2020-01-10Added support for antialiased canvas clippingNader Jawad
Updated native hwui implementation to pass in optional anti-alias flag to canvas clipping operations. Made the default behavior to enable canvas clipping Bug: 69115461 Test: Added test to CtsUiRenderingTestCases Change-Id: I996f4b56e161cdc9f1ec5eba9c30f94474520af5
2020-01-10Include text draws in looper refactorNathaniel Nifong
Test: built for pixel3, confirm shadows on text of launcher icons visible on a background image that shows it well. Bug:144199311 Change-Id: Ia2e71a1f0982ef94a9b0c0573bf76ead0c0b9b81
2019-09-03use canvaspriv for legacy flag.Mike Reed
This allows us to remove the legacy enum from SkCanvas.h Test: make Change-Id: I892f18169d9eaeead8332a63d1cebf28bba4159c
2019-07-29pass Paint not SkPaint to CanvasMike Reed
Test: cts Change-Id: I9a3314bc3f221b6e884c8c84d7b0241f7c5be600
2019-07-15Remove final usage of asSkCanvasJohn Reck
Bug: 137581257 Test: builds Change-Id: Ib38f85c11be332e6cd784f8bbf55f58cde72ac09
2019-05-02Fix fading edge effect from impacting neighboring pixelsDerek Sollenberger
Bug: 129117085 Test: skia unit tests and test cases described in the bug Change-Id: Ieaa7c831dd6298ac0565e6f1837b1c1dbd4545da
2019-04-11Update to new factories for effectsMike Reed
Test: make Change-Id: Ib342878524b51d0eacf6c60ece3c7da8bf27d2c0
2019-01-29don't pass bounds to textblobbuilderMike Reed
Rely on builder to compute it Test: make Change-Id: Ib04b5a79d4e94e269761dd23171ca517e5aebed9
2019-01-24Store SkFont in android::PaintMike Reed
Test: CTS Change-Id: I974fad5a7a8cf54007f0a30f4fe4ae6eb6e01ae1
2019-01-08don't toggle between Paint and SkPaintMike Reed
Test: make Change-Id: Id5864591db0577a24833bbb90036b9554ce130d4
2019-01-01drawTextRSXform is deprecatedMike Reed
Test: make Change-Id: I9c041497688b2657e153eeda4c895cd810fd7f94
2018-12-20Improve performance of unclipped save layers.Derek Sollenberger
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-04use SkTextEncodingMike Reed
Test: make Change-Id: I699aa495573e410043caaf97599172471fe8895d
2018-11-28Merge "Set the color space to sRGB on the Surface and remove colorFilter."Derek Sollenberger
2018-11-21pass font instead of paint to blobbuilderMike Reed
Test: make Change-Id: I8605b03098f8fe1d255d3e4d690680c52baf2352
2018-11-07Set the color space to sRGB on the Surface and remove colorFilter.Derek Sollenberger
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-01move alignment to Paint (from SkPaint)Mike Reed
Test: make Change-Id: I35633b0a43b68b4784d8f253a9c37d1d8da7dc87
2018-10-02Added support for Canvas#drawDoubleRoundRect in application Canvas APINader Jawad
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-07-11Replace SkDrawFilter with PaintFilter.Ben Wagner
Skia is removing SkDrawFilter. Test: refactoring CL. Existing unit tests still pass. Change-Id: If81c1a2feabf7d377ae1d7bcb3e8cf0f599ad3ce
2018-05-09A better HW Bitmap uploaderJohn Reck
Move all HW bitmap upload operations off of RenderThread. Ensure EGL context outlives all upload requests Bug: 79250950 Test: builds, boots, systrace is good, CTS bitmap tests pass Change-Id: I5ace6c516d33b1afdf1a407cd8b183f6b60c22c1
2018-04-12Remove Properties::isSkiaPipeline (3/!?)John Reck
Test: hwuiunit & CtsUiRenderingTestCases pass Change-Id: Ie7b336eacdd1b8660e09653c64eb6ea0a7b4a258
2018-03-14Update text alignment when using drawTextOnPath.Derek Sollenberger
This is only a partial fix for the bug, but does ensure that Skia doesn't attempt to realign the text after minikin already has. Test: CtsGraphicsTestCases and test app in bug. Bug: 25360203 Change-Id: I6222963b23b910f0261f562f8816604575d540fa
2018-02-08Draw text with a hairline stroke as if it is fill styleStan Iliev
Dew to a side effect of HWUI opengl pipeline, the hairline stroke is not respected, but it is drawn as a fill style. Implement the same behaviour for skiagl pipeline with SDK API 27 and older. On SDK released with Android P, the hairline stroke is respected. Bug: 72494357 Test: Ran duolingo app Change-Id: I48bdcf3ddec4bf65b5e93e01c5002177c4e3da90
2018-02-06remove unused/deprecated flags from savelayerMike Reed
Test: make Change-Id: I39e41a80430dca7878e6983b098c1c4541904fd1
2018-01-24Initial implmentation of AnimatedImageDrawables on the RenderThread.Derek Sollenberger
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-17Make ImageDecoder return animated DrawablesLeon Scroggins III
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-11Improve correctness of SkiaCanvas::drawLayoutOnPathStan Iliev
Align glyph to a tangent touching SkPath in the midle of the symbol. Previously wrong tangent crossing the path at the beginning of the glyph was used. Test: Ran the test app attached to the bug Bug: 71525360 Change-Id: I310394d11e185de314f66a6b332f804188e42ed9
2017-12-11Enable fast drawing for solid color nine patch rectanglesStan Iliev
Pass a hint to Skia, about which lattice rectangles are solid color rectangles. Bug: 69796044 Test: Measured ninepatch performance using sample app from the bug Change-Id: Ib07b1b64c78ab16195f9af88a989d28682084565
2017-11-29Fix text encoding in some macrobench testsStan Iliev
Fix crash in macrobench tests, caused by incorrect text encoding. Test: Ran macrobench tests Change-Id: I3522004f70c7037299fb92157ac8633ebb170131
2017-11-06If the absolute value of a sweep angle >= 360 then draw it as an oval.Derek Sollenberger
Skia's drawArc API is defined to keep winding when drawing an arc with a sweep angle > 360. This allows for special path effects and for points on the arc to potentially be double drawn. This is not the case for the HWUI implementation that optimistically turns the call into a drawOval. This CL updates Skia's pipeline to be in line with the HWUI implemenation. Test: CtsGraphicsTestCases were added to cover this Bug: 68764873 Change-Id: I22cd15a53cd2df44421518256d45a2b5d0525a86
2017-11-03Format the world (or just HWUI)John Reck
Test: No code changes, just ran through clang-format Change-Id: Id23aa4ec7eebc0446fe3a30260f33e7fd455bb8c