public void DrawPrimitiveList(List <Primitive> primitiveList, bool useBoxModel, Rect nodeRect, StyleRuleSet ruleSet, MeshList meshList) { Rect rect = nodeRect; if (useBoxModel) { GetBoxes(nodeRect, ruleSet, out var bRect, out var pRect, out rect); var shapeMesh = MeshPool.ShapeMeshPool.Get(); shapeMesh.Clear(); shapeMesh.CommandBuffer.Add(DrawCommand.Default); var imageMesh = MeshPool.ImageMeshPool.Get(); imageMesh.Clear(); this.DrawBoxModelPrimitive(shapeMesh, imageMesh, bRect, pRect, rect, ruleSet); meshList.AddOrUpdateShapeMesh(shapeMesh); meshList.AddOrUpdateImageMesh(imageMesh); } foreach (var primitive in primitiveList) { switch (primitive) { case PathPrimitive p: { var shapeMesh = MeshPool.ShapeMeshPool.Get(); shapeMesh.Clear(); shapeMesh.CommandBuffer.Add(DrawCommand.Default); this.DrawPathPrimitive(shapeMesh, p, (Vector)rect.Location); meshList.AddOrUpdateShapeMesh(shapeMesh); } break; case TextPrimitive t: { var textMesh = MeshPool.TextMeshPool.Get(); textMesh.Clear(); this.DrawTextPrimitive(textMesh, t, rect, ruleSet, primitive.Offset); meshList.AddOrUpdateTextMesh(textMesh); } break; case ImagePrimitive i: { var imageMesh = MeshPool.ImageMeshPool.Get(); imageMesh.Clear(); this.DrawImagePrimitive(imageMesh, i, rect, ruleSet, primitive.Offset); meshList.AddOrUpdateImageMesh(imageMesh); } break; default: throw new ArgumentOutOfRangeException(); } } }
public void DrawPrimitive(Geometry geometry, Rect nodeRect, StyleRuleSet ruleSet, MeshList meshList) { Rect rect = nodeRect; if (geometry == null) { return; } switch (geometry) { case PathGeometry p: { var shapeMesh = MeshPool.ShapeMeshPool.Get(); shapeMesh.Clear(); shapeMesh.CommandBuffer.Add(DrawCommand.Default); this.DrawPathPrimitive(shapeMesh, p, (Vector)rect.Location); meshList.AddOrUpdateShapeMesh(shapeMesh); } break; case TextGeometry t: { var textMesh = MeshPool.TextMeshPool.Get(); textMesh.Clear(); this.DrawTextPrimitive(textMesh, t, rect, ruleSet, geometry.Offset); meshList.AddOrUpdateTextMesh(textMesh); } break; case ImageGeometry i: { var imageMesh = MeshPool.ImageMeshPool.Get(); imageMesh.Clear(); this.DrawImagePrimitive(imageMesh, i, rect, ruleSet, geometry.Offset); meshList.AddOrUpdateImageMesh(imageMesh); } break; default: throw new ArgumentOutOfRangeException(); } }