Fix wxGTK compilation with Cairo 1.2

Avoid using cairo_clip_extents() function, which was added in 1.4,
unless we have at least this version at both compile- and run-time.

This allows the library to be compiled under CentOS 5, which only has
Cairo 1.2 and which is, unfortunately, still in use.
This commit is contained in:
Vadim Zeitlin
2018-02-09 23:26:36 +01:00
parent 85bb678e54
commit 4265e671fd

View File

@@ -2408,10 +2408,21 @@ void wxCairoContext::ResetClip()
void wxCairoContext::GetClipBox(wxDouble* x, wxDouble* y, wxDouble* w, wxDouble* h) void wxCairoContext::GetClipBox(wxDouble* x, wxDouble* y, wxDouble* w, wxDouble* h)
{ {
double x1, y1, x2, y2; double x1, y1, x2, y2;
cairo_clip_extents(m_context, &x1, &y1, &x2, &y2); #if CAIRO_VERSION >= CAIRO_VERSION_ENCODE(1, 4, 0)
// Check if we have an empty clipping box. if ( cairo_version() >= CAIRO_VERSION_ENCODE(1, 4, 0) )
if ( x2 - x1 <= DBL_MIN || y2 - y1 <= DBL_MIN ) {
cairo_clip_extents(m_context, &x1, &y1, &x2, &y2);
// Check if we have an empty clipping box.
if ( x2 - x1 <= DBL_MIN || y2 - y1 <= DBL_MIN )
x1 = x2 = y1 = y2 = 0.0;
}
else
#endif // Cairo >= 1.4
{
// There doesn't seem to be any way to get the clipping box with this
// ancient version.
x1 = x2 = y1 = y2 = 0.0; x1 = x2 = y1 = y2 = 0.0;
}
if ( x ) if ( x )
*x = x1; *x = x1;