Skip to content

backend_agg cleanup. #9916

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 3, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 17 additions & 11 deletions lib/matplotlib/backends/backend_agg.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
import numpy as np
from collections import OrderedDict
from math import radians, cos, sin
from matplotlib import rcParams, __version__
from matplotlib import cbook, rcParams, __version__
from matplotlib.backend_bases import (
_Backend, FigureCanvasBase, FigureManagerBase, RendererBase, cursors)
from matplotlib.figure import Figure
Expand Down Expand Up @@ -68,7 +68,11 @@ class RendererAgg(RendererBase):
The renderer handles all the drawing primitives using a graphics
context instance that controls the colors/styles
"""
debug=1

@property
@cbook.deprecated("2.2")
def debug(self):
return 1

# we want to cache the fonts at the class level so that when
# multiple figures are created we can reuse them. This helps with
Expand All @@ -79,16 +83,17 @@ class RendererAgg(RendererBase):
# draw, and release it when it is done. This allows multiple
# renderers to share the cached fonts, but only one figure can
# draw at time and so the font cache is used by only one
# renderer at a time
# renderer at a time.

lock = threading.RLock()

def __init__(self, width, height, dpi):
RendererBase.__init__(self)

self.dpi = dpi
self.width = width
self.height = height
self._renderer = _RendererAgg(int(width), int(height), dpi, debug=False)
self._renderer = _RendererAgg(int(width), int(height), dpi)
self._filter_renderers = []

self._update_methods()
Expand Down Expand Up @@ -158,12 +163,14 @@ def draw_path(self, gc, path, transform, rgbFace=None):
try:
self._renderer.draw_path(gc, p, transform, rgbFace)
except OverflowError:
raise OverflowError("Exceeded cell block limit (set 'agg.path.chunksize' rcparam)")
raise OverflowError("Exceeded cell block limit (set "
"'agg.path.chunksize' rcparam)")
else:
try:
self._renderer.draw_path(gc, path, transform, rgbFace)
except OverflowError:
raise OverflowError("Exceeded cell block limit (set 'agg.path.chunksize' rcparam)")
raise OverflowError("Exceeded cell block limit (set "
"'agg.path.chunksize' rcparam)")


def draw_mathtext(self, gc, x, y, s, prop, angle):
Expand Down Expand Up @@ -232,8 +239,8 @@ def get_text_width_height_descent(self, s, prop, ismath):

flags = get_hinting_flag()
font = self._get_agg_font(prop)
font.set_text(s, 0.0, flags=flags) # the width and height of unrotated string
w, h = font.get_width_height()
font.set_text(s, 0.0, flags=flags)
w, h = font.get_width_height() # width and height of unrotated string
d = font.get_descent()
w /= 64.0 # convert from subpixels
h /= 64.0
Expand Down Expand Up @@ -367,9 +374,8 @@ def post_processing(image, dpi):
post_processing is plotted (using draw_image) on it.
"""

# WARNING.
# For agg_filter to work, the rendere's method need
# to overridden in the class. See draw_markers, and draw_path_collections
# WARNING: For agg_filter to work, the renderer's method need to
# overridden in the class. See draw_markers and draw_path_collections.

width, height = int(self.width), int(self.height)

Expand Down
2 changes: 1 addition & 1 deletion pytest.ini
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ pep8ignore =
tools/subset.py E221 E231 E251 E261 E302 E501 E701 E703

matplotlib/backends/qt_editor/formlayout.py E301 E402 E501
matplotlib/backends/backend_agg.py E225 E228 E231 E261 E301 E302 E303 E501 E701
matplotlib/backends/backend_agg.py E225 E228 E231 E261 E301 E302 E303 E701
matplotlib/backends/backend_cairo.py E203 E211 E221 E231 E261 E272 E302 E303 E401 E402 E501 E701 E711
matplotlib/backends/backend_gdk.py E202 E203 E211 E221 E225 E231 E261 E302 E303 E402 E501 E702 E711
matplotlib/backends/backend_gtk.py E201 E202 E203 E211 E221 E222 E225 E231 E251 E261 E262 E301 E302 E303 E401 E402 E501 E701 E702 E703
Expand Down