• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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.datatypes
18 
19 import android.tools.common.withCache
20 import kotlin.js.JsExport
21 import kotlin.js.JsName
22 
23 /**
24  * Wrapper for SizeProto (frameworks/native/services/surfaceflinger/layerproto/common.proto)
25  *
26  * This class is used by flicker and Winscope
27  */
28 @JsExport
29 open class Size
30 protected constructor(@JsName("width") val width: Int, @JsName("height") val height: Int) :
31     DataType() {
32     override val isEmpty = height == 0 || width == 0
33 
doPrintValuenull34     override fun doPrintValue() = "$width x $height"
35 
36     companion object {
37         @JsName("EMPTY")
38         val EMPTY: Size
39             get() = withCache { Size(width = 0, height = 0) }
40         @JsName("from") fun from(width: Int, height: Int): Size = withCache { Size(width, height) }
41     }
42 }
43