private void updateTextureAndDistortionMesh() {
   final ScreenParams screen = this.mHmd.getScreenParams();
   final CardboardDeviceParams cdp = this.mHmd.getCardboardDeviceParams();
   if (this.mProgramHolder == null) {
     this.mProgramHolder = this.createProgramHolder();
   }
   if (this.mProgramHolderAberration == null) {
     this.mProgramHolderAberration = (ProgramHolderAberration) this.createProgramHolder(true);
   }
   final float textureWidthTanAngle = this.mLeftEyeViewport.width + this.mRightEyeViewport.width;
   final float textureHeightTanAngle =
       Math.max(this.mLeftEyeViewport.height, this.mRightEyeViewport.height);
   final int[] maxTextureSize = {0};
   GLES20.glGetIntegerv(GLES20.GL_MAX_TEXTURE_SIZE, maxTextureSize, 0);
   final int textureWidthPx =
       Math.min(Math.round(textureWidthTanAngle * this.mXPxPerTanAngle), maxTextureSize[0]);
   final int textureHeightPx =
       Math.min(Math.round(textureHeightTanAngle * this.mYPxPerTanAngle), maxTextureSize[0]);
   float xEyeOffsetTanAngleScreen =
       (screen.getWidthMeters() / 2.0f - cdp.getInterLensDistance() / 2.0f)
           / this.mMetersPerTanAngle;
   final float yEyeOffsetTanAngleScreen =
       (cdp.getVerticalDistanceToLensCenter() - screen.getBorderSizeMeters())
           / this.mMetersPerTanAngle;
   this.mLeftEyeDistortionMesh =
       this.createDistortionMesh(
           this.mLeftEyeViewport,
           textureWidthTanAngle,
           textureHeightTanAngle,
           xEyeOffsetTanAngleScreen,
           yEyeOffsetTanAngleScreen);
   xEyeOffsetTanAngleScreen =
       screen.getWidthMeters() / this.mMetersPerTanAngle - xEyeOffsetTanAngleScreen;
   this.mRightEyeDistortionMesh =
       this.createDistortionMesh(
           this.mRightEyeViewport,
           textureWidthTanAngle,
           textureHeightTanAngle,
           xEyeOffsetTanAngleScreen,
           yEyeOffsetTanAngleScreen);
   this.setupRenderTextureAndRenderbuffer(textureWidthPx, textureHeightPx);
   this.mFovsChanged = false;
 }
 public void updateViewports(final Viewport leftViewport, final Viewport rightViewport) {
   leftViewport.setViewport(
       Math.round(this.mLeftEyeViewport.x * this.mXPxPerTanAngle * this.mResolutionScale),
       Math.round(this.mLeftEyeViewport.y * this.mYPxPerTanAngle * this.mResolutionScale),
       Math.round(this.mLeftEyeViewport.width * this.mXPxPerTanAngle * this.mResolutionScale),
       Math.round(this.mLeftEyeViewport.height * this.mYPxPerTanAngle * this.mResolutionScale));
   rightViewport.setViewport(
       Math.round(this.mRightEyeViewport.x * this.mXPxPerTanAngle * this.mResolutionScale),
       Math.round(this.mRightEyeViewport.y * this.mYPxPerTanAngle * this.mResolutionScale),
       Math.round(this.mRightEyeViewport.width * this.mXPxPerTanAngle * this.mResolutionScale),
       Math.round(this.mRightEyeViewport.height * this.mYPxPerTanAngle * this.mResolutionScale));
   this.mViewportsChanged = false;
 }