Skip to content

Commit

Permalink
Vito Drawee compatibility: Added rounding at render time as an option…
Browse files Browse the repository at this point in the history
… for RoundingParamsWrapper

Reviewed By: kartavya-ramnani

Differential Revision: D67980120

fbshipit-source-id: 5cef6283caff17fd02a6cf450c1d22163fdf58e0
  • Loading branch information
oprisnik authored and facebook-github-bot committed Jan 10, 2025
1 parent fd79fd2 commit bd4f011
Showing 1 changed file with 17 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,30 @@ package com.facebook.fresco.vito.draweesupport
import com.facebook.drawee.generic.RoundingParams
import com.facebook.fresco.vito.options.BorderOptions
import com.facebook.fresco.vito.options.RoundingOptions
import com.facebook.fresco.vito.options.RoundingOptions.Companion.CORNER_RADIUS_UNSET

object RoundingParamsWrapper {

@JvmStatic
fun roundingOptionsFromRoundingParams(roundingParams: RoundingParams?): RoundingOptions? {
@JvmOverloads
fun roundingOptionsFromRoundingParams(
roundingParams: RoundingParams?,
roundAtRenderTime: Boolean = false
): RoundingOptions? {
return when {
roundingParams == null -> null
roundingParams.roundAsCircle -> RoundingOptions.asCircle(true)
roundingParams.roundAsCircle ->
if (roundAtRenderTime) {
RoundingOptions.asCircle(true, true)
} else {
RoundingOptions.asCircle()
}
roundingParams.cornersRadii != null ->
RoundingOptions.forCornerRadii(roundingParams.cornersRadii!!, true)
if (roundAtRenderTime) {
RoundingOptions(false, CORNER_RADIUS_UNSET, roundingParams.cornersRadii!!, true, true)
} else {
RoundingOptions.forCornerRadii(roundingParams.cornersRadii!!, true)
}
// TODO: we also have an overlay color mode where you specify a color to be drawn on top. Vito
// does not support this.
// Probably only used for borders
Expand Down

0 comments on commit bd4f011

Please sign in to comment.