1 /* 2 * Copyright (C) 2025 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 package com.android.mechanics.impl 18 19 /** 20 * Describes how the [currentSegment] is different from last frame's [lastSegment]. 21 * 22 * This affects how the discontinuities are animated and [Guarantee]s applied. 23 */ 24 internal enum class SegmentChangeType { 25 /** 26 * The segment has the same key, this is considered equivalent. 27 * 28 * Only the [GuaranteeState] needs to be kept updated. 29 */ 30 Same, 31 32 /** 33 * The segment's direction changed, however the min / max breakpoints remain the same: This is a 34 * direction change within a segment. 35 * 36 * The delta between the mapping must be animated with the reset spring, and there is no 37 * guarantee associated with the change. 38 */ 39 SameOppositeDirection, 40 41 /** 42 * The segment and its direction change. This is a direction change that happened over a segment 43 * boundary. 44 * 45 * The direction change might have happened outside the [lastSegment] already, since a segment 46 * can't be exited at the entry side. 47 */ 48 Direction, 49 50 /** 51 * The segment changed, due to the [currentInput] advancing in the [currentDirection], crossing 52 * one or more breakpoints. 53 * 54 * The guarantees of all crossed breakpoints have to be applied. The [GuaranteeState] must be 55 * reset, and a new [DiscontinuityAnimation] is started. 56 */ 57 Traverse, 58 59 /** 60 * The spec was changed and added or removed the previous and/or current segment. 61 * 62 * The [MotionValue] does not have a semantic understanding of this change, hence the difference 63 * output produced by the previous and current mapping are animated with the 64 * [MotionSpec.resetSpring] 65 */ 66 Spec, 67 } 68