-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Expire gradient cache based on texture size
Avoid caching gradients and reusing generated textures when their size change. This change adds an optional `CacheExpirable` interface for Canvas objects to implement, allowing the painter to know when the cached textures shouldn't be used. Fixes #4608.
- Loading branch information
1 parent
4f9d61b
commit 6f1bf29
Showing
6 changed files
with
124 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package cache | ||
|
||
import ( | ||
"testing" | ||
|
||
"fyne.io/fyne/v2" | ||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
func TestGetTexture_noCache(t *testing.T) { | ||
obj := &dummyObject{} | ||
texture, ok := GetTexture(obj) | ||
assert.False(t, ok) | ||
assert.Equal(t, texture, NoTexture) | ||
} | ||
|
||
func TestGetTexture_existingCache(t *testing.T) { | ||
obj := &dummyObject{} | ||
origTexture := TextureType(42) | ||
Check failure on line 19 in internal/cache/texture_common_test.go GitHub Actions / mobile_tests (1.19.x)
|
||
SetTexture(obj, origTexture, nil) | ||
texture, ok := GetTexture(obj) | ||
assert.True(t, ok) | ||
assert.Equal(t, texture, origTexture) | ||
} | ||
|
||
func TestGetTexture_expiredCache(t *testing.T) { | ||
obj := &dummyObject{} | ||
origTexture := TextureType(42) | ||
Check failure on line 28 in internal/cache/texture_common_test.go GitHub Actions / mobile_tests (1.19.x)
|
||
SetTexture(obj, origTexture, nil) | ||
|
||
obj.Resize(fyne.NewSize(100, 100)) | ||
texture, ok := GetTexture(obj) | ||
assert.False(t, ok) | ||
assert.Equal(t, texture, NoTexture) | ||
} |