コード例 #1
0
        protected void fillGeometry(iPathGeometry path, SolidColorData color, bool vaa, int instance = 0)
        {
            getCurrentTransform(out Matrix3x2 tform, out float pixel);
            if (!path.testApproximateBounds(ref tform) || color.brushType == eBrushType.Null)
            {
                return;
            }

            eBuildFilledMesh fillOptions = DrawUtilsPrivate.fillFlagsFromColor(color.brushType, false);

            if (fillOptions == eBuildFilledMesh.None)
            {
                return;                 // Null brush
            }
            if (!vaa)
            {
                fillOptions &= ~eBuildFilledMesh.VAA;
            }

            sPendingDrawCall pdc = tesselatorThread.fill(path, ref tform, pixel, fillOptions, instance);

            flushIfNeeded(pdc.drawInfo.drawCallsCount);

            Order o = order();

            drawMeshes.meshes.add(ref pdc);
            calls.add(sDrawCall.solidColorFill(o, ref tform, color.paletteIndex));
        }
コード例 #2
0
        protected void drawText(string text, Font font, ref Rect rectangle, SolidColorData foreground, SolidColorData background)
        {
            getCurrentTransform(out Matrix3x2 tform, out float pixel);
            var transformedRect = tform.transformRectangle(ref rectangle);

            if (!DrawDevice.clipSpaceRectangle.intersects(ref transformedRect) || foreground.brushType == eBrushType.Null)
            {
                return;
            }

            flushIfNeeded(1);

            IntMatrix?     intMtx;
            CPoint         startingPoint = transformToPhysicalPixels(rectangle.topLeft, out intMtx);
            CSize          size          = (rectangle.size / pixel).roundToInt().asSize;
            CRect          textRect      = new CRect(startingPoint, size);
            eTextRendering trs           = textRenderingStyle(intMtx);

            Order o = drawMeshes.addText(ref currentZ, text, font, ref textRect, foreground.paletteIndex, trs);

            bool opaqueBackground = background.brushType == eBrushType.Opaque;

            passFlags |= eRenderPassFlags.Transparent;
            calls.add(sDrawCall.drawText(o, ref tform, foreground.paletteIndex,
                                         background.paletteIndex, opaqueBackground,
                                         pixel, trs));
        }
コード例 #3
0
        protected void fillRectangle(ref Rect rectangle, SolidColorData color)
        {
            getCurrentTransform(out Matrix3x2 tform, out float pixel);
            var transformedRect = tform.transformRectangle(ref rectangle);

            if (!DrawDevice.clipSpaceRectangle.intersects(ref transformedRect) || color.brushType == eBrushType.Null)
            {
                return;
            }

            flushIfNeeded(1);
            Order o = drawMeshes.addRectangle(ref currentZ, ref rectangle, null);

            calls.add(sDrawCall.builtinShapeNoVaa(o, ref tform, color.paletteIndex));
        }
コード例 #4
0
        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));
        }
コード例 #5
0
        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));
        }
コード例 #6
0
        protected void drawConsoleText(string text, int width, Font font, Vector2 position, SolidColorData foreground, SolidColorData background)
        {
            getCurrentTransform(out Matrix3x2 tform, out float pixel);
            IntMatrix?intMtx;
            CPoint    startingPoint = transformToPhysicalPixels(position, out intMtx);

            if (!intMtx.HasValue)
            {
                throw new ApplicationException("iDrawContext.drawConsoleText doesn't currently support transforms");
            }

            eTextRendering trs = textRenderingStyle(intMtx);

            CRect rect = new CRect(startingPoint, new CSize());

            Order o = drawMeshes.addText(ref currentZ, text, font, ref rect, foreground.paletteIndex, trs, width);

            bool opaqueBackground = background.brushType == eBrushType.Opaque;

            passFlags |= eRenderPassFlags.Transparent;

            calls.add(sDrawCall.drawText(o, ref tform, foreground.paletteIndex,
                                         background.paletteIndex, opaqueBackground,
                                         pixel, trs));
        }