summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Lloyd Pique <lpique@google.com> 2018-01-22 17:31:47 -0800
committer Lloyd Pique <lpique@google.com> 2018-03-26 17:25:28 -0700
commit0c3a88319136a8ce0e7050ef5695610a986ce900 (patch)
treec6850ce8d00efdcb097994ba8f3c271ed512d728
parentda901cc5c5be85aa7a41800099bc89353d89d5a8 (diff)
SF: Separate EventControlThread into interface and impl
Test: Builds Bug: 74827900 Change-Id: Ib79503860bf9409cc71d98e2e845ffaff114fbb1 (cherry picked from commit 379adc10ebe94eec8c7754d262c6184fbfb3f0a3)
-rw-r--r--services/surfaceflinger/EventControlThread.cpp5
-rw-r--r--services/surfaceflinger/EventControlThread.h15
-rw-r--r--services/surfaceflinger/SurfaceFlinger.cpp5
3 files changed, 20 insertions, 5 deletions
diff --git a/services/surfaceflinger/EventControlThread.cpp b/services/surfaceflinger/EventControlThread.cpp
index ac54059360..fb6cff5705 100644
--- a/services/surfaceflinger/EventControlThread.cpp
+++ b/services/surfaceflinger/EventControlThread.cpp
@@ -26,6 +26,10 @@
namespace android {
+EventControlThread::~EventControlThread() = default;
+
+namespace impl {
+
EventControlThread::EventControlThread(EventControlThread::SetVSyncEnabledFunction function)
: mSetVSyncEnabled(function) {
pthread_setname_np(mThread.native_handle(), "EventControlThread");
@@ -67,4 +71,5 @@ void EventControlThread::threadMain() NO_THREAD_SAFETY_ANALYSIS {
}
}
+} // namespace impl
} // namespace android
diff --git a/services/surfaceflinger/EventControlThread.h b/services/surfaceflinger/EventControlThread.h
index 321fb79831..9be4e7cd8e 100644
--- a/services/surfaceflinger/EventControlThread.h
+++ b/services/surfaceflinger/EventControlThread.h
@@ -16,8 +16,8 @@
#pragma once
-#include <cstddef>
#include <condition_variable>
+#include <cstddef>
#include <functional>
#include <mutex>
#include <thread>
@@ -30,12 +30,22 @@ class SurfaceFlinger;
class EventControlThread {
public:
+ virtual ~EventControlThread();
+
+ virtual void setVsyncEnabled(bool enabled) = 0;
+};
+
+namespace impl {
+
+class EventControlThread final : public android::EventControlThread {
+public:
using SetVSyncEnabledFunction = std::function<void(bool)>;
explicit EventControlThread(SetVSyncEnabledFunction function);
~EventControlThread();
- void setVsyncEnabled(bool enabled);
+ // EventControlThread implementation
+ void setVsyncEnabled(bool enabled) override;
private:
void threadMain();
@@ -51,4 +61,5 @@ private:
std::thread mThread{&EventControlThread::threadMain, this};
};
+} // namespace impl
} // namespace android
diff --git a/services/surfaceflinger/SurfaceFlinger.cpp b/services/surfaceflinger/SurfaceFlinger.cpp
index 932b92e653..cdf126e9e2 100644
--- a/services/surfaceflinger/SurfaceFlinger.cpp
+++ b/services/surfaceflinger/SurfaceFlinger.cpp
@@ -639,9 +639,8 @@ void SurfaceFlinger::init() {
}
}
- mEventControlThread = std::make_unique<EventControlThread>([this](bool enabled) {
- setVsyncEnabled(HWC_DISPLAY_PRIMARY, enabled);
- });
+ mEventControlThread = std::make_unique<impl::EventControlThread>(
+ [this](bool enabled) { setVsyncEnabled(HWC_DISPLAY_PRIMARY, enabled); });
// initialize our drawing state
mDrawingState = mCurrentState;