SF: add partial implementation of VSyncReactor

Adds an adaptor for the VSyncDispatch/VSyncTracker system
that will implemente the DispSync interface. Implementation
is only partial, will build out rest in subsequent MPs.

Bug: 140303479
Test: 6 new unit tests (VSyncReactor)

Change-Id: I11441f0f5bac9095d14122f487ab99bbdf44a7e3
diff --git a/services/surfaceflinger/Scheduler/VSyncReactor.h b/services/surfaceflinger/Scheduler/VSyncReactor.h
new file mode 100644
index 0000000..05fd0fd
--- /dev/null
+++ b/services/surfaceflinger/Scheduler/VSyncReactor.h
@@ -0,0 +1,49 @@
+/*
+ * Copyright 2019 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#pragma once
+
+#include <android-base/thread_annotations.h>
+#include <ui/FenceTime.h>
+#include <memory>
+#include <mutex>
+#include <vector>
+
+namespace android::scheduler {
+
+class VSyncDispatch;
+class VSyncTracker;
+
+// TODO (b/145217110): consider renaming.
+class VSyncReactor /* TODO (b/140201379): : public android::DispSync */ {
+public:
+    VSyncReactor(std::unique_ptr<VSyncDispatch> dispatch, std::unique_ptr<VSyncTracker> tracker,
+                 size_t pendingFenceLimit);
+
+    bool addPresentFence(const std::shared_ptr<FenceTime>& fence);
+    void setIgnorePresentFences(bool ignoration);
+
+private:
+    std::unique_ptr<VSyncDispatch> const mDispatch;
+    std::unique_ptr<VSyncTracker> const mTracker;
+    size_t const mPendingLimit;
+
+    std::mutex mMutex;
+    bool mIgnorePresentFences GUARDED_BY(mMutex) = false;
+    std::vector<std::shared_ptr<FenceTime>> mUnfiredFences GUARDED_BY(mMutex);
+};
+
+} // namespace android::scheduler