virtual public void Draw(FairyBatch batch) { ValidateMatrix(false); if (_paintingMode != 0) { if (graphics != null && paintingGraphics.texture != null) { batch.PushRenderTarget(paintingGraphics.texture, Vector2.Transform(Vector2.Zero, _localToWorldMatrix) + new Vector2(_paintingMargin.left, _paintingMargin.top)); batch.Draw(graphics, _alpha, _grayed, BlendMode.Normal, ref _localToWorldMatrix, null); batch.PopRenderTarget(); } if (!(this is Container)) { batch.Draw(paintingGraphics, 1, false, _blendMode, ref _localToWorldMatrix, _filter); } } else { if (graphics != null) { batch.Draw(graphics, _alpha, _grayed, _blendMode, ref _localToWorldMatrix, _filter); } } }
override public void Draw(FairyBatch batch) { base.Draw(batch); if (_paintingMode != 0 && paintingGraphics.texture != null) { batch.PushRenderTarget(paintingGraphics.texture, Vector2.Transform(Vector2.Zero, _localToWorldMatrix) + new Vector2(_paintingMargin.left, _paintingMargin.top)); } if (_clipRect != null) { //在这里可以直接使用 _localToWorldMatrix, 因为已经更新 Rectangle clipRect = (Rectangle)_clipRect; Matrix mat = Matrix.Identity; ToolSet.TransformRect(ref clipRect, ref _localToWorldMatrix, ref mat); batch.EnterClipping(clipRect); } float savedAlpha = batch.alpha; batch.alpha *= this.alpha; bool savedGrayed = batch.grayed; batch.grayed = batch.grayed || this.grayed; int cnt = _children.Count; for (int i = 0; i < cnt; i++) { DisplayObject child = _children[i]; if (child.visible) { child.Draw(batch); } } if (_clipRect != null) { batch.LeaveClipping(); } if (_paintingMode != 0 && paintingGraphics.texture != null) { batch.PopRenderTarget(); batch.Draw(paintingGraphics, 1, false, _blendMode, ref _localToWorldMatrix, _filter); } batch.alpha = savedAlpha; batch.grayed = savedGrayed; }