Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 76ecdca

Browse filesBrowse files
authored
Merge pull request #14795 from anntzer/supports_blit
Autodetect whether a canvas class supports blitting.
2 parents 507bd38 + e4efe88 commit 76ecdca
Copy full SHA for 76ecdca

File tree

Expand file treeCollapse file tree

3 files changed

+28
-2
lines changed
Filter options
Expand file treeCollapse file tree

3 files changed

+28
-2
lines changed

‎lib/matplotlib/backend_bases.py

Copy file name to clipboardExpand all lines: lib/matplotlib/backend_bases.py
+5-1Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1581,7 +1581,6 @@ class FigureCanvasBase:
15811581
'close_event'
15821582
]
15831583

1584-
supports_blit = True
15851584
fixed_dpi = None
15861585

15871586
filetypes = _default_filetypes
@@ -1597,6 +1596,11 @@ class FigureCanvasBase:
15971596
register_backend('tiff', 'matplotlib.backends.backend_agg',
15981597
'Tagged Image File Format')
15991598

1599+
@cbook._classproperty
1600+
def supports_blit(cls):
1601+
return (hasattr(cls, "copy_from_bbox")
1602+
and hasattr(cls, "restore_region"))
1603+
16001604
def __init__(self, figure):
16011605
self._fix_ipython_backend2gui()
16021606
self._is_idle_drawing = True

‎lib/matplotlib/backends/backend_cairo.py

Copy file name to clipboardExpand all lines: lib/matplotlib/backends/backend_cairo.py
-1Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -390,7 +390,6 @@ def set_linewidth(self, w):
390390

391391

392392
class FigureCanvasCairo(FigureCanvasBase):
393-
supports_blit = False
394393

395394
def print_png(self, fobj, *args, **kwargs):
396395
self._get_printed_image_surface().write_to_png(fobj)

‎lib/matplotlib/cbook/__init__.py

Copy file name to clipboardExpand all lines: lib/matplotlib/cbook/__init__.py
+23Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2131,3 +2131,26 @@ def _check_getitem(_mapping, **kwargs):
21312131
raise ValueError(
21322132
"{!r} is not a valid value for {}; supported values are {}"
21332133
.format(v, k, ', '.join(map(repr, mapping)))) from None
2134+
2135+
2136+
class _classproperty:
2137+
"""
2138+
Like `property`, but also triggers on access via the class, and it is the
2139+
*class* that's passed as argument.
2140+
2141+
Examples
2142+
--------
2143+
::
2144+
class C:
2145+
@classproperty
2146+
def foo(cls):
2147+
return cls.__name__
2148+
2149+
assert C.foo == "C"
2150+
"""
2151+
2152+
def __init__(self, fget):
2153+
self._fget = fget
2154+
2155+
def __get__(self, instance, owner):
2156+
return self._fget(owner)

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.