Movatterモバイル変換


[0]ホーム

URL:


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

Sign up
Appearance settings

Commit9c169f3

Browse files
authored
Merge pull request#21304 from meeseeksmachine/auto-backport-of-pr-21294-on-v3.5.x
Backport PR#21294 on branch v3.5.x (Disable blitting on GTK4 backends)
2 parentsb70b681 +cbd6ed6 commit9c169f3

File tree

2 files changed

+13
-44
lines changed

2 files changed

+13
-44
lines changed

‎lib/matplotlib/backends/backend_gtk4.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ def _mpl_to_gtk_cursor(mpl_cursor):
5252

5353
classFigureCanvasGTK4(Gtk.DrawingArea,FigureCanvasBase):
5454
required_interactive_framework="gtk4"
55+
supports_blit=False
5556
_timer_cls=TimerGTK4
5657
_context_is_scaled=False
5758

‎lib/matplotlib/backends/backend_gtk4agg.py

Lines changed: 12 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -8,67 +8,35 @@
88
from .importbackend_agg,backend_gtk4
99
from .backend_cairoimportcairo
1010
from .backend_gtk4importGtk,_BackendGTK4
11-
frommatplotlibimporttransforms
1211

1312

1413
classFigureCanvasGTK4Agg(backend_gtk4.FigureCanvasGTK4,
1514
backend_agg.FigureCanvasAgg):
1615
def__init__(self,figure):
1716
backend_gtk4.FigureCanvasGTK4.__init__(self,figure)
18-
self._bbox_queue= []
1917

2018
defon_draw_event(self,widget,ctx):
2119
scale=self.device_pixel_ratio
2220
allocation=self.get_allocation()
23-
w=allocation.width*scale
24-
h=allocation.height*scale
2521

26-
ifnotlen(self._bbox_queue):
27-
Gtk.render_background(
28-
self.get_style_context(),ctx,
29-
allocation.x,allocation.y,
30-
allocation.width,allocation.height)
31-
bbox_queue= [transforms.Bbox([[0,0], [w,h]])]
32-
else:
33-
bbox_queue=self._bbox_queue
22+
Gtk.render_background(
23+
self.get_style_context(),ctx,
24+
allocation.x,allocation.y,
25+
allocation.width,allocation.height)
3426

3527
ctx=backend_cairo._to_context(ctx)
3628

37-
forbboxinbbox_queue:
38-
x=int(bbox.x0)
39-
y=h-int(bbox.y1)
40-
width=int(bbox.x1)-int(bbox.x0)
41-
height=int(bbox.y1)-int(bbox.y0)
42-
43-
buf=cbook._unmultiplied_rgba8888_to_premultiplied_argb32(
44-
np.asarray(self.copy_from_bbox(bbox)))
45-
image=cairo.ImageSurface.create_for_data(
46-
buf.ravel().data,cairo.FORMAT_ARGB32,width,height)
47-
image.set_device_scale(scale,scale)
48-
ctx.set_source_surface(image,x/scale,y/scale)
49-
ctx.paint()
50-
51-
iflen(self._bbox_queue):
52-
self._bbox_queue= []
29+
buf=cbook._unmultiplied_rgba8888_to_premultiplied_argb32(
30+
np.asarray(self.renderer.buffer_rgba()))
31+
height,width,_=buf.shape
32+
image=cairo.ImageSurface.create_for_data(
33+
buf.ravel().data,cairo.FORMAT_ARGB32,width,height)
34+
image.set_device_scale(scale,scale)
35+
ctx.set_source_surface(image,0,0)
36+
ctx.paint()
5337

5438
returnFalse
5539

56-
defblit(self,bbox=None):
57-
# If bbox is None, blit the entire canvas to gtk. Otherwise
58-
# blit only the area defined by the bbox.
59-
ifbboxisNone:
60-
bbox=self.figure.bbox
61-
62-
scale=self.device_pixel_ratio
63-
allocation=self.get_allocation()
64-
x=int(bbox.x0/scale)
65-
y=allocation.height-int(bbox.y1/scale)
66-
width= (int(bbox.x1)-int(bbox.x0))//scale
67-
height= (int(bbox.y1)-int(bbox.y0))//scale
68-
69-
self._bbox_queue.append(bbox)
70-
self.queue_draw_area(x,y,width,height)
71-
7240
defdraw(self):
7341
backend_agg.FigureCanvasAgg.draw(self)
7442
super().draw()

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp