sDrawCommand(iPathGeometry geometry, eMesh command, sStrokeStyle ss, float w) { this.geometry = geometry; this.command = command; strokeStyle = ss; width = w; }
void iDrawContext.fillAndStroke(iGeometry geometry, iBrush fill, iBrush stroke, float strokeWidth, iStrokeStyle strokeStyle) { sStrokeStyle ss = strokeStyle?.strokeStyle ?? defaultStrokeStyle(); iPathGeometry path = (iPathGeometry)geometry; fillAndStrokeGeometry(path, fill.data(), stroke.data(), strokeWidth, ref ss); }
void iDrawContext.drawGeometry(iGeometry geometry, iBrush brush, float width, iStrokeStyle strokeStyle) { switch (brush) { case SolidColorBrush solidColor: var cd = solidColor.data; sStrokeStyle ss = strokeStyle?.strokeStyle ?? defaultStrokeStyle(); strokeGeometry((iPathGeometry)geometry, cd, null, width, ref ss); return; } throw new NotImplementedException(); }
protected override void createResources(IRenderDevice rd) { var dd = context.drawDevice; sStrokeStyle ss = new sStrokeStyle() { lineJoin = pathLineJoin, miterLimit = 2, startCap = lineCaps, endCap = lineCaps, }; strokeStyle = dd.createStrokeStyle(ss); onResized(dd.viewportSize, context.dpiScalingFactor); dd.resized.add(this, onResized); brushes = brushColors.Select(dd.createSolidBrush).ToArray(); if (playAnimation) { context.animation.startDelta(this); } }
protected void fillAndStrokeGeometry(iPathGeometry path, SolidColorData?fill, SolidColorData stroke, float width, ref sStrokeStyle strokeStyle, int instance = 0) { if ((fill?.brushType ?? eBrushType.Null) == eBrushType.Null) { // No fill, just stroke if (stroke.brushType != eBrushType.Null) { strokeGeometry(path, stroke, null, width, ref strokeStyle, instance); } return; } if (stroke.brushType == eBrushType.Null) { // No stroke, just fill fillGeometry(path, fill.Value, true, instance); return; } getCurrentTransform(out Matrix3x2 tform, out float pixel); if (!path.testApproximateBounds(ref tform, width)) { return; } eBuildFilledMesh fillOptions = DrawUtilsPrivate.fillFlagsFromColor(fill.Value.brushType, true); StrokeRenderParams srp = StrokeRenderParams.strokedPath(stroke.paletteIndex, width, pixel); Order o; if (fill.Value == stroke) { // Colors are the same, combine the draw calls sPendingDrawCall pdc = tesselatorThread.fillAndStroke(path, ref tform, pixel, fillOptions, new sStrokeInfo(strokeStyle, srp.meshWidth), instance); flushIfNeeded(pdc.drawInfo.drawCallsCount); o = order(); drawMeshes.meshes.add(ref pdc); calls.add(sDrawCall.solidColorStroke(o, ref tform, ref srp)); return; } var pendingCalls = tesselatorThread.fillAndStrokeSeparate(path, ref tform, pixel, fillOptions, new sStrokeInfo(strokeStyle, srp.meshWidth), instance); byte dcc = pendingCalls.Item1.drawInfo.drawCallsCount; dcc += pendingCalls.Item2.drawInfo.drawCallsCount; flushIfNeeded(dcc); o = order(); drawMeshes.meshes.add(ref pendingCalls.Item1); calls.add(sDrawCall.solidColorFill(o, ref tform, fill.Value.paletteIndex)); o = order(); drawMeshes.meshes.add(ref pendingCalls.Item2); calls.add(sDrawCall.solidColorStroke(o, ref tform, ref srp)); }
protected void strokeGeometry(iPathGeometry path, SolidColorData color, SolidColorData?filledColor, float width, ref sStrokeStyle strokeStyle, int instance = 0) { getCurrentTransform(out Matrix3x2 tform, out float pixel); if (!path.testApproximateBounds(ref tform, width) || color.brushType == eBrushType.Null) { return; } int fillColorIndex = filledColor?.paletteIndex ?? (int)eNamedColor.Transparent; StrokeRenderParams srp = StrokeRenderParams.strokedPath(color.paletteIndex, width, pixel, fillColorIndex); sPendingDrawCall pdc = tesselatorThread.stroke(path, ref tform, pixel, new sStrokeInfo(strokeStyle, srp.meshWidth), instance); flushIfNeeded(pdc.drawInfo.drawCallsCount); Order o = order(); drawMeshes.meshes.add(ref pdc); calls.add(sDrawCall.solidColorStroke(o, ref tform, ref srp)); }