Commit Graph

51 Commits

Author SHA1 Message Date
Paul Chote
de4a7cecf0 Rework multi-resolution sprite handling:
- Sprite.Bounds now refers to rectangles in the source image.
  Use this when copying pixels, etc.
- Sprite.Size now refers to sizes in effective pixel coordinates.
  Use this when rendering.
- Sheet.DPIScale has been removed.
- "Density" term is introduced to refer to the number of artwork
  pixels per effective pixel.
2020-02-26 23:47:15 +01:00
Paul Chote
d91495a041 Allocate 1px empty margin between sprites. 2020-01-26 20:22:49 +01:00
Paul Chote
1111ce4754 Add support for 32 bit BGRA sprites. 2020-01-17 16:49:58 +01:00
abcdefg30
23b3c237b7 Update the year numbers in all license headers to 2020 2020-01-05 17:00:34 +00:00
Paul Chote
ab4a7e3558 Replace System.Drawing primitives with our own. 2019-03-04 18:26:42 +00:00
abcdefg30
cadbd0d9ab Change the year number in all cs headers from 2018 to 2019 2019-01-26 23:15:21 +01:00
Paul Chote
84e965835b Remove System.Bitmap from badge and mod icons. 2019-01-08 21:20:06 +00:00
Paul Chote
f65a777366 Remove System.Bitmap from map preview loading. 2019-01-08 21:20:06 +00:00
Paul Chote
ba38878933 Add TextureChannel.RGBA for RBGA sprites. 2018-06-04 23:33:57 +02:00
Paul Chote
952f41b4e4 Add --dump-sequence-sheets Utility command.
This can be used to debug and optimize the texture
data that is uploaded to VRAM.
2018-04-30 02:05:43 +02:00
Arular101
8a60918841 Update copyright notice year to 2018 2018-01-17 00:47:34 +01:00
Paul Chote
956ea5197b Fix BGRA channel count. 2017-02-04 17:05:00 +00:00
Taryn Hill
43317e0f5d Update copyright notice year to 2017 2016-12-31 23:46:13 -06:00
Paul Chote
756d2428d9 Add depth support to TileSet. 2016-04-21 17:23:08 +01:00
Paul Chote
5d0990f1c6 Removing remaining SheetType.DualIndexed plumbing. 2016-04-15 16:53:37 -04:00
Paul Chote
2915db67c4 Add depth buffer support to sprites and sequences. 2016-04-15 09:42:29 -04:00
Paul Chote
e71225496b Clarify GPL version. 2016-02-21 16:30:48 +00:00
Paul Chote
b396965fd9 Update licence header year. 2016-02-21 16:27:31 +00:00
RoosterDragon
8e89a6a696 Simplify names, remove unused usings, remove redundant casts. 2016-01-17 21:35:36 +00:00
Paul Chote
e819ff832b Record the SheetType in each Sheet. 2015-10-17 22:28:19 +01:00
RoosterDragon
b48b994f16 Remove half-baked thread-safety mechanisms from Sheet.
Sheet is now thread-unsafe, rather than attempting to expose a dodgy thread safety model.
2015-05-20 18:50:28 +01:00
RoosterDragon
c313c52e96 Avoid a globally shared SheetBuilder in SpriteFont.
A globally shared sheet builder leaks memory and resources between mod switches. Instead, we create and inject the sheet builder during mod startup to ensure we still share the builder across all fonts, but can reclaim it when the mod is unloaded.
2015-01-19 21:04:17 +00:00
abcdefg30
8ca61aa917 Updated all year numbers 2015-01-09 21:18:05 +01:00
RoosterDragon
b28d999131 Made SheetBuilder rely on global settings rather than global renderer.
Additionally exposed an InitializeSettings method on game to initialize the global settings so that other classes can set up all the secret dependencies on the global settings required.
2014-12-22 17:39:19 +00:00
RoosterDragon
9cbac2d5e1 Clean up style of files affected by the last commit. 2014-12-22 17:34:02 +00:00
RoosterDragon
f0f02dff5c Dispose of graphics resources deterministically.
Textures, FrameBuffers and VertexBuffers allocated by the Sdl2 Renderer were only being released via finalizers. This could lead to OpenGL out of memory errors since resources may not be cleaned up in a timely manner. To avoid this, IDisposable has been implemented and transitively applied to classes that use these resources.

As a side-effect some static state is no longer static, particularly in Renderer, in order to facilitate this change and just for nicer design in general.

Also dispose some bitmaps.
2014-12-22 17:34:01 +00:00
RoosterDragon
ff16690b86 Lazily generate buffer in Sheet.
The managed byte buffer is created on demand, meaning a newly allocated sheet will not waste memory holding onto the buffer until some changes are actually required to be written. This avoids a newly allocated sheet wasting memory on buffers that do not differ from their backing texture.
2014-11-29 12:04:00 +00:00
RoosterDragon
3a30748f05 Reduce working set by releasing buffers for sheets.
Sheets carry a managed buffer of data that allows updates to be made without having to constantly fetch and set data to the texture memory of the video card. This is useful for things like SheetBuilder which make small progressive changes to sheets.

However these buffers are often large and are kept alive because sheets are referenced by the sprites that use them. If this buffer is explicitly null'ed when it is no longer needed then the GC can reclaim it. Sometimes a buffer need not even be created because the object using the sheet only works on the texture directly anyway.

In practise, this reduced memory consumed by such buffers from ~165 MiB to ~112 MiB (at the start of a new RA skirmish mission).
2014-07-02 17:25:56 +01:00
ScottNZ
dbffce81a6 Remove unused usings 2014-06-15 22:16:40 +12:00
RoosterDragon
b733465f33 General uncontroversial cleanup:
- Made private methods static where possible (runtime can elide checking the object for null).
- Declared attribute classes as sealed (allows reflection on attributes to complete faster).
- Moved some static cctor's into field initializers (static cctor's are slower than static field initializers).
- Made classes static if they contained only static methods (can't create instances of useless objects).
- Use inferable Exts.Lazy and not new Lazy<T>().
- Added required STAThread attribute to CrashDialog.
- Removed unused parameters in private methods.
- Added Serializable attribute to exceptions.
- Added parameter name in calls to ArgumentNullException.
- Use of as operator instead of is + cast.
- Changed (x as Foo).Bar anti-pattern into ((Foo)x).Bar. Results in sensible cast exceptions on error rather than null dereferences.
- Removed unused method in NullShader.
2014-05-23 15:50:54 +01:00
Paul Chote
4935266945 Merge FileFormats dll into Game and reorganise namespaces. 2014-04-17 01:20:47 +12:00
Paul Chote
3f63eb4ec6 Allow SheetBuilder to be used from mod code. 2014-04-03 07:15:03 +13:00
Paul Chote
c30b18a9d6 Introduce MapCache and MapPreview for improved UI map previews. 2014-03-16 21:45:59 +13:00
Paul Chote
f92ce8bf51 Define a consistent interface for sprite loading. Fixes #4176. 2013-12-01 09:47:49 +13:00
Paul Chote
01155a655a Allow empty sprites to be allocated. 2013-12-01 09:47:48 +13:00
ScottNZ
1394c1dcee Remove some misc redundancies 2013-11-12 19:39:39 +13:00
Paul Chote
a1dd7cff7b Support additive blending for D2K explosions. 2013-08-14 17:31:02 +12:00
Paul Chote
da4a2f548b Support loading sprites with non-zero offsets. 2013-07-16 19:40:54 +12:00
Paul Chote
e5bcb88b0e Support sprites with an internal offset. 2013-06-15 19:16:08 +12:00
Paul Chote
013ad0617e Allow sheets to wrap an ITexture directly. 2013-06-15 19:16:07 +12:00
Paul Chote
0e1c12131a Generalize SheetBuilder overflow behavior. 2013-06-15 19:16:07 +12:00
Paul Chote
4ebe547a05 Allow SheetBuilder to generate 1/2/4 channel sheets.
This makes the SpriteFont RBGA sprite hack explicit,
and adds a DualIndexed option to be used by the voxel
renderer.
2013-05-15 20:18:41 +12:00
Paul Chote
891158ca44 Allow SheetBuilder to throw an exception on sheet overflow.
This removes unnecessary checks from TerrainRenderer
and will be used in the voxel renderer.
2013-05-15 20:18:41 +12:00
Chris Forbes
55036cd58c fix trailing whitespace everywhere 2011-09-26 08:40:39 +13:00
Paul Chote
094907c1a9 Update copyright header. Normalize line endings to LF. 2011-02-13 10:38:57 +13:00
Bob
0e16aa339d move SheetBuilder singleton onto ModData 2010-08-21 17:44:06 +12:00
alzeih
2f9f539857 big pile of Render refactoring 2010-07-21 18:59:33 +12:00
Chris Forbes
d5f12dd8ee trim down license spam in all files 2010-07-18 16:48:21 +12:00
Chris Forbes
e5951b1502 moved bridge support into ra 2010-05-20 18:16:09 +12:00
Chris Forbes
d37a59d1c9 proper handling of dirty sheets (about 2 years overdue) 2010-03-17 23:29:59 +13:00