From ca8a2896b499ea27245d310fc22bab5ba5e1c845 Mon Sep 17 00:00:00 2001 From: Hajime Hoshi Date: Fri, 17 Nov 2023 13:07:43 +0900 Subject: [PATCH] text/v2: performance optimization by using image.RGBA Apparently, image.RGBA doesn't use the slow path at draw.Draw, which is called from a rasterizer's Draw. Updates #2454 --- text/v2/gotextseg.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/text/v2/gotextseg.go b/text/v2/gotextseg.go index 5a399656f..15916c6f0 100644 --- a/text/v2/gotextseg.go +++ b/text/v2/gotextseg.go @@ -116,7 +116,7 @@ func segmentsToImage(segs []api.Segment, subpixelOffset fixed.Point26_6, glyphBo } } - dst := image.NewAlpha(image.Rect(0, 0, w, h)) + dst := image.NewRGBA(image.Rect(0, 0, w, h)) rast.Draw(dst, dst.Bounds(), image.Opaque, image.Point{}) return ebiten.NewImageFromImage(dst) }