diff options
Diffstat (limited to 'libs')
| -rw-r--r-- | libs/renderengine/include/renderengine/RenderEngine.h | 4 | ||||
| -rw-r--r-- | libs/renderengine/threaded/RenderEngineThreaded.cpp | 14 | ||||
| -rw-r--r-- | libs/renderengine/threaded/RenderEngineThreaded.h | 1 |
3 files changed, 19 insertions, 0 deletions
diff --git a/libs/renderengine/include/renderengine/RenderEngine.h b/libs/renderengine/include/renderengine/RenderEngine.h index b9cc6485e5..d646756fc4 100644 --- a/libs/renderengine/include/renderengine/RenderEngine.h +++ b/libs/renderengine/include/renderengine/RenderEngine.h @@ -189,6 +189,10 @@ public: static void validateInputBufferUsage(const sp<GraphicBuffer>&); static void validateOutputBufferUsage(const sp<GraphicBuffer>&); + // Allows flinger to get the render engine thread id for power management with ADPF + // Returns the tid of the renderengine thread if it's threaded, and std::nullopt otherwise + virtual std::optional<pid_t> getRenderEngineTid() const { return std::nullopt; } + protected: RenderEngine() : RenderEngine(RenderEngineType::GLES) {} diff --git a/libs/renderengine/threaded/RenderEngineThreaded.cpp b/libs/renderengine/threaded/RenderEngineThreaded.cpp index 08fc81468c..a7176d3279 100644 --- a/libs/renderengine/threaded/RenderEngineThreaded.cpp +++ b/libs/renderengine/threaded/RenderEngineThreaded.cpp @@ -389,6 +389,20 @@ void RenderEngineThreaded::onActiveDisplaySizeChanged(ui::Size size) { mCondition.notify_one(); } +std::optional<pid_t> RenderEngineThreaded::getRenderEngineTid() const { + std::promise<pid_t> tidPromise; + std::future<pid_t> tidFuture = tidPromise.get_future(); + { + std::lock_guard lock(mThreadMutex); + mFunctionCalls.push([&tidPromise](renderengine::RenderEngine& instance) { + tidPromise.set_value(gettid()); + }); + } + + mCondition.notify_one(); + return std::make_optional(tidFuture.get()); +} + } // namespace threaded } // namespace renderengine } // namespace android diff --git a/libs/renderengine/threaded/RenderEngineThreaded.h b/libs/renderengine/threaded/RenderEngineThreaded.h index 0159cfaece..1ba72ddf81 100644 --- a/libs/renderengine/threaded/RenderEngineThreaded.h +++ b/libs/renderengine/threaded/RenderEngineThreaded.h @@ -66,6 +66,7 @@ public: int getContextPriority() override; bool supportsBackgroundBlur() override; void onActiveDisplaySizeChanged(ui::Size size) override; + std::optional<pid_t> getRenderEngineTid() const override; protected: void mapExternalTextureBuffer(const sp<GraphicBuffer>& buffer, bool isRenderable) override; |