summaryrefslogtreecommitdiff
path: root/libs/hwui/Mesh.cpp
AgeCommit message (Collapse)Author
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
2023-11-30Fix assertion checks in libs/hwui/Mesh.cpp mashixing
The original code contained assertions that checked `fICount` and `fIOffset`, which seem to be mistakenly copied from the Skia codebase. This commit corrects the assertions to properly reflect the variables used in the AOSP codebase, updating them to `mIndexCount` and `mIndexOffset` as intended. The correction ensures accurate runtime checks for the expected conditions and prevents compilation error due to undeclared identifier. Bug: 313566801 Change-Id: I1432598be14a6960d0dbe373e1ac997f5f5f8ee6 Signed-off-by: Shixing Ma <mashixing@xiaomi.corp-partner.google.com>
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