• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2022 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #include "gui/VsyncEventData.h"
18 #include <gui/DisplayEventReceiver.h>
19 #include <private/gui/ParcelUtils.h>
20 #include <utils/Log.h>
21 #include <utils/Looper.h>
22 #include <cstdint>
23 
24 namespace android::gui {
25 
preferredVsyncId() const26 int64_t VsyncEventData::preferredVsyncId() const {
27     return frameTimelines[preferredFrameTimelineIndex].vsyncId;
28 }
29 
preferredDeadlineTimestamp() const30 int64_t VsyncEventData::preferredDeadlineTimestamp() const {
31     return frameTimelines[preferredFrameTimelineIndex].deadlineTimestamp;
32 }
33 
preferredExpectedPresentationTime() const34 int64_t VsyncEventData::preferredExpectedPresentationTime() const {
35     return frameTimelines[preferredFrameTimelineIndex].expectedPresentationTime;
36 }
37 
readFromParcel(const Parcel * parcel)38 status_t ParcelableVsyncEventData::readFromParcel(const Parcel* parcel) {
39     if (parcel == nullptr) {
40         ALOGE("%s: Null parcel", __func__);
41         return BAD_VALUE;
42     }
43 
44     SAFE_PARCEL(parcel->readInt64, &vsync.frameInterval);
45 
46     uint64_t uintPreferredFrameTimelineIndex;
47     SAFE_PARCEL(parcel->readUint64, &uintPreferredFrameTimelineIndex);
48     vsync.preferredFrameTimelineIndex = static_cast<size_t>(uintPreferredFrameTimelineIndex);
49 
50     for (int i = 0; i < VsyncEventData::kFrameTimelinesLength; i++) {
51         SAFE_PARCEL(parcel->readInt64, &vsync.frameTimelines[i].vsyncId);
52         SAFE_PARCEL(parcel->readInt64, &vsync.frameTimelines[i].deadlineTimestamp);
53         SAFE_PARCEL(parcel->readInt64, &vsync.frameTimelines[i].expectedPresentationTime);
54     }
55 
56     return OK;
57 }
writeToParcel(Parcel * parcel) const58 status_t ParcelableVsyncEventData::writeToParcel(Parcel* parcel) const {
59     SAFE_PARCEL(parcel->writeInt64, vsync.frameInterval);
60     SAFE_PARCEL(parcel->writeUint64, vsync.preferredFrameTimelineIndex);
61     for (int i = 0; i < VsyncEventData::kFrameTimelinesLength; i++) {
62         SAFE_PARCEL(parcel->writeInt64, vsync.frameTimelines[i].vsyncId);
63         SAFE_PARCEL(parcel->writeInt64, vsync.frameTimelines[i].deadlineTimestamp);
64         SAFE_PARCEL(parcel->writeInt64, vsync.frameTimelines[i].expectedPresentationTime);
65     }
66 
67     return OK;
68 }
69 
70 }; // namespace android::gui
71