mirror of
				https://github.com/RGBCube/serenity
				synced 2025-10-31 10:22:45 +00:00 
			
		
		
		
	 7f46d31849
			
		
	
	
		7f46d31849
		
	
	
	
	
		
			
			Instead of each card being responsible for painting its own bitmaps, we now have a CardPainter which is responsible for this. It paints a given card the first time it is requested, and then re-uses that bitmap when requested in the future. This saves memory for duplicate cards (such as in Spider where several sets of the same suit are used) or unused ones (for example, the inverted cards which are only used by Hearts). It also means we don't throw away bitmaps and then re-create identical ones when starting a new game. We get some nice memory savings from this: | | Before | After | Before (Virtual) | After (Virtual) | |:----------|---------:|---------:|-----------------:|----------------:| | Hearts | 12.2 MiB | 9.3 MiB | 25.1 MiB | 22.2 MiB | | Spider | 12.1 MiB | 10.1 MiB | 29.2 MiB | 22.9 MiB | | Solitaire | 16.4 MiB | 9.0 MiB | 25.0 MiB | 21.9 MiB | All these measurements taken from x86_64 build, from a fresh launch of each game after the animation has finished, but without making any moves. The Hearts value will go up once inverted cards start being requested.
		
			
				
	
	
		
			9 lines
		
	
	
	
		
			174 B
		
	
	
	
		
			CMake
		
	
	
	
	
	
			
		
		
	
	
			9 lines
		
	
	
	
		
			174 B
		
	
	
	
		
			CMake
		
	
	
	
	
	
| set(SOURCES
 | |
|     Card.cpp
 | |
|     CardGame.cpp
 | |
|     CardPainter.cpp
 | |
|     CardStack.cpp
 | |
| )
 | |
| 
 | |
| serenity_lib(LibCards cards)
 | |
| target_link_libraries(LibCards LibC LibCore LibConfig LibGUI)
 |