Commit Graph

22 Commits

Author SHA1 Message Date
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
RoosterDragon
7030d8b2b6 Changed HardwarePalette.ApplyModifiers to be more efficient.
- Add separate ImmutablePalette and MutablePalette classes since the distinction is extremely important to HardwarePalette.
- Keep a cache of palettes in HardwarePalette to avoid reallocation them every time ApplyModifiers is called.
- Palettes that are not allowed to be modified are copied to the buffer once when added, rather than every time ApplyModifiers is called.
- The AdjustPalette method now takes a read-only dictionary to prevent the dictionary being messed with.
- Added a constant for the palette size to remove its usage as a magic number in several areas.
- The ColorPreviewManagerWidget is annoying in that it needs to actually permanently update a palette after it has been added. To allow this, HardwarePalette now allows a palette to be replaced after initialization. The WorldRenderer therefore now also updates the PaletteReference it created earlier with the new palette to prevent stale data being used elsewhere.
2014-06-28 01:11:48 +01:00
RoosterDragon
4ce8a4a648 Use Marshal.Copy for faster array copying.
- Rewrite several methods to use Marshal.Copy to copy data faster and more succinctly compared to doing it manually.
- Rewrite Sheet.AsBitmap(TextureChannel, Palette) with a faster and more self descriptive loop.
2014-06-11 05:02:38 +01:00
Paul Chote
e347cdfb32 Merge pull request #5410 from RoosterDragon/IDisposable
Disposable fixup
2014-06-11 10:55:44 +12:00
RoosterDragon
a598a01108 Fixed IDisposable implementation and usage.
- Implement IDisposable interface correctly, with sealed classes where possible for simplicity.
- Add using statement around undisposed local variables.
2014-06-10 11:23:55 +01:00
Pavlos Touboulidis
7d352fdad1 MapCache performance improvements 2014-05-31 23:49:04 +03:00
Pavlos Touboulidis
441d602a6d Fix thread synchronization problem with Sheet.dirty 2014-05-31 17:26:24 +03:00
Paul Chote
4935266945 Merge FileFormats dll into Game and reorganise namespaces. 2014-04-17 01:20:47 +12:00
Paul Chote
013ad0617e Allow sheets to wrap an ITexture directly. 2013-06-15 19:16:07 +12:00
Paul Chote
c13c989fe8 Allow sheet contents to be exported to bitmap. 2013-05-15 19:24:19 +12:00
Paul Chote
7d543abb92 Always store Sheet data as bytes. 2013-05-15 19:24:19 +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
Paul Chote
dbd076543b Low level loadscreen displays earlier 2010-08-25 21:17:05 +12:00
Chris Forbes
0a041fe425 use byte[] backing for Sheet. bitmap backing is still available for Chrome RGBA hack. 2010-08-19 19:22:03 +12:00
Chris Forbes
1595c6a0ed interim hack to support use of raw data in Sheet 2010-08-19 18:42:45 +12:00
Bob
ede160f1b6 move some more (gameplay related) widgets into mods/ 2010-07-30 20:55:03 +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
d37a59d1c9 proper handling of dirty sheets (about 2 years overdue) 2010-03-17 23:29:59 +13:00
alzeih
7881deca30 Everything is now OpenRA, not OpenRa 2010-02-27 21:10:22 +13:00