exp/app/debug: fit the FPS counter's aspect ratio to the backing image.

Ever since we moved to a bitmap font instead of using freetype, the backing
image's dimensions are 43x9, not 50x12, and we might as well match. For
example, the output will be exactly 43x9 pixels at 72DPI, or 86x18 pixels at
144DPI, etc.

Change-Id: I99975cc780760b28b73fbf6d55befbe500f1a6e1
Reviewed-on: https://go-review.googlesource.com/11880
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
This commit is contained in:
Nigel Tao
2015-07-03 12:32:37 +10:00
parent c0fb3fcc1e
commit 8631054b13

View File

@ -27,10 +27,12 @@ var fps struct {
// DrawFPS draws the per second framerate in the bottom-left of the screen.
func DrawFPS(c event.Config) {
const imgW, imgH = 7*(fontWidth+1) + 1, fontHeight + 2
fps.mu.Lock()
if fps.c != c || fps.m == nil {
fps.c = c
fps.m = glutil.NewImage(7*(fontWidth+1)+1, fontHeight+2)
fps.m = glutil.NewImage(imgW, imgH)
}
fps.mu.Unlock()
@ -66,8 +68,8 @@ func DrawFPS(c event.Config) {
fps.m.Upload()
fps.m.Draw(
c,
geom.Point{0, c.Height - 12},
geom.Point{50, c.Height - 12},
geom.Point{0, c.Height - imgH},
geom.Point{imgW, c.Height - imgH},
geom.Point{0, c.Height},
fps.m.Bounds(),
)