| Siarhei Vishniakou | fc434ac | 2021-01-13 10:28:00 -1000 | [diff] [blame] | 1 | /* | 
|  | 2 | * Copyright (C) 2021 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 | #define LOG_TAG "FrameTimelineInfo" | 
|  | 18 |  | 
|  | 19 | #include <inttypes.h> | 
|  | 20 |  | 
|  | 21 | #include <android/os/IInputConstants.h> | 
|  | 22 | #include <gui/FrameTimelineInfo.h> | 
|  | 23 | #include <gui/LayerState.h> | 
|  | 24 | #include <utils/Errors.h> | 
|  | 25 |  | 
|  | 26 | #include <cmath> | 
|  | 27 |  | 
|  | 28 | using android::os::IInputConstants; | 
|  | 29 |  | 
|  | 30 | namespace android { | 
|  | 31 |  | 
|  | 32 | status_t FrameTimelineInfo::write(Parcel& output) const { | 
|  | 33 | SAFE_PARCEL(output.writeInt64, vsyncId); | 
|  | 34 | SAFE_PARCEL(output.writeInt32, inputEventId); | 
|  | 35 | return NO_ERROR; | 
|  | 36 | } | 
|  | 37 |  | 
|  | 38 | status_t FrameTimelineInfo::read(const Parcel& input) { | 
|  | 39 | SAFE_PARCEL(input.readInt64, &vsyncId); | 
|  | 40 | SAFE_PARCEL(input.readInt32, &inputEventId); | 
|  | 41 | return NO_ERROR; | 
|  | 42 | } | 
|  | 43 |  | 
|  | 44 | void FrameTimelineInfo::merge(const FrameTimelineInfo& other) { | 
|  | 45 | // When merging vsync Ids we take the oldest valid one | 
|  | 46 | if (vsyncId != INVALID_VSYNC_ID && other.vsyncId != INVALID_VSYNC_ID) { | 
|  | 47 | if (other.vsyncId > vsyncId) { | 
|  | 48 | vsyncId = other.vsyncId; | 
|  | 49 | inputEventId = other.inputEventId; | 
|  | 50 | } | 
|  | 51 | } else if (vsyncId == INVALID_VSYNC_ID) { | 
|  | 52 | vsyncId = other.vsyncId; | 
|  | 53 | inputEventId = other.inputEventId; | 
|  | 54 | } | 
|  | 55 | } | 
|  | 56 |  | 
|  | 57 | void FrameTimelineInfo::clear() { | 
|  | 58 | vsyncId = INVALID_VSYNC_ID; | 
|  | 59 | inputEventId = IInputConstants::INVALID_INPUT_EVENT_ID; | 
|  | 60 | } | 
|  | 61 |  | 
|  | 62 | }; // namespace android |