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 <private/gui/ParcelUtils.h> 25 #include <utils/Errors.h> 26 27 #include <cmath> 28 29 using android::os::IInputConstants; 30 31 namespace android { 32 write(Parcel & output) const33status_t FrameTimelineInfo::write(Parcel& output) const { 34 SAFE_PARCEL(output.writeInt64, vsyncId); 35 SAFE_PARCEL(output.writeInt32, inputEventId); 36 return NO_ERROR; 37 } 38 read(const Parcel & input)39status_t FrameTimelineInfo::read(const Parcel& input) { 40 SAFE_PARCEL(input.readInt64, &vsyncId); 41 SAFE_PARCEL(input.readInt32, &inputEventId); 42 return NO_ERROR; 43 } 44 merge(const FrameTimelineInfo & other)45void FrameTimelineInfo::merge(const FrameTimelineInfo& other) { 46 // When merging vsync Ids we take the oldest valid one 47 if (vsyncId != INVALID_VSYNC_ID && other.vsyncId != INVALID_VSYNC_ID) { 48 if (other.vsyncId > vsyncId) { 49 vsyncId = other.vsyncId; 50 inputEventId = other.inputEventId; 51 } 52 } else if (vsyncId == INVALID_VSYNC_ID) { 53 vsyncId = other.vsyncId; 54 inputEventId = other.inputEventId; 55 } 56 } 57 clear()58void FrameTimelineInfo::clear() { 59 vsyncId = INVALID_VSYNC_ID; 60 inputEventId = IInputConstants::INVALID_INPUT_EVENT_ID; 61 } 62 63 }; // namespace android 64