hajimehoshi / ebiten

Ebitengine - A dead simple 2D game engine for Go
https://ebitengine.org
Apache License 2.0
11.02k stars 660 forks source link

ebiten: enable to pass a regular `image.Image` to `DrawImage` and so on #2127

Closed hajimehoshi closed 2 years ago

hajimehoshi commented 2 years ago

This is still a draft.

Probably the concern is that this could cause a performance issue that is hard to investigate...

hajimehoshi commented 2 years ago

/CC @eihigh

hajimehoshi commented 2 years ago

If the composition mode is 'Copy', DrawImage would work as 'ReplacePixels'.

tinne26 commented 2 years ago

While I can see there are some benefits to setting up a cache, I think the alternative implementation without caching should also be considered. I think simply documenting that using images that are not *ebiten.Image can fall back to slow paths is acceptable. Users can still create their own *ebiten.Images when necessary. This is the same that happens today, albeit with multiple functions (DrawImage / Set / ReplacePixels) instead of just one.

hajimehoshi commented 2 years ago

The concern is that users might abuse DrawImage with image.Image even though we warn such usages are slow. Actually Set was used more often than I expected... Set didn't have such warnings so this was my responsibility, but I think basically we cannot control how often they are used as long as the API is easy to access.

hajimehoshi commented 2 years ago

This would contribute to the API's easiness, but make its simplicity worse. This is opposite to my policy unforutnately.