1 /* 2 * Copyright (C) 2023 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.tools.common.traces.wm 18 19 import android.tools.common.datatypes.Insets 20 import android.tools.common.datatypes.Rect 21 import android.tools.common.withCache 22 import kotlin.js.JsExport 23 import kotlin.js.JsName 24 25 /** Representation of a display cutout from a WM trace */ 26 @JsExport 27 class DisplayCutout 28 private constructor( 29 val insets: Insets, 30 val boundLeft: Rect, 31 val boundTop: Rect, 32 val boundRight: Rect, 33 val boundBottom: Rect, 34 val waterfallInsets: Insets 35 ) { equalsnull36 override fun equals(other: Any?): Boolean { 37 if (this === other) return true 38 if (other !is DisplayCutout) return false 39 40 if (insets != other.insets) return false 41 if (boundLeft != other.boundLeft) return false 42 if (boundTop != other.boundTop) return false 43 if (boundRight != other.boundRight) return false 44 if (boundBottom != other.boundBottom) return false 45 if (waterfallInsets != other.waterfallInsets) return false 46 47 return true 48 } 49 hashCodenull50 override fun hashCode(): Int { 51 var result = insets.hashCode() 52 result = 31 * result + boundLeft.hashCode() 53 result = 31 * result + boundTop.hashCode() 54 result = 31 * result + boundRight.hashCode() 55 result = 31 * result + boundBottom.hashCode() 56 result = 31 * result + waterfallInsets.hashCode() 57 return result 58 } 59 toStringnull60 override fun toString(): String { 61 return "DisplayCutout(" + 62 "insets=$insets, " + 63 "boundLeft=$boundLeft, " + 64 "boundTop=$boundTop, " + 65 "boundRight=$boundRight, " + 66 "boundBottom=$boundBottom, " + 67 "waterfallInsets=$waterfallInsets" + 68 ")" 69 } 70 71 companion object { 72 @JsName("from") fromnull73 fun from( 74 insets: Insets, 75 boundLeft: Rect, 76 boundTop: Rect, 77 boundRight: Rect, 78 boundBottom: Rect, 79 waterfallInsets: Insets 80 ): DisplayCutout = withCache { 81 DisplayCutout(insets, boundLeft, boundTop, boundRight, boundBottom, waterfallInsets) 82 } 83 } 84 } 85