Hajime Hoshi
e0790ee950
Revert "graphics: Delay draw commands and execute them only when needed"
...
This reverts commit 0c70823f27
.
Reason: Switching apps on Android sometimes broke the screen
2019-09-19 01:18:53 +09:00
Hajime Hoshi
0c70823f27
graphics: Delay draw commands and execute them only when needed
...
This change introduces a queue for delayed graphics commands.
When an image's pixels are retrieved or the screen is rendered,
Ebiten calculates the set of the necessary draw commands and
execute them.
This reduces the number of draw calls especially for the launching
phase.
Fixes #921
2019-09-19 01:09:48 +09:00
Hajime Hoshi
464713f19d
graphics: Refactoring
2019-08-25 22:06:20 +09:00
Hajime Hoshi
3646e7930d
graphics: Bug fix: the flag and the enqueueing operation must be protected by a same mutex
...
It was theoretically possible that an item was enqueued even
though the flag said it should not.
2019-08-25 21:22:54 +09:00
Hajime Hoshi
fc939fabb8
graphics: Bug fix: Copy variables out of the closures
2019-08-25 21:06:44 +09:00
Hajime Hoshi
d2312f1450
shareable: Lock before BeginFrame
...
This make package shareable more consistent. The mutex is lock
after EndFrame and before BeginFrame, and the similar rule will be
applied at launching (BeginFrame unlocks the lock in any cases).
Instead, package ebiten queues image operations if BeginFrame and
doesn't create provisional non-shared images. This should improve
performance at launching since this reduces the number of draw
calls, especifally for creating new images.
Updates #879 .
Updates #921 .
2019-08-25 18:12:04 +09:00
Hajime Hoshi
3960a4bbdf
restorable: Add (*Image).Fill
...
This resets the infomation for restoring if possible. This makes
it more efficient to use offscreens.
2019-08-25 02:57:44 +09:00
Hajime Hoshi
b8eeded538
graphics: Remove 'resetRestoringState'
...
This is basically a revert of 2d079b123f
As filling can happen on a part of a shared image, resetting the
restoring state was wrong.
2019-08-25 02:18:51 +09:00
Hajime Hoshi
e931494c66
shareable: Allocate the screen framebuffer image lazily
...
This improves consistency.
2019-08-25 00:43:29 +09:00
Hajime Hoshi
ef56d0a535
Refactoring: isRunning -> isImageAvailable
2019-08-25 00:14:37 +09:00
Hajime Hoshi
c49815a2b2
docs: Update the link
2019-08-22 23:16:44 +09:00
Hajime Hoshi
07c484fa49
graphics: Fix documentation
2019-08-21 01:43:08 +09:00
Hajime Hoshi
42d7cce989
graphics: Update docs about (*Image).Dispose
...
Updates #920
2019-08-19 22:41:45 +09:00
Hajime Hoshi
215e9e5c66
graphics: Fix wrong comments
2019-07-31 01:58:54 +09:00
Hajime Hoshi
fc42af208d
graphics: Use 1x1 image for empty images
...
This change leaves some empty images for DrawTriangles.
2019-07-30 23:11:06 +09:00
Hajime Hoshi
b210339786
graphics: Use 'negative' mipmap when enlarging a too small image
...
This is a hack to render edges correctly.
This works only when the filter is nearest.
Fixes #611
2019-07-30 23:03:55 +09:00
Hajime Hoshi
2d079b123f
restorable: Add ResetRestoringState to reset the state
...
After Fill command, the image doesn't have to keep the restoring
information. Now Fill command is as same as DrawTriangles, there
is no way for restorable.Image to know whether it can reset the
state or not. ResetRestoringState clears the state explicitly.
2019-07-20 14:04:02 +09:00
Hajime Hoshi
0dc1d0eba5
graphics: Clear/Fill is now implemented with DrawImage
...
Only clearing the screen still requires the special method.
2019-07-20 04:34:42 +09:00
Hajime Hoshi
801e0c4d47
graphics: Refactoring
2019-07-15 03:10:37 +09:00
Hajime Hoshi
e499535728
graphics: Move functions to the package ebiten
2019-06-26 22:23:09 +09:00
Hajime Hoshi
f40798b586
graphics: Move const definitions to driver package
...
Let's keep 'graphics' package as a package for utility functions
or testable functions as much as possible.
2019-06-26 01:05:13 +09:00
Hajime Hoshi
f48a72a43e
shareable: Refactoring: Remove PutQuadVertices
2019-06-22 21:13:44 +09:00
Hajime Hoshi
f3cdb0537b
graphics: Move the vertices backend to ebiten package
...
Now restorable/sharable packages cannot use the same vertices
backend, but I think this won't affect the performance
significantly.
2019-06-22 00:02:22 +09:00
Hajime Hoshi
3eee4754c5
graphics: Use the common vertices backend for PutVertex
2019-06-21 02:30:58 +09:00
Hajime Hoshi
008de78cec
graphics: Refactoring: Change QuadVertices -> PutQuadVertices for consistency
2019-06-21 02:20:31 +09:00
Hajime Hoshi
5c93462a9d
graphics: Refactoring: Merge DrawImage and drawImage
2019-06-12 23:54:59 +09:00
Hajime Hoshi
cc8e8aef19
graphics: Bounds doesn't work when the image is disposed
2019-05-11 22:44:52 +09:00
Hajime Hoshi
6022d8856e
graphics: Bug fix: level must be >= 0
...
There was a cache that level can be negative. This change fixes
this.
2019-04-25 02:49:59 +09:00
Hajime Hoshi
cce41e8152
graphics: Rename DrawImage -> DrawTriangles for consistency
2019-04-22 23:12:36 +09:00
Hajime Hoshi
c8cc98e307
graphics: Fix documents about At
2019-04-11 14:12:22 -07:00
Hajime Hoshi
61156dd90e
graphics: Rename pixelsToSet -> pendingPixels
2019-04-11 14:02:41 -07:00
Hajime Hoshi
3cb9d18fc4
graphics: Bug fix: Too small mipmap
...
Bug: #839
2019-04-07 05:29:46 +09:00
Hajime Hoshi
5195161253
graphics: Remove SetFinalizer at Image
...
Package shareable should take care of this.
Finalizers are called at arbitrary timing in a different goroutine
and might cause tough problems. This might be related to #821 .
2019-02-22 11:08:34 +09:00
Hajime Hoshi
6c47e31f49
graphics: Do nothing at Dispose of a subimage
2019-02-22 00:08:19 +09:00
Hajime Hoshi
9595f7ae26
graphics: Refactoring: Use a value type of bounds instead of a pointer
2019-02-21 23:51:05 +09:00
Hajime Hoshi
5ed6565d1d
graphics: Bug fix: SubImage's SubImage's bounds was wrong
2019-02-21 23:44:57 +09:00
Hajime Hoshi
8f133c443e
graphics: Change the definition of isSubImage
2019-02-21 23:27:40 +09:00
Hajime Hoshi
75a0d109be
graphics: Rename isSubimage -> isSubImage
2019-02-21 23:24:02 +09:00
Hajime Hoshi
8934f8296f
graphics: Bug fix: Don't touch pixelsToSet when disposing a subimage
...
This change also removes finalizer for subimages since this is not
necessary.
Fixes #823
2019-02-21 23:07:11 +09:00
Hajime Hoshi
ef31a6bb21
graphics: Update comments about makeVolatile
2019-02-13 09:47:30 +09:00
Hajime Hoshi
83da4ea112
graphics: Forbid mipmap for a volatile image explicitly
2019-02-13 01:58:08 +09:00
Hajime Hoshi
5990da4844
graphics: Add makeVolatile instead of newVolatileImage
2019-02-13 00:41:26 +09:00
Hajime Hoshi
5fed3d3bed
shareable: Add MakeVolatile
2019-02-13 00:41:24 +09:00
Hajime Hoshi
b962d58097
graphics: Fix comments
2019-02-12 14:36:06 +09:00
Hajime Hoshi
a3eddeb50f
Improve panic messages
2019-02-06 23:43:03 -10:00
Jake Bentvelzen
4cb79888fe
graphics: Clear mipmap map to avoid unnecessary allocation ( #799 )
...
This change uses a pattern that Go 1.11+ compilers can optimize to a clear operation
https://github.com/golang/go/blob/master/doc/go1.11.html#L447
2019-01-27 21:30:30 +09:00
Hajime Hoshi
b5ee209e0b
graphics: Bug fix: Filter was not used when SourceRect is used
2019-01-24 14:22:53 +09:00
Hajime Hoshi
15b13c8b62
graphics: Fix comments to be more precise
2019-01-22 00:18:32 +09:00
Hajime Hoshi
8f3ef39d74
graphics: Fix some comments to adjust 80 chars in one line
2019-01-21 11:58:41 +09:00
Hajime Hoshi
29211238d3
graphics: Misspelling again
2019-01-21 11:24:43 +09:00
Hajime Hoshi
234f29e5f6
graphics: Misspelling
2019-01-21 11:22:35 +09:00
Hajime Hoshi
92d6c6bc58
graphics: Fix documents about DrawImage and ColorM
2019-01-21 11:19:23 +09:00
Hajime Hoshi
aa2919ada4
graphics: Add comments about DrawImage
2019-01-20 03:27:02 +09:00
Hajime Hoshi
10cb0bba5f
graphics: Add documentation about texture atlas size
2019-01-19 22:14:50 +09:00
Hajime Hoshi
c1c0306471
graphics: Update the document about DrawImage
2019-01-19 22:14:04 +09:00
Hajime Hoshi
58cc5cb105
graphics: Better error message for At and Set ( #790 )
2019-01-19 02:59:22 +09:00
Hajime Hoshi
dd59d8ae6e
Fix comments
2019-01-19 02:30:06 +09:00
Hajime Hoshi
107dfe5074
graphics: Improve Set speed
...
On GopherJS, copying a struct is very heavy. This change avoids
copying (color) structs when possible.
2019-01-14 04:25:43 +09:00
Hajime Hoshi
6b110bf99e
graphics: Better implementation of Set
2019-01-14 04:07:26 +09:00
Hajime Hoshi
128e99b6af
graphics: Implement (*Image).Set
2019-01-14 02:25:36 +09:00
Hajime Hoshi
1e1f309a1c
shareable: Add Fill
...
Before introducing Fill, filling an image with a solid color was
implemented by ReplacePixels. When an offscreen image is used, the
offscreen image is not fully cleared or filled with a color and
out of (0,0)-(width,height) region. This causes a glitch thin line
on mobile platforms.
This change adds (*shareable.Image).Fill to fill the whole
framebuffer region of the image.
2019-01-13 02:12:47 +09:00
Hajime Hoshi
d5e6e6893e
graphics: Refactoring
2019-01-13 00:56:33 +09:00
Hajime Hoshi
ea9eac0461
graphics: Add explicit types for documents (godoc.org)
2018-12-24 19:36:41 +09:00
Hajime Hoshi
f1582c2d73
graphics: Add Address representing a sampler address mode
...
Fixes #761
2018-12-24 17:29:31 +09:00
Hajime Hoshi
529cd3376b
graphics: Fix comments about Vertex
2018-12-23 06:14:35 +09:00
Hajime Hoshi
189b8a17e9
graphics: Use source-border check even at DrawTriangles
...
DrawTriangles can now take a sub-image.
2018-12-23 03:24:39 +09:00
Hajime Hoshi
1a54ff34e6
graphics: Forbid nil at ReplacePixels explicitly
2018-11-28 22:26:34 +01:00
Hajime Hoshi
b48d501bc0
graphics: Explicit limitation of indices at DrawTriangles
...
Fixes #728
2018-11-23 19:02:10 +09:00
Hajime Hoshi
7586c660d5
graphics: Change the number of floats for a vertex from 10 to 12
...
This is a preparation for Metal, that forces 4 floats for a vertex
position.
2018-11-17 15:30:11 +09:00
Hajime Hoshi
dfb63852c2
graphics: Refactoring
2018-11-09 01:40:05 +09:00
Hajime Hoshi
9f0d14dd05
graphics: Add tests for #732
2018-11-09 00:48:21 +09:00
Hajime Hoshi
f54bdfa159
Reland: graphics: Bug fix: a sub image's Size was wrong
...
Size() usages are also fixed.
Fixes #732
2018-11-08 12:58:14 +09:00
Hajime Hoshi
27331024af
Revert "graphics: Bug fix: a sub image's Size was wrong"
...
This reverts commit 76ac850f6b
.
Reason: This breaks many examples
2018-11-08 12:19:38 +09:00
Hajime Hoshi
76ac850f6b
graphics: Bug fix: a sub image's Size was wrong
...
Fixes #732
2018-11-08 04:22:19 +09:00
seebs
74e204d952
graphics: Speed up DrawTriangles ( #723 )
...
DrawTriangles is expensive and slow because of massive memory
allocation and garbage collection costs. This patch moves from ~47TPS
on my laptop (with ~24k triangles) to 60TPS. The first part
is just allocating the right size of vertex buffer up front; that
got to about 55TPS. The second part replaces the frequent
allocations of []float32 in Vertex() calls with writing the
desired values into a provided destination slice.
Time spent in drawing triangles for 1,000 frames:
13.07s baseline
11.09s preallocate whole buffer to avoid resizing
6.13s use new PutVertex function
This might need some cleanup, but I think it's good evidence that
the design change is viable.
2018-10-31 10:53:17 +09:00
Hajime Hoshi
ec92f61a3e
graphics: Misspelling
2018-10-29 02:05:59 +09:00
Hajime Hoshi
27ee54b008
graphics: Forbid using a subimage at DrawTriangles ( #727 )
2018-10-29 01:37:59 +09:00
Hajime Hoshi
ce1c616f69
Merge graphics and graphicsutil
2018-10-28 23:03:06 +09:00
Hajime Hoshi
ff54d3b681
Move CompositeMode to graphics package
2018-10-28 21:49:47 +09:00
Hajime Hoshi
06f2052817
Add graphics package and move Filter to graphics
2018-10-28 20:25:52 +09:00
Hajime Hoshi
2da5192510
Rename graphics -> graphicscommand
2018-10-28 20:10:05 +09:00
Hajime Hoshi
3349a2c520
graphics: Add comments
2018-10-28 19:41:39 +09:00
Hajime Hoshi
781554ecb9
graphics: Refactoring
2018-10-28 19:35:01 +09:00
Hajime Hoshi
710f56531f
graphics: Experimental: (*image.Image).SubImage
...
Fixes #722
2018-10-28 02:19:14 +09:00
Hajime Hoshi
41877bba0b
graphics: Add image state check at DrawTriangles
2018-10-28 01:43:28 +09:00
Hajime Hoshi
170f0fcaa9
graphics: Refactoring
2018-10-28 01:39:58 +09:00
Hajime Hoshi
5f04f05cb1
graphics: Add comments
2018-10-26 03:29:20 +09:00
Hajime Hoshi
d3bd858aba
graphics: Bug fix: Mipmap was not invalidated at DrawTriangle
...
Fixes #725
2018-10-26 02:08:18 +09:00
Hajime Hoshi
8b82667df1
graphics: Bug fix: Violating edge pixels with linear filter
...
Fixes #724
2018-10-26 00:48:51 +09:00
Hajime Hoshi
58f4feda8d
graphics: Refactoring (preparing SubImage)
2018-10-25 12:48:24 +09:00
Hajime Hoshi
765af5a7af
gofmt -s -w
2018-10-25 12:47:27 +09:00
Hajime Hoshi
ce60f44490
graphics: Add (*mipmap).original()
2018-10-25 02:11:54 +09:00
Hajime Hoshi
15cad6ed9a
graphics: Rename shareableImages -> mipmap
2018-10-25 02:05:25 +09:00
Hajime Hoshi
022c40aa17
graphics: Move creating mipmap logic to shareableImages
2018-10-25 01:35:34 +09:00
Hajime Hoshi
4cd3e3ae30
Update go.mod/go.sum
2018-10-24 01:16:17 +09:00
Hajime Hoshi
7494b19dea
graphics: Refactoring: Add shareableImages struct
2018-10-24 01:09:59 +09:00
Hajime Hoshi
5e09da1298
graphics: Bug fix: don't apply color matrix when creating mipmap images
...
TODO: Add tests.
Fixes #710
2018-10-11 02:34:07 +09:00
Yuval Langer
8ba787522f
Fix minor typo ( #706 )
2018-10-09 03:19:27 +09:00
Hajime Hoshi
8772d310fe
Revert "Revert "graphics: Fix documentation about DrawImage""
...
This reverts commit f16c7cb90d
.
Reason: Oops, I reverted a wrong commit
2018-08-14 12:27:18 +09:00
Hajime Hoshi
f16c7cb90d
Revert "graphics: Fix documentation about DrawImage"
...
This reverts commit 610bf6e39f
.
Reason: This caused a new black line at the bottom (macOS).
2018-08-14 12:26:28 +09:00