Skip to content

Commit abbcb3e

Browse files
committed
Rebase for mpl3.
1 parent 7a727a1 commit abbcb3e

File tree

2 files changed

+21
-21
lines changed

2 files changed

+21
-21
lines changed

doc/api/backend_cairo_api.rst

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,7 @@
22
:mod:`matplotlib.backends.backend_cairo`
33
========================================
44

5-
.. Building the docs requires either adding pycairo/cairocffi as docs build
6-
dependency, or bumping the minimal numpy version to one that supports
7-
MagicMocks (which does define `__index__`) as indices (recent numpys do, but
8-
1.7.1 doesn't).
9-
10-
.. .. automodule:: matplotlib.backends.backend_cairo
11-
.. :members:
12-
.. :undoc-members:
13-
.. :show-inheritance:
5+
.. automodule:: matplotlib.backends.backend_cairo
6+
:members:
7+
:undoc-members:
8+
:show-inheritance:

lib/matplotlib/backends/backend_cairo.py

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,7 @@
33
==============================
44
:Author: Steve Chaplin and others
55
6-
This backend depends on `cairo <http://cairographics.org>`_, and either on
7-
cairocffi, or (Python 2 only) on pycairo.
6+
This backend depends on cairocffi or pycairo.
87
"""
98

109
import six
@@ -36,13 +35,14 @@
3635
"cairo>=1.4.0 is required".format(cairo.version))
3736
backend_version = cairo.version
3837

38+
from matplotlib import cbook
3939
from matplotlib.backend_bases import (
4040
_Backend, FigureCanvasBase, FigureManagerBase, GraphicsContextBase,
4141
RendererBase)
42+
from matplotlib.font_manager import ttfFontProperty
4243
from matplotlib.mathtext import MathTextParser
4344
from matplotlib.path import Path
4445
from matplotlib.transforms import Affine2D
45-
from matplotlib.font_manager import ttfFontProperty
4646

4747

4848
def _premultiplied_argb32_to_unmultiplied_rgba8888(buf):
@@ -94,7 +94,7 @@ def buffer_info(self):
9494
_CAIRO_PATH_TYPE_SIZES[cairo.PATH_CLOSE_PATH] = 1
9595

9696

97-
def _convert_paths_slow(ctx, paths, transforms, clip=None):
97+
def _append_paths_slow(ctx, paths, transforms, clip=None):
9898
for path, transform in zip(paths, transforms):
9999
for points, code in path.iter_segments(transform, clip=clip):
100100
if code == Path.MOVETO:
@@ -112,7 +112,7 @@ def _convert_paths_slow(ctx, paths, transforms, clip=None):
112112
ctx.curve_to(*points)
113113

114114

115-
def _convert_paths_fast(ctx, paths, transforms, clip=None):
115+
def _append_paths_fast(ctx, paths, transforms, clip=None):
116116
# We directly convert to the internal representation used by cairo, for
117117
# which ABI compatibility is guaranteed. The layout for each item is
118118
# --CODE(4)-- -LENGTH(4)- ---------PAD(8)---------
@@ -160,11 +160,11 @@ def _convert_paths_fast(ctx, paths, transforms, clip=None):
160160
cairo.cairo.cairo_append_path(ctx._pointer, ptr)
161161

162162

163-
_convert_paths = _convert_paths_fast if HAS_CAIRO_CFFI else _convert_paths_slow
163+
_append_paths = _append_paths_fast if HAS_CAIRO_CFFI else _append_paths_slow
164164

165165

166-
def _convert_path(ctx, path, transform, clip=None):
167-
return _convert_paths(ctx, [path], [transform], clip)
166+
def _append_path(ctx, path, transform, clip=None):
167+
return _append_paths(ctx, [path], [transform], clip)
168168

169169

170170
class RendererCairo(RendererBase):
@@ -226,6 +226,11 @@ def _fill_and_stroke(self, ctx, fill_c, alpha, alpha_overrides):
226226
ctx.restore()
227227
ctx.stroke()
228228

229+
@staticmethod
230+
@cbook.deprecated("3.0")
231+
def convert_path(ctx, path, transform, clip=None):
232+
_append_path(ctx, path, transform, clip)
233+
229234
def draw_path(self, gc, path, transform, rgbFace=None):
230235
ctx = gc.ctx
231236
# Clip the path to the actual rendering extents if it isn't filled.
@@ -235,7 +240,7 @@ def draw_path(self, gc, path, transform, rgbFace=None):
235240
transform = (transform
236241
+ Affine2D().scale(1, -1).translate(0, self.height))
237242
ctx.new_path()
238-
_convert_path(ctx, path, transform, clip)
243+
_append_path(ctx, path, transform, clip)
239244
self._fill_and_stroke(
240245
ctx, rgbFace, gc.get_alpha(), gc.get_forced_alpha())
241246

@@ -245,7 +250,7 @@ def draw_markers(self, gc, marker_path, marker_trans, path, transform,
245250

246251
ctx.new_path()
247252
# Create the path for the marker; it needs to be flipped here already!
248-
_convert_path(ctx, marker_path, marker_trans + Affine2D().scale(1, -1))
253+
_append_path(ctx, marker_path, marker_trans + Affine2D().scale(1, -1))
249254
marker_path = ctx.copy_path_flat()
250255

251256
# Figure out whether the path has a fill
@@ -316,7 +321,7 @@ def _draw_paths():
316321
gc.ctx.new_path()
317322
paths, transforms = zip(*grouped_draw)
318323
grouped_draw.clear()
319-
_convert_paths(gc.ctx, paths, transforms)
324+
_append_paths(gc.ctx, paths, transforms)
320325
self._fill_and_stroke(
321326
gc.ctx, rgb_fc, gc.get_alpha(), gc.get_forced_alpha())
322327

@@ -529,7 +534,7 @@ def set_clip_path(self, path):
529534
ctx.new_path()
530535
affine = (affine
531536
+ Affine2D().scale(1, -1).translate(0, self.renderer.height))
532-
_convert_path(ctx, tpath, affine)
537+
_append_path(ctx, tpath, affine)
533538
ctx.clip()
534539

535540
def set_dashes(self, offset, dashes):

0 commit comments

Comments
 (0)