50 lines
919 B
Go
50 lines
919 B
Go
package edebug
|
|
|
|
import (
|
|
"fmt"
|
|
"image"
|
|
"log"
|
|
"runtime/debug"
|
|
|
|
"bou.ke/monkey"
|
|
"github.com/hajimehoshi/ebiten/v2"
|
|
)
|
|
|
|
var verbose bool
|
|
|
|
func printCall(message string) {
|
|
log.Println(message)
|
|
if !verbose {
|
|
return
|
|
}
|
|
debug.PrintStack()
|
|
}
|
|
|
|
func SetVerbose(v bool) {
|
|
verbose = v
|
|
}
|
|
|
|
func Start() {
|
|
{
|
|
var g *monkey.PatchGuard
|
|
g = monkey.Patch(ebiten.NewImage, func(width, height int) *ebiten.Image {
|
|
g.Unpatch()
|
|
defer g.Restore()
|
|
printCall(fmt.Sprintf("NewImage(%d,%d)", width, height))
|
|
return ebiten.NewImage(width, height)
|
|
})
|
|
}
|
|
{
|
|
var g *monkey.PatchGuard
|
|
g = monkey.Patch(ebiten.NewImageWithOptions, func(bounds image.Rectangle, options *ebiten.NewImageOptions) *ebiten.Image {
|
|
g.Unpatch()
|
|
defer g.Restore()
|
|
printCall(fmt.Sprintf("NewImageWithOptions(%s,%p)", bounds, options))
|
|
return ebiten.NewImageWithOptions(bounds, options)
|
|
})
|
|
}
|
|
}
|
|
|
|
func Stop() {
|
|
monkey.UnpatchAll()
|
|
}
|