summaryrefslogtreecommitdiff
path: root/libs/hwui/SkiaCanvas.cpp
AgeCommit message (Collapse)Author
2024-11-09Correctly render ISO gainmapped images Alec Mouri
* Apply the gainmap in reverse when using an HDR base image * Support alternative primaries * Nudge the guards that optimize away applying the gainmap shader Bug: 349357636 Flag: com.android.graphics.hwui.flags.iso_gainmap_apis Test: GainmapTests Change-Id: I230a765feddb306330e643e6ead8e62719f49ee5
2024-09-30Add null colorspace protection John Reck
Fixes: 367272642 Test: none Flag: EXEMPT bugfix Change-Id: I6831512e799df9025a91d768094a1862802803e4
2024-09-05Remove fix_double_underline flag Seigo Nonaka
Bug: 297336724 Bug: 364533012 Flag: EXEMPT removing com.android.text.flags.fix_double_underline Test: N/A Change-Id: I794d7f7061e7f11be495a3b26ba98a8fc69c5820
2024-03-10Fix Mesh UAF, uniform handling, and performance bug. Alex Strelnikov
Prior to this change, the render thread would only receive a non-owning pointer or reference to a Mesh. Also because the Mesh itself was passed by pointer, the refcount in its uniform sk_sp<SkData> would not be incremented until an SkMesh was updated on the render thread, causing uniform setting calls on the UI thread to impact prior draw calls with the same mesh. The dirty flag used for the uniforms was also signaling a reupload of vertex and index data to the GPU. This fix adds a MeshBufferData class to handle keeping Skia buffers up-to-date, and a Mesh::Snapshot class that carries shared ownership of all pieces needed to construct an SkMesh. The snapshot is stored on the render thread by value and increments the refcount of the uniform sk_sp<SkData>. Because the current Android Mesh API does not support partial buffer updates, there is no need for a dirty flag, as comparing the DirectContextID and checking if the buffers have been created is sufficient. Creating an SkMesh is performed lazily inside the SkMesh getter of the snapshot. BUG: 328507000 Test: atest CtsUiRenderingTestCases:MeshTest Change-Id: Iabe83dca462d4526c118047621b131009032d35b
2024-02-14add clipShader API to android.graphics.Canvas Jorge Betancourt
Test: atest CtsUiRenderingTestCases:android.uirendering.cts.testclasses.ShaderClippingTests Bug: 280116960 Change-Id: Ic78c4b2ca01e6af9e5af757aa64e15e248cadcf8
2024-01-30add API for 4x4 Matrix to platform graphics Jorge Betancourt
Test: atest CtsUiRenderingTestCases:android.uirendering.cts.testclasses.CanvasTests#testDrawWithConcatenatedMatrix44 && atest CtsGraphicsTestCases:android.graphics.cts.Matrix44Test Bug: 280116960 Change-Id: Ifd336585f578592985d45bbe6ad0728fbcdafa4b
2023-11-15Only use the gainmap shader if we might need it John Reck
Skip using the gainmap shader when drawing to a bitmap with a known SDR colorspace as it'll be a no-op in rendering results since W=1.0, but it'll be very expensive in runtime due to CPU evaluation of the SKSL shader. Before: createScaledBitmapWithGainmap_median (ns): 179,455,037 After: createScaledBitmapWithGainmap_median (ns): 15,643,742 Bug: 311085927 Test: benchmark in CL Change-Id: I3f2506a2bd86bbe29c6e0837d31e4a231a7c182a
2023-09-27Draw a single underline if multiple fonts are used in a single line. Seigo Nonaka
Bug: 297336724 Test: atest hwui_unit_tests (with flag on/off) Change-Id: I48018abd68c767c9c7ad08722a8974efc1bfe67c
2023-03-31Support rendering gainmaps to PQ & HLG John Reck
Bug: 270744068 Test: GainmapTests in uirendering Change-Id: I57e55b1a27d49c19d232ad9c4418d715eca57f7c
2023-02-25Defer Meshed creation Nader Jawad
Refactored Mesh API to defer creation of SkMesh instances until a GrDirectContext can be obtained on the RenderThread. This creates an SkMesh during the prepare tree step when the UI thread is blocked to ensure no concurrency issues. Bug: b/265044322 Test: atest CtsUiRenderingTestCases:MeshTest Change-Id: Ica8c364b99952e0ee71f7b95b312cf29c51ebc2a
2023-01-20Merge "Revert "add support for rendering lottie animations through a ↵ Leon Scroggins
LottieDrawable""
2023-01-19Revert "add support for rendering lottie animations through a LottieDrawable" Jorge Betancourt
This reverts commit 2e58b5c4b9f7d96ce84ccc0dabe2fcd3667052fe. Reason for revert: prep for mainline Bug: 257304231 Change-Id: I51515a6eed577ad098020588f12cafc8fff0541e
2023-01-18Remove SkAutoSTMalloc and other private Skia functions Kevin Lubick
Bug: skbug.com/13983 Change-Id: I094a0ae69653d428f2c47d1fdbb2cd32def9a347
2023-01-11Merge "Replace SkDeque with std::deque in SkiaCanvas" TreeHugger Robot
2023-01-11Replace SkDeque with std::deque in SkiaCanvas Kevin Lubick
SkDeque is private to Skia and the std library one should be sufficient. This change was started by kjlubick@ and continued by nscobie@. Test: existing presubmits (functionality unchanged) Change-Id: I60751aa77337c1601428d00d3ba4bc4b8ccb67a9
2023-01-06add support for rendering lottie animations through a LottieDrawable Jorge Betancourt
This is an initial push that only supports basic playback Test: frameworks/base/tests/VectorDrawableTest and run LottieDrawable activity Change-Id: Ic34366b0cd0984a512d8684d476227830903f778 Bug: 257304231
2022-12-03Exposed SkCanvas::drawMesh Angel Aguayo
Added drawMesh method to the Canvas API, utilizing SkCanvas::drawMesh. Bug: b/253321460 Test: HwAccelerationTest MeshActivity Change-Id: I43802af61bbd6f76444b4e4b7cec2b95bae34f66
2022-09-16Merge "Revert^2 "Support alpha for SurfaceView"" Alec Mouri
2022-09-12Revert^2 "Support alpha for SurfaceView" Alec Mouri
3fde6cee3c54269ea40158a3057fd61daa82dac7 This is the same CL as the original CL, with the exception that SurfaceView#isZOrderedOnTop checks mRequestedSubLayer, rather than mSubLayer. This is to fix a CTS failure with InlineContentViewTest#testSetZOrderedOnTop, which set the Z order of an offscreen SurfaceView without binding it to a layout. Change-Id: Ifdfa710d87f7ea4c333505ffdcc7fbff06245fba
2022-09-09Merge "Revert "Support alpha for SurfaceView"" Alec Mouri
2022-09-08Revert "Support alpha for SurfaceView" Samiul Islam
Revert submission 19562144-surfaceview-alpha Reason for revert: Presubmit breakage b/245651921 Reverted Changes: I7510a3a6c:Add CTS for applying alpha for SurfaceView Ibc14b18f1:Support alpha for SurfaceView Change-Id: I498c98951a53e6bb1c1251dceb9d150311b07cc8
2022-09-08Merge "Support alpha for SurfaceView" Alec Mouri
2022-09-07Support alpha for SurfaceView Alec Mouri
Basically, this removes an excuse for apps to use TextureView for video playback or one-off HDR images prior to HDR UI being ready everywhere. The idea is that for Z-above, applying alpha is easy, because the surface just needs to be have alpha modulated. Z-below is a little bit more creative - the alpha is applied to the hole punch and drawn using DST_OUT blending semantics. This allows for views underneath the SurfaceView to blend with surface, while being occluded by views on top of the SurfaceView. There may need to be some complex view hierarchies that would be useful to test, but simple view layouts seem to work. Note that this is guarded with a target SDK check, to defend against applications that are propagated alpha to child views while expecting opaque SurfaceViews. Bug: 241474646 Test: HWAccelerationTest doesn't look broken Change-Id: Ibc14b18f1ce6f25250318db50275c6b8c972bade
2022-09-01Merge "Move SkiaCanvas::Clip above SkiaCanvas::SkiaCanvas" am: 770e68977b ↵ Ryan Prichard
am: d80d36a428 am: eda3dacc31 am: 86a8d4f4d4 am: e406bb523a Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/2200075 Change-Id: Iab55e8449d54380693cfe2cc78ea02eae2a0e611 Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-08-26Move SkiaCanvas::Clip above SkiaCanvas::SkiaCanvas Ryan Prichard
After upgrading libc++, there are errors complaining about the the incomplete Clip type in the "std::vector<Clip> mClipStack" member of SkiaCanvas. The "SkiaCanvas::SkiaCanvas() {}" ctor can call ~vector (maybe when an exception is thrown), and ~vector needs to know the size of Clip. (I'm not sure why this wasn't a problem before, but this seems to fix the problem.) Bug: http://b/175635923 Test: treehugger Change-Id: I1d689c91be3b0530272836eeb727709ff1084545
2022-02-24Fix includes of SkRRect and other Skia headers Kevin Lubick
I would like to (re-)land https://skia-review.googlesource.com/c/skia/+/512158 which tidies up includes around SkRRect. I searched for all places in libs/hwui that used SkRRect and made sure they either forward declared it or included it, as appropriate. While going through these files, I fixed a few other includes that stood out to me, e.g. SkPaint, SkCanvas, etc to make sure the files that use the symbols are the ones including them (and lessening transitive dependencies). Change-Id: I44792a6b9f06a54d052cefa4cbc9342f46ab2a4f
2021-08-03Emulate replace clip ops using SkAndroidFrameworkUtils::ResetClip Michael Ludwig
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-07-12Store filterbitmap on Paint Mike Reed
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-05-06Adding force-dark support to RippleDrawable Lucas 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 RenderThread Lucas 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 SurfaceView Nader 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 filtering Mike 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 Android Mike Reed
Test: make Bug: 178700363 Change-Id: I1d328275ab5e0c9b6b9171ef075f71274e50a3f5
2021-01-29Modernize calls to drawImage Mike Reed
1. drawBitmap --> drawImage 2. drawImage now always requires sampling parameter Bug:178700363 Test: make Change-Id: I96f610a180b3774ba955cc334949fd62b1cf4d69
2021-01-28Pass filtering to drawLattice Mike 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-shader Mike 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 implementation Nader 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 HWUI John 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 + drawTextOnPath Leon 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.h Brian 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 clipping Nader 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 refactor Nathaniel 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