Loading services/surfaceflinger/Android.mk +1 −1 Original line number Diff line number Diff line Loading @@ -9,7 +9,7 @@ LOCAL_SRC_FILES := \ DisplayDevice.cpp \ DispSync.cpp \ EventControlThread.cpp \ StartBootAnimThread.cpp \ StartPropertySetThread.cpp \ EventThread.cpp \ FrameTracker.cpp \ GpuService.cpp \ Loading services/surfaceflinger/StartBootAnimThread.cpp→services/surfaceflinger/StartPropertySetThread.cpp +10 −7 Original line number Diff line number Diff line Loading @@ -15,20 +15,23 @@ */ #include <cutils/properties.h> #include "StartBootAnimThread.h" #include "StartPropertySetThread.h" namespace android { StartBootAnimThread::StartBootAnimThread(): Thread(false) { } StartPropertySetThread::StartPropertySetThread(bool timestampPropertyValue): Thread(false), mTimestampPropertyValue(timestampPropertyValue) {} status_t StartBootAnimThread::Start() { return run("SurfaceFlinger::StartBootAnimThread", PRIORITY_NORMAL); status_t StartPropertySetThread::Start() { return run("SurfaceFlinger::StartPropertySetThread", PRIORITY_NORMAL); } bool StartBootAnimThread::threadLoop() { bool StartPropertySetThread::threadLoop() { // Set property service.sf.present_timestamp, consumer need check its readiness property_set(kTimestampProperty, mTimestampPropertyValue ? "1" : "0"); // Clear BootAnimation exit flag property_set("service.bootanim.exit", "0"); // Start BootAnimation if not started property_set("ctl.start", "bootanim"); // Exit immediately return false; Loading services/surfaceflinger/StartBootAnimThread.h→services/surfaceflinger/StartPropertySetThread.h +6 −2 Original line number Diff line number Diff line Loading @@ -24,17 +24,21 @@ namespace android { class StartBootAnimThread : public Thread { class StartPropertySetThread : public Thread { // Boot animation is triggered via calls to "property_set()" which can block // if init's executing slow operation such as 'mount_all --late' (currently // happening 1/10th with fsck) concurrently. Running in a separate thread // allows to pursue the SurfaceFlinger's init process without blocking. // see b/34499826. // Any property_set() will block during init stage so need to be offloaded // to this thread. see b/63844978. public: StartBootAnimThread(); StartPropertySetThread(bool timestampPropertyValue); status_t Start(); private: virtual bool threadLoop(); static constexpr const char* kTimestampProperty = "service.sf.present_timestamp"; const bool mTimestampPropertyValue; }; } Loading services/surfaceflinger/SurfaceFlinger.cpp +17 −16 Original line number Diff line number Diff line Loading @@ -346,8 +346,8 @@ sp<IBinder> SurfaceFlinger::getBuiltInDisplay(int32_t id) { void SurfaceFlinger::bootFinished() { if (mStartBootAnimThread->join() != NO_ERROR) { ALOGE("Join StartBootAnimThread failed!"); if (mStartPropertySetThread->join() != NO_ERROR) { ALOGE("Join StartPropertySetThread failed!"); } const nsecs_t now = systemTime(); const nsecs_t duration = now - mBootTime; Loading Loading @@ -531,6 +531,8 @@ private: sp<VSyncSource::Callback> mCallback; }; // Do not call property_set on main thread which will be blocked by init // Use StartPropertySetThread instead. void SurfaceFlinger::init() { ALOGI( "SurfaceFlinger's main thread ready to run. " "Initializing graphics H/W..."); Loading Loading @@ -580,14 +582,6 @@ void SurfaceFlinger::init() { Mutex::Autolock _l(mStateLock); // Inform native graphics APIs whether the present timestamp is supported: if (getHwComposer().hasCapability( HWC2::Capability::PresentFenceIsNotReliable)) { property_set(kTimestampProperty, "0"); } else { property_set(kTimestampProperty, "1"); } if (useVrFlinger) { auto vrFlingerRequestDisplayCallback = [this] (bool requestDisplay) { ALOGI("VR request display mode: requestDisplay=%d", requestDisplay); Loading Loading @@ -622,9 +616,16 @@ void SurfaceFlinger::init() { mRenderEngine->primeCache(); mStartBootAnimThread = new StartBootAnimThread(); if (mStartBootAnimThread->Start() != NO_ERROR) { ALOGE("Run StartBootAnimThread failed!"); // Inform native graphics APIs whether the present timestamp is supported: if (getHwComposer().hasCapability( HWC2::Capability::PresentFenceIsNotReliable)) { mStartPropertySetThread = new StartPropertySetThread(false); } else { mStartPropertySetThread = new StartPropertySetThread(true); } if (mStartPropertySetThread->Start() != NO_ERROR) { ALOGE("Run StartPropertySetThread failed!"); } ALOGV("Done initializing"); Loading @@ -633,10 +634,10 @@ void SurfaceFlinger::init() { void SurfaceFlinger::startBootAnim() { // Start boot animation service by setting a property mailbox // if property setting thread is already running, Start() will be just a NOP mStartBootAnimThread->Start(); mStartPropertySetThread->Start(); // Wait until property was set if (mStartBootAnimThread->join() != NO_ERROR) { ALOGE("Join StartBootAnimThread failed!"); if (mStartPropertySetThread->join() != NO_ERROR) { ALOGE("Join StartPropertySetThread failed!"); } } Loading services/surfaceflinger/SurfaceFlinger.h +2 −3 Original line number Diff line number Diff line Loading @@ -58,7 +58,7 @@ #include "LayerVector.h" #include "MessageQueue.h" #include "SurfaceInterceptor.h" #include "StartBootAnimThread.h" #include "StartPropertySetThread.h" #include "DisplayHardware/HWComposer.h" #include "Effects/Daltonizer.h" Loading Loading @@ -227,7 +227,6 @@ private: enum { LOG_FRAME_STATS_PERIOD = 30*60*60 }; static const size_t MAX_LAYERS = 4096; static constexpr const char* kTimestampProperty = "service.sf.present_timestamp"; // We're reference counted, never destroy SurfaceFlinger directly virtual ~SurfaceFlinger(); Loading Loading @@ -434,7 +433,7 @@ private: bool isLocalScreenshot); #endif sp<StartBootAnimThread> mStartBootAnimThread = nullptr; sp<StartPropertySetThread> mStartPropertySetThread = nullptr; /* ------------------------------------------------------------------------ * EGL Loading Loading
services/surfaceflinger/Android.mk +1 −1 Original line number Diff line number Diff line Loading @@ -9,7 +9,7 @@ LOCAL_SRC_FILES := \ DisplayDevice.cpp \ DispSync.cpp \ EventControlThread.cpp \ StartBootAnimThread.cpp \ StartPropertySetThread.cpp \ EventThread.cpp \ FrameTracker.cpp \ GpuService.cpp \ Loading
services/surfaceflinger/StartBootAnimThread.cpp→services/surfaceflinger/StartPropertySetThread.cpp +10 −7 Original line number Diff line number Diff line Loading @@ -15,20 +15,23 @@ */ #include <cutils/properties.h> #include "StartBootAnimThread.h" #include "StartPropertySetThread.h" namespace android { StartBootAnimThread::StartBootAnimThread(): Thread(false) { } StartPropertySetThread::StartPropertySetThread(bool timestampPropertyValue): Thread(false), mTimestampPropertyValue(timestampPropertyValue) {} status_t StartBootAnimThread::Start() { return run("SurfaceFlinger::StartBootAnimThread", PRIORITY_NORMAL); status_t StartPropertySetThread::Start() { return run("SurfaceFlinger::StartPropertySetThread", PRIORITY_NORMAL); } bool StartBootAnimThread::threadLoop() { bool StartPropertySetThread::threadLoop() { // Set property service.sf.present_timestamp, consumer need check its readiness property_set(kTimestampProperty, mTimestampPropertyValue ? "1" : "0"); // Clear BootAnimation exit flag property_set("service.bootanim.exit", "0"); // Start BootAnimation if not started property_set("ctl.start", "bootanim"); // Exit immediately return false; Loading
services/surfaceflinger/StartBootAnimThread.h→services/surfaceflinger/StartPropertySetThread.h +6 −2 Original line number Diff line number Diff line Loading @@ -24,17 +24,21 @@ namespace android { class StartBootAnimThread : public Thread { class StartPropertySetThread : public Thread { // Boot animation is triggered via calls to "property_set()" which can block // if init's executing slow operation such as 'mount_all --late' (currently // happening 1/10th with fsck) concurrently. Running in a separate thread // allows to pursue the SurfaceFlinger's init process without blocking. // see b/34499826. // Any property_set() will block during init stage so need to be offloaded // to this thread. see b/63844978. public: StartBootAnimThread(); StartPropertySetThread(bool timestampPropertyValue); status_t Start(); private: virtual bool threadLoop(); static constexpr const char* kTimestampProperty = "service.sf.present_timestamp"; const bool mTimestampPropertyValue; }; } Loading
services/surfaceflinger/SurfaceFlinger.cpp +17 −16 Original line number Diff line number Diff line Loading @@ -346,8 +346,8 @@ sp<IBinder> SurfaceFlinger::getBuiltInDisplay(int32_t id) { void SurfaceFlinger::bootFinished() { if (mStartBootAnimThread->join() != NO_ERROR) { ALOGE("Join StartBootAnimThread failed!"); if (mStartPropertySetThread->join() != NO_ERROR) { ALOGE("Join StartPropertySetThread failed!"); } const nsecs_t now = systemTime(); const nsecs_t duration = now - mBootTime; Loading Loading @@ -531,6 +531,8 @@ private: sp<VSyncSource::Callback> mCallback; }; // Do not call property_set on main thread which will be blocked by init // Use StartPropertySetThread instead. void SurfaceFlinger::init() { ALOGI( "SurfaceFlinger's main thread ready to run. " "Initializing graphics H/W..."); Loading Loading @@ -580,14 +582,6 @@ void SurfaceFlinger::init() { Mutex::Autolock _l(mStateLock); // Inform native graphics APIs whether the present timestamp is supported: if (getHwComposer().hasCapability( HWC2::Capability::PresentFenceIsNotReliable)) { property_set(kTimestampProperty, "0"); } else { property_set(kTimestampProperty, "1"); } if (useVrFlinger) { auto vrFlingerRequestDisplayCallback = [this] (bool requestDisplay) { ALOGI("VR request display mode: requestDisplay=%d", requestDisplay); Loading Loading @@ -622,9 +616,16 @@ void SurfaceFlinger::init() { mRenderEngine->primeCache(); mStartBootAnimThread = new StartBootAnimThread(); if (mStartBootAnimThread->Start() != NO_ERROR) { ALOGE("Run StartBootAnimThread failed!"); // Inform native graphics APIs whether the present timestamp is supported: if (getHwComposer().hasCapability( HWC2::Capability::PresentFenceIsNotReliable)) { mStartPropertySetThread = new StartPropertySetThread(false); } else { mStartPropertySetThread = new StartPropertySetThread(true); } if (mStartPropertySetThread->Start() != NO_ERROR) { ALOGE("Run StartPropertySetThread failed!"); } ALOGV("Done initializing"); Loading @@ -633,10 +634,10 @@ void SurfaceFlinger::init() { void SurfaceFlinger::startBootAnim() { // Start boot animation service by setting a property mailbox // if property setting thread is already running, Start() will be just a NOP mStartBootAnimThread->Start(); mStartPropertySetThread->Start(); // Wait until property was set if (mStartBootAnimThread->join() != NO_ERROR) { ALOGE("Join StartBootAnimThread failed!"); if (mStartPropertySetThread->join() != NO_ERROR) { ALOGE("Join StartPropertySetThread failed!"); } } Loading
services/surfaceflinger/SurfaceFlinger.h +2 −3 Original line number Diff line number Diff line Loading @@ -58,7 +58,7 @@ #include "LayerVector.h" #include "MessageQueue.h" #include "SurfaceInterceptor.h" #include "StartBootAnimThread.h" #include "StartPropertySetThread.h" #include "DisplayHardware/HWComposer.h" #include "Effects/Daltonizer.h" Loading Loading @@ -227,7 +227,6 @@ private: enum { LOG_FRAME_STATS_PERIOD = 30*60*60 }; static const size_t MAX_LAYERS = 4096; static constexpr const char* kTimestampProperty = "service.sf.present_timestamp"; // We're reference counted, never destroy SurfaceFlinger directly virtual ~SurfaceFlinger(); Loading Loading @@ -434,7 +433,7 @@ private: bool isLocalScreenshot); #endif sp<StartBootAnimThread> mStartBootAnimThread = nullptr; sp<StartPropertySetThread> mStartPropertySetThread = nullptr; /* ------------------------------------------------------------------------ * EGL Loading