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

Enlarging an image fails on Android Huawei ALE-L02 #1044

Closed
hajimehoshi opened this issue Jan 1, 2020 · 4 comments
Closed

Enlarging an image fails on Android Huawei ALE-L02 #1044

hajimehoshi opened this issue Jan 1, 2020 · 4 comments

Comments

@hajimehoshi
Copy link
Owner

Reported by @wasedaigo . This is different from #879. I have not confirmed yet.

@hajimehoshi hajimehoshi added this to the v1.11.0 milestone Jan 1, 2020
@hajimehoshi hajimehoshi changed the title Wrong rendering on Android Huawei P8 Lite Enlarging an image fails on Android Huawei P8 Lite Jan 3, 2020
@hajimehoshi
Copy link
Owner Author

huawei

@hajimehoshi hajimehoshi modified the milestones: v1.11.0, v1.10.3 Jan 3, 2020
@hajimehoshi
Copy link
Owner Author

The fundamental fix is:

diff --git a/mipmap.go b/mipmap.go
index aa8fe158..452dbbb8 100644
--- a/mipmap.go
+++ b/mipmap.go
@@ -111,8 +111,9 @@ func (m *mipmap) drawImage(src *mipmap, bounds image.Rectangle, geom *GeoM, colo
        if level > 6 {
                level = 6
        }
-       if level < -6 {
-               level = -6
+       // If tooBigScale is 4, level -10 means that the maximum scale is 4 * 2^10 = 4096. This should be enough.
+       if level < -10 {
+               level = -10
        }

        cr, cg, cb, ca := float32(1), float32(1), float32(1), float32(1)
@@ -303,7 +304,10 @@ func (m *mipmap) mipmapLevel(geom *GeoM, width, height int, filter driver.Filter

        // Use 'negative' mipmap to render edges correctly (#611, #907).
        // It looks like 128 is the enlargement factor that causes edge missings to pass the test TestImageStretch.
-       const tooBigScale = 128
+       var tooBigScale float32 = 128
+       if !uiDriver().Graphics().HasHighPrecisionFloat() {
+               tooBigScale = 4
+       }
        if sx, sy := geomScaleSize(geom); sx >= tooBigScale || sy >= tooBigScale {
                // If the filter is not nearest, the target needs to be rendered with graduation. Don't use mipmaps.
                if filter != driver.FilterNearest {

The problem is that HasHighPrecisionFloat cannot be called when the game is not started.

@hajimehoshi
Copy link
Owner Author

Let's move the mipmap part so that buffered package will be a user. buffer.Image will have DrawImage.

@hajimehoshi hajimehoshi modified the milestones: v1.10.3, v1.11.0 Jan 7, 2020
@hajimehoshi hajimehoshi changed the title Enlarging an image fails on Android Huawei P8 Lite Enlarging an image fails on Android Huawei ALE-L02 Jan 7, 2020
hajimehoshi added a commit that referenced this issue Jan 7, 2020
Mipmap calculation must be executed after the main loop starts
because the graphics driver's HasHighPrecisionFloat is needed.
Then, operations on mipmap images must be called from images in
buffered package.

Updates #1044
@hajimehoshi
Copy link
Owner Author

hajimehoshi commented Jan 7, 2020

I changed the milestone because

  • This is not so a serious bug (hopefully)
  • This requires a relatively big change
  • Android user cannot use Go modules so far then fixing master branch is enough

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant