Skip to content

Commit

Permalink
Fix the flicker on originalFill image load (#1434)
Browse files Browse the repository at this point in the history
Just skip frame 1 the flicker goes :)

Fixes #1432
  • Loading branch information
andydotxyz committed Oct 22, 2020
1 parent d373dcb commit 7aad1cc
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Expand Up @@ -56,6 +56,7 @@ More detailed release notes can be found on the [releases page](https://github.c
* Respect SelectEntry datta changes on refresh (#1462)
* Incorrect SelectEntry dropdown button position (#1361)
* don't allow both single and double tap events to fire (#1381)
* Fix issue where long or tall images could jump on load (#1266, #1432)
* Add missing raster support in software render
* Respect GOOS/GOARCH in fyne command utilities
* BSD support in build tools
Expand Down
18 changes: 14 additions & 4 deletions internal/painter/image.go
Expand Up @@ -67,7 +67,9 @@ func PaintImage(img *canvas.Image, c fyne.Canvas, width, height int) image.Image
aspects[img.Resource] = aspect
// if the image specifies it should be original size we need at least that many pixels on screen
if img.FillMode == canvas.ImageFillOriginal {
checkImageMinSize(img, c, origW, origH)
if !checkImageMinSize(img, c, origW, origH) {
return nil
}
}

tex = image.NewNRGBA(image.Rect(0, 0, texW, texH))
Expand All @@ -79,6 +81,7 @@ func PaintImage(img *canvas.Image, c fyne.Canvas, width, height int) image.Image
fyne.LogError("SVG Render error:", err)
return nil
}

svgCachePut(img.Resource, tex, width, height)
}

Expand All @@ -97,7 +100,9 @@ func PaintImage(img *canvas.Image, c fyne.Canvas, width, height int) image.Image
aspects[img] = float32(origSize.X) / float32(origSize.Y)
// if the image specifies it should be original size we need at least that many pixels on screen
if img.FillMode == canvas.ImageFillOriginal {
checkImageMinSize(img, c, origSize.X, origSize.Y)
if !checkImageMinSize(img, c, origSize.X, origSize.Y) {
return nil
}
}

return scaleImage(pixels, width, height, img.ScaleMode)
Expand All @@ -107,7 +112,9 @@ func PaintImage(img *canvas.Image, c fyne.Canvas, width, height int) image.Image
aspects[img] = float32(origSize.X) / float32(origSize.Y)
// if the image specifies it should be original size we need at least that many pixels on screen
if img.FillMode == canvas.ImageFillOriginal {
checkImageMinSize(img, c, origSize.X, origSize.Y)
if !checkImageMinSize(img, c, origSize.X, origSize.Y) {
return nil
}
}

return scaleImage(img.Image, width, height, img.ScaleMode)
Expand Down Expand Up @@ -145,11 +152,14 @@ func drawSVGSafely(icon *oksvg.SvgIcon, raster *rasterx.Dasher) error {
return err
}

func checkImageMinSize(img *canvas.Image, c fyne.Canvas, pixX, pixY int) {
func checkImageMinSize(img *canvas.Image, c fyne.Canvas, pixX, pixY int) bool {
dpSize := fyne.NewSize(internal.UnscaleInt(c, pixX), internal.UnscaleInt(c, pixY))

if img.MinSize() != dpSize {
img.SetMinSize(dpSize)
canvas.Refresh(img) // force the initial size to be respected
return false
}

return true
}

0 comments on commit 7aad1cc

Please sign in to comment.