From 2248f52cd8102e5bc71c5c1dca7a85e90fea1276 Mon Sep 17 00:00:00 2001 From: Rachel Lee Date: Fri, 27 Jan 2023 16:45:23 -0800 Subject: Framework code for Attached Choreographer. Allows a direct association of a Layer (via LayerHistory) to attached choreographer. The EventThread checks whether the vsync is in phase for a choreographer. Bug: 255838011 Test: atest AttachedChoreographerNativeTest Change-Id: I9cb35bced5e6d4509609ad7698ab2902a31d5b98 --- libs/gui/SurfaceControl.cpp | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) (limited to 'libs/gui/SurfaceControl.cpp') diff --git a/libs/gui/SurfaceControl.cpp b/libs/gui/SurfaceControl.cpp index 7aee882422..c5f9c38ca3 100644 --- a/libs/gui/SurfaceControl.cpp +++ b/libs/gui/SurfaceControl.cpp @@ -26,6 +26,7 @@ #include #include #include +#include #include #include @@ -34,8 +35,9 @@ #include #include -#include #include +#include +#include #include #include #include @@ -191,6 +193,24 @@ const std::string& SurfaceControl::getName() const { return mName; } +std::shared_ptr SurfaceControl::getChoreographer() { + if (mChoreographer) { + return mChoreographer; + } + sp looper = Looper::getForThread(); + if (!looper.get()) { + ALOGE("%s: No looper prepared for thread", __func__); + return nullptr; + } + mChoreographer = std::make_shared(looper, getHandle()); + status_t result = mChoreographer->initialize(); + if (result != OK) { + ALOGE("Failed to initialize choreographer"); + mChoreographer = nullptr; + } + return mChoreographer; +} + sp SurfaceControl::getIGraphicBufferProducer() { getSurface(); -- cgit v1.2.3-59-g8ed1b