Commit 27e9eedd authored by Marco Serantoni's avatar Marco Serantoni

speedup enhancement and little cleanup

parent 6dfcf0b6
...@@ -69,10 +69,13 @@ static int xcliplo = 0, ...@@ -69,10 +69,13 @@ static int xcliplo = 0,
ycliplo = 0, ycliplo = 0,
xcliphi = 2000, xcliphi = 2000,
ycliphi = 2000; ycliphi = 2000;
static int lastcolor = -1;
static int lastwidth = -1; static int s_DC_lastcolor = -1;
static int s_Last_Pen_Style = -1; static int s_DC_lastwidth = -1;
static wxDC* lastDC = NULL; static int s_DC_lastpenstyle = -1;
static int s_DC_lastbrushcolor = -1;
static int s_DC_lastbrushfill = -1;
static wxDC* s_DC_lastDC = NULL;
/* Local functions: */ /* Local functions: */
...@@ -520,9 +523,10 @@ static void WinClipAndDrawLine( EDA_Rect* ClipBox, wxDC* DC, ...@@ -520,9 +523,10 @@ static void WinClipAndDrawLine( EDA_Rect* ClipBox, wxDC* DC,
*/ */
void GRResetPenAndBrush( wxDC* DC ) void GRResetPenAndBrush( wxDC* DC )
{ {
lastcolor = -1;
GRSetBrush( DC, BLACK ); // Force no fill GRSetBrush( DC, BLACK ); // Force no fill
lastDC = NULL; s_DC_lastbrushcolor = -1;
s_DC_lastcolor = -1;
s_DC_lastDC = NULL;
} }
...@@ -540,10 +544,10 @@ void GRSetColorPen( wxDC* DC, int Color, int width, int style ) ...@@ -540,10 +544,10 @@ void GRSetColorPen( wxDC* DC, int Color, int width, int style )
Color = BLACK; Color = BLACK;
} }
if( lastcolor != Color if( s_DC_lastcolor != Color ||
|| lastwidth != width s_DC_lastwidth != width ||
|| s_Last_Pen_Style != style s_DC_lastpenstyle != style ||
|| lastDC != DC ) s_DC_lastDC != DC )
{ {
wxPen pen; wxPen pen;
...@@ -555,11 +559,11 @@ void GRSetColorPen( wxDC* DC, int Color, int width, int style ) ...@@ -555,11 +559,11 @@ void GRSetColorPen( wxDC* DC, int Color, int width, int style )
DC->SetPen( pen ); DC->SetPen( pen );
lastcolor = Color; s_DC_lastcolor = Color;
lastwidth = width; s_DC_lastwidth = width;
lastDC = DC; s_DC_lastpenstyle = style;
s_DC_lastDC = DC;
s_Last_Pen_Style = style;
} }
} }
...@@ -568,17 +572,29 @@ void GRSetBrush( wxDC* DC, int Color, int fill ) ...@@ -568,17 +572,29 @@ void GRSetBrush( wxDC* DC, int Color, int fill )
{ {
if( ForceBlackPen ) if( ForceBlackPen )
Color = BLACK; Color = BLACK;
wxBrush DrawBrush;
DrawBrush.SetColour( MakeColour( Color ) );
if( fill ) if( s_DC_lastbrushcolor != Color ||
DrawBrush.SetStyle( wxSOLID ); s_DC_lastbrushfill != fill ||
else s_DC_lastDC != DC )
DrawBrush.SetStyle( wxTRANSPARENT ); {
DC->SetBrush( DrawBrush ); wxBrush DrawBrush;
DrawBrush.SetColour( MakeColour( Color ) );
if( fill )
DrawBrush.SetStyle( wxSOLID );
else
DrawBrush.SetStyle( wxTRANSPARENT );
DC->SetBrush( DrawBrush );
s_DC_lastbrushcolor = Color;
s_DC_lastbrushfill = fill;
s_DC_lastDC = DC;
}
} }
/** function GRForceBlackPen /** function GRForceBlackPen
* @param flagforce True to force a black pen whenever the asked color * @param flagforce True to force a black pen whenever the asked color
*/ */
...@@ -689,10 +705,10 @@ void GRSDashedLine( EDA_Rect* ClipBox, ...@@ -689,10 +705,10 @@ void GRSDashedLine( EDA_Rect* ClipBox,
{ {
GRLastMoveToX = x2; GRLastMoveToX = x2;
GRLastMoveToY = y2; GRLastMoveToY = y2;
lastcolor = -1; s_DC_lastcolor = -1;
GRSetColorPen( DC, Color, width, wxSHORT_DASH ); GRSetColorPen( DC, Color, width, wxSHORT_DASH );
GRSLine( ClipBox, DC, x1, y1, x2, y2, width, Color ); GRSLine( ClipBox, DC, x1, y1, x2, y2, width, Color );
lastcolor = -1; s_DC_lastcolor = -1;
GRSetColorPen( DC, Color, width ); GRSetColorPen( DC, Color, width );
} }
...@@ -704,10 +720,10 @@ void GRSDashedLineTo( EDA_Rect* ClipBox, ...@@ -704,10 +720,10 @@ void GRSDashedLineTo( EDA_Rect* ClipBox,
int width, int width,
int Color ) int Color )
{ {
lastcolor = -1; s_DC_lastcolor = -1;
GRSetColorPen( DC, Color, width, wxSHORT_DASH ); GRSetColorPen( DC, Color, width, wxSHORT_DASH );
GRSLine( ClipBox, DC, GRLastMoveToX, GRLastMoveToY, x2, y2, width, Color ); GRSLine( ClipBox, DC, GRLastMoveToX, GRLastMoveToY, x2, y2, width, Color );
lastcolor = -1; s_DC_lastcolor = -1;
GRSetColorPen( DC, Color, width ); GRSetColorPen( DC, Color, width );
GRLastMoveToX = x2; GRLastMoveToX = x2;
GRLastMoveToY = y2; GRLastMoveToY = y2;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment