@@ -39,6 +39,7 @@ def __init__(
39
39
self ._pos = position
40
40
self ._pixel_ratio = pixel_ratio
41
41
self ._pixelated = False
42
+ self ._area = None # Cached area for the last draw call
42
43
43
44
self .texture = self .ctx .texture (self .size_scaled , components = 4 )
44
45
self .fbo : Framebuffer = self .ctx .framebuffer (color_attachments = [self .texture ])
@@ -278,19 +279,24 @@ def _update_geometry(self, area: Rect | None = None) -> None:
278
279
"""
279
280
Update the internal geometry of the surface mesh.
280
281
281
- The geometry is a triangle strip with 4 verties .
282
+ The geometry is a triangle strip with 4 vertices .
282
283
"""
283
284
if area is None :
284
285
area = LBWH (0 , 0 , * self .size )
285
286
287
+ if self ._area == area :
288
+ return
289
+ self ._area = area
290
+
286
291
# Clamp the area inside the surface
287
292
# This is the local area inside the surface
288
293
_size = Vec2 (* self .size )
289
- _pos = Vec2 (area .left , area .bottom )
294
+ _pos = Vec2 (* self .position )
295
+ _area_pos = Vec2 (area .left , area .bottom )
290
296
_area_size = Vec2 (area .width , area .height )
291
297
292
- b1 = _pos .clamp (Vec2 (0.0 ), _size )
293
- end_point = _pos + _area_size
298
+ b1 = _area_pos .clamp (Vec2 (0.0 ), _size )
299
+ end_point = _area_pos + _area_size
294
300
b2 = end_point .clamp (Vec2 (0.0 ), _size )
295
301
b = b2 - b1
296
302
l_area = Vec4 (b1 .x , b1 .y , b .x , b .y )
0 commit comments