Skip to content

Commit

Permalink
Fix performance issue where images could re-draw a lot when not needed
Browse files Browse the repository at this point in the history
  • Loading branch information
andydotxyz committed Mar 30, 2021
1 parent 23ba3f4 commit 1dfd83b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
4 changes: 4 additions & 0 deletions canvas/image.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,10 @@ func (i *Image) Alpha() float64 {
// Resize on an image will scale the content or reposition it according to FillMode.
// It will normally cause a Refresh to ensure the pixels are recalculated.
func (i *Image) Resize(s fyne.Size) {
if s == i.Size() {
return
}

i.baseObject.Resize(s)

Refresh(i)
Expand Down
4 changes: 4 additions & 0 deletions canvas/raster.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@ func (r *Raster) Alpha() float64 {
// Resize on a raster image causes the new size to be set and then calls Refresh.
// This causes the underlying data to be recalculated and a new output to be drawn.
func (r *Raster) Resize(s fyne.Size) {
if s == r.Size() {
return
}

r.baseObject.Resize(s)
Refresh(r)
}
Expand Down

0 comments on commit 1dfd83b

Please sign in to comment.