Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix blurry DefaultTtfFontAsBitmap text in CachedContainer when virtual size < window size #1760

Merged
merged 4 commits into from
Jul 17, 2023

Conversation

eaboll
Copy link
Contributor

@eaboll eaboll commented Jul 4, 2023

Adds CachedContainer.expensiveScaling: Boolean?, which enables scaling of the content based on the actual window size instead of just the virtual size. Set to true by default.

This fixes part of issue #1748. The default non-bitmap font is still blurry regardless of whether or not it's in a CachedContainer.

In the sandbox:

image

@codecov-commenter
Copy link

codecov-commenter commented Jul 4, 2023

Codecov Report

Patch coverage: 32.35% and project coverage change: +0.01 🎉

Comparison is base (38a8fa9) 51.11% compared to head (59cb483) 51.13%.

❗ Your organization is not using the GitHub App Integration. As a result you may experience degraded service beginning May 15th. Please install the Github App Integration for your organization. Read more.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1760      +/-   ##
==========================================
+ Coverage   51.11%   51.13%   +0.01%     
==========================================
  Files        1737     1737              
  Lines      102045   102072      +27     
  Branches    14472    14474       +2     
==========================================
+ Hits        52158    52192      +34     
- Misses      45892    45908      +16     
+ Partials     3995     3972      -23     
Flag Coverage Δ
unittests 51.13% <32.35%> (+0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
...sandbox/src/commonMain/kotlin/samples/MainCache.kt 0.00% <0.00%> (ø)
...nMain/kotlin/korlibs/korge/view/CachedContainer.kt 78.75% <73.33%> (-1.54%) ⬇️

... and 22 files with indirect coverage changes

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

@soywiz
Copy link
Member

soywiz commented Jul 4, 2023

Awesome. Thanks for implementing it!

I have noticed a small tweak that could improve it further if you can change it

var cache: Boolean = true
var cache: Boolean = true,
@property:ViewProperty
var expensiveScaling: Boolean = true,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we have expensiveScaling: Boolean? = null ?

When constructing KorGE we have a quality parameter. Can we use the quality parameter to determine the value when not specified?

Here's the quality:

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This PR https://github.com/korlibs/korge/pull/1762/files will be needed, so it is possible to access tue GameWindow quality inside the RenderContext

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we have expensiveScaling: Boolean? = null ?

Excellent idea, implemented! 59cb483

Comment on lines +93 to +96
val doExpensiveScaling = expensiveScaling ?: when(ctx.quality) {
GameWindow.Quality.PERFORMANCE -> false
else -> true
}
Copy link
Member

@soywiz soywiz Jul 5, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you think that by adding some properties to the Quality enum, could we avoid somehow the when so the code gets simpler?

var cache: Boolean = true
var cache: Boolean = true,
@property:ViewProperty
var expensiveScaling: Boolean? = null,
Copy link
Member

@soywiz soywiz Jul 5, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure about this name. People might ask: In which way is this expensive? What scaling mean in this context?
Could we rename it, or pass something else to a Boolean?

@soywiz
Copy link
Member

soywiz commented Jul 17, 2023

Thanks @eaboll for implementing this!

To avoid this getting outdated, I'm going to merge it and make a few adjustments.
I'm going to change CachedContainer.expensiveScaling to CachedContainer.quality and going to adjust Quality to be accessible from outside, and to simplify the when.

@soywiz soywiz merged commit 924b1cd into korlibs:main Jul 17, 2023
10 checks passed
soywiz added a commit that referenced this pull request Jul 17, 2023
…n virtual size < window size (#1760)"

This reverts commit 924b1cd.
soywiz added a commit that referenced this pull request Jul 17, 2023
…ity (#1803)

* Added `korlibs.image.Quality` and make `GameWindow.Quality` implement it + tests

* Add Views.quality as an alias of GameWindow::quality

* Make enumerable debug view properties to support nullable values

* Add Missing Quality.LIST

* Test Quality.LIST

* Adds QualityProvider with a ViewPropertyProvider listing available Qualities

* Adds CachedContainer.renderQuality, backporting changes from @eaboll in #1760

* Backport example from other PR, but do not change the virtual size to avoid it to be misleading; just scale the container
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants