public void enableClipRegion ( ) { if ( mClippingEnabled ) { Log . w ( TAG , "Clipping has been enabled already for %s!" , getName ( ) ) ; return ; } Log . d ( Log . SUBSYSTEM . WIDGET , TAG , "enableClipping for %s [%f, %f, %f]" , getName ( ) , getViewPortWidth ( ) , getViewPortHeight ( ) , getViewPortDepth ( ) ) ; mClippingEnabled = true ; GVRTexture texture = WidgetLib . getTextureHelper ( ) . getSolidColorTexture ( Color . YELLOW ) ; GVRSceneObject clippingObj = new GVRSceneObject ( mContext , getViewPortWidth ( ) , getViewPortHeight ( ) , texture ) ; clippingObj . setName ( "clippingObj" ) ; clippingObj . getRenderData ( ) . setRenderingOrder ( GVRRenderData . GVRRenderingOrder . STENCIL ) . setStencilTest ( true ) . setStencilFunc ( GLES30 . GL_ALWAYS , 1 , 0xFF ) . setStencilOp ( GLES30 . GL_KEEP , GLES30 . GL_KEEP , GLES30 . GL_REPLACE ) . setStencilMask ( 0xFF ) ; mSceneObject . addChildObject ( clippingObj ) ; for ( Widget child : getChildren ( ) ) { setObjectClipped ( child ) ; } }
Enable clipping for the Widget . Widget content including its children will be clipped by a rectangular View Port . By default clipping is disabled .