From 74ab36c125cba7810a599477e25f72362a20db29 Mon Sep 17 00:00:00 2001 From: Artur Wieczorek Date: Wed, 22 Feb 2017 21:18:45 +0100 Subject: [PATCH] Simplify PostScript code generated by wxPostScriptDC to draw elliptic arc Optimize procedure 'ellipticarc' by doing all operations on the operand stack instead of creating local dictionary and temporary variables. --- docs/changes.txt | 1 + src/generic/dcpsg.cpp | 37 ++++++++++++++++--------------------- 2 files changed, 17 insertions(+), 21 deletions(-) diff --git a/docs/changes.txt b/docs/changes.txt index 74dfa7d4b2..7ee9000229 100644 --- a/docs/changes.txt +++ b/docs/changes.txt @@ -128,6 +128,7 @@ All (GUI): - Deprecate wxEVT_STC_KEY and wxEVT_STC_URIDROPPED events (NewPagodi). - Optimize font registration in PostScript code emitted by wxPostScriptDC. - Fix drawing filled arc with wxPostScriptDC::DrawArc(). +- Optimize PostScript code emitted by wxPostScriptDC to draw elliptic arcs. wxGTK: diff --git a/src/generic/dcpsg.cpp b/src/generic/dcpsg.cpp index 3249cca99f..c0e1536c1d 100644 --- a/src/generic/dcpsg.cpp +++ b/src/generic/dcpsg.cpp @@ -88,27 +88,22 @@ static const char *wxPostScriptHeaderEllipse = " setmatrix\n" // -> restore transformation matrix "} def\n"; -static const char *wxPostScriptHeaderEllipticArc= "\ -/ellipticarcdict 8 dict def\n\ -ellipticarcdict /mtrx matrix put\n\ -/ellipticarc\n\ -{ ellipticarcdict begin\n\ - /do_fill exch def\n\ - /endangle exch def\n\ - /startangle exch def\n\ - /yrad exch def\n\ - /xrad exch def \n\ - /y exch def\n\ - /x exch def\n\ - /savematrix mtrx currentmatrix def\n\ - x y translate\n\ - xrad yrad scale\n\ - do_fill { 0 0 moveto } if\n\ - 0 0 1 startangle endangle arc\n\ - savematrix setmatrix\n\ - do_fill { fill }{ stroke } ifelse\n\ - end\n\ -} def\n"; +static const char *wxPostScriptHeaderEllipticArc= +"/ellipticarc {\n" // x y xrad yrad startangle endangle do_fill +" dup\n" // x y xrad yrad startangle endangle do_fill do_fill +" 8 1 roll\n" // do_fill x y xrad yrad startangle endangle do_fill +" matrix currentmatrix\n" // do_fill x y xrad yrad startangle endangle do_fill CTM +" 0 0 1\n" // do_fill x y xrad yrad startangle endangle do_fill CTM 0 0 1 +" 11 4 roll\n" // do_fill CTM 0 0 1 x y xrad yrad startangle endangle do_fill +" 7 3 roll\n" // do_fill CTM 0 0 1 startangle endangle do_fill x y xrad yrad +" 4 2 roll\n" // do_fill CTM 0 0 1 startangle endangle do_fill xrad yrad x y +" translate\n" // do_fill CTM 0 0 1 startangle endangle do_fill xrad yrad +" scale\n" // do_fill CTM 0 0 1 startangle endangle do_fill +" { 0 0 moveto } if\n" // do_fill CTM 0 0 1 startangle endangle +" arc\n" // do_fill CTM -> draw arc +" setmatrix\n" // do_fill -> restore transformation matrix +" { fill }{ stroke } ifelse\n" // -> fill or stroke +"} def\n"; static const char *wxPostScriptHeaderSpline = "\ /DrawSplineSection {\n\