[Git][wxwidgets/wxwidgets][master] 5 commits: Cache wxUxThemeIsActive() result

0 views
Skip to first unread message

Vadim Zeitlin (@_VZ_)

unread,
Aug 30, 2025, 1:38:50 PM (8 days ago) Aug 30
to wx-commi...@googlegroups.com


Vadim Zeitlin pushed to branch master at wxWidgets / wxWidgets


Commits:
7de98bd7 by Vadim Zeitlin at 2025-08-30T16:36:20+02:00
Cache wxUxThemeIsActive() result

Win32 IsAppThemed() and IsThemeActive() functions are surprisingly
rather expensive and calling them from every wxEVT_PAINT handler, when
using wxRendererNative::Get(), can noticeably hurt performance, so cache
their return result and don't call them again, as the app can't become
(not) themed during its execution if it started in the other state
(although its theme can change).

- - - - -
ab26fc41 by Vadim Zeitlin at 2025-08-30T16:36:20+02:00
Cache wxUILocale::GetLayoutDirection() result in wxMSW

Retrieving it every time is relatively slow.

- - - - -
0c10521d by Vadim Zeitlin at 2025-08-30T17:15:33+02:00
Initialize wxDCImpl members in their declarations

Make it more obvious that all members are initialized correctly.

This requires not using bit fields for boolean members any longer, as
they can only be initialized in their declarations with C++20, but it
doesn't seem like we really need to use bit fields here anyhow, wxDC
objects are not optimized for space anyhow and the program is never
going to have that many of them.

Also inline ctor and dtor for a tiny performance gain.

- - - - -
e99449ad by Vadim Zeitlin at 2025-08-30T17:16:52+02:00
Allow disabling automatic bounding box updates

Doing it when the bounding box is not used anyhow is useless and wastes
time unnecessary, notably wxDC::DrawText() can skip calculating the text
width, which is relatively expensive, if the bounding box is not needed.

- - - - -
510c5d1e by Vadim Zeitlin at 2025-08-30T19:26:50+02:00
Merge branch 'misc-drawing-opt'

Some easy (even if small) performance gains that can/will be reused to
optimize wxSTC painting.

See #25745.

- - - - -


14 changed files:

- include/wx/dc.h
- interface/wx/dc.h
- src/common/dcbase.cpp
- src/common/dcgraph.cpp
- src/common/dcsvg.cpp
- src/dfb/dc.cpp
- src/generic/dcpsg.cpp
- src/gtk/dc.cpp
- src/gtk/dcclient.cpp
- src/gtk/print.cpp
- src/msw/dc.cpp
- src/msw/uilocale.cpp
- src/msw/uxtheme.cpp
- src/x11/dcclient.cpp


Changes:

=====================================
include/wx/dc.h
=====================================
@@ -169,8 +169,10 @@ public:
class WXDLLIMPEXP_CORE wxDCImpl: public wxObject
{
public:
- wxDCImpl( wxDC *owner );
- virtual ~wxDCImpl();
+ wxDCImpl( wxDC *owner ) : m_owner(owner)
+ {
+ }
+ virtual ~wxDCImpl() = default;

wxDC *GetOwner() const { return m_owner; }
void SetOwner(wxDC* owner) { m_owner = owner; }
@@ -238,6 +240,17 @@ public:

// bounding box

+ void DisableAutomaticBoundingBoxUpdates()
+ {
+ m_isBBoxValid = false;
+ m_updateBBox = false;
+ }
+
+ bool AreAutomaticBoundingBoxUpdatesEnabled() const
+ {
+ return m_updateBBox;
+ }
+
virtual void CalcBoundingBox(wxCoord x, wxCoord y)
{
// Bounding box is internally stored in device units.
@@ -634,67 +647,96 @@ protected:


// window on which the DC draws or nullptr
- wxWindow *m_window;
+ wxWindow *m_window = nullptr;

// flags
- bool m_colour:1;
- bool m_ok:1;
- bool m_clipping:1;
- bool m_isInteractive:1;
- bool m_isBBoxValid:1;
+ bool m_colour = true;
+ bool m_ok = true;
+ bool m_clipping = false;
+ bool m_isInteractive = false;
+ bool m_isBBoxValid = false;

// coordinate system variables

- wxCoord m_logicalOriginX, m_logicalOriginY;
- wxCoord m_deviceOriginX, m_deviceOriginY; // Usually 0,0, can be change by user
+ wxCoord m_logicalOriginX = 0,
+ m_logicalOriginY = 0;
+ wxCoord m_deviceOriginX = 0,
+ m_deviceOriginY = 0;
+
+ // Non-zero for Postscript where the native origin in the bottom left
+ // corner.
+ wxCoord m_deviceLocalOriginX = 0,
+ m_deviceLocalOriginY = 0;

- wxCoord m_deviceLocalOriginX, m_deviceLocalOriginY; // non-zero if native top-left corner
- // is not at 0,0. This was the case under
- // Mac's GrafPorts (coordinate system
- // used toplevel window's origin) and
- // e.g. for Postscript, where the native
- // origin in the bottom left corner.
- double m_logicalScaleX, m_logicalScaleY;
- double m_userScaleX, m_userScaleY;
- double m_scaleX, m_scaleY; // calculated from logical scale and user scale
+ double m_logicalScaleX = 1.0,
+ m_logicalScaleY = 1.0;
+ double m_userScaleX = 1.0,
+ m_userScaleY = 1.0;

- int m_signX, m_signY; // Used by SetAxisOrientation() to invert the axes
+ // Calculated from logical scale and user scale.
+ double m_scaleX = 1.0,
+ m_scaleY = 1.0;

- double m_contentScaleFactor; // used by high resolution displays (retina)
+ // Used by SetAxisOrientation() to invert the axes.
+ int m_signX = 1,
+ m_signY = 1;
+
+ // > 1 on high resolution displays.
+ double m_contentScaleFactor = 1.0;

// Pixel per mm in horizontal and vertical directions.
//
// These variables are computed on demand by GetMMToPX[xy]() functions,
// don't access them directly other than for assigning to them.
- mutable double m_mm_to_pix_x,
- m_mm_to_pix_y;
+ mutable double m_mm_to_pix_x = 0.0,
+ m_mm_to_pix_y = 0.0;

// bounding and clipping boxes
- wxCoord m_minX, m_minY, m_maxX, m_maxY; // Bounding box is stored in device units.
- wxCoord m_clipX1, m_clipY1, m_clipX2, m_clipY2; // Some derived classes operate directly on clipping box given in logical units.

- wxRasterOperationMode m_logicalFunction;
- int m_backgroundMode;
- wxMappingMode m_mappingMode;
+ // Bounding box is stored in device units.
+ wxCoord m_minX = 0,
+ m_minY = 0,
+ m_maxX = 0,
+ m_maxY = 0;
+
+ // Some derived classes use clipping box given in logical units directly.
+ wxCoord m_clipX1 = 0,
+ m_clipY1 = 0,
+ m_clipX2 = 0,
+ m_clipY2 = 0;
+
+ wxRasterOperationMode m_logicalFunction = wxCOPY;
+ int m_backgroundMode = wxBRUSHSTYLE_TRANSPARENT;
+ wxMappingMode m_mappingMode = wxMM_TEXT;

wxPen m_pen;
wxBrush m_brush;
wxBrush m_backgroundBrush;
- wxColour m_textForegroundColour;
- wxColour m_textBackgroundColour;
+ wxColour m_textForegroundColour = *wxBLACK;
+ wxColour m_textBackgroundColour = *wxWHITE;
wxFont m_font;

#if wxUSE_PALETTE
wxPalette m_palette;
- bool m_hasCustomPalette;
+ bool m_hasCustomPalette = false;
#endif // wxUSE_PALETTE

private:
// Return the full DC area in logical coordinates.
wxRect GetLogicalArea() const;

- wxCoord m_devClipX1, m_devClipY1, m_devClipX2, m_devClipY2; // For proper calculations of clipping box we need to store it in device units.
- bool m_useDevClipCoords;
+ // For proper calculations of clipping box we need to store it in device units.
+ wxCoord m_devClipX1 = 0,
+ m_devClipY1 = 0,
+ m_devClipX2 = 0,
+ m_devClipY2 = 0;
+
+ bool m_useDevClipCoords = false;
+
+ // If true (the default), the bounding box is updated automatically by
+ // all drawing operations, otherwise it is not to save some time if it's
+ // not needed anyhow.
+ bool m_updateBBox = true;

wxDECLARE_ABSTRACT_CLASS(wxDCImpl);
};
@@ -986,6 +1028,11 @@ public:

// bounding box

+ void DisableAutomaticBoundingBoxUpdates()
+ { m_pimpl->DisableAutomaticBoundingBoxUpdates(); }
+ bool AreAutomaticBoundingBoxUpdatesEnabled() const
+ { return m_pimpl->AreAutomaticBoundingBoxUpdatesEnabled(); }
+
void CalcBoundingBox(wxCoord x, wxCoord y)
{ m_pimpl->CalcBoundingBox(x,y); }
void ResetBoundingBox()


=====================================
interface/wx/dc.h
=====================================
@@ -1567,9 +1567,44 @@ public:

/**
@name Bounding box functions
+
+ By default, wxDC maintains the coordinates of the bounding box
+ containing all the drawing operations performed on it. This can be
+ useful to determine the area of the DC that was modified, for example
+ to optimize the redrawing of a window.
+
+ If the application code doesn't need this information, it can save some
+ time by calling DisableAutomaticBoundingBoxUpdates() to disable the
+ default behaviour. Note that even in this case, the bounding box can
+ still be updated by calling CalcBoundingBox() manually, but it won't be
+ done automatically by the drawing functions.
*/
///@{

+ /**
+ Disable automatic bounding box updates.
+
+ Such updates are enabled by default but can be disabled to make the
+ drawing functions slightly faster.
+
+ @see AreAutomaticBoundingBoxUpdatesEnabled()
+
+ @since 3.3.2
+ */
+ void DisableAutomaticBoundingBoxUpdates();
+
+ /**
+ Check if automatic bounding box updates are performed.
+
+ Returns @true if the automatic bounding box updates are enabled (this
+ is the default) or @false if they are disabled.
+
+ @see DisableAutomaticBoundingBoxUpdates()
+
+ @since 3.3.2
+ */
+ bool AreAutomaticBoundingBoxUpdatesEnabled() const;
+
/**
Adds the specified point to the bounding box which can be retrieved
with MinX(), MaxX() and MinY(), MaxY() functions.


=====================================
src/common/dcbase.cpp
=====================================
@@ -319,47 +319,6 @@ int wxPrinterDC::GetResolution() const

wxIMPLEMENT_ABSTRACT_CLASS(wxDCImpl, wxObject);

-wxDCImpl::wxDCImpl( wxDC *owner )
- : m_window(nullptr)
- , m_colour(true)
- , m_ok(true)
- , m_clipping(false)
- , m_isInteractive(0)
- , m_isBBoxValid(false)
- , m_logicalOriginX(0), m_logicalOriginY(0)
- , m_deviceOriginX(0), m_deviceOriginY(0)
- , m_deviceLocalOriginX(0), m_deviceLocalOriginY(0)
- , m_logicalScaleX(1.0), m_logicalScaleY(1.0)
- , m_userScaleX(1.0), m_userScaleY(1.0)
- , m_scaleX(1.0), m_scaleY(1.0)
- , m_signX(1), m_signY(1)
- , m_contentScaleFactor(1)
- , m_mm_to_pix_x(0.0), m_mm_to_pix_y(0.0)
- , m_minX(0), m_minY(0), m_maxX(0), m_maxY(0)
- , m_clipX1(0), m_clipY1(0), m_clipX2(0), m_clipY2(0)
- , m_logicalFunction(wxCOPY)
- , m_backgroundMode(wxBRUSHSTYLE_TRANSPARENT)
- , m_mappingMode(wxMM_TEXT)
- , m_pen()
- , m_brush()
- , m_backgroundBrush()
- , m_textForegroundColour(*wxBLACK)
- , m_textBackgroundColour(*wxWHITE)
- , m_font()
-#if wxUSE_PALETTE
- , m_palette()
- , m_hasCustomPalette(false)
-#endif // wxUSE_PALETTE
- , m_devClipX1(0), m_devClipY1(0), m_devClipX2(0), m_devClipY2(0)
- , m_useDevClipCoords(false)
-{
- m_owner = owner;
-}
-
-wxDCImpl::~wxDCImpl()
-{
-}
-
// ----------------------------------------------------------------------------
// clipping
// ----------------------------------------------------------------------------
@@ -664,7 +623,8 @@ void wxDCImpl::DoDrawCheckMark(wxCoord x1, wxCoord y1,
DoDrawLine(x1, y3, x3, y2);
DoDrawLine(x3, y2, x2, y1);

- CalcBoundingBox(x1, y1, x2, y2);
+ if ( AreAutomaticBoundingBoxUpdatesEnabled() )
+ CalcBoundingBox(x1, y1, x2, y2);
}

bool
@@ -1322,7 +1282,8 @@ void wxDC::DrawLabel(const wxString& text,
*rectBounding = wxRect(x, y - heightText, widthText, heightText);
}

- m_pimpl->CalcBoundingBox(wxPoint(x0, y0), wxSize(width0, height));
+ if ( AreAutomaticBoundingBoxUpdatesEnabled() )
+ m_pimpl->CalcBoundingBox(wxPoint(x0, y0), wxSize(width0, height));
}

/*


=====================================
src/common/dcgraph.cpp
=====================================
@@ -281,7 +281,8 @@ void wxGCDCImpl::DoDrawBitmap( const wxBitmap &bmp, wxCoord x, wxCoord y,
m_graphicContext->DrawBitmap( bmpCopy, x, y, w, h );
}

- CalcBoundingBox(wxPoint(x, y), bmp.GetLogicalSize());
+ if ( AreAutomaticBoundingBoxUpdatesEnabled() )
+ CalcBoundingBox(wxPoint(x, y), bmp.GetLogicalSize());
}

void wxGCDCImpl::DoDrawIcon( const wxIcon &icon, wxCoord x, wxCoord y )
@@ -294,7 +295,8 @@ void wxGCDCImpl::DoDrawIcon( const wxIcon &icon, wxCoord x, wxCoord y )

m_graphicContext->DrawIcon( icon , x, y, w, h );

- CalcBoundingBox(wxPoint(x, y), wxSize(w, h));
+ if ( AreAutomaticBoundingBoxUpdatesEnabled() )
+ CalcBoundingBox(wxPoint(x, y), wxSize(w, h));
}

bool wxGCDCImpl::StartDoc( const wxString& message )
@@ -671,7 +673,8 @@ void wxGCDCImpl::DoDrawLine( wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2 )

m_graphicContext->StrokeLine(x1,y1,x2,y2);

- CalcBoundingBox(x1, y1, x2, y2);
+ if ( AreAutomaticBoundingBoxUpdatesEnabled() )
+ CalcBoundingBox(x1, y1, x2, y2);
}

void wxGCDCImpl::DoCrossHair( wxCoord x, wxCoord y )
@@ -688,7 +691,8 @@ void wxGCDCImpl::DoCrossHair( wxCoord x, wxCoord y )
m_graphicContext->StrokeLine(0,y,w,y);
m_graphicContext->StrokeLine(x,0,x,h);

- CalcBoundingBox(0, 0, w, h);
+ if ( AreAutomaticBoundingBoxUpdatesEnabled() )
+ CalcBoundingBox(0, 0, w, h);
}

void wxGCDCImpl::DoDrawArc( wxCoord x1, wxCoord y1,
@@ -736,7 +740,8 @@ void wxGCDCImpl::DoDrawArc( wxCoord x1, wxCoord y1,
path.AddLineToPoint( xc, yc );
m_graphicContext->DrawPath(path);

- CalcBoundingBoxForBox(path.GetBox());
+ if ( AreAutomaticBoundingBoxUpdatesEnabled() )
+ CalcBoundingBoxForBox(path.GetBox());
}

void wxGCDCImpl::DoDrawEllipticArc( wxCoord x, wxCoord y, wxCoord w, wxCoord h,
@@ -786,7 +791,8 @@ void wxGCDCImpl::DoDrawEllipticArc( wxCoord x, wxCoord y, wxCoord w, wxCoord h,
box.m_x += dx;
box.m_y += dy;

- CalcBoundingBoxForBox(box);
+ if ( AreAutomaticBoundingBoxUpdatesEnabled() )
+ CalcBoundingBoxForBox(box);

m_graphicContext->PopState();
}
@@ -804,7 +810,8 @@ void wxGCDCImpl::DoDrawPoint( wxCoord x, wxCoord y )
// Raster-based DCs draw a single pixel regardless of scale
m_graphicContext->DrawRectangle(x, y, 1 / m_scaleX, 1 / m_scaleY);

- CalcBoundingBox(x, y);
+ if ( AreAutomaticBoundingBoxUpdatesEnabled() )
+ CalcBoundingBox(x, y);
}

void wxGCDCImpl::DoDrawLines(int n, const wxPoint points[],
@@ -836,8 +843,11 @@ void wxGCDCImpl::DoDrawLines(int n, const wxPoint points[],

m_graphicContext->StrokeLines( n , pointsD.get());

- CalcBoundingBox(minX + xoffset, minY + yoffset,
- maxX + xoffset, maxY + yoffset);
+ if ( AreAutomaticBoundingBoxUpdatesEnabled() )
+ {
+ CalcBoundingBox(minX + xoffset, minY + yoffset,
+ maxX + xoffset, maxY + yoffset);
+ }
}

#if wxUSE_SPLINES
@@ -876,7 +886,8 @@ void wxGCDCImpl::DoDrawSpline(const wxPointList *points)

m_graphicContext->StrokePath( path );

- CalcBoundingBoxForBox(path.GetBox());
+ if ( AreAutomaticBoundingBoxUpdatesEnabled() )
+ CalcBoundingBoxForBox(path.GetBox());
}
#endif // wxUSE_SPLINES

@@ -919,8 +930,11 @@ void wxGCDCImpl::DoDrawPolygon( int n, const wxPoint points[],

m_graphicContext->DrawLines( n+(closeIt?1:0) , pointsD.get(), fillStyle);

- CalcBoundingBox(minX + xoffset, minY + yoffset,
- maxX + xoffset, maxY + yoffset);
+ if ( AreAutomaticBoundingBoxUpdatesEnabled() )
+ {
+ CalcBoundingBox(minX + xoffset, minY + yoffset,
+ maxX + xoffset, maxY + yoffset);
+ }
}

void wxGCDCImpl::DoDrawPolyPolygon(int n,
@@ -951,7 +965,8 @@ void wxGCDCImpl::DoDrawPolyPolygon(int n,
}
m_graphicContext->DrawPath( path , fillStyle);

- CalcBoundingBoxForBox(path.GetBox());
+ if ( AreAutomaticBoundingBoxUpdatesEnabled() )
+ CalcBoundingBoxForBox(path.GetBox());
}

void wxGCDCImpl::DoDrawRectangle(wxCoord x, wxCoord y, wxCoord w, wxCoord h)
@@ -965,7 +980,8 @@ void wxGCDCImpl::DoDrawRectangle(wxCoord x, wxCoord y, wxCoord w, wxCoord h)
if (w == 0 || h == 0)
return;

- CalcBoundingBox(wxPoint(x, y), wxSize(w, h));
+ if ( AreAutomaticBoundingBoxUpdatesEnabled() )
+ CalcBoundingBox(wxPoint(x, y), wxSize(w, h));

if (m_pen.IsNonTransparent())
{
@@ -993,7 +1009,8 @@ void wxGCDCImpl::DoDrawRoundedRectangle(wxCoord x, wxCoord y,
if (w == 0 || h == 0)
return;

- CalcBoundingBox(wxPoint(x, y), wxSize(w, h));
+ if ( AreAutomaticBoundingBoxUpdatesEnabled() )
+ CalcBoundingBox(wxPoint(x, y), wxSize(w, h));

if (m_pen.IsNonTransparent())
{
@@ -1012,7 +1029,8 @@ void wxGCDCImpl::DoDrawEllipse(wxCoord x, wxCoord y, wxCoord w, wxCoord h)
if ( !m_logicalFunctionSupported )
return;

- CalcBoundingBox(wxPoint(x, y), wxSize(w, h));
+ if ( AreAutomaticBoundingBoxUpdatesEnabled() )
+ CalcBoundingBox(wxPoint(x, y), wxSize(w, h));

m_graphicContext->DrawEllipse(x,y,w,h);
}
@@ -1118,7 +1136,8 @@ bool wxGCDCImpl::DoStretchBlit(
// reset composition
m_graphicContext->SetCompositionMode(formerMode);

- CalcBoundingBox(wxPoint(xdest, ydest), wxSize(dstWidth, dstHeight));
+ if ( AreAutomaticBoundingBoxUpdatesEnabled() )
+ CalcBoundingBox(wxPoint(xdest, ydest), wxSize(dstWidth, dstHeight));

return retval;
}
@@ -1171,12 +1190,15 @@ void wxGCDCImpl::DoDrawRotatedText(const wxString& text, wxCoord x, wxCoord y,
// determining which of them is really topmost/leftmost/...)

// "upper left" and "upper right"
- CalcBoundingBox(x, y, x + wxCoord(w*cos(rad)), y - wxCoord(w*sin(rad)));
+ if ( AreAutomaticBoundingBoxUpdatesEnabled() )
+ {
+ CalcBoundingBox(x, y, x + wxCoord(w*cos(rad)), y - wxCoord(w*sin(rad)));

- // "bottom left" and "bottom right"
- x += (wxCoord)(h*sin(rad));
- y += (wxCoord)(h*cos(rad));
- CalcBoundingBox(x, y, x + wxCoord(w*cos(rad)), y - wxCoord(w*sin(rad)));
+ // "bottom left" and "bottom right"
+ x += (wxCoord)(h*sin(rad));
+ y += (wxCoord)(h*cos(rad));
+ CalcBoundingBox(x, y, x + wxCoord(w*cos(rad)), y - wxCoord(w*sin(rad)));
+ }
}

void wxGCDCImpl::DoDrawText(const wxString& str, wxCoord x, wxCoord y)
@@ -1212,7 +1234,8 @@ void wxGCDCImpl::DoDrawText(const wxString& str, wxCoord x, wxCoord y)

m_graphicContext->SetCompositionMode(curMode);

- CalcBoundingBox(wxPoint(x, y), GetOwner()->GetTextExtent(str));
+ if ( AreAutomaticBoundingBoxUpdatesEnabled() )
+ CalcBoundingBox(wxPoint(x, y), GetOwner()->GetTextExtent(str));
}

bool wxGCDCImpl::CanGetTextExtent() const
@@ -1374,7 +1397,8 @@ void wxGCDCImpl::DoGradientFillLinear(const wxRect& rect,
m_graphicContext->SetPen(m_pen);
m_graphicContext->SetBrush(m_brush);

- CalcBoundingBox(rect);
+ if ( AreAutomaticBoundingBoxUpdatesEnabled() )
+ CalcBoundingBox(rect);
}

void wxGCDCImpl::DoGradientFillConcentric(const wxRect& rect,
@@ -1405,7 +1429,8 @@ void wxGCDCImpl::DoGradientFillConcentric(const wxRect& rect,
m_graphicContext->SetPen(m_pen);
m_graphicContext->SetBrush(m_brush);

- CalcBoundingBox(rect);
+ if ( AreAutomaticBoundingBoxUpdatesEnabled() )
+ CalcBoundingBox(rect);
}

void wxGCDCImpl::DoDrawCheckMark(wxCoord x, wxCoord y,


=====================================
src/common/dcsvg.cpp
=====================================
@@ -633,7 +633,8 @@ void wxSVGFileDCImpl::DoDrawLine(wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2)

write(s);

- CalcBoundingBox(x1, y1, x2, y2);
+ if ( AreAutomaticBoundingBoxUpdatesEnabled() )
+ CalcBoundingBox(x1, y1, x2, y2);
}

void wxSVGFileDCImpl::DoDrawLines(int n, const wxPoint points[], wxCoord xoffset, wxCoord yoffset)
@@ -646,12 +647,14 @@ void wxSVGFileDCImpl::DoDrawLines(int n, const wxPoint points[], wxCoord xoffset
s = wxString::Format(wxS(" <path d=\"M%d %d"),
(points[0].x + xoffset), (points[0].y + yoffset));

- CalcBoundingBox(points[0].x + xoffset, points[0].y + yoffset);
+ if ( AreAutomaticBoundingBoxUpdatesEnabled() )
+ CalcBoundingBox(points[0].x + xoffset, points[0].y + yoffset);

for (int i = 1; i < n; ++i)
{
s += wxString::Format(wxS(" L%d %d"), (points[i].x + xoffset), (points[i].y + yoffset));
- CalcBoundingBox(points[i].x + xoffset, points[i].y + yoffset);
+ if ( AreAutomaticBoundingBoxUpdatesEnabled() )
+ CalcBoundingBox(points[i].x + xoffset, points[i].y + yoffset);
}

s += wxString::Format(wxS("\" style=\"fill:none\" %s %s/>\n"),
@@ -681,8 +684,11 @@ void wxSVGFileDCImpl::DoDrawSpline(const wxPointList* points)

s += wxString::Format("M %s %s L %s %s",
NumStr(p1.m_x), NumStr(p1.m_y), NumStr(p3.m_x), NumStr(p3.m_y));
- CalcBoundingBox(wxRound(p1.m_x), wxRound(p1.m_y));
- CalcBoundingBox(wxRound(p3.m_x), wxRound(p3.m_y));
+ if ( AreAutomaticBoundingBoxUpdatesEnabled() )
+ {
+ CalcBoundingBox(wxRound(p1.m_x), wxRound(p1.m_y));
+ CalcBoundingBox(wxRound(p3.m_x), wxRound(p3.m_y));
+ }

while ( itPt != points->end() )
{
@@ -700,11 +706,15 @@ void wxSVGFileDCImpl::DoDrawSpline(const wxPointList* points)
s += wxString::Format(" C %s %s, %s %s, %s %s",
NumStr(c1.m_x), NumStr(c1.m_y), NumStr(c2.m_x), NumStr(c2.m_y), NumStr(p3.m_x), NumStr(p3.m_y));

- CalcBoundingBox(wxRound(p0.m_x), wxRound(p0.m_y));
- CalcBoundingBox(wxRound(p3.m_x), wxRound(p3.m_y));
+ if ( AreAutomaticBoundingBoxUpdatesEnabled() )
+ {
+ CalcBoundingBox(wxRound(p0.m_x), wxRound(p0.m_y));
+ CalcBoundingBox(wxRound(p3.m_x), wxRound(p3.m_y));
+ }
}
s += wxString::Format(" L %s %s", NumStr(p2.m_x), NumStr(p2.m_y));
- CalcBoundingBox(wxRound(p2.m_x), wxRound(p2.m_y));
+ if ( AreAutomaticBoundingBoxUpdatesEnabled() )
+ CalcBoundingBox(wxRound(p2.m_x), wxRound(p2.m_y));

s += wxString::Format("\" style=\"fill:none\" %s %s/>\n",
GetRenderMode(m_renderingMode), GetPenPattern(m_pen));
@@ -748,10 +758,13 @@ void wxSVGFileDCImpl::DoDrawRotatedText(const wxString& sText, wxCoord x, wxCoor
const double dy = heightLine * cos(rad);

// Update bounding box: upper left, upper right, bottom left, bottom right
- CalcBoundingBox(x, y);
- CalcBoundingBox((wxCoord)(x + w * cos(rad)), (wxCoord)(y - h * sin(rad)));
- CalcBoundingBox((wxCoord)(x + h * sin(rad)), (wxCoord)(y + h * cos(rad)));
- CalcBoundingBox((wxCoord)(x + h * sin(rad) + w * cos(rad)), (wxCoord)(y + h * cos(rad) - w * sin(rad)));
+ if ( AreAutomaticBoundingBoxUpdatesEnabled() )
+ {
+ CalcBoundingBox(x, y);
+ CalcBoundingBox((wxCoord)(x + w * cos(rad)), (wxCoord)(y - h * sin(rad)));
+ CalcBoundingBox((wxCoord)(x + h * sin(rad)), (wxCoord)(y + h * cos(rad)));
+ CalcBoundingBox((wxCoord)(x + h * sin(rad) + w * cos(rad)), (wxCoord)(y + h * cos(rad) - w * sin(rad)));
+ }

// Create text style string
wxString fontstyle;
@@ -863,7 +876,8 @@ void wxSVGFileDCImpl::DoDrawRoundedRectangle(wxCoord x, wxCoord y, wxCoord width

write(s);

- CalcBoundingBox(wxPoint(x, y), wxSize(width, height));
+ if ( AreAutomaticBoundingBoxUpdatesEnabled() )
+ CalcBoundingBox(wxPoint(x, y), wxSize(width, height));
}

void wxSVGFileDCImpl::DoDrawPolygon(int n, const wxPoint points[],
@@ -879,7 +893,8 @@ void wxSVGFileDCImpl::DoDrawPolygon(int n, const wxPoint points[],
for (int i = 0; i < n; i++)
{
s += wxString::Format(wxS("%d %d "), points[i].x + xoffset, points[i].y + yoffset);
- CalcBoundingBox(points[i].x + xoffset, points[i].y + yoffset);
+ if ( AreAutomaticBoundingBoxUpdatesEnabled() )
+ CalcBoundingBox(points[i].x + xoffset, points[i].y + yoffset);
}

s += wxString::Format(wxS("\" %s %s %s style=\"fill-rule:%s;\"/>\n"),
@@ -946,7 +961,8 @@ void wxSVGFileDCImpl::DoDrawEllipse(wxCoord x, wxCoord y, wxCoord width, wxCoord

write(s);

- CalcBoundingBox(wxPoint(x, y), wxSize(width, height));
+ if ( AreAutomaticBoundingBoxUpdatesEnabled() )
+ CalcBoundingBox(wxPoint(x, y), wxSize(width, height));
}

void wxSVGFileDCImpl::DoDrawArc(wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2, wxCoord xc, wxCoord yc)
@@ -1144,7 +1160,8 @@ void wxSVGFileDCImpl::DoGradientFillLinear(const wxRect& rect,

write(s);

- CalcBoundingBox(rect);
+ if ( AreAutomaticBoundingBoxUpdatesEnabled() )
+ CalcBoundingBox(rect);
}

void wxSVGFileDCImpl::DoGradientFillConcentric(const wxRect& rect,
@@ -1183,7 +1200,8 @@ void wxSVGFileDCImpl::DoGradientFillConcentric(const wxRect& rect,

write(s);

- CalcBoundingBox(rect);
+ if ( AreAutomaticBoundingBoxUpdatesEnabled() )
+ CalcBoundingBox(rect);
}

void wxSVGFileDCImpl::DoSetDeviceClippingRegion(const wxRegion& region)


=====================================
src/dfb/dc.cpp
=====================================
@@ -133,8 +133,11 @@ void wxDFBDCImpl::Clear()
wxColour clr = m_backgroundBrush.GetColour();
m_surface->Clear(clr.Red(), clr.Green(), clr.Blue(), clr.Alpha());

- wxSize size(GetSize());
- CalcBoundingBox(XDEV2LOG(0), YDEV2LOG(0), XDEV2LOG(size.x), YDEV2LOG(size.y));
+ if ( AreAutomaticBoundingBoxUpdatesEnabled() )
+ {
+ wxSize size(GetSize());
+ CalcBoundingBox(XDEV2LOG(0), YDEV2LOG(0), XDEV2LOG(size.x), YDEV2LOG(size.y));
+ }
}

extern bool wxDoFloodFill(wxDC *dc, wxCoord x, wxCoord y,
@@ -202,7 +205,8 @@ void wxDFBDCImpl::DoDrawLine(wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2)

m_surface->DrawLine(xx1, yy1, xx2, yy2);

- CalcBoundingBox(x1, y1, x2, y2);
+ if ( AreAutomaticBoundingBoxUpdatesEnabled() )
+ CalcBoundingBox(x1, y1, x2, y2);
}

// Draws an arc of a circle, centred on (xc, yc), with starting point (x1, y1)
@@ -282,7 +286,8 @@ void wxDFBDCImpl::DoDrawRectangle(wxCoord x, wxCoord y, wxCoord width, wxCoord h
m_surface->DrawRectangle(xx, yy, ww, hh);
}

- CalcBoundingBox(wxPoint(x, y), wxSize(width, height));
+ if ( AreAutomaticBoundingBoxUpdatesEnabled() )
+ CalcBoundingBox(wxPoint(x, y), wxSize(width, height));
}

void wxDFBDCImpl::DoDrawRoundedRectangle(wxCoord WXUNUSED(x),
@@ -328,7 +333,8 @@ void wxDFBDCImpl::DoDrawText(const wxString& text, wxCoord x, wxCoord y)
// update the bounding box
wxCoord w, h;
DoGetTextExtent(text, &w, &h);
- CalcBoundingBox(wxPoint(x, y), wxSize(w, h));
+ if ( AreAutomaticBoundingBoxUpdatesEnabled() )
+ CalcBoundingBox(wxPoint(x, y), wxSize(w, h));

// if background mode is solid, DrawText must paint text's background:
if ( m_backgroundMode == wxBRUSHSTYLE_SOLID )
@@ -689,7 +695,8 @@ bool wxDFBDCImpl::DoBlitFromSurface(const wxIDirectFBSurfacePtr& src,
return false;
}

- CalcBoundingBox(wxPoint(dstx, dsty), wxSize(w, h));
+ if ( AreAutomaticBoundingBoxUpdatesEnabled() )
+ CalcBoundingBox(wxPoint(dstx, dsty), wxSize(w, h));

DFBRectangle srcRect = { srcx, srcy, w, h };
DFBRectangle dstRect = { XLOG2DEV(dstx), YLOG2DEV(dsty),


=====================================
src/generic/dcpsg.cpp
=====================================
@@ -419,7 +419,8 @@ void wxPostScriptDCImpl::DoDrawLine (wxCoord x1, wxCoord y1, wxCoord x2, wxCoord
buffer.Replace( ",", "." );
PsPrint( buffer );

- CalcBoundingBox( x1, y1, x2, y2 );
+ if ( AreAutomaticBoundingBoxUpdatesEnabled() )
+ CalcBoundingBox( x1, y1, x2, y2 );
}

void wxPostScriptDCImpl::DoDrawArc (wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2, wxCoord xc, wxCoord yc)
@@ -498,7 +499,8 @@ void wxPostScriptDCImpl::DoDrawArc (wxCoord x1, wxCoord y1, wxCoord x2, wxCoord
PsPrint( "stroke\n" );
}

- CalcBoundingBox( xc-i_radius, yc-i_radius, xc+i_radius, yc+i_radius );
+ if ( AreAutomaticBoundingBoxUpdatesEnabled() )
+ CalcBoundingBox( xc-i_radius, yc-i_radius, xc+i_radius, yc+i_radius );
}

void wxPostScriptDCImpl::DoDrawEllipticArc(wxCoord x,wxCoord y,wxCoord w,wxCoord h,double sa,double ea)
@@ -533,7 +535,8 @@ void wxPostScriptDCImpl::DoDrawEllipticArc(wxCoord x,wxCoord y,wxCoord w,wxCoord
buffer.Replace( ",", "." );
PsPrint( buffer );

- CalcBoundingBox( wxPoint(x, y), wxSize(w, h) );
+ if ( AreAutomaticBoundingBoxUpdatesEnabled() )
+ CalcBoundingBox( wxPoint(x, y), wxSize(w, h) );
}

if ( m_pen.IsNonTransparent() )
@@ -549,7 +552,8 @@ void wxPostScriptDCImpl::DoDrawEllipticArc(wxCoord x,wxCoord y,wxCoord w,wxCoord
buffer.Replace( ",", "." );
PsPrint( buffer );

- CalcBoundingBox( wxPoint(x, y), wxSize(w, h) );
+ if ( AreAutomaticBoundingBoxUpdatesEnabled() )
+ CalcBoundingBox( wxPoint(x, y), wxSize(w, h) );
}
}

@@ -572,7 +576,8 @@ void wxPostScriptDCImpl::DoDrawPoint (wxCoord x, wxCoord y)
buffer.Replace( ",", "." );
PsPrint( buffer );

- CalcBoundingBox( x, y );
+ if ( AreAutomaticBoundingBoxUpdatesEnabled() )
+ CalcBoundingBox( x, y );
}

void wxPostScriptDCImpl::DoDrawPolygon (int n, const wxPoint points[], wxCoord xoffset, wxCoord yoffset, wxPolygonFillMode fillStyle)
@@ -595,7 +600,8 @@ void wxPostScriptDCImpl::DoDrawPolygon (int n, const wxPoint points[], wxCoord x
buffer.Replace( ",", "." );
PsPrint( buffer );

- CalcBoundingBox( points[0].x + xoffset, points[0].y + yoffset );
+ if ( AreAutomaticBoundingBoxUpdatesEnabled() )
+ CalcBoundingBox( points[0].x + xoffset, points[0].y + yoffset );

for (int i = 1; i < n; i++)
{
@@ -606,7 +612,8 @@ void wxPostScriptDCImpl::DoDrawPolygon (int n, const wxPoint points[], wxCoord x
buffer.Replace( ",", "." );
PsPrint( buffer );

- CalcBoundingBox( points[i].x + xoffset, points[i].y + yoffset);
+ if ( AreAutomaticBoundingBoxUpdatesEnabled() )
+ CalcBoundingBox( points[i].x + xoffset, points[i].y + yoffset);
}

PsPrint( (fillStyle == wxODDEVEN_RULE ? "eofill\n" : "fill\n") );
@@ -626,7 +633,8 @@ void wxPostScriptDCImpl::DoDrawPolygon (int n, const wxPoint points[], wxCoord x
buffer.Replace( ",", "." );
PsPrint( buffer );

- CalcBoundingBox( points[0].x + xoffset, points[0].y + yoffset );
+ if ( AreAutomaticBoundingBoxUpdatesEnabled() )
+ CalcBoundingBox( points[0].x + xoffset, points[0].y + yoffset );

for (int i = 1; i < n; i++)
{
@@ -637,7 +645,8 @@ void wxPostScriptDCImpl::DoDrawPolygon (int n, const wxPoint points[], wxCoord x
buffer.Replace( ",", "." );
PsPrint( buffer );

- CalcBoundingBox( points[i].x + xoffset, points[i].y + yoffset);
+ if ( AreAutomaticBoundingBoxUpdatesEnabled() )
+ CalcBoundingBox( points[i].x + xoffset, points[i].y + yoffset);
}

PsPrint( "closepath\n" );
@@ -668,7 +677,8 @@ void wxPostScriptDCImpl::DoDrawPolyPolygon (int n, const int count[], const wxPo
buffer.Replace( ",", "." );
PsPrint( buffer );

- CalcBoundingBox( points[ofs].x + xoffset, points[ofs].y + yoffset );
+ if ( AreAutomaticBoundingBoxUpdatesEnabled() )
+ CalcBoundingBox( points[ofs].x + xoffset, points[ofs].y + yoffset );

for (int j = 1; j < count[i]; j++)
{
@@ -679,7 +689,8 @@ void wxPostScriptDCImpl::DoDrawPolyPolygon (int n, const int count[], const wxPo
buffer.Replace( ",", "." );
PsPrint( buffer );

- CalcBoundingBox( points[ofs+j].x + xoffset, points[ofs+j].y + yoffset);
+ if ( AreAutomaticBoundingBoxUpdatesEnabled() )
+ CalcBoundingBox( points[ofs+j].x + xoffset, points[ofs+j].y + yoffset);
}
}
PsPrint( (fillStyle == wxODDEVEN_RULE ? "eofill\n" : "fill\n") );
@@ -702,7 +713,8 @@ void wxPostScriptDCImpl::DoDrawPolyPolygon (int n, const int count[], const wxPo
buffer.Replace( ",", "." );
PsPrint( buffer );

- CalcBoundingBox( points[ofs].x + xoffset, points[ofs].y + yoffset );
+ if ( AreAutomaticBoundingBoxUpdatesEnabled() )
+ CalcBoundingBox( points[ofs].x + xoffset, points[ofs].y + yoffset );

for (int j = 1; j < count[i]; j++)
{
@@ -713,7 +725,8 @@ void wxPostScriptDCImpl::DoDrawPolyPolygon (int n, const int count[], const wxPo
buffer.Replace( ",", "." );
PsPrint( buffer );

- CalcBoundingBox( points[ofs+j].x + xoffset, points[ofs+j].y + yoffset);
+ if ( AreAutomaticBoundingBoxUpdatesEnabled() )
+ CalcBoundingBox( points[ofs+j].x + xoffset, points[ofs+j].y + yoffset);
}
}
PsPrint( "closepath\n" );
@@ -733,8 +746,11 @@ void wxPostScriptDCImpl::DoDrawLines (int n, const wxPoint points[], wxCoord xof
SetPen (m_pen);

int i;
- for ( i =0; i<n ; i++ )
- CalcBoundingBox( points[i].x+xoffset, points[i].y+yoffset );
+ if ( AreAutomaticBoundingBoxUpdatesEnabled() )
+ {
+ for ( i =0; i<n ; i++ )
+ CalcBoundingBox( points[i].x+xoffset, points[i].y+yoffset );
+ }

wxString buffer;
buffer.Printf( "newpath\n"
@@ -782,7 +798,8 @@ void wxPostScriptDCImpl::DoDrawRectangle (wxCoord x, wxCoord y, wxCoord width, w
buffer.Replace( ",", "." );
PsPrint( buffer );

- CalcBoundingBox( wxPoint(x, y), wxSize(width, height) );
+ if ( AreAutomaticBoundingBoxUpdatesEnabled() )
+ CalcBoundingBox( wxPoint(x, y), wxSize(width, height) );
}

if ( m_pen.IsNonTransparent() )
@@ -804,7 +821,8 @@ void wxPostScriptDCImpl::DoDrawRectangle (wxCoord x, wxCoord y, wxCoord width, w
buffer.Replace( ",", "." );
PsPrint( buffer );

- CalcBoundingBox( wxPoint(x, y), wxSize(width, height) );
+ if ( AreAutomaticBoundingBoxUpdatesEnabled() )
+ CalcBoundingBox( wxPoint(x, y), wxSize(width, height) );
}
}

@@ -853,7 +871,8 @@ void wxPostScriptDCImpl::DoDrawRoundedRectangle (wxCoord x, wxCoord y, wxCoord w
buffer.Replace( ",", "." );
PsPrint( buffer );

- CalcBoundingBox( wxPoint(x, y), wxSize(width, height) );
+ if ( AreAutomaticBoundingBoxUpdatesEnabled() )
+ CalcBoundingBox( wxPoint(x, y), wxSize(width, height) );
}

if ( m_pen.IsNonTransparent() )
@@ -884,7 +903,8 @@ void wxPostScriptDCImpl::DoDrawRoundedRectangle (wxCoord x, wxCoord y, wxCoord w
buffer.Replace( ",", "." );
PsPrint( buffer );

- CalcBoundingBox( wxPoint(x, y), wxSize(width, height) );
+ if ( AreAutomaticBoundingBoxUpdatesEnabled() )
+ CalcBoundingBox( wxPoint(x, y), wxSize(width, height) );
}
}

@@ -908,7 +928,8 @@ void wxPostScriptDCImpl::DoDrawEllipse (wxCoord x, wxCoord y, wxCoord width, wxC
buffer.Replace( ",", "." );
PsPrint( buffer );

- CalcBoundingBox( x - width, y - height, x + width, y + height );
+ if ( AreAutomaticBoundingBoxUpdatesEnabled() )
+ CalcBoundingBox( x - width, y - height, x + width, y + height );
}

if ( m_pen.IsNonTransparent() )
@@ -924,7 +945,8 @@ void wxPostScriptDCImpl::DoDrawEllipse (wxCoord x, wxCoord y, wxCoord width, wxC
buffer.Replace( ",", "." );
PsPrint( buffer );

- CalcBoundingBox( x - width, y - height, x + width, y + height );
+ if ( AreAutomaticBoundingBoxUpdatesEnabled() )
+ CalcBoundingBox( x - width, y - height, x + width, y + height );
}
}

@@ -1364,7 +1386,8 @@ void wxPostScriptDCImpl::DoDrawText( const wxString& text, wxCoord x, wxCoord y

DrawAnyText(textbuf, text_descent, size);

- CalcBoundingBox(wxPoint(x, y), GetOwner()->GetMultiLineTextExtent(text));
+ if ( AreAutomaticBoundingBoxUpdatesEnabled() )
+ CalcBoundingBox(wxPoint(x, y), GetOwner()->GetMultiLineTextExtent(text));
}

void wxPostScriptDCImpl::DoDrawRotatedText( const wxString& text, wxCoord x, wxCoord y, double angle )
@@ -1406,14 +1429,17 @@ void wxPostScriptDCImpl::DoDrawRotatedText( const wxString& text, wxCoord x, wxC
buffer.Replace( ",", "." );
PsPrint( buffer );

- wxCoord w, h;
- GetOwner()->GetMultiLineTextExtent(text, &w, &h);
- // "upper left" and "upper right"
- CalcBoundingBox(x, y, x + wxCoord(w*cos(rad)), y - wxCoord(w*sin(rad)));
- // "bottom left" and "bottom right"
- x += (wxCoord)(h*sin(rad));
- y += (wxCoord)(h*cos(rad));
- CalcBoundingBox(x, y, x + wxCoord(w*cos(rad)), y - wxCoord(w*sin(rad)));
+ if ( AreAutomaticBoundingBoxUpdatesEnabled() )
+ {
+ wxCoord w, h;
+ GetOwner()->GetMultiLineTextExtent(text, &w, &h);
+ // "upper left" and "upper right"
+ CalcBoundingBox(x, y, x + wxCoord(w*cos(rad)), y - wxCoord(w*sin(rad)));
+ // "bottom left" and "bottom right"
+ x += (wxCoord)(h*sin(rad));
+ y += (wxCoord)(h*cos(rad));
+ CalcBoundingBox(x, y, x + wxCoord(w*cos(rad)), y - wxCoord(w*sin(rad)));
+ }
}

void wxPostScriptDCImpl::SetBackground (const wxBrush& brush)
@@ -1453,8 +1479,11 @@ void wxPostScriptDCImpl::DoDrawSpline( const wxPointList *points )
buffer.Replace( ",", "." );
PsPrint( buffer );

- CalcBoundingBox( (wxCoord)p1.m_x, (wxCoord)p1.m_y );
- CalcBoundingBox( (wxCoord)p3.m_x, (wxCoord)p3.m_y );
+ if ( AreAutomaticBoundingBoxUpdatesEnabled() )
+ {
+ CalcBoundingBox( (wxCoord)p1.m_x, (wxCoord)p1.m_y );
+ CalcBoundingBox( (wxCoord)p3.m_x, (wxCoord)p3.m_y );
+ }

while ( itPt != points->end() )
{
@@ -1476,8 +1505,11 @@ void wxPostScriptDCImpl::DoDrawSpline( const wxPointList *points )
buffer.Replace( ",", "." );
PsPrint( buffer );

- CalcBoundingBox( (wxCoord)p0.m_x, (wxCoord)p0.m_y );
- CalcBoundingBox( (wxCoord)p3.m_x, (wxCoord)p3.m_y );
+ if ( AreAutomaticBoundingBoxUpdatesEnabled() )
+ {
+ CalcBoundingBox( (wxCoord)p0.m_x, (wxCoord)p0.m_y );
+ CalcBoundingBox( (wxCoord)p3.m_x, (wxCoord)p3.m_y );
+ }
}

/*
@@ -1491,7 +1523,8 @@ void wxPostScriptDCImpl::DoDrawSpline( const wxPointList *points )
buffer.Replace( ",", "." );
PsPrint( buffer );

- CalcBoundingBox((wxCoord)p2.m_x, (wxCoord)p2.m_y);
+ if ( AreAutomaticBoundingBoxUpdatesEnabled() )
+ CalcBoundingBox((wxCoord)p2.m_x, (wxCoord)p2.m_y);
}
#endif // wxUSE_SPLINES



=====================================
src/gtk/dc.cpp
=====================================
@@ -104,7 +104,8 @@ void wxGTKCairoDCImpl::DoDrawText(const wxString& text, int x, int y)
int w, h;
DoGetTextExtent(text, &w, &h);

- CalcBoundingBox(wxPoint(x, y), wxSize(w, h));
+ if ( AreAutomaticBoundingBoxUpdatesEnabled() )
+ CalcBoundingBox(wxPoint(x, y), wxSize(w, h));

const bool yInverted = m_signY < 0;
if (xInverted || yInverted)
@@ -161,21 +162,24 @@ void wxGTKCairoDCImpl::DoDrawRotatedText(const wxString& text, int x, int y, dou
m_maxX = maxX;
m_maxY = maxY;

- CalcBoundingBox(x, y);
- int w, h;
- DoGetTextExtent(text, &w, &h);
- cairo_matrix_t m;
- cairo_matrix_init_translate(&m, x, y);
- cairo_matrix_rotate(&m, rad);
- double xx = w, yy = 0;
- cairo_matrix_transform_point(&m, &xx, &yy);
- CalcBoundingBox(int(xx), int(yy));
- xx = w; yy = h;
- cairo_matrix_transform_point(&m, &xx, &yy);
- CalcBoundingBox(int(xx), int(yy));
- xx = 0; yy = h;
- cairo_matrix_transform_point(&m, &xx, &yy);
- CalcBoundingBox(int(xx), int(yy));
+ if ( AreAutomaticBoundingBoxUpdatesEnabled() )
+ {
+ CalcBoundingBox(x, y);
+ int w, h;
+ DoGetTextExtent(text, &w, &h);
+ cairo_matrix_t m;
+ cairo_matrix_init_translate(&m, x, y);
+ cairo_matrix_rotate(&m, rad);
+ double xx = w, yy = 0;
+ cairo_matrix_transform_point(&m, &xx, &yy);
+ CalcBoundingBox(int(xx), int(yy));
+ xx = w; yy = h;
+ cairo_matrix_transform_point(&m, &xx, &yy);
+ CalcBoundingBox(int(xx), int(yy));
+ xx = 0; yy = h;
+ cairo_matrix_transform_point(&m, &xx, &yy);
+ CalcBoundingBox(int(xx), int(yy));
+ }
}

void wxGTKCairoDCImpl::DoDrawCheckMark(int x, int y, int width, int height)


=====================================
src/gtk/dcclient.cpp
=====================================
@@ -527,7 +527,8 @@ void wxWindowDCImpl::DoDrawLine( wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2
if (m_gdkwindow)
gdk_draw_line( m_gdkwindow, m_penGC, XLOG2DEV(x1), YLOG2DEV(y1), XLOG2DEV(x2), YLOG2DEV(y2) );

- CalcBoundingBox(x1, y1, x2, y2);
+ if ( AreAutomaticBoundingBoxUpdatesEnabled() )
+ CalcBoundingBox(x1, y1, x2, y2);
}
}

@@ -657,7 +658,8 @@ void wxWindowDCImpl::DoDrawArc( wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2,
}
}

- CalcBoundingBox(x1, y1, x2, y2);
+ if ( AreAutomaticBoundingBoxUpdatesEnabled() )
+ CalcBoundingBox(x1, y1, x2, y2);
}

void wxWindowDCImpl::DoDrawEllipticArc( wxCoord x, wxCoord y, wxCoord width, wxCoord height, double sa, double ea )
@@ -704,7 +706,8 @@ void wxWindowDCImpl::DoDrawEllipticArc( wxCoord x, wxCoord y, wxCoord width, wxC
gdk_draw_arc( m_gdkwindow, m_penGC, FALSE, xx, yy, ww, hh, start, end );
}

- CalcBoundingBox( wxPoint(x, y), wxSize(width, height) );
+ if ( AreAutomaticBoundingBoxUpdatesEnabled() )
+ CalcBoundingBox( wxPoint(x, y), wxSize(width, height) );
}

void wxWindowDCImpl::DoDrawPoint( wxCoord x, wxCoord y )
@@ -714,7 +717,8 @@ void wxWindowDCImpl::DoDrawPoint( wxCoord x, wxCoord y )
if ( m_pen.IsNonTransparent() && m_gdkwindow )
gdk_draw_point( m_gdkwindow, m_penGC, XLOG2DEV(x), YLOG2DEV(y) );

- CalcBoundingBox (x, y);
+ if ( AreAutomaticBoundingBoxUpdatesEnabled() )
+ CalcBoundingBox (x, y);
}

void wxWindowDCImpl::DoDrawLines( int n, const wxPoint points[], wxCoord xoffset, wxCoord yoffset )
@@ -747,7 +751,8 @@ void wxWindowDCImpl::DoDrawLines( int n, const wxPoint points[], wxCoord xoffset
gpts_alloc[i].x = XLOG2DEV(points[i].x + xoffset);
gpts_alloc[i].y = YLOG2DEV(points[i].y + yoffset);
}
- CalcBoundingBox(points[i].x + xoffset, points[i].y + yoffset);
+ if ( AreAutomaticBoundingBoxUpdatesEnabled() )
+ CalcBoundingBox(points[i].x + xoffset, points[i].y + yoffset);
}

if (m_gdkwindow)
@@ -784,7 +789,8 @@ void wxWindowDCImpl::DoDrawPolygon( int n, const wxPoint points[],
gdkpoints_alloc[i].x = XLOG2DEV(points[i].x + xoffset);
gdkpoints_alloc[i].y = YLOG2DEV(points[i].y + yoffset);
}
- CalcBoundingBox(points[i].x + xoffset, points[i].y + yoffset);
+ if ( AreAutomaticBoundingBoxUpdatesEnabled() )
+ CalcBoundingBox(points[i].x + xoffset, points[i].y + yoffset);
}

if (m_gdkwindow)
@@ -855,7 +861,8 @@ void wxWindowDCImpl::DoDrawRectangle( wxCoord x, wxCoord y, wxCoord width, wxCoo
}
}

- CalcBoundingBox( wxPoint(x, y), wxSize(width, height) );
+ if ( AreAutomaticBoundingBoxUpdatesEnabled() )
+ CalcBoundingBox( wxPoint(x, y), wxSize(width, height) );
}

void wxWindowDCImpl::DoDrawRoundedRectangle( wxCoord x, wxCoord y, wxCoord width, wxCoord height, double radius )
@@ -936,7 +943,8 @@ void wxWindowDCImpl::DoDrawRoundedRectangle( wxCoord x, wxCoord y, wxCoord width
}

// this ignores the radius
- CalcBoundingBox( wxPoint(x, y), wxSize(width, height) );
+ if ( AreAutomaticBoundingBoxUpdatesEnabled() )
+ CalcBoundingBox( wxPoint(x, y), wxSize(width, height) );
}

void wxWindowDCImpl::DoDrawEllipse( wxCoord x, wxCoord y, wxCoord width, wxCoord height )
@@ -978,7 +986,8 @@ void wxWindowDCImpl::DoDrawEllipse( wxCoord x, wxCoord y, wxCoord width, wxCoord
gdk_draw_arc( m_gdkwindow, m_penGC, false, xx, yy, ww, hh, 0, 360*64 );
}

- CalcBoundingBox( wxPoint(x, y), wxSize(width, height) );
+ if ( AreAutomaticBoundingBoxUpdatesEnabled() )
+ CalcBoundingBox( wxPoint(x, y), wxSize(width, height) );
}

void wxWindowDCImpl::DoDrawIcon( const wxIcon &icon, wxCoord x, wxCoord y )
@@ -1087,7 +1096,8 @@ void wxWindowDCImpl::DoDrawBitmap( const wxBitmap &bitmap,
// notice that as the bitmap is not drawn upside down (or right to left)
// even if the corresponding axis direction is inversed, we need to take it
// into account when calculating its bounding box
- CalcBoundingBox(wxPoint(x, y), wxSize(m_signX*w, m_signY*h));
+ if ( AreAutomaticBoundingBoxUpdatesEnabled() )
+ CalcBoundingBox(wxPoint(x, y), wxSize(m_signX*w, m_signY*h));

// device coords
int xx = LogicalToDeviceX(x);
@@ -1236,7 +1246,8 @@ bool wxWindowDCImpl::DoBlit( wxCoord xdest, wxCoord ydest,
return false;
}

- CalcBoundingBox(wxPoint(xdest, ydest), wxSize(width, height) );
+ if ( AreAutomaticBoundingBoxUpdatesEnabled() )
+ CalcBoundingBox(wxPoint(xdest, ydest), wxSize(width, height) );

// source device coords
int src_x = source->LogicalToDeviceX(xsrc);
@@ -1422,7 +1433,8 @@ void wxWindowDCImpl::DoDrawRotatedText(const wxString& text, int xLogical, int y

if (wxIsNullDouble(angle))
{
- CalcBoundingBox(wxPoint(xLogical, yLogical), wxSize(w, h));
+ if ( AreAutomaticBoundingBoxUpdatesEnabled() )
+ CalcBoundingBox(wxPoint(xLogical, yLogical), wxSize(w, h));
}
else
{
@@ -1445,8 +1457,14 @@ void wxWindowDCImpl::DoDrawRotatedText(const wxString& text, int xLogical, int y
minY = (wxCoord)(dmin(dmin(0, y2), dmin(y3, y4)) - 0.5);
x += minX;
y += minY;
- CalcBoundingBox(DeviceToLogicalX(x), DeviceToLogicalY(y),
- DeviceToLogicalX(x + maxX - minX), DeviceToLogicalY(y + maxY - minY));
+
+ if ( AreAutomaticBoundingBoxUpdatesEnabled() )
+ {
+ CalcBoundingBox(DeviceToLogicalX(x),
+ DeviceToLogicalY(y),
+ DeviceToLogicalX(x + maxX - minX),
+ DeviceToLogicalY(y + maxY - minY));
+ }
}

gdk_draw_layout_with_colors(m_gdkwindow, m_textGC, x, y, m_layout, nullptr, bg_col);


=====================================
src/gtk/print.cpp
=====================================
@@ -1317,7 +1317,8 @@ void wxGtkPrinterDCImpl::DoGradientFillConcentric(const wxRect& rect, const wxCo

cairo_pattern_destroy(gradient);

- CalcBoundingBox(wxPoint(xR, yR), wxSize(w, h));
+ if ( AreAutomaticBoundingBoxUpdatesEnabled() )
+ CalcBoundingBox(wxPoint(xR, yR), wxSize(w, h));
}

void wxGtkPrinterDCImpl::DoGradientFillLinear(const wxRect& rect, const wxColour& initialColour, const wxColour& destColour, wxDirection nDirection)
@@ -1366,7 +1367,8 @@ void wxGtkPrinterDCImpl::DoGradientFillLinear(const wxRect& rect, const wxColour

cairo_pattern_destroy(gradient);

- CalcBoundingBox(wxPoint(x, y), wxSize(w, h));
+ if ( AreAutomaticBoundingBoxUpdatesEnabled() )
+ CalcBoundingBox(wxPoint(x, y), wxSize(w, h));
}

bool wxGtkPrinterDCImpl::DoGetPixel(wxCoord WXUNUSED(x1),
@@ -1387,7 +1389,8 @@ void wxGtkPrinterDCImpl::DoDrawLine(wxCoord x1, wxCoord y1, wxCoord x2, wxCoord
cairo_line_to ( m_cairo, XLOG2DEV(x2), YLOG2DEV(y2) );
cairo_stroke ( m_cairo );

- CalcBoundingBox( x1, y1, x2, y2 );
+ if ( AreAutomaticBoundingBoxUpdatesEnabled() )
+ CalcBoundingBox( x1, y1, x2, y2 );
}

void wxGtkPrinterDCImpl::DoCrossHair(wxCoord x, wxCoord y)
@@ -1403,7 +1406,8 @@ void wxGtkPrinterDCImpl::DoCrossHair(wxCoord x, wxCoord y)
cairo_line_to (m_cairo, XLOG2DEVREL(w), YLOG2DEV(y));

cairo_stroke (m_cairo);
- CalcBoundingBox( 0, 0, w, h );
+ if ( AreAutomaticBoundingBoxUpdatesEnabled() )
+ CalcBoundingBox( 0, 0, w, h );
}

void wxGtkPrinterDCImpl::DoDrawArc(wxCoord x1,wxCoord y1,wxCoord x2,wxCoord y2,wxCoord xc,wxCoord yc)
@@ -1455,9 +1459,12 @@ void wxGtkPrinterDCImpl::DoDrawArc(wxCoord x1,wxCoord y1,wxCoord x2,wxCoord y2,w
cairo_stroke(m_cairo);
}

- CalcBoundingBox (x1, y1);
- CalcBoundingBox (xc, yc);
- CalcBoundingBox (x2, y2);
+ if ( AreAutomaticBoundingBoxUpdatesEnabled() )
+ {
+ CalcBoundingBox (x1, y1);
+ CalcBoundingBox (xc, yc);
+ CalcBoundingBox (x2, y2);
+ }
}

void wxGtkPrinterDCImpl::DoDrawEllipticArc(wxCoord x,wxCoord y,wxCoord w,wxCoord h,double sa,double ea)
@@ -1480,7 +1487,8 @@ void wxGtkPrinterDCImpl::DoDrawEllipticArc(wxCoord x,wxCoord y,wxCoord w,wxCoord
SetBrush( m_brush );
cairo_fill( m_cairo );

- CalcBoundingBox(wxPoint(x, y), wxSize(w, h));
+ if ( AreAutomaticBoundingBoxUpdatesEnabled() )
+ CalcBoundingBox(wxPoint(x, y), wxSize(w, h));
}

void wxGtkPrinterDCImpl::DoDrawPoint(wxCoord x, wxCoord y)
@@ -1494,7 +1502,8 @@ void wxGtkPrinterDCImpl::DoDrawPoint(wxCoord x, wxCoord y)
cairo_line_to ( m_cairo, XLOG2DEV(x), YLOG2DEV(y) );
cairo_stroke ( m_cairo );

- CalcBoundingBox( x, y );
+ if ( AreAutomaticBoundingBoxUpdatesEnabled() )
+ CalcBoundingBox( x, y );
}

void wxGtkPrinterDCImpl::DoDrawLines(int n, const wxPoint points[], wxCoord xoffset, wxCoord yoffset)
@@ -1508,8 +1517,11 @@ void wxGtkPrinterDCImpl::DoDrawLines(int n, const wxPoint points[], wxCoord xoff
SetPen (m_pen);

int i;
- for ( i =0; i<n ; i++ )
- CalcBoundingBox( points[i].x+xoffset, points[i].y+yoffset);
+ if ( AreAutomaticBoundingBoxUpdatesEnabled() )
+ {
+ for ( i =0; i<n ; i++ )
+ CalcBoundingBox( points[i].x+xoffset, points[i].y+yoffset);
+ }

cairo_move_to ( m_cairo, XLOG2DEV(points[0].x+xoffset), YLOG2DEV(points[0].y+yoffset) );

@@ -1557,7 +1569,8 @@ void wxGtkPrinterDCImpl::DoDrawPolygon(int n, const wxPoint points[],
cairo_stroke(m_cairo);
}

- CalcBoundingBox( x, y );
+ if ( AreAutomaticBoundingBoxUpdatesEnabled() )
+ CalcBoundingBox( x, y );
}

void wxGtkPrinterDCImpl::DoDrawPolyPolygon(int n, const int count[], const wxPoint points[],
@@ -1591,7 +1604,8 @@ void wxGtkPrinterDCImpl::DoDrawRectangle(wxCoord x, wxCoord y, wxCoord width, wx
cairo_stroke(m_cairo);
}

- CalcBoundingBox(wxPoint(x, y), wxSize(width, height));
+ if ( AreAutomaticBoundingBoxUpdatesEnabled() )
+ CalcBoundingBox(wxPoint(x, y), wxSize(width, height));
}

void wxGtkPrinterDCImpl::DoDrawRoundedRectangle(wxCoord x, wxCoord y, wxCoord width, wxCoord height, double radius)
@@ -1644,7 +1658,8 @@ void wxGtkPrinterDCImpl::DoDrawRoundedRectangle(wxCoord x, wxCoord y, wxCoord wi
cairo_stroke(m_cairo);
}

- CalcBoundingBox(wxPoint(x, y), wxSize(width, height));
+ if ( AreAutomaticBoundingBoxUpdatesEnabled() )
+ CalcBoundingBox(wxPoint(x, y), wxSize(width, height));
}

void wxGtkPrinterDCImpl::DoDrawEllipse(wxCoord x, wxCoord y, wxCoord width, wxCoord height)
@@ -1672,7 +1687,8 @@ void wxGtkPrinterDCImpl::DoDrawEllipse(wxCoord x, wxCoord y, wxCoord width, wxCo
cairo_stroke(m_cairo);
}

- CalcBoundingBox(wxPoint(x, y), wxSize(width, height));
+ if ( AreAutomaticBoundingBoxUpdatesEnabled() )
+ CalcBoundingBox(wxPoint(x, y), wxSize(width, height));
}

#if wxUSE_SPLINES
@@ -1704,7 +1720,8 @@ void wxGtkPrinterDCImpl::DoDrawSpline(const wxPointList *points)
cairo_move_to( m_cairo, XLOG2DEV((wxCoord)x1), YLOG2DEV((wxCoord)y1) );
cairo_line_to( m_cairo, XLOG2DEV((wxCoord)x3), YLOG2DEV((wxCoord)y3) );

- CalcBoundingBox( (wxCoord)x1, (wxCoord)y1, (wxCoord)x3, (wxCoord)y3 );
+ if ( AreAutomaticBoundingBoxUpdatesEnabled() )
+ CalcBoundingBox( (wxCoord)x1, (wxCoord)y1, (wxCoord)x3, (wxCoord)y3 );

node = node->GetNext();
while (node)
@@ -1726,7 +1743,8 @@ void wxGtkPrinterDCImpl::DoDrawSpline(const wxPointList *points)
XLOG2DEV((wxCoord)x2), YLOG2DEV((wxCoord)y2),
XLOG2DEV((wxCoord)x3), YLOG2DEV((wxCoord)y3) );

- CalcBoundingBox( (wxCoord)x1, (wxCoord)y1, (wxCoord)x3, (wxCoord)y3 );
+ if ( AreAutomaticBoundingBoxUpdatesEnabled() )
+ CalcBoundingBox( (wxCoord)x1, (wxCoord)y1, (wxCoord)x3, (wxCoord)y3 );

node = node->GetNext();
}
@@ -1802,7 +1820,8 @@ void wxGtkPrinterDCImpl::DoDrawBitmap( const wxBitmap& bitmap, wxCoord x, wxCoor
cairo_fill(m_cairo);
#endif

- CalcBoundingBox(0, 0, bw, bh);
+ if ( AreAutomaticBoundingBoxUpdatesEnabled() )
+ CalcBoundingBox(0, 0, bw, bh);
}

void wxGtkPrinterDCImpl::DoDrawText(const wxString& text, wxCoord x, wxCoord y )
@@ -1856,7 +1875,8 @@ void wxGtkPrinterDCImpl::DoDrawRotatedText(const wxString& text, wxCoord x, wxCo
pango_layout_set_attributes(m_layout, nullptr);
}

- CalcBoundingBox(wxPoint(x, y), wxSize(w, h));
+ if ( AreAutomaticBoundingBoxUpdatesEnabled() )
+ CalcBoundingBox(wxPoint(x, y), wxSize(w, h));
}

void wxGtkPrinterDCImpl::Clear()


=====================================
src/msw/dc.cpp
=====================================
@@ -633,7 +633,8 @@ bool wxMSWDCImpl::DoFloodFill(wxCoord x,
wxLogLastError(wxT("ExtFloodFill"));
}

- CalcBoundingBox(x, y);
+ if ( AreAutomaticBoundingBoxUpdatesEnabled() )
+ CalcBoundingBox(x, y);

return success;
}
@@ -703,7 +704,8 @@ void wxMSWDCImpl::DoCrossHair(wxCoord x, wxCoord y)
wxDrawLine(GetHdc(), XLOG2DEV(x), YLOG2DEV(rect.top), XLOG2DEV(x), YLOG2DEV(rect.bottom));
}

- CalcBoundingBox(rect.left, rect.top, rect.right, rect.bottom);
+ if ( AreAutomaticBoundingBoxUpdatesEnabled() )
+ CalcBoundingBox(rect.left, rect.top, rect.right, rect.bottom);
}

void wxMSWDCImpl::DoDrawLine(wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2)
@@ -735,7 +737,8 @@ void wxMSWDCImpl::DoDrawLine(wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2)
wxDrawLine(GetHdc(), XLOG2DEV(x1), YLOG2DEV(y1), XLOG2DEV(x2), YLOG2DEV(y2));
}

- CalcBoundingBox(x1, y1, x2, y2);
+ if ( AreAutomaticBoundingBoxUpdatesEnabled() )
+ CalcBoundingBox(x1, y1, x2, y2);
}

// Draws an arc of a circle, centred on (xc, yc), with starting point (x1, y1)
@@ -787,7 +790,8 @@ void wxMSWDCImpl::DoDrawArc(wxCoord x1, wxCoord y1,
Arc(GetHdc(),xxx1,yyy1,xxx2,yyy2, xx1,yy1,xx2,yy2);
}

- CalcBoundingBox(xc - r, yc - r, xc + r, yc + r);
+ if ( AreAutomaticBoundingBoxUpdatesEnabled() )
+ CalcBoundingBox(xc - r, yc - r, xc + r, yc + r);
}

void wxMSWDCImpl::DoDrawPoint(wxCoord x, wxCoord y)
@@ -800,7 +804,8 @@ void wxMSWDCImpl::DoDrawPoint(wxCoord x, wxCoord y)

SetPixel(GetHdc(), XLOG2DEV(x), YLOG2DEV(y), color);

- CalcBoundingBox(x, y);
+ if ( AreAutomaticBoundingBoxUpdatesEnabled() )
+ CalcBoundingBox(x, y);
}

void wxMSWDCImpl::DoDrawPolygon(int n,
@@ -825,7 +830,8 @@ void wxMSWDCImpl::DoDrawPolygon(int n,
cpoints[i].x = points[i].x + xoffset;
cpoints[i].y = points[i].y + yoffset;

- CalcBoundingBox(cpoints[i].x, cpoints[i].y);
+ if ( AreAutomaticBoundingBoxUpdatesEnabled() )
+ CalcBoundingBox(cpoints[i].x, cpoints[i].y);

// Now convert them to the device coordinates that we need to use.
cpoints[i].x += XLOG2DEV(0);
@@ -835,9 +841,12 @@ void wxMSWDCImpl::DoDrawPolygon(int n,
}
else
{
- int i;
- for (i = 0; i < n; i++)
- CalcBoundingBox(points[i].x, points[i].y);
+ if ( AreAutomaticBoundingBoxUpdatesEnabled() )
+ {
+ int i;
+ for (i = 0; i < n; i++)
+ CalcBoundingBox(points[i].x, points[i].y);
+ }

Polygon(GetHdc(), reinterpret_cast<const POINT*>(points), n);
}
@@ -867,7 +876,8 @@ wxMSWDCImpl::DoDrawPolyPolygon(int n,
cpoints[i].x = points[i].x + xoffset;
cpoints[i].y = points[i].y + yoffset;

- CalcBoundingBox(cpoints[i].x, cpoints[i].y);
+ if ( AreAutomaticBoundingBoxUpdatesEnabled() )
+ CalcBoundingBox(cpoints[i].x, cpoints[i].y);

cpoints[i].x += XLOG2DEV(0);
cpoints[i].y += YLOG2DEV(0);
@@ -876,8 +886,11 @@ wxMSWDCImpl::DoDrawPolyPolygon(int n,
}
else
{
- for (i = 0; i < cnt; i++)
- CalcBoundingBox(points[i].x, points[i].y);
+ if ( AreAutomaticBoundingBoxUpdatesEnabled() )
+ {
+ for (i = 0; i < cnt; i++)
+ CalcBoundingBox(points[i].x, points[i].y);
+ }

PolyPolygon(GetHdc(), reinterpret_cast<const POINT*>(points), count, n);
}
@@ -895,7 +908,8 @@ void wxMSWDCImpl::DoDrawLines(int n, const wxPoint points[], wxCoord xoffset, wx
cpoints[i].x = (int)(points[i].x + xoffset);
cpoints[i].y = (int)(points[i].y + yoffset);

- CalcBoundingBox(cpoints[i].x, cpoints[i].y);
+ if ( AreAutomaticBoundingBoxUpdatesEnabled() )
+ CalcBoundingBox(cpoints[i].x, cpoints[i].y);

cpoints[i].x += XLOG2DEV(0);
cpoints[i].y += YLOG2DEV(0);
@@ -904,9 +918,12 @@ void wxMSWDCImpl::DoDrawLines(int n, const wxPoint points[], wxCoord xoffset, wx
}
else
{
- int i;
- for (i = 0; i < n; i++)
- CalcBoundingBox(points[i].x, points[i].y);
+ if ( AreAutomaticBoundingBoxUpdatesEnabled() )
+ {
+ int i;
+ for (i = 0; i < n; i++)
+ CalcBoundingBox(points[i].x, points[i].y);
+ }

Polyline(GetHdc(), reinterpret_cast<const POINT*>(points), n);
}
@@ -941,7 +958,8 @@ void wxMSWDCImpl::DoDrawRectangle(wxCoord x, wxCoord y, wxCoord width, wxCoord h

(void)Rectangle(GetHdc(), x1dev, y1dev, x2dev, y2dev);

- CalcBoundingBox(x, y, x2, y2);
+ if ( AreAutomaticBoundingBoxUpdatesEnabled() )
+ CalcBoundingBox(x, y, x2, y2);
}

void wxMSWDCImpl::DoDrawRoundedRectangle(wxCoord x, wxCoord y, wxCoord width, wxCoord height, double radius)
@@ -972,7 +990,8 @@ void wxMSWDCImpl::DoDrawRoundedRectangle(wxCoord x, wxCoord y, wxCoord width, wx
(void)RoundRect(GetHdc(), XLOG2DEV(x), YLOG2DEV(y), XLOG2DEV(x2),
YLOG2DEV(y2), (int) (2*radius), (int)( 2*radius));

- CalcBoundingBox(x, y, x2, y2);
+ if ( AreAutomaticBoundingBoxUpdatesEnabled() )
+ CalcBoundingBox(x, y, x2, y2);
}

void wxMSWDCImpl::DoDrawEllipse(wxCoord x, wxCoord y, wxCoord width, wxCoord height)
@@ -989,7 +1008,8 @@ void wxMSWDCImpl::DoDrawEllipse(wxCoord x, wxCoord y, wxCoord width, wxCoord hei

::Ellipse(GetHdc(), XLOG2DEV(x), YLOG2DEV(y), XLOG2DEV(x2), YLOG2DEV(y2));

- CalcBoundingBox(x, y, x2, y2);
+ if ( AreAutomaticBoundingBoxUpdatesEnabled() )
+ CalcBoundingBox(x, y, x2, y2);
}

#if wxUSE_SPLINES
@@ -1028,7 +1048,8 @@ void wxMSWDCImpl::DoDrawSpline(const wxPointList *points)
bezier_pos++;
lppt[ bezier_pos ] = lppt[ bezier_pos-1 ];
bezier_pos++;
- CalcBoundingBox(x1, y1);
+ if ( AreAutomaticBoundingBoxUpdatesEnabled() )
+ CalcBoundingBox(x1, y1);

p = *itPt; ++itPt;
x2 = p->x;
@@ -1040,7 +1061,8 @@ void wxMSWDCImpl::DoDrawSpline(const wxPointList *points)
bezier_pos++;
lppt[ bezier_pos ] = lppt[ bezier_pos-1 ];
bezier_pos++;
- CalcBoundingBox(x2, y2);
+ if ( AreAutomaticBoundingBoxUpdatesEnabled() )
+ CalcBoundingBox(x2, y2);

while ( itPt != points->end() )
{
@@ -1067,7 +1089,8 @@ void wxMSWDCImpl::DoDrawSpline(const wxPointList *points)
cx1 = cx4;
cy1 = cy4;

- CalcBoundingBox(x2, y2);
+ if ( AreAutomaticBoundingBoxUpdatesEnabled() )
+ CalcBoundingBox(x2, y2);
}

lppt[ bezier_pos ] = lppt[ bezier_pos-1 ];
@@ -1122,7 +1145,8 @@ void wxMSWDCImpl::DoDrawEllipticArc(wxCoord x,wxCoord y,wxCoord w,wxCoord h,doub
(void)Arc(GetHdc(), XLOG2DEV(x), YLOG2DEV(y), XLOG2DEV(x2), YLOG2DEV(y2),
rx1, ry1, rx2, ry2);

- CalcBoundingBox(x, y, x2, y2);
+ if ( AreAutomaticBoundingBoxUpdatesEnabled() )
+ CalcBoundingBox(x, y, x2, y2);
}

void wxMSWDCImpl::DoDrawIcon(const wxIcon& icon, wxCoord x, wxCoord y)
@@ -1146,7 +1170,8 @@ void wxMSWDCImpl::DoDrawIcon(const wxIcon& icon, wxCoord x, wxCoord y)
::DrawIconEx(GetHdc(), XLOG2DEV(x), YLOG2DEV(y), GetHiconOf(icon), icon.GetWidth(), icon.GetHeight(), 0, nullptr, DI_NORMAL);
}

- CalcBoundingBox(wxPoint(x, y), icon.GetSize());
+ if ( AreAutomaticBoundingBoxUpdatesEnabled() )
+ CalcBoundingBox(wxPoint(x, y), icon.GetSize());
}

void wxMSWDCImpl::DoDrawBitmap( const wxBitmap &bmp, wxCoord x, wxCoord y, bool useMask )
@@ -1191,7 +1216,8 @@ void wxMSWDCImpl::DoDrawBitmap( const wxBitmap &bmp, wxCoord x, wxCoord y, bool
if ( AlphaBlt(this, XLOG2DEV(x), YLOG2DEV(y), width, height,
0, 0, width, height, hdcMem, curBmp) )
{
- CalcBoundingBox(wxPoint(x, y), bmp.GetSize());
+ if ( AreAutomaticBoundingBoxUpdatesEnabled() )
+ CalcBoundingBox(wxPoint(x, y), bmp.GetSize());
return;
}
}
@@ -1300,7 +1326,8 @@ void wxMSWDCImpl::DoDrawBitmap( const wxBitmap &bmp, wxCoord x, wxCoord y, bool
::DeleteDC( memdc );
}

- CalcBoundingBox(wxPoint(x, y), bmp.GetSize());
+ if ( AreAutomaticBoundingBoxUpdatesEnabled() )
+ CalcBoundingBox(wxPoint(x, y), bmp.GetSize());
}

void wxMSWDCImpl::DoDrawText(const wxString& text, wxCoord x, wxCoord y)
@@ -1324,8 +1351,8 @@ void wxMSWDCImpl::DoDrawText(const wxString& text, wxCoord x, wxCoord y)

DrawAnyText(text, x, y);

- // update the bounding box
- CalcBoundingBox(wxPoint(x, y), GetOwner()->GetTextExtent(text));
+ if ( AreAutomaticBoundingBoxUpdatesEnabled() )
+ CalcBoundingBox(wxPoint(x, y), GetOwner()->GetTextExtent(text));
}

void wxMSWDCImpl::DrawAnyText(const wxString& text, wxCoord x, wxCoord y)
@@ -1416,14 +1443,16 @@ void wxMSWDCImpl::DoDrawRotatedText(const wxString& text,
// call the bounding box by adding all four vertices of the rectangle
// containing the text to it (simpler and probably not slower than
// determining which of them is really topmost/leftmost/...)
+ if ( AreAutomaticBoundingBoxUpdatesEnabled() )
+ {
+ // "upper left" and "upper right"
+ CalcBoundingBox(x, y, x + wxCoord(w*cos(rad)), y - wxCoord(w*sin(rad)));

- // "upper left" and "upper right"
- CalcBoundingBox(x, y, x + wxCoord(w*cos(rad)), y - wxCoord(w*sin(rad)));
-
- // "bottom left" and "bottom right"
- x += (wxCoord)(h*sin(rad));
- y += (wxCoord)(h*cos(rad));
- CalcBoundingBox(x, y, x + wxCoord(w*cos(rad)), y - wxCoord(w*sin(rad)));
+ // "bottom left" and "bottom right"
+ x += (wxCoord)(h*sin(rad));
+ y += (wxCoord)(h*cos(rad));
+ CalcBoundingBox(x, y, x + wxCoord(w*cos(rad)), y - wxCoord(w*sin(rad)));
+ }
}

// ---------------------------------------------------------------------------
@@ -2140,7 +2169,8 @@ bool wxMSWDCImpl::DoStretchBlit(wxCoord xdest, wxCoord ydest,
if ( AlphaBlt(this, xdest, ydest, dstWidth, dstHeight,
xsrc, ysrc, srcWidth, srcHeight, hdcSrc, bmpSrc) )
{
- CalcBoundingBox(bbox);
+ if ( AreAutomaticBoundingBoxUpdatesEnabled() )
+ CalcBoundingBox(bbox);
return true;
}
}
@@ -2427,7 +2457,10 @@ bool wxMSWDCImpl::DoStretchBlit(wxCoord xdest, wxCoord ydest,
}

if ( success )
- CalcBoundingBox(bbox);
+ {
+ if ( AreAutomaticBoundingBoxUpdatesEnabled() )
+ CalcBoundingBox(bbox);
+ }

return success;
}
@@ -2768,7 +2801,8 @@ void wxMSWDCImpl::DoGradientFillLinear (const wxRect& rect,
: GRADIENT_FILL_RECT_V
) )
{
- CalcBoundingBox(rect);
+ if ( AreAutomaticBoundingBoxUpdatesEnabled() )
+ CalcBoundingBox(rect);
}
else
{


=====================================
src/msw/uilocale.cpp
=====================================
@@ -629,11 +629,17 @@ public:

wxLayoutDirection GetLayoutDirection() const override
{
- wxString str = DoGetInfo(LOCALE_IREADINGLAYOUT);
- // str contains a number between 0 and 3:
- // 0 = LTR, 1 = RTL, 2 = TTB+RTL, 3 = TTB + LTR
- // If str equals 1 return RTL, otherwise LTR
- return (str.IsSameAs("1") ? wxLayout_RightToLeft : wxLayout_LeftToRight);
+ if ( m_layoutDir == wxLayout_Default )
+ {
+ wxString str = DoGetInfo(LOCALE_IREADINGLAYOUT);
+ // str contains a number between 0 and 3:
+ // 0 = LTR, 1 = RTL, 2 = TTB+RTL, 3 = TTB + LTR
+ // If str equals 1 return RTL, otherwise LTR
+ m_layoutDir = str.IsSameAs("1") ? wxLayout_RightToLeft
+ : wxLayout_LeftToRight;
+ }
+
+ return m_layoutDir;
}

int CompareStrings(const wxString& lhs, const wxString& rhs,
@@ -692,6 +698,8 @@ private:

const wchar_t* const m_name;

+ mutable wxLayoutDirection m_layoutDir = wxLayout_Default;
+
wxDECLARE_NO_COPY_CLASS(wxUILocaleImplName);
};



=====================================
src/msw/uxtheme.cpp
=====================================
@@ -35,7 +35,13 @@

bool wxUxThemeIsActive()
{
- return ::IsAppThemed() && ::IsThemeActive();
+ static int s_isActive = -1;
+ if ( s_isActive == -1 )
+ {
+ s_isActive = ::IsAppThemed() && ::IsThemeActive() ? 1 : 0;
+ }
+
+ return s_isActive != 0;
}

/* static */


=====================================
src/x11/dcclient.cpp
=====================================
@@ -405,7 +405,8 @@ void wxWindowDCImpl::DoDrawLine( wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2
// (GC) m_penGC, XLOG2DEV(x1), YLOG2DEV(y1), XLOG2DEV(x2), YLOG2DEV(y2) );
}

- CalcBoundingBox(x1, y1, x2, y2);
+ if ( AreAutomaticBoundingBoxUpdatesEnabled() )
+ CalcBoundingBox(x1, y1, x2, y2);
}
}

@@ -536,7 +537,8 @@ void wxWindowDCImpl::DoDrawArc( wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2,
}
}

- CalcBoundingBox(x1, y1, x2, y2);
+ if ( AreAutomaticBoundingBoxUpdatesEnabled() )
+ CalcBoundingBox(x1, y1, x2, y2);
}

void wxWindowDCImpl::DoDrawEllipticArc( wxCoord x, wxCoord y, wxCoord width, wxCoord height, double sa, double ea )
@@ -615,7 +617,8 @@ void wxWindowDCImpl::DoDrawEllipticArc( wxCoord x, wxCoord y, wxCoord width, wxC
}
}

- CalcBoundingBox(wxPoint(x, y), wxSize(width, height));
+ if ( AreAutomaticBoundingBoxUpdatesEnabled() )
+ CalcBoundingBox(wxPoint(x, y), wxSize(width, height));
}

void wxWindowDCImpl::DoDrawPoint( wxCoord x, wxCoord y )
@@ -626,7 +629,8 @@ void wxWindowDCImpl::DoDrawPoint( wxCoord x, wxCoord y )
XDrawPoint( (Display*) m_display, (Window) m_x11window,
(GC) m_penGC, XLOG2DEV(x), YLOG2DEV(y) );

- CalcBoundingBox (x, y);
+ if ( AreAutomaticBoundingBoxUpdatesEnabled() )
+ CalcBoundingBox (x, y);
}

void wxWindowDCImpl::DoDrawLines( int n, const wxPoint points[], wxCoord xoffset, wxCoord yoffset )
@@ -642,7 +646,8 @@ void wxWindowDCImpl::DoDrawLines( int n, const wxPoint points[], wxCoord xoffset
xpoints[i].x = XLOG2DEV (points[i].x + xoffset);
xpoints[i].y = YLOG2DEV (points[i].y + yoffset);

- CalcBoundingBox( points[i].x + xoffset, points[i].y + yoffset );
+ if ( AreAutomaticBoundingBoxUpdatesEnabled() )
+ CalcBoundingBox( points[i].x + xoffset, points[i].y + yoffset );
}
XDrawLines( (Display*) m_display, (Window) m_x11window, (GC) m_penGC, xpoints.get(), n, 0 );
}
@@ -662,7 +667,8 @@ void wxWindowDCImpl::DoDrawPolygon( int n, const wxPoint points[],
xpoints[i].x = XLOG2DEV (points[i].x + xoffset);
xpoints[i].y = YLOG2DEV (points[i].y + yoffset);

- CalcBoundingBox (points[i].x + xoffset, points[i].y + yoffset);
+ if ( AreAutomaticBoundingBoxUpdatesEnabled() )
+ CalcBoundingBox (points[i].x + xoffset, points[i].y + yoffset);
}

if (m_x11window)
@@ -806,7 +812,8 @@ void wxWindowDCImpl::DoDrawRectangle( wxCoord x, wxCoord y, wxCoord width, wxCoo
}
}

- CalcBoundingBox(wxPoint(x, y), wxSize(width, height));
+ if ( AreAutomaticBoundingBoxUpdatesEnabled() )
+ CalcBoundingBox(wxPoint(x, y), wxSize(width, height));
}

void wxWindowDCImpl::DoDrawRoundedRectangle( wxCoord x, wxCoord y, wxCoord width, wxCoord height, double radius )
@@ -928,7 +935,8 @@ void wxWindowDCImpl::DoDrawRoundedRectangle( wxCoord x, wxCoord y, wxCoord width
}

// this ignores the radius
- CalcBoundingBox(wxPoint(x, y), wxSize(width, height));
+ if ( AreAutomaticBoundingBoxUpdatesEnabled() )
+ CalcBoundingBox(wxPoint(x, y), wxSize(width, height));
}

void wxWindowDCImpl::DoDrawEllipse( wxCoord x, wxCoord y, wxCoord width, wxCoord height )
@@ -1004,7 +1012,8 @@ void wxWindowDCImpl::DoDrawEllipse( wxCoord x, wxCoord y, wxCoord width, wxCoord
}
}

- CalcBoundingBox(wxPoint(x, y), wxSize(width, height));
+ if ( AreAutomaticBoundingBoxUpdatesEnabled() )
+ CalcBoundingBox(wxPoint(x, y), wxSize(width, height));
}

void wxWindowDCImpl::DoDrawIcon( const wxIcon &icon, wxCoord x, wxCoord y)
@@ -1030,7 +1039,8 @@ void wxWindowDCImpl::DoDrawBitmap( const wxBitmap &bitmap,
int w = bitmap.GetWidth();
int h = bitmap.GetHeight();

- CalcBoundingBox(wxPoint(x, y), wxSize(w, h));
+ if ( AreAutomaticBoundingBoxUpdatesEnabled() )
+ CalcBoundingBox(wxPoint(x, y), wxSize(w, h));

if (!m_x11window) return;

@@ -1148,7 +1158,8 @@ void wxWindowDCImpl::DoDrawBitmap( const wxBitmap &bitmap,
int w = bitmap.GetWidth();
int h = bitmap.GetHeight();

- CalcBoundingBox(wxPoint(x, y), wxSize(w, h));
+ if ( AreAutomaticBoundingBoxUpdatesEnabled() )
+ CalcBoundingBox(wxPoint(x, y), wxSize(w, h));

if (!m_x11window) return;

@@ -1366,7 +1377,8 @@ bool wxWindowDCImpl::DoBlit( wxCoord xdest, wxCoord ydest, wxCoord width, wxCoor
}
}

- CalcBoundingBox(wxPoint(xdest, ydest), wxSize(width, height));
+ if ( AreAutomaticBoundingBoxUpdatesEnabled() )
+ CalcBoundingBox(wxPoint(xdest, ydest), wxSize(width, height));

// scale/translate size and position
wxCoord xx = XLOG2DEV(xdest);
@@ -1581,7 +1593,8 @@ void wxWindowDCImpl::DoDrawText( const wxString &text, wxCoord x, wxCoord y )

g_object_unref( G_OBJECT( layout ) );

- CalcBoundingBox(wxPoint(x, y), wxSize(width, height));
+ if ( AreAutomaticBoundingBoxUpdatesEnabled() )
+ CalcBoundingBox(wxPoint(x, y), wxSize(width, height));
}

void wxWindowDCImpl::DoDrawRotatedText(const wxString& text,



View it on GitLab: https://gitlab.com/wxwidgets/wxwidgets/-/compare/2b6475846db22096ef5ed9796347f00de4bc2049...510c5d1e084375cafcb9c47c5162074f21b3db1e

--
View it on GitLab: https://gitlab.com/wxwidgets/wxwidgets/-/compare/2b6475846db22096ef5ed9796347f00de4bc2049...510c5d1e084375cafcb9c47c5162074f21b3db1e
You're receiving this email because of your account on gitlab.com.


Reply all
Reply to author
Forward
0 new messages