1 /* 2 * Copyright (C) 2020 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.server.wm.traces.common 18 19 /** 20 * Wrapper for ColorProto (frameworks/native/services/surfaceflinger/layerproto/common.proto) 21 * 22 * This class is used by flicker and Winscope 23 */ 24 class Color(r: Float, g: Float, b: Float, val a: Float) : Color3(r, g, b) { 25 override val isEmpty: Boolean 26 get() = a == 0f || r < 0 || g < 0 || b < 0 27 28 override val isNotEmpty: Boolean 29 get() = !isEmpty 30 prettyPrintnull31 override fun prettyPrint(): String { 32 val parentPrint = super.prettyPrint() 33 return "$parentPrint a:$a" 34 } 35 equalsnull36 override fun equals(other: Any?): Boolean { 37 if (this === other) return true 38 if (other !is Color) return false 39 if (!super.equals(other)) return false 40 41 if (a != other.a) return false 42 43 return true 44 } 45 hashCodenull46 override fun hashCode(): Int { 47 var result = super.hashCode() 48 result = 31 * result + a.hashCode() 49 return result 50 } 51 52 companion object { 53 val EMPTY: Color = Color(r = -1f, g = -1f, b = -1f, a = 0f) 54 } 55 } 56