Commit Graph

3282 Commits

Author SHA1 Message Date
Hajime Hoshi
14c327c89b internal/atlas: replace Pixels with At to reduce unnecessary slice allocations 2022-03-20 18:39:17 +09:00
Hajime Hoshi
11ff0ab48c internal/atlas: refactoring: remove arguments from Pixels 2022-03-20 18:28:57 +09:00
Hajime Hoshi
367a9ec5bf internal/atlas: refactoring 2022-03-20 18:07:29 +09:00
Hajime Hoshi
54b4e87506 internal/restorable: bug fix: ReplacePixels on a sub-image might panic on Android
If regions by ReplacePixel are overlapped, this can panics. This can
happen only on Android, where a context lost can happen.

Thus, a sub-image cannot call a direct ReplacePixels. internal/buffer
has to care this.
2022-03-20 18:01:37 +09:00
Hajime Hoshi
696bbc088f internal/ui: rename variables 2022-03-20 16:51:23 +09:00
Hajime Hoshi
c3e855ab02 internal/buffered: refactoring 2022-03-20 16:44:11 +09:00
Hajime Hoshi
673556d03f internal/ui: move the error handlings to the ui package 2022-03-20 16:26:26 +09:00
Hajime Hoshi
bd07f6246f internal/buffered: remove mysterious comments 2022-03-20 05:17:43 +09:00
Hajime Hoshi
cc574ad67e internal/atlas: rename functions: Area -> Region 2022-03-20 04:20:23 +09:00
Hajime Hoshi
b59dd45239 internal/buffered: separate ReplacePixels with the large-area and small-area versions
For the large-area version, this doesn't require a graphics driver.
This is necessary to ensure that ReplacePixels never needs a graphics
driver.
2022-03-20 04:13:31 +09:00
Hajime Hoshi
4cbce71b2b internal/graphicscommand: move the choice of graphics drivers to internal/ui 2022-03-20 02:51:31 +09:00
Hajime Hoshi
1d9982ee6d internal/ui: move the dependency on graphicscommand from ebiten to ui 2022-03-20 02:00:44 +09:00
Hajime Hoshi
e78f34aa26 internal/ui: add Image
This is a preparation for a refactoring. Image will be a proxy to
pass a graphics driver to the lower layer.
2022-03-20 01:39:05 +09:00
Hajime Hoshi
3e44a20b22 internal/graphicscommand: swap arguments 2022-03-20 00:09:17 +09:00
Hajime Hoshi
8e3576b404 internal/mipmap: remove unused functions 2022-03-19 23:45:15 +09:00
Hajime Hoshi
7c2300b352 internal/graphicscommand: reduce the usages of the graphicsDriver function 2022-03-19 23:03:34 +09:00
Hajime Hoshi
58366ce64d internal/glfw: make the file operation atomic
If multiple Ebiten processes start at the same time, the file operation
can cause a race condition. Add a file lock to avoid this.
2022-03-18 20:32:25 +09:00
Hajime Hoshi
2e6bb8c4e2 internal/graphicsdriver/metal: add comments 2022-03-14 22:02:44 +09:00
Hajime Hoshi
a617576879 internal/shaderir: replace Mul with ComponentWiseMul and MatrixMul
This is a preparation for DirectX / HLSL.

Updates #1007
2022-03-13 19:17:46 +09:00
Hajime Hoshi
044d41dd2d internal/shaderir: change Op from string to int
This is a preparation to distinguish Hadamard product and matrix
product for HLSL.

Updates #1007
2022-03-13 16:20:04 +09:00
Hajime Hoshi
7d0f95e9be internal/graphicsdriver: refactoring: replace Uniform with []float32
Closes #2016
2022-03-13 03:42:13 +09:00
Hajime Hoshi
35a5c88901 internal/graphics: rename constants 2022-03-12 04:01:48 +09:00
Hajime Hoshi
98e2d86ea3 internal/shaderir/msl: refactoring 2022-03-12 00:18:55 +09:00
Hajime Hoshi
5715539a0f internal/shaderir/glsl, internal/shaderir/msl: refactoring 2022-03-11 15:18:38 +09:00
Hajime Hoshi
e63709a2a5 internal/shaderir/glsl: refactoring 2022-03-11 02:03:15 +09:00
Hajime Hoshi
6f00221051 internal/shaderir/msl: rename the package name
Updates #2010
2022-03-10 16:25:11 +09:00
Hajime Hoshi
5f97bdc1d3 internal/shader: fix typo
Updates #2011
2022-03-10 02:54:32 +09:00
Hajime Hoshi
5614e9d7eb internal/shader: fix misspellings 2022-03-10 02:52:44 +09:00
Hajime Hoshi
880dd0682e internal/shader: bug fix: fix some failing tests 2022-03-10 02:24:29 +09:00
Hajime Hoshi
d3b72d4ef9 internal/shader: add test files
Updates #2011
2022-03-10 01:02:51 +09:00
Hajime Hoshi
de05ede27e internal/shader: bug fix: evaluate the builtin float/int functions in the pre-compile phase correctly
Closes #2011
2022-03-10 00:47:16 +09:00
Hajime Hoshi
47bfd0db9e internal/shaderir/metal: rename to msl
Closes #2010
2022-03-10 00:14:06 +09:00
Hajime Hoshi
5e5e3c64ac internal/shaderir/metal: remove a redundant case 2022-03-09 02:54:31 +09:00
Hajime Hoshi
15064dbdc1 internal/shaderir/glsl, internal/shaderir/metal: simplify function names 2022-03-09 01:43:36 +09:00
Hajime Hoshi
e4fba8b047 bug fix: compile error with Go 1.16 and older 2022-03-08 00:08:53 +09:00
Hajime Hoshi
86ba7719eb internal/ui: bug fix: use CompareAndSwap 2022-03-07 23:51:10 +09:00
Hajime Hoshi
c37ffecafd internal/graphicsdriver/metal: reorder uniform variables
This might improve memory allocations.

This makes the code more consistent with HLSL's packing rule [1]

[1] https://docs.microsoft.com/en-us/windows/win32/direct3dhlsl/dx-graphics-hlsl-packing-rules
2022-03-05 22:12:08 +09:00
Hajime Hoshi
9c6b7aaca3 internal/ui: catch the error at At correctly 2022-03-05 01:44:59 +09:00
Hajime Hoshi
df2133186d internal/shaderir: bug fix: test failures 2022-03-04 19:01:58 +09:00
Hajime Hoshi
3c1e64dd67 internal/shaderir/metal: bug fix: define the 'mod' function correctly
Closes #2006
2022-03-04 18:05:44 +09:00
Hajime Hoshi
d4d4b9c070 internal/graphicsdriver/metal, internal/graphicsdriver/opengl: more efficient modulo 2022-03-04 03:47:55 +09:00
Hajime Hoshi
ed22052e5f internal/graphicscommand: add a comment 2022-02-28 00:15:52 +09:00
Hajime Hoshi
dd8900ea48 internal/graphicsdriver: refactoring: choose the graphics driver at this package 2022-02-27 23:51:19 +09:00
Hajime Hoshi
99f8e335ee ebiten: refactoring 2022-02-27 22:21:57 +09:00
Hajime Hoshi
77f765d483 internal/testing: bug fix: considering the case when Y is inverted
Closes #2003
2022-02-27 22:14:32 +09:00
Hajime Hoshi
4ca1220671 internal/graphicscommand: bug fix: compile error, test failures 2022-02-27 20:13:21 +09:00
Hajime Hoshi
b22309a0e5 internal/graphicsdriver: replace Pixels with ReadPixels
Now preparing a byte slice is the caller's responsibility.
2022-02-27 20:03:13 +09:00
Hajime Hoshi
1cb7633ff6 internal/ui: bug fix: atomic.Value.Store cannot be called when a differnet type value is already stored 2022-02-27 17:41:19 +09:00
Hajime Hoshi
566957dc1c internal/graphicsdriver/metal: invert Y at the vertex shader
Instead of using a negative height in the viewport, invert the Y direction
at the vertex shader. This is a little more readable as a negative height
is hacky.

This is a preparation for DirectX 12. DirectX 12's coodination system
is very similar to Metal, but doesn't treat a negative height in its
viewport unfortunately.

Updates #1007
2022-02-27 01:53:03 +09:00
divVerent
ea35296be7
ebiten: provide SetScreenFilterEnabled, a way to disable the default screen filter (#1997)
Using FilterNearest rather than filterScreen or FilterLinear speeds up a
Dell E6500 from 23fps->36fps and 27fps->48fps.

Updates #1772
2022-02-24 03:46:27 +09:00
divVerent
f2209a0b51
internal/atlas: optimization: send premultiplied alpha from vertex to fragment shader. (#1996)
Note that this applies only to the builtin shaders - interface for Kage stays
unchanged for compatibility.

Minor compatibility delta: when interpolating alpha values, previous code has
created nonsense values, such as, when interpolating from
fully-transparent-black (0,0,0,0) to opaque-white (1,1,1,1), something like
half-transparent-grey (0.25,0.25,0.25,0.5) where half-transparent-white
(0.5,0.5,0.5,0.5) is used by the new code.

I assume this is a strict improvement, however this may warrant some testing.

Possible later improvement could be moving the premultiplication from fragment
shader to CPU. Did not do this as it makes the code rather inconsistent of Kage
vs built-in shader usage.

Updates #1772
2022-02-24 02:27:50 +09:00
divVerent
476f4e3f9a
internal/gamepad: fix SetWindowLongPtrW crash on 32-bit Windows (#1999)
Closes #1998
2022-02-23 23:18:20 +09:00
Hajime Hoshi
8b7273b74a internal/graphicsdriver/metal: call PresentDrawable only when necessary 2022-02-22 01:37:13 +09:00
Hajime Hoshi
ee911fd892 internal/graphicsdriver/metal: fix an error message 2022-02-20 22:01:36 +09:00
Hajime Hoshi
bf33658e64 internal/gamepad: respect original names more 2022-02-15 04:07:11 +09:00
Hajime Hoshi
f17d222a4b internal/atlas: resolve deferred every frame instead of every tick
Resolving defferred functions doesn't have to be done every tick. Rather,
this should be done every frame as this is related to rendering.
2022-02-14 03:45:58 +09:00
Hajime Hoshi
4949c49cd0 internal/ui: refactoring 2022-02-14 03:39:02 +09:00
Hajime Hoshi
871121abe3 internal/ui: refactoring: remove (*contextImpl).layout 2022-02-14 02:59:02 +09:00
Hajime Hoshi
cffa123405 internal/ui: refactoring: remove sizeChanged for js
It is safe to call Layout every frame.
2022-02-14 02:50:32 +09:00
Hajime Hoshi
e2f0878a4c internal/ui: refactoring: remove sizeChanged
It is safe to call Layout every frame.
2022-02-14 02:17:52 +09:00
Hajime Hoshi
fcd4453e4f ebiten: remove RunOnMainThread
Unfortunately, there are several issues in RunOnMainThread:

 * RunOnMainThread cannot be portable: It is impossible to implement this
   correctly on mobiles.
 * RunOnMainThread doesn't make sense on mobiles: the rendering works on
   a different thread (goroutine) on mobiles.
 * RunOnMainThread can cause deadlocks very easily.

Until we find a better solution, let's remove this.

Closes #1945
2022-02-14 01:49:42 +09:00
Hajime Hoshi
e09c1bf8f1 internal/ui: refactoring: remove an error value from runOnAnotherThreadFromMainThread 2022-02-14 00:55:58 +09:00
Hajime Hoshi
ce3f83958e internal/graphicscommand: rename RunOnMainThread -> RunOnRenderingThread 2022-02-14 00:20:49 +09:00
Hajime Hoshi
b695cb928a internal/ui: remove RunWithoutMainLoop in non-mobile environments 2022-02-13 22:31:48 +09:00
Hajime Hoshi
82b9f7dc56 ebiten: refactoring: remove setScreenClearedEveryFrame 2022-02-13 20:40:46 +09:00
Hajime Hoshi
0c1c40995c internal/ui: rename types and members: uiContext -> gameForUI 2022-02-13 20:20:46 +09:00
Hajime Hoshi
29382b424b internal/ui: refactoring: remove some exposed functions 2022-02-13 20:09:13 +09:00
Hajime Hoshi
08defeeded internal/ui: move more logics to internal/ui 2022-02-13 20:02:49 +09:00
Hajime Hoshi
9b2f0b6c56 internal/ui: rename ResetForFrame -> ResetForTick
Resetting happens every tick, not every frame.
2022-02-13 19:54:40 +09:00
Hajime Hoshi
a2cb9fda82 internal/ui: make adjustPosition concurrent-safe 2022-02-13 19:52:39 +09:00
Hajime Hoshi
31aa01131d ebiten: refactoring: reduce call of ui.Get() 2022-02-13 19:40:48 +09:00
Hajime Hoshi
6a8e45e6c1 internal/ui: refactoring: simplify ResetForFrame
Updating the layout is already done every frame, so doing this in
ResetForFrame is not needed.

Updates #490
2022-02-13 19:31:35 +09:00
Hajime Hoshi
7b164882fc internal/ui: refactoring: move AdjustPosition to the package internal/ui 2022-02-13 19:14:29 +09:00
Hajime Hoshi
08ae7006ef internal/ui: refactoring: move some logics to internal/ui 2022-02-13 19:02:59 +09:00
Hajime Hoshi
2609d73a1a internal/ui: refactoring: move some logics to internal/ui 2022-02-13 18:01:18 +09:00
Hajime Hoshi
b282b1805b internal/ui: refactoring: add ui.SetError
This is a preparation to move uiContext to the package internal/ui.
2022-02-13 17:17:08 +09:00
Hajime Hoshi
ab1ad2c72f .github/workflow: add a test to build with the build tag ebitencbackend 2022-02-13 16:57:48 +09:00
Hajime Hoshi
73d995740f internal/ui: bug fix: compile error with ebitencbackend 2022-02-13 16:48:30 +09:00
Hajime Hoshi
e9cfbc1630 internal/ui: refactoring: remove Graphics() 2022-02-13 04:17:39 +09:00
Hajime Hoshi
1c57393393 internal/graphicsdriver/metal: refactoring 2022-02-13 01:00:20 +09:00
Hajime Hoshi
5f59807284 internal/gamepad: refactoring 2022-02-12 03:49:09 +09:00
Hajime Hoshi
ab5daa0f90 internal/ui: separate graphics_ios.go to each archtecture
This change removes the support of 32bit iOS. 32bit iOS is no longer
supported by Go 1.15.
2022-02-12 02:14:32 +09:00
Hajime Hoshi
162f62f54e internal/graphicsdriver/metal/mtl: bug fix: test compile error 2022-02-11 23:23:22 +09:00
Hajime Hoshi
176e984a58 internal/ui: refactoring: remove dependency on the package mtl 2022-02-11 23:11:49 +09:00
Hajime Hoshi
6f3c6d6c1b internal/graphicsdriver/meta: rename function 2022-02-11 22:47:13 +09:00
Hajime Hoshi
cc4e2f08be internal/graphicsdriver/metal: rename files 2022-02-11 21:49:05 +09:00
Hajime Hoshi
76848f48e6 internal/ui: simplify build tags 2022-02-11 20:47:14 +09:00
Hajime Hoshi
2c2c4bc428 ebiten: add WindowResizingModeType and its constants and functions
This allows a new state to disallow resizing the window but allow
making the window fullscreen on macOS by a user.

This change adds the new type WindowResizingModeType. There are
these constants of this type:

 * WindowResizingModeDisabled
 * WindowResizingModeOnlyFullscreenEnabled
 * WindowResizingModeEnabled

Closes #1819
2022-02-11 04:59:04 +09:00
Hajime Hoshi
f1987cae10 internal/ui: refactoring 2022-02-10 19:35:51 +09:00
Hajime Hoshi
35b9dd0846 internal/ui: give up SetWindowAspectRatioFixed
Unfortunately, it is almost impossible to provide a consistent behavior
to keep the aspect ratio of the window on Windows. Instead of having an
incomplete API, let's remove this.

Closes #1988
2022-02-10 18:35:00 +09:00
Hajime Hoshi
0291986658 internal/ui: bug fix: make the window resizable after the window is created
Making the window resizable BEFORE the window is created doesn't
work correctly, especially when switching to enable resizing later.

Closes #1987
2022-02-10 00:53:22 +09:00
Hajime Hoshi
5899470511 internal/ui: enable vsync even when resizing the window
Now I couldn't see the issue. Probably the implementation of
internal/graphicsdriver/metal has changed since the last fix, but
I am not sure.

Updates #1740
Closes #1954
2022-02-09 23:59:38 +09:00
Hajime Hoshi
edca32e520 internal/ui: bug fix: do not set the minimum window width for macOS
Shrinking a window size by a cursor sometimes makes a smaller window
than 126px. To avoid such flaky behavior, do not set the limitation of
the minimum window width.

On Linux/UNIX, there should not be reasons to limit the window width.

Updates #165
2022-02-09 23:30:26 +09:00
Hajime Hoshi
ad675640b1 internal/ui: bug fix: the aspect ratio should update the window size limits
Updates #1804
2022-02-09 23:18:41 +09:00
Hajime Hoshi
f2da62a175 internal/ui: refactoring 2022-02-09 22:22:14 +09:00
Hajime Hoshi
57c123a412 internal/ui: add comments
Updates #1804
2022-02-09 22:16:31 +09:00
Hajime Hoshi
891ca2a08d ebiten: add IsWindowAspectRatioFixed
This also updates examples/windowsize.

Closes #1804
2022-02-09 20:06:18 +09:00
Hajime Hoshi
7482cae978 internal/ui: bug fix: the aspect ratio must be updated whenever the window size is forcibly updated
This also adds a new flag -aspectratiofixed to examples/windowsize

Updates #1804
2022-02-09 19:56:50 +09:00
Hajime Hoshi
740dfd5aed internal/glfw: refactoring: keep the original API when possible
Updates #1804
2022-02-09 19:36:47 +09:00
Hajime Hoshi
623c050537 ebiten: rename SetKeepWindowAspectRatio -> SetWindowAspectRatioFixed
Updates #1804
2022-02-09 19:29:55 +09:00