Skip to content

Commit 8260a5a

Browse files
committed
Removing clip that is no longer needed
1 parent 78cfcbe commit 8260a5a

File tree

2 files changed

+7
-84
lines changed

2 files changed

+7
-84
lines changed

lib/matplotlib/backends/backend_macosx.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -107,8 +107,7 @@ def draw_gouraud_triangle(self, gc, points, colors, transform):
107107
def draw_image(self, gc, x, y, im):
108108
im.flipud_out()
109109
nrows, ncols, data = im.as_rgba_str()
110-
gc.draw_image(x, y, nrows, ncols, data, gc.get_clip_rectangle(),
111-
*gc.get_clip_path())
110+
gc.draw_image(x, y, nrows, ncols, data)
112111
im.flipud_out()
113112

114113
def draw_tex(self, gc, x, y, s, prop, angle, ismath='TeX!', mtext=None):

src/_macosx.m

+6-82
Original file line numberDiff line numberDiff line change
@@ -1157,43 +1157,6 @@ static int _get_snap(GraphicsContext* self, enum e_snap_mode* mode)
11571157
return Py_None;
11581158
}
11591159

1160-
static BOOL _clip(CGContextRef cr, PyObject* object)
1161-
{
1162-
if (object == Py_None) return true;
1163-
1164-
PyArrayObject* array = NULL;
1165-
array = (PyArrayObject*) PyArray_FromObject(object, PyArray_DOUBLE, 2, 2);
1166-
if (!array)
1167-
{
1168-
PyErr_SetString(PyExc_ValueError, "failed to read clipping bounding box");
1169-
return false;
1170-
}
1171-
1172-
if (PyArray_NDIM(array)!=2 || PyArray_DIM(array, 0)!=2 || PyArray_DIM(array, 1)!=2)
1173-
{
1174-
Py_DECREF(array);
1175-
PyErr_SetString(PyExc_ValueError, "clipping bounding box should be a 2x2 array");
1176-
return false;
1177-
}
1178-
1179-
const double l = *(double*)PyArray_GETPTR2(array, 0, 0);
1180-
const double b = *(double*)PyArray_GETPTR2(array, 0, 1);
1181-
const double r = *(double*)PyArray_GETPTR2(array, 1, 0);
1182-
const double t = *(double*)PyArray_GETPTR2(array, 1, 1);
1183-
1184-
Py_DECREF(array);
1185-
1186-
CGRect rect;
1187-
rect.origin.x = (CGFloat) l;
1188-
rect.origin.y = (CGFloat) b;
1189-
rect.size.width = (CGFloat) (r-l);
1190-
rect.size.height = (CGFloat) (t-b);
1191-
1192-
CGContextClipToRect(cr, rect);
1193-
1194-
return true;
1195-
}
1196-
11971160
static int _transformation_converter(PyObject* object, void* pointer)
11981161
{
11991162
CGAffineTransform* matrix = (CGAffineTransform*)pointer;
@@ -3038,9 +3001,6 @@ static void _data_provider_release(void* info, const void* data, size_t size)
30383001
const char* data;
30393002
int n;
30403003
PyObject* image;
3041-
PyObject* cliprect;
3042-
PyObject* clippath;
3043-
PyObject* clippath_transform;
30443004

30453005
CGContextRef cr = self->cr;
30463006
if (!cr)
@@ -3049,18 +3009,14 @@ static void _data_provider_release(void* info, const void* data, size_t size)
30493009
return NULL;
30503010
}
30513011

3052-
if(!PyArg_ParseTuple(args, "ffiiOOOO", &x,
3053-
&y,
3054-
&nrows,
3055-
&ncols,
3056-
&image,
3057-
&cliprect,
3058-
&clippath,
3059-
&clippath_transform)) return NULL;
3012+
if(!PyArg_ParseTuple(args, "ffiiO", &x,
3013+
&y,
3014+
&nrows,
3015+
&ncols,
3016+
&image)) return NULL;
30603017

30613018
CGColorSpaceRef colorspace;
30623019
CGDataProviderRef provider;
3063-
double rect[4] = {0.0, 0.0, self->size.width, self->size.height};
30643020

30653021
if (!PyBytes_Check(image))
30663022
{
@@ -3118,40 +3074,8 @@ static void _data_provider_release(void* info, const void* data, size_t size)
31183074
return NULL;
31193075
}
31203076

3121-
BOOL ok = true;
3122-
CGContextSaveGState(cr);
3123-
if (!_clip(cr, cliprect)) ok = false;
3124-
else if (clippath!=Py_None)
3125-
{
3126-
int n;
3127-
void* iterator = get_path_iterator(clippath,
3128-
clippath_transform,
3129-
0,
3130-
0,
3131-
rect,
3132-
SNAP_AUTO,
3133-
1.0,
3134-
0);
3135-
if (iterator)
3136-
{
3137-
n = _draw_path(cr, iterator);
3138-
free_path_iterator(iterator);
3139-
if (n > 0) CGContextClip(cr);
3140-
}
3141-
else
3142-
{
3143-
PyErr_SetString(PyExc_RuntimeError,
3144-
"draw_image: failed to obtain path iterator for clipping");
3145-
ok = false;
3146-
}
3147-
}
3148-
3149-
if (ok) CGContextDrawImage(cr, CGRectMake(x,y,ncols,nrows), bitmap);
3150-
3077+
CGContextDrawImage(cr, CGRectMake(x,y,ncols,nrows), bitmap);
31513078
CGImageRelease(bitmap);
3152-
CGContextRestoreGState(cr);
3153-
3154-
if (!ok) return NULL;
31553079

31563080
Py_INCREF(Py_None);
31573081
return Py_None;

0 commit comments

Comments
 (0)