summaryrefslogtreecommitdiff
path: root/services/surfaceflinger/RegionSamplingThread.h
AgeCommit message (Collapse)Author
2023-01-24SF: Move ownership of VsyncModulator to Scheduler Dominik Laskowski
...as a prerequisite for calculating the VSYNC deadline of the leader display (and deriving per-display state from it, e.g. present fences, traces) in the Scheduler. Bug: 241285475 Bug: 241285191 Test: Boot Change-Id: Ieea136616435464dd0756525f94441b8e82ad06a
2022-10-28SF: Use layer id for region sampling stop layer Vishnu Nair
Cleanup before layer refbase removal. We can lookup the stop layer by using a unique id. Bug: 238781169 Test: presubmit Change-Id: I33da6899adebc33c814656591f78187f08c53e80
2021-11-23Migrate IRegionSamplingListener interface to AIDL Huihong Luo
This addresses security vulnerabilities due to hard coded binder interface. Bug: 195660647 Test: (1) atest RegionSamplingTest (2) install Google I/O 2019 app, tap Agenda menu, scrolling to examine the bottom horizontal bar color changes Change-Id: If2d33c5168b2df5fc7fd8f55e3bca75d3f385a89
2021-10-15Consolidate WpHash declaration to a common file Angel Aguayo
Bug: b/193932763 Test: frameworks/native/test Change-Id: Ib19f191ed8031b77c059b644fe5df3c8137e6619
2021-05-13SF: region sampling scheduling optimization Ady Abraham
Schedule the region sampling thread more wisely by estimating when the next invalidate is going to happen. This makes the region sampling to be scheduled often at times where the main thread is idle, without eating the budget in an invalidate message. Bug: 181983990 Test: SF unit tests Test: observe systrace Change-Id: I1faca3aa7f882ed7c69e77e6a0877c10d57f0f1c
2021-04-16Revert "Revert "Add ExternalTexture class into RenderEngine inte..." Alec Mouri
Revert submission 14199598-revert-14086921-renderengine-external-tex-QJNBWQMQEU Reason for revert: Prepare for relanding Reverted Changes: I01e65a7f4:Revert "Update WaylandRenderSurface to accomodate ... I7d58118c1:Revert "Update Readback VTS to align with RenderEn... I1501890f4:Revert "Add ExternalTexture class into RenderEngin... Added the following fixes: 1. CachedSet renders to intermediate texture variable rather than mTexture directly, since mTexture is not guaranteed to be nonnull. 2. Add null check when setting new buffer in BLAST. Bug: 185524947 Bug: 180767535 Test: builds, boots Test: librenderengine_test Change-Id: I52ea82e24336b496d996bbe3e445db0affe1abb8
2021-04-15Revert "Add ExternalTexture class into RenderEngine interface" Alec Mouri
Revert submission 14086921-renderengine-external-tex Reason for revert: Potential culprit for b/185361988 Reverted Changes: I7796764e2:Update WaylandRenderSurface to accomodate interfac... I13904eec4:Update Readback VTS to align with RenderEngine int... I222c71e6e:Add ExternalTexture class into RenderEngine interf... Change-Id: I1501890f4861a3df7ce273f1fe2ccdb275e2632c
2021-04-13Add ExternalTexture class into RenderEngine interface Alec Mouri
ExternalTexture is an RAII structure that wraps raw GraphicBuffers that are passed into RenderEngine. ExternalTexture's role is to help with managing GPU resources of GraphicBuffers by mapping buffers into textures, EGLImages, or AutoBackendTextures depending on the RenderEngine backend. Under the hood, mapExternalTextureBuffer and unmapExternalTextureBuffer (renamed from cacheExternalTextureBuffer and unbindExternalTextureBuffer respectively) are used to help tie resource management to the ExternalTexture lifetime. The main motivation for this is that currently managing buffer lifecycle has historically been errorprone and caused memory leaks, so this improves code health. As part of this: * mapExternalTextureBuffer and unmapExternalTextureBuffer are now protected methods, and are never called outside of RenderEngine with the exception of creating and destroying ExternalTextures. * Because GLESRenderEngine's output buffers are cached differently from Skia RenderEngine, if there are output-only buffers then disable the mapExternalTextureBuffer calls whenever GLESRenderEngine is used. * Custom RAII classes in the Planner and in BufferLayerConsumer are now removed since they're subsumed by ExternalTexture * RenderSurface now controls its own management of ExternalTextures in a small queue * cleanFramebufferCache is now unimplemented for Skia, because ExternalTextures are now deleted whenever a RenderSurface is deleted. Bug: 180767535 Test: libsurfaceflinger_unittest Test: libcompositionengine_test Test: librenderengine_test Test: Simulate virtual displays Test: Screen reotation Test: Movie playback on Google TV Test: Force GPU composition Test: screenshot Change-Id: I222c71e6e1c67485cdeac49e2cb829289af9efec
2020-08-24SurfaceFlinger: use duration instead of offset Ady Abraham
This change is using the duration given to sf/app without converting them back to the legacy offset. This allows us to get the expected vsync associated with a wakeup event. This change also required some refactoring: - Move the periodic callback interface out of DispSync and in to DispSyncSource - Translate legacy offsets to duration in case that duration is not specified in the build files - Add support to VSD to expose the deadline timestamp of when a frame needs to be ready by Bug: 162888874 Test: SF unit tests Test: examine systraces Change-Id: I87a53cc7dea931d3c195eab6842e003ca4516885
2020-04-22Lookup layer handle when registering region sampling listener Alec Mouri
We must do this in order to prevent clients from providing a bogus handle when registering a region sampling listener. Fortunately, this particular path required a permissions check so it cannot be accessed from arbitrary apps on unrooted devices. But, we should not allow this type of memory corruption to be reachable by the system. Bug: 153467444 Test: libgui_test Test: Repro steps in the bug no longer reproduce Change-Id: I883506798574dfd0688371fdb6305cfad9d153fc
2019-07-03Merge "SF: delay region sampling when short on time" into qt-r1-dev am: ↵ Kevin DuBois
5bb9322330 am: e3b2036a57 Change-Id: I28756ef7a917ea96aed0970a2520de48c4b0cbea
2019-06-24SF: Renaming IdleTimer to OneShotTimer Ana Krulec
IdleTimer class is used for more than just idle timer, so renaming the class to a more appropriate name. Test: manual Bug: 132811842 Change-Id: Iabfaa28038dc90430a51536ef874618e35ed9014
2019-06-19SF: delay region sampling when short on time John Dias
In a number of janky traces, particularly at high frame rates, we've seen the surfaceflinger thread overrunning its time slot. In some of those cases, the surfaceflinger thread is doing region-sampling. This change causes region-sampling to check how much time is left until the next vsync before deciding whether to sample this frame. If low on time, it will defer the sampling to a later frame. Bug: 133779857 Test: trace inspection from scrolling in various apps Change-Id: I92c2368e80033c1ba6e27f947a456d14db02064c
2019-05-29SF: adapt region sampling to display orientation Kevin DuBois
Pass in the orientation flags of SF to RenderEngine when conducting the sampling composition. This resulted mis-sampled areas, especially when the region was outside of the clip of the 0-degree rotated display. Bug: 132394665 Test: manual verification with 90, 270, 0 rotations Test: new tests in libsurfaceflinger_unittest#RegionSamplingTest.* Change-Id: I2869ef191572dbcc9170df8d3ed17414ab053ca4
2019-05-09sf: avoid lock on main thread during luma calc Kevin DuBois
The luma calculation operation was previously done while holding a lock that was also used to protect the request to collect the next sample. When the main thread would request the next sample, it could stall waiting on the longer luma calculation to complete. This patch refactors the sampling request locking mechanisms so sampling request signalling is protected by one lock, and the members needed during the sampling thread operations are protected by another lock. Fixes: http://b/132110951 Test: collect traces during during problematic animation (agsa initial query for info) and verify problem went away Test: visually inspect jank during agsa continued conversation Test: libgui#RegionSamplingTest Test: monkey 6000 event inject Change-Id: I291d6bcb80d0588f2e1f3689bfdd4b3434132e90
2019-05-02sf: reuse luma sampling buffer when available Kevin DuBois
Reuse the luma sampling buffer when available, saving a frequent buffer reallocation. Depending on driver refcounting behavior, this could have resulted in the buffer free on the SF main thread (and typically did on referenced device, costing about ~500us @10hz). Test: verify luma sampling work reduces from ~2ms -> 1.5ms Test: RegionSamplingTest in libgui Fixes: 131416627 Change-Id: I8e6d57ae25bd37ceec828c82796f0f4f8f45636e
2019-04-03SF: fix off-by one in luma mean calculation Kevin DuBois
There was an off by one error in luma mean calculation that could lead to segfault. Flaw was figured out in writing the 5 attached unit tests for the function. Condition would be obscure in the wild, but an exactly half-white, half-another-color in the sampled region could present condition. Fixes: 129858549 Test: libsurfaceflinger_unittest (5 new tests) Change-Id: I920cd9cac15122178ec9258e33c9bc35b1bb9357
2019-03-07SF: rate-limit luma sampling Kevin DuBois
Instead of sampling the luma regions every frame, introduce a rate limiting system to reduce load. Introduces a few tunables to control the rate, which is defaulted to 10Hz, when there is content being watched for luma. Test: manual systrace inspection, using SamplingDemo Test: libgui_test --gtest_filter="RegionSampling*" Test: atest CompositionSamplingListenerTest Fixes: 126747045 Change-Id: I7cae3e90fb405ba72dc2f276a88be48f1533a219
2019-02-25SF: tidy comments for luma sampling. Kevin DuBois
Tidying of const, comment and one internal fn name for Region Luma sampling. Test: libgui_test --gtest_filter="RegionSamp*" Change-Id: I46895c8ed5b2e2045d7ce7444085585b62b5ab6e
2019-02-22[sf] Implement addSamplingListener Dan Stoza
Implements ISurfaceComposer::addSamplingListener, which allows a client to receive streaming median luma updates for a given region of the screen. Bug: 119639245 Test: Manual using SamplingDemo in libgui Test: Automated libgui_test in Ic85a97f475a3414a79d3719bbd0b2b648bbccfb0 Change-Id: Ic52359aeab884e734a806372be0eb4e327c45298