question: public void drawBitmapWithCircleOnCanvas ( Bitmap bitmap , Canvas canvas , RectF source , @ NonNull RectF dest ) { if ( bitmap == null ) { if ( getStyle ( ) == SHAPE_CIRCLE ) { canvas . drawCircle ( dest . centerX ( ) , dest . centerY ( ) , Math . min ( dest . width ( ) , dest . height ( ) ) / 2f , mSolidColorPaint ) ; } else { final float cornerRadius = getCalculatedCornerRadius ( ) ; canvas . drawRoundRect ( dest , cornerRadius , cornerRadius , mSolidColorPaint ) ; } return ; } final BitmapShader shader = new BitmapShader ( bitmap , Shader . TileMode . CLAMP , Shader . TileMode . CLAMP ) ; mMatrix . reset ( ) ; switch ( getScaleType ( ) ) { case CENTER_CROP : { final float srcRatio = source . width ( ) / source . height ( ) ; final float dstRatio = dest . width ( ) / dest . height ( ) ; if ( srcRatio > dstRatio ) { mTempDestination . top = dest . top ; mTempDestination . bottom = dest . bottom ; final float dstWidth = dest . height ( ) * srcRatio ; mTempDestination . left = dest . centerX ( ) - dstWidth / 2 ; mTempDestination . right = dest . centerX ( ) + dstWidth / 2 ; } else if ( srcRatio < dstRatio ) { mTempDestination . left = dest . left ; mTempDestination . right = dest . right ; final float dstHeight = dest . width ( ) / srcRatio ; mTempDestination . top = dest . centerY ( ) - dstHeight / 2 ; mTempDestination . bottom = dest . centerY ( ) + dstHeight / 2 ; } else { mTempDestination . set ( dest ) ; } break ; } default : { mTempDestination . set ( dest ) ; break ; } } mMatrix . setRectToRect ( source , mTempDestination , ScaleToFit . CENTER ) ; shader . setLocalMatrix ( mMatrix ) ; mBitmapPaint . setShader ( shader ) ; if ( mBorderEnabled ) { final float inset = mBorderPaint . getStrokeWidth ( ) / 2 ; if ( getStyle ( ) == SHAPE_CIRCLE ) { final float circleRadius = Math . min ( dest . width ( ) , dest . height ( ) ) / 2f - inset / 2 ; canvas . drawCircle ( dest . centerX ( ) , dest . centerY ( ) , circleRadius , mBitmapPaint ) ; } else { final float cornerRadius = getCalculatedCornerRadius ( ) ; dest . inset ( inset , inset ) ; canvas . drawRoundRect ( dest , cornerRadius , cornerRadius , mBitmapPaint ) ; dest . inset ( - inset , - inset ) ; } } else { if ( getStyle ( ) == SHAPE_CIRCLE ) { final float circleRadius = Math . min ( dest . width ( ) , dest . height ( ) ) / 2f ; canvas . drawCircle ( dest . centerX ( ) , dest . centerY ( ) , circleRadius , mBitmapPaint ) ; } else { final float cornerRadius = getCalculatedCornerRadius ( ) ; canvas . drawRoundRect ( dest , cornerRadius , cornerRadius , mBitmapPaint ) ; } } }
target:  Given the source bitmap and a canvas, draws the bitmap through a circular mask. Only draws a circle with diameter equal to the destination width.