@@ -15,60 +15,30 @@ class FigureCanvasGTK4Agg(backend_gtk4.FigureCanvasGTK4,
15
15
backend_agg .FigureCanvasAgg ):
16
16
def __init__ (self , figure ):
17
17
backend_gtk4 .FigureCanvasGTK4 .__init__ (self , figure )
18
- self ._bbox_queue = []
19
18
20
19
def on_draw_event (self , widget , ctx ):
21
20
scale = self .device_pixel_ratio
22
21
allocation = self .get_allocation ()
23
- w = allocation .width * scale
24
- h = allocation .height * scale
22
+ width = int ( allocation .width * scale )
23
+ height = int ( allocation .height * scale )
25
24
26
- if not len (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
25
+ Gtk .render_background (
26
+ self .get_style_context (), ctx ,
27
+ allocation .x , allocation .y ,
28
+ allocation .width , allocation .height )
34
29
35
30
ctx = backend_cairo ._to_context (ctx )
36
31
37
- for bbox in bbox_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
- if len (self ._bbox_queue ):
52
- self ._bbox_queue = []
32
+ buf = cbook ._unmultiplied_rgba8888_to_premultiplied_argb32 (
33
+ np .asarray (self .copy_from_bbox ([[0 , 0 ], [width , height ]])))
34
+ image = cairo .ImageSurface .create_for_data (
35
+ buf .ravel ().data , cairo .FORMAT_ARGB32 , width , height )
36
+ image .set_device_scale (scale , scale )
37
+ ctx .set_source_surface (image , 0 , 0 )
38
+ ctx .paint ()
53
39
54
40
return False
55
41
56
- def blit (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
- if bbox is None :
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
-
72
42
def draw (self ):
73
43
backend_agg .FigureCanvasAgg .draw (self )
74
44
super ().draw ()
0 commit comments