refactor(renderer): enhance buffered image clearing logic in G2DBaseControlImpl for improved rendering performance

This commit is contained in:
extio-de
2026-01-18 20:02:59 +01:00
parent 7bc3807f63
commit 49bffa1459

View File

@@ -1,5 +1,6 @@
package de.extio.game_engine.renderer.g2d.control.impl;
import java.awt.AlphaComposite;
import java.awt.Graphics2D;
import java.awt.Transparency;
import java.awt.image.BufferedImage;
@@ -268,7 +269,10 @@ public abstract class G2DBaseControlImpl implements BaseControl {
final int width = Math.max(1, this.width);
final int height = Math.max(1, this.height);
if (this.bufferedImage != null && this.bufferedImage.getWidth() == width && this.bufferedImage.getHeight() == height) {
this.bufferedImageGraphics.clearRect(0, 0, width, height);
final var oldComposite = this.bufferedImageGraphics.getComposite();
this.bufferedImageGraphics.setComposite(AlphaComposite.Clear);
this.bufferedImageGraphics.fillRect(0, 0, width, height);
this.bufferedImageGraphics.setComposite(oldComposite);
}
else {
this.disposeBufferedImage();