Skip to content

Commit

Permalink
Remove checks from Rect creation (#867)
Browse files Browse the repository at this point in the history
  • Loading branch information
MatkovIvan authored Feb 7, 2024
1 parent a95eb8c commit 265da83
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 14 deletions.
10 changes: 2 additions & 8 deletions skiko/src/commonMain/kotlin/org/jetbrains/skia/IRect.kt
Original file line number Diff line number Diff line change
Expand Up @@ -60,23 +60,17 @@ class IRect internal constructor(val left: Int, val top: Int, val right: Int, va
companion object {
@JvmStatic
fun makeLTRB(l: Int, t: Int, r: Int, b: Int): IRect {
require(l <= r) { "IRect::makeLTRB expected l <= r, got $l > $r" }
require(t <= b) { "IRect::makeLTRB expected t <= b, got $t > $b" }
return IRect(l, t, r, b)
}

@JvmStatic
fun makeXYWH(l: Int, t: Int, w: Int, h: Int): IRect {
require(w >= 0) { "IRect::makeXYWH expected w >= 0, got: $w" }
require(h >= 0) { "IRect::makeXYWH expected h >= 0, got: $h" }
return if (w >= 0 && h >= 0) IRect(l, t, l + w, t + h) else throw IllegalArgumentException()
return IRect(l, t, l + w, t + h)
}

@JvmStatic
fun makeWH(w: Int, h: Int): IRect {
require(w >= 0) { "IRect::makeWH expected w >= 0, got: $w" }
require(h >= 0) { "IRect::makeWH expected h >= 0, got: $h" }
return if (w >= 0 && h >= 0) IRect(0, 0, w, h) else throw IllegalArgumentException()
return IRect(0, 0, w, h)
}
}
}
6 changes: 0 additions & 6 deletions skiko/src/commonMain/kotlin/org/jetbrains/skia/Rect.kt
Original file line number Diff line number Diff line change
Expand Up @@ -88,15 +88,11 @@ open class Rect constructor(val left: Float, val top: Float, val right: Float, v
companion object {
@JvmStatic
fun makeLTRB(l: Float, t: Float, r: Float, b: Float): Rect {
require(l <= r) { "Rect::makeLTRB expected l <= r, got $l > $r" }
require(t <= b) { "Rect::makeLTRB expected t <= b, got $t > $b" }
return Rect(l, t, r, b)
}

@JvmStatic
fun makeWH(w: Float, h: Float): Rect {
require(w >= 0) { "Rect::makeWH expected w >= 0, got: $w" }
require(h >= 0) { "Rect::makeWH expected h >= 0, got: $h" }
return Rect(0f, 0f, w, h)
}

Expand All @@ -107,8 +103,6 @@ open class Rect constructor(val left: Float, val top: Float, val right: Float, v

@JvmStatic
fun makeXYWH(l: Float, t: Float, w: Float, h: Float): Rect {
require(w >= 0) { "Rect::makeXYWH expected w >= 0, got: $w" }
require(h >= 0) { "Rect::makeXYWH expected h >= 0, got: $h" }
return Rect(l, t, l + w, t + h)
}

Expand Down

0 comments on commit 265da83

Please sign in to comment.