fun measure()

in amazon-chime-sdk/src/main/java/com/amazonaws/services/chime/sdk/meetings/internal/utils/VideoLayoutMeasure.kt [28:61]


    fun measure(
        widthSpec: Int,
        heightSpec: Int,
        frameWidth: Int,
        frameHeight: Int
    ): Point {
        // Calculate max allowed layout size.
        val maxWidth = View.getDefaultSize(Int.MAX_VALUE, widthSpec)
        val maxHeight =
                View.getDefaultSize(Int.MAX_VALUE, heightSpec)
        if (frameWidth == 0 || frameHeight == 0 || maxWidth == 0 || maxHeight == 0) {
            return Point(maxWidth, maxHeight)
        }
        // Calculate desired display size based on scaling type, video aspect ratio,
        // and maximum layout size.
        val frameAspect = frameWidth / frameHeight.toFloat()
        val layoutSize: Point =
                getDisplaySize(
                        scalingType.visibleFraction,
                        frameAspect,
                        maxWidth,
                        maxHeight
                )

        // If the measure specification is forcing a specific size, yield.
        // MeasureSpec.EXACTLY implies that parent view should control child size
        if (View.MeasureSpec.getMode(widthSpec) == View.MeasureSpec.EXACTLY) {
            layoutSize.x = maxWidth
        }
        if (View.MeasureSpec.getMode(heightSpec) == View.MeasureSpec.EXACTLY) {
            layoutSize.y = maxHeight
        }
        return layoutSize
    }