RenderLayer _createMaskLayer(RenderLayer parentLayer, Rect maskBounds, Action <Paint> drawCallback, Paint paint) { var textureWidth = Mathf.CeilToInt((float)maskBounds.width * this._devicePixelRatio); textureWidth = Mathf.Max(1, textureWidth); var textureHeight = Mathf.CeilToInt((float)maskBounds.height * this._devicePixelRatio); textureHeight = Mathf.Max(1, textureHeight); var maskLayer = new RenderLayer { rtID = Shader.PropertyToID("_rtID_" + this._layers.Count + "_" + parentLayer.layers.Count), width = textureWidth, height = textureHeight, layerBounds = maskBounds, }; parentLayer.layers.Add(maskLayer); this._layers.Add(maskLayer); var parentState = parentLayer.states.Last(); var maskState = maskLayer.states.Last(); maskState.matrix = parentState.matrix; drawCallback(Paint.shapeOnly(paint)); var removed = this._layers.removeLast(); D.assert(removed == maskLayer); return(maskLayer); }
RenderLayer _createMaskLayer(RenderLayer parentLayer, Rect maskBounds, Action <Paint> drawCallback, Paint paint) { var textureWidth = Mathf.CeilToInt(maskBounds.width * this._devicePixelRatio); if (textureWidth < 1) { textureWidth = 1; } var textureHeight = Mathf.CeilToInt(maskBounds.height * this._devicePixelRatio); if (textureHeight < 1) { textureHeight = 1; } var maskLayer = new RenderLayer { rtID = Shader.PropertyToID("_rtID_" + this._layers.Count + "_" + parentLayer.layers.Count), width = textureWidth, height = textureHeight, layerBounds = maskBounds, filterMode = FilterMode.Bilinear, }; parentLayer.layers.Add(maskLayer); this._layers.Add(maskLayer); this._currentLayer = maskLayer; var parentState = parentLayer.states[parentLayer.states.Count - 1]; var maskState = maskLayer.states[maskLayer.states.Count - 1]; maskState.matrix = parentState.matrix; drawCallback(Paint.shapeOnly(paint)); var removed = this._layers.removeLast(); D.assert(removed == maskLayer); this._currentLayer = this._layers[this._layers.Count - 1]; return(maskLayer); }