diff --git a/src/common/dcsvg.cpp b/src/common/dcsvg.cpp index ca44afcac3..9eb2f4f0fb 100644 --- a/src/common/dcsvg.cpp +++ b/src/common/dcsvg.cpp @@ -934,6 +934,9 @@ void wxSVGFileDCImpl::DoSetClippingRegion(int x, int y, int width, int height) m_clipUniqueId++; m_clipNestingLevel++; + + // Update the base class m_clip[XY][12] fields too. + wxDCImpl::DoSetClippingRegion(x, y, width, height); } void wxSVGFileDCImpl::DestroyClippingRegion() @@ -958,6 +961,9 @@ void wxSVGFileDCImpl::DestroyClippingRegion() DoStartNewGraphics(); m_clipUniqueId = 0; + + // Also update the base class clipping region information. + wxDCImpl::DestroyClippingRegion(); } void wxSVGFileDCImpl::DoGetTextExtent(const wxString& string, wxCoord *w, wxCoord *h, wxCoord *descent, wxCoord *externalLeading, const wxFont *font) const diff --git a/tests/graphics/clippingbox.cpp b/tests/graphics/clippingbox.cpp index 6068660f91..42eed74701 100644 --- a/tests/graphics/clippingbox.cpp +++ b/tests/graphics/clippingbox.cpp @@ -21,7 +21,9 @@ #if wxUSE_GRAPHICS_CONTEXT #include "wx/dcgraph.h" #endif // wxUSE_GRAPHICS_CONTEXT +#include "wx/dcsvg.h" +#include "testfile.h" // ---------------------------------------------------------------------------- // test class @@ -2122,3 +2124,29 @@ void ClippingBoxTestCaseGCBase::RegionsAndPushPopState() } #endif // wxUSE_GRAPHICS_CONTEXT + +#if wxUSE_SVG + +// We can't reuse the existing tests for wxSVGFileDC as we can't check its +// output, but we can still at least check the behaviour of GetClippingBox(). +TEST_CASE("ClippingBoxTestCaseSVGDC", "[clip][svgdc]") +{ + TestFile tf; + wxSVGFileDC dc(tf.GetName(), s_dcSize.x, s_dcSize.y); + + wxRect rect; + dc.GetClippingBox(rect); + CHECK( rect == wxRect(s_dcSize) ); + + const wxRect rectClip(10, 20, 80, 75); + dc.SetClippingRegion(rectClip); + + dc.GetClippingBox(rect); + CHECK( rect == rectClip ); + + dc.DestroyClippingRegion(); + dc.GetClippingBox(rect); + CHECK( rect == wxRect(s_dcSize) ); +} + +#endif // wxUSE_SVG