summaryrefslogtreecommitdiff
path: root/libs/gui/VsyncEventData.cpp
diff options
context:
space:
mode:
author Rachel Lee <rnlee@google.com> 2022-01-20 13:57:18 -0800
committer Rachel Lee <rnlee@google.com> 2022-02-07 10:44:05 -0800
commit18c3437b13645962af487703b15815f93e8ee565 (patch)
treed5c51545436696758c85c8e734009a187c5c4e6f /libs/gui/VsyncEventData.cpp
parent0d94320c36cddc1fa11b642186a8165f076f46fd (diff)
Split VsyncEventData from DisplayEventDispatcher.
Bug: 205721584 Test: atest libsurfaceflinger_unittest Change-Id: I51b18ed356ae7a29f8a88634346c0025321dbe08
Diffstat (limited to 'libs/gui/VsyncEventData.cpp')
-rw-r--r--libs/gui/VsyncEventData.cpp76
1 files changed, 76 insertions, 0 deletions
diff --git a/libs/gui/VsyncEventData.cpp b/libs/gui/VsyncEventData.cpp
new file mode 100644
index 0000000000..aad81d0198
--- /dev/null
+++ b/libs/gui/VsyncEventData.cpp
@@ -0,0 +1,76 @@
+/*
+ * Copyright (C) 2022 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.
+ */
+
+#include "gui/VsyncEventData.h"
+#include <gui/DisplayEventReceiver.h>
+#include <private/gui/ParcelUtils.h>
+#include <utils/Log.h>
+#include <utils/Looper.h>
+#include <cstdint>
+
+namespace android::gui {
+
+status_t VsyncEventData::readFromParcel(const Parcel* parcel) {
+ if (parcel == nullptr) {
+ ALOGE("%s: Null parcel", __func__);
+ return BAD_VALUE;
+ }
+
+ SAFE_PARCEL(parcel->readInt64, &id)
+ SAFE_PARCEL(parcel->readInt64, &deadlineTimestamp);
+ SAFE_PARCEL(parcel->readInt64, &frameInterval);
+
+ uint64_t uintPreferredFrameTimelineIndex;
+ SAFE_PARCEL(parcel->readUint64, &uintPreferredFrameTimelineIndex);
+ preferredFrameTimelineIndex = static_cast<size_t>(uintPreferredFrameTimelineIndex);
+
+ std::vector<FrameTimeline> timelines;
+ SAFE_PARCEL(parcel->readParcelableVector, &timelines);
+ std::copy_n(timelines.begin(), timelines.size(), frameTimelines.begin());
+
+ return OK;
+}
+status_t VsyncEventData::writeToParcel(Parcel* parcel) const {
+ SAFE_PARCEL(parcel->writeInt64, id)
+ SAFE_PARCEL(parcel->writeInt64, deadlineTimestamp);
+ SAFE_PARCEL(parcel->writeInt64, frameInterval);
+ SAFE_PARCEL(parcel->writeUint64, preferredFrameTimelineIndex);
+ SAFE_PARCEL(parcel->writeParcelableVector,
+ std::vector(frameTimelines.begin(), frameTimelines.end()));
+
+ return OK;
+}
+status_t VsyncEventData::FrameTimeline::readFromParcel(const Parcel* parcel) {
+ if (parcel == nullptr) {
+ ALOGE("%s: Null parcel", __func__);
+ return BAD_VALUE;
+ }
+
+ SAFE_PARCEL(parcel->readInt64, &id)
+ SAFE_PARCEL(parcel->readInt64, &deadlineTimestamp);
+ SAFE_PARCEL(parcel->readInt64, &expectedPresentTime);
+
+ return OK;
+}
+status_t VsyncEventData::FrameTimeline::writeToParcel(Parcel* parcel) const {
+ SAFE_PARCEL(parcel->writeInt64, id);
+ SAFE_PARCEL(parcel->writeInt64, deadlineTimestamp);
+ SAFE_PARCEL(parcel->writeInt64, expectedPresentTime);
+
+ return OK;
+}
+
+}; // namespace android::gui