public void adjustForVerticalVideo ( SCREEN_ROTATION orientation , boolean scaleToFit ) { synchronized ( mDrawLock ) { mCorrectVerticalVideo = true ; mScaleToFit = scaleToFit ; requestedOrientation = orientation ; Matrix . setIdentityM ( IDENTITY_MATRIX , 0 ) ; switch ( orientation ) { case VERTICAL : if ( scaleToFit ) { Matrix . rotateM ( IDENTITY_MATRIX , 0 , - 90 , 0f , 0f , 1f ) ; Matrix . scaleM ( IDENTITY_MATRIX , 0 , 3.16f , 1.0f , 1f ) ; } else { Matrix . scaleM ( IDENTITY_MATRIX , 0 , 0.316f , 1f , 1f ) ; } break ; case UPSIDEDOWN_LANDSCAPE : if ( scaleToFit ) { Matrix . rotateM ( IDENTITY_MATRIX , 0 , - 180 , 0f , 0f , 1f ) ; } break ; case UPSIDEDOWN_VERTICAL : if ( scaleToFit ) { Matrix . rotateM ( IDENTITY_MATRIX , 0 , 90 , 0f , 0f , 1f ) ; Matrix . scaleM ( IDENTITY_MATRIX , 0 , 3.16f , 1.0f , 1f ) ; } else { Matrix . scaleM ( IDENTITY_MATRIX , 0 , 0.316f , 1f , 1f ) ; } break ; } } }
Adjust the MVP Matrix to rotate and crop the texture to make vertical video appear upright