Commit Graph

526 Commits

Author SHA1 Message Date
Hajime Hoshi
7ac1f62c52 graphics: Fix comments
Updates #983
2019-11-16 01:54:21 +09:00
Hajime Hoshi
c60a32a479 graphics: Avoid all copying pixels
This is a breaking change: ReplacePixels now takes the ownership
of the given pixels.

Fixes #983
2019-11-16 01:51:36 +09:00
Hajime Hoshi
77a8ece691 graphics: Remove unnecessary copying pixels
Updates #983
2019-11-16 01:38:38 +09:00
Hajime Hoshi
5027bc1af5 buffered: Allow Set before the game runs
Fixes #949
2019-10-12 03:13:29 +09:00
Hajime Hoshi
1b011e3864 graphics: Bug fix: unexpected panic at Set with an out-of-range position 2019-10-12 02:28:55 +09:00
Hajime Hoshi
2d2da09b85 graphics: At doesn't have to discard pending pixels 2019-10-05 00:18:45 +09:00
Hajime Hoshi
4c90674e17 graphics: Keep pendingPixels not to read pixels from GPU unnecessarily
Fixes #947
2019-10-05 00:14:52 +09:00
Hajime Hoshi
79b32c7601 graphics: Add buffered package
Moved the command queue to the package.
2019-09-21 22:34:37 +09:00
Hajime Hoshi
0a872b342a shareable: Change the argument to color.RGBA at Fill
The argument will be copied explicitly.
2019-09-21 21:16:46 +09:00
Hajime Hoshi
1c2c932c6c graphics: Remove MakeVolatile/IsVolatile 2019-09-21 14:53:52 +09:00
Hajime Hoshi
52b52e7d92 grpahics: Move DrawImage implementation to mipmap and remove (*mipmap).original() 2019-09-19 11:25:33 +09:00
Hajime Hoshi
e585fda253 grpahics: Move DrawTriangles implementation to mipmap 2019-09-19 11:15:14 +09:00
Hajime Hoshi
504a433540 graphics: Reduce original() usage 2019-09-19 02:27:20 +09:00
Hajime Hoshi
95bc445fea graphics: Refactoring: Remove imports 2019-09-19 02:17:35 +09:00
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
Hajime Hoshi
2360b2930f graphics: Add DrawTriangles
Fixes #624
2018-08-14 01:23:14 +09:00
Hajime Hoshi
610bf6e39f graphics: Fix documentation about DrawImage 2018-08-11 02:14:37 +09:00
Hajime Hoshi
690c3cf981 graphics: Embed 'scale' part of the color matrix
If the color matrix includes only 'scale' part, they are embedded
into vertices in order to reduce draw calls.

Fixes #662
2018-08-10 23:20:55 +09:00
Hajime Hoshi
3daaef2cab restorable: Refactoring: Use ReplacePixels(nil, ...) for clearing an image 2018-08-09 01:16:46 +09:00
Hajime Hoshi
c68c36b0b7 restoreable: Add ClearState to clear the state explicitly
Fixes #566
2018-08-09 00:12:45 +09:00
Hajime Hoshi
77e905eb25 Revert "graphics: Embed color matrices values to vertices (#655)"
This reverts commit 5a9235aaf9.
2018-08-06 01:44:31 +09:00
Hajime Hoshi
bf19f902af Revert "graphics: Fix DrawImage comment"
This reverts commit 8e6314f856.
2018-08-06 01:44:31 +09:00
Hajime Hoshi
bac0431c9f graphics: Simplify mipmap calculation 2018-08-03 00:02:49 +09:00
Hajime Hoshi
5c201af311 graphics: Bug fix: compile error 2018-07-31 01:56:59 +09:00
Hajime Hoshi
0956ca0ea6 graphicsutil: Add MipmapLevel 2018-07-31 01:47:03 +09:00
Hajime Hoshi
b8ab1363d2 graphics: Bug fix: mipmap level calculation 2018-07-31 01:02:09 +09:00
Hajime Hoshi
d7d02e6d6a Reland: graphics: mipmap images should be volatile when the base image is volatile
This is not a bug fix, but should improve performance.
2018-07-30 00:26:36 +09:00
Hajime Hoshi
20c8d7317c graphics: Add comments 2018-07-30 00:02:03 +09:00
Hajime Hoshi
5be58086b5 Revert "graphics: Bug fix: mipmap images should be volatile when the base image is volatile"
This reverts commit 0f82330009.
2018-07-29 23:58:46 +09:00
Hajime Hoshi
0f82330009 graphics: Bug fix: mipmap images should be volatile when the base image is volatile 2018-07-29 23:54:46 +09:00
Hajime Hoshi
8a221a5774 graphics: Use mipmap images for minifying images with linear filter
Fixes #578
2018-07-29 23:33:49 +09:00
Hajime Hoshi
8e6314f856 graphics: Fix DrawImage comment 2018-07-26 11:40:01 +09:00
Hajime Hoshi
5a9235aaf9
graphics: Embed color matrices values to vertices (#655)
Fixes #531
2018-07-26 11:37:27 +09:00
Hajime Hoshi
5249afc06b graphicsutil: Add QuadIndices 2018-07-21 03:40:37 +09:00
Hajime Hoshi
2e7745044d shareable: Fix Image.DrawImage to accept vertices and indices 2018-07-21 03:30:27 +09:00
Hajime Hoshi
6c8b7f8e9c graphics: Refactoring: Reduce error propagations 2018-07-12 03:08:50 +09:00
Hajime Hoshi
840c4d24df graphicsutil: Accept matrix parameters directly for performance 2018-06-19 00:19:32 +09:00
Hajime Hoshi
ac24a8382f graphicsutil: Extract matrix applying for performance 2018-06-17 19:45:09 +09:00
Hajime Hoshi
95561bbf6b affine: Use float32 values for GeoM
float32 was slow on GopherJS, but not slow on Wasm.
2018-06-17 15:38:10 +09:00
Hajime Hoshi
b4ace53596 affine: Remove GeoM to avoid GeoM allocations on the heap 2018-06-17 00:59:50 +09:00
Hajime Hoshi
e53fa53f7d graphics: Prefer ReplacePixels to DrawImage for small images 2018-05-03 11:52:04 +09:00
Hajime Hoshi
4d3d407205 graphics: Add comments to At 2018-05-01 18:07:52 +09:00
Hajime Hoshi
63c33b24df graphics: Refactoring 2018-04-16 01:51:32 +09:00
Hajime Hoshi
008ed26276 graphics: Check isDisposed at (*Image).Clear and Fill 2018-04-08 01:39:06 +09:00
Hajime Hoshi
c62e63f874 graphics: Remove 'filter' argument from newVolatileImage (#503) 2018-04-06 03:34:14 +09:00
Hajime Hoshi
7b5ad46e49 shareable: NewImage* now returns a cleared image 2018-04-06 02:08:12 +09:00
Hajime Hoshi
87daa82ad9 graphics: Replace emptyImage with dummyImage (not initialized) 2018-04-06 00:49:49 +09:00
Hajime Hoshi
abdfb3b713 graphics: Initialize (*Image).addr asap not to rely on the fact that fill is called 2018-04-06 00:35:18 +09:00
Hajime Hoshi
af0d6d7a48 graphics: Remove GuaranteedMaxImageSize 2018-04-03 22:59:19 +09:00
Hajime Hoshi
a36ea971b4 examples/airship: Improve z values 2018-03-12 03:18:07 +09:00
Hajime Hoshi
a335b0c5a3 graphics: Fix comments about MaxImageSize 2018-03-12 02:01:30 +09:00