1 /* 2 * Copyright 2024 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 android.view; 18 19 import android.os.Parcel; 20 import android.os.Parcelable; 21 22 /** 23 * A class to create and manage FrameRateCategoryRate for 24 * categories Normal and High. 25 * @hide 26 */ 27 public class FrameRateCategoryRate implements Parcelable { 28 29 private final float mNormal; 30 private final float mHigh; 31 32 /** 33 * Creates a FrameRateCategoryRate with the provided rates 34 * for the categories Normal and High respectively; 35 * 36 * @param normal rate for the category Normal. 37 * @param high rate for the category High. 38 * @hide 39 */ FrameRateCategoryRate(float normal, float high)40 public FrameRateCategoryRate(float normal, float high) { 41 this.mNormal = normal; 42 this.mHigh = high; 43 } 44 45 /** 46 * @return the value for the category normal; 47 * @hide 48 */ getNormal()49 public float getNormal() { 50 return mNormal; 51 } 52 53 /** 54 * @return the value for the category high; 55 * @hide 56 */ getHigh()57 public float getHigh() { 58 return mHigh; 59 } 60 61 @Override equals(Object o)62 public boolean equals(Object o) { 63 if (o == this) { 64 return true; 65 } 66 if (!(o instanceof FrameRateCategoryRate)) { 67 return false; 68 } 69 FrameRateCategoryRate that = (FrameRateCategoryRate) o; 70 return mNormal == that.mNormal && mHigh == that.mHigh; 71 72 } 73 74 @Override hashCode()75 public int hashCode() { 76 int result = 1; 77 result = 31 * result + Float.hashCode(mNormal); 78 result = 31 * result + Float.hashCode(mHigh); 79 return result; 80 } 81 82 @Override toString()83 public String toString() { 84 return "FrameRateCategoryRate {" 85 + "normal=" + mNormal 86 + ", high=" + mHigh 87 + '}'; 88 } 89 90 @Override writeToParcel(Parcel dest, int flags)91 public void writeToParcel(Parcel dest, int flags) { 92 dest.writeFloat(mNormal); 93 dest.writeFloat(mHigh); 94 } 95 96 @Override describeContents()97 public int describeContents() { 98 return 0; 99 } 100 101 public static final Creator<FrameRateCategoryRate> CREATOR = 102 new Creator<>() { 103 @Override 104 public FrameRateCategoryRate createFromParcel(Parcel in) { 105 return new FrameRateCategoryRate(in.readFloat(), in.readFloat()); 106 } 107 108 @Override 109 public FrameRateCategoryRate[] newArray(int size) { 110 return new FrameRateCategoryRate[size]; 111 } 112 }; 113 } 114