mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-12-25 03:08:54 +01:00
graphicscommand: Dump internal image info on the debug mode
Closes #1714
This commit is contained in:
parent
852c787743
commit
60b8f82bfd
@ -21,6 +21,8 @@ import (
|
||||
"fmt"
|
||||
)
|
||||
|
||||
const IsDebug = true
|
||||
|
||||
func Logf(format string, args ...interface{}) {
|
||||
fmt.Printf(format, args...)
|
||||
}
|
||||
|
@ -17,5 +17,7 @@
|
||||
|
||||
package debug
|
||||
|
||||
const IsDebug = false
|
||||
|
||||
func Logf(format string, args ...interface{}) {
|
||||
}
|
||||
|
@ -217,7 +217,7 @@ func (q *commandQueue) flush() error {
|
||||
|
||||
es := q.indices
|
||||
vs := q.vertices
|
||||
debug.Logf("--\nGraphics commands:\n")
|
||||
debug.Logf("Graphics commands:\n")
|
||||
|
||||
if theGraphicsDriver.HasHighPrecisionFloat() {
|
||||
n := q.nvertices / graphics.VertexFloatNum
|
||||
|
@ -18,9 +18,11 @@ import (
|
||||
"fmt"
|
||||
"image"
|
||||
"os"
|
||||
"sort"
|
||||
"strings"
|
||||
|
||||
"github.com/hajimehoshi/ebiten/v2/internal/affine"
|
||||
"github.com/hajimehoshi/ebiten/v2/internal/debug"
|
||||
"github.com/hajimehoshi/ebiten/v2/internal/driver"
|
||||
"github.com/hajimehoshi/ebiten/v2/internal/graphics"
|
||||
"github.com/hajimehoshi/ebiten/v2/internal/png"
|
||||
@ -240,3 +242,13 @@ func (i *Image) Dump(path string, blackbg bool, rect image.Rectangle) error {
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func LogImagesInfo(images []*Image) {
|
||||
sort.Slice(images, func(a, b int) bool {
|
||||
return images[a].id < images[b].id
|
||||
})
|
||||
for _, i := range images {
|
||||
w, h := i.InternalSize()
|
||||
debug.Logf(" %d: (%d, %d)\n", i.id, w, h)
|
||||
}
|
||||
}
|
||||
|
@ -18,6 +18,7 @@ import (
|
||||
"image"
|
||||
"path/filepath"
|
||||
|
||||
"github.com/hajimehoshi/ebiten/v2/internal/debug"
|
||||
"github.com/hajimehoshi/ebiten/v2/internal/driver"
|
||||
"github.com/hajimehoshi/ebiten/v2/internal/graphicscommand"
|
||||
)
|
||||
@ -57,6 +58,15 @@ var theImages = &images{
|
||||
//
|
||||
// ResolveStaleImages is intended to be called at the end of a frame.
|
||||
func ResolveStaleImages() error {
|
||||
if debug.IsDebug {
|
||||
debug.Logf("Internal image sizes:\n")
|
||||
imgs := make([]*graphicscommand.Image, 0, len(theImages.images))
|
||||
for i := range theImages.images {
|
||||
imgs = append(imgs, i.image)
|
||||
}
|
||||
graphicscommand.LogImagesInfo(imgs)
|
||||
}
|
||||
|
||||
if err := graphicscommand.FlushCommands(); err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -160,6 +160,8 @@ func (c *uiContext) update(updateCount int) error {
|
||||
return err
|
||||
}
|
||||
|
||||
debug.Logf("----\n")
|
||||
|
||||
if err := buffered.BeginFrame(); err != nil {
|
||||
return err
|
||||
}
|
||||
@ -185,7 +187,7 @@ func (c *uiContext) updateImpl(updateCount int) error {
|
||||
updateCount = 1
|
||||
c.updateCalled = true
|
||||
}
|
||||
debug.Logf("--\nUpdate count per frame: %d\n", updateCount)
|
||||
debug.Logf("Update count per frame: %d\n", updateCount)
|
||||
|
||||
for i := 0; i < updateCount; i++ {
|
||||
if err := hooks.RunBeforeUpdateHooks(); err != nil {
|
||||
|
Loading…
Reference in New Issue
Block a user