Changeset - r28210:eaa3026e9a5f
[Not reviewed]
master
0 11 0
rubidium42 - 5 months ago 2023-11-30 00:29:23
rubidium@openttd.org
Remove: ZOOM_LVL_COUNT

This is the only enumeration with a COUNT and END. The logic of the COUNT
implied that BEGIN could be non-zero, but all but two uses of zoom level
assume that BEGIN is zero, making the separate count only confusing.
11 files changed with 16 insertions and 18 deletions:
0 comments (0 inline, 0 general)
src/blitter/32bpp_optimized.cpp
Show inline comments
 
@@ -277,7 +277,7 @@ template <bool Tpal_to_rgb> Sprite *Blit
 
	/* streams of pixels (a, r, g, b channels)
 
	 *
 
	 * stored in separated stream so data are always aligned on 4B boundary */
 
	Colour *dst_px_orig[ZOOM_LVL_COUNT];
 
	Colour *dst_px_orig[ZOOM_LVL_END];
 

	
 
	/* interleaved stream of 'm' channel and 'n' channel
 
	 * 'n' is number of following pixels with the same alpha channel class
 
@@ -285,10 +285,10 @@ template <bool Tpal_to_rgb> Sprite *Blit
 
	 *
 
	 * it has to be stored in one stream so fewer registers are used -
 
	 * x86 has problems with register allocation even with this solution */
 
	uint16_t *dst_n_orig[ZOOM_LVL_COUNT];
 
	uint16_t *dst_n_orig[ZOOM_LVL_END];
 

	
 
	/* lengths of streams */
 
	uint32_t lengths[ZOOM_LVL_COUNT][2];
 
	uint32_t lengths[ZOOM_LVL_END][2];
 

	
 
	ZoomLevel zoom_min;
 
	ZoomLevel zoom_max;
src/blitter/32bpp_optimized.hpp
Show inline comments
 
@@ -17,7 +17,7 @@ class Blitter_32bppOptimized : public Bl
 
public:
 
	/** Data stored about a (single) sprite. */
 
	struct SpriteData {
 
		uint32_t offset[ZOOM_LVL_COUNT][2]; ///< Offsets (from .data) to streams for different zoom levels, and the normal and remap image information.
 
		uint32_t offset[ZOOM_LVL_END][2]; ///< Offsets (from .data) to streams for different zoom levels, and the normal and remap image information.
 
		byte data[];                      ///< Data, all zoomlevels.
 
	};
 

	
src/blitter/32bpp_sse2.hpp
Show inline comments
 
@@ -72,7 +72,7 @@ public:
 
	};
 
	struct SpriteData {
 
		SpriteFlags flags;
 
		SpriteInfo infos[ZOOM_LVL_COUNT];
 
		SpriteInfo infos[ZOOM_LVL_END];
 
		byte data[]; ///< Data, all zoomlevels.
 
	};
 

	
src/blitter/8bpp_optimized.hpp
Show inline comments
 
@@ -18,7 +18,7 @@ class Blitter_8bppOptimized FINAL : publ
 
public:
 
	/** Data stored about a (single) sprite. */
 
	struct SpriteData {
 
		uint32_t offset[ZOOM_LVL_COUNT]; ///< Offsets (from .data) to streams for different zoom levels.
 
		uint32_t offset[ZOOM_LVL_END]; ///< Offsets (from .data) to streams for different zoom levels.
 
		byte data[];                   ///< Data, all zoomlevels.
 
	};
 

	
src/sound.cpp
Show inline comments
 
@@ -195,7 +195,7 @@ static void StartSound(SoundID sound_id,
 

	
 

	
 
static const byte _vol_factor_by_zoom[] = {255, 255, 255, 190, 134, 87};
 
static_assert(lengthof(_vol_factor_by_zoom) == ZOOM_LVL_COUNT);
 
static_assert(lengthof(_vol_factor_by_zoom) == ZOOM_LVL_END);
 

	
 
static const byte _sound_base_vol[] = {
 
	128,  90, 128, 128, 128, 128, 128, 128,
 
@@ -258,7 +258,7 @@ static void SndPlayScreenCoordFx(SoundID
 
			StartSound(
 
				sound,
 
				panning,
 
				_vol_factor_by_zoom[vp->zoom - ZOOM_LVL_BEGIN]
 
				_vol_factor_by_zoom[vp->zoom]
 
			);
 
			return;
 
		}
src/spritecache.cpp
Show inline comments
 
@@ -457,7 +457,7 @@ static void *ReadSprite(const SpriteCach
 

	
 
	Debug(sprite, 9, "Load sprite {}", id);
 

	
 
	SpriteLoader::Sprite sprite[ZOOM_LVL_COUNT];
 
	SpriteLoader::Sprite sprite[ZOOM_LVL_END];
 
	uint8_t sprite_avail = 0;
 
	sprite[ZOOM_LVL_NORMAL].type = sprite_type;
 

	
 
@@ -1051,4 +1051,4 @@ void GfxClearFontSpriteCache()
 
	}
 
}
 

	
 
/* static */ ReusableBuffer<SpriteLoader::CommonPixel> SpriteLoader::Sprite::buffer[ZOOM_LVL_COUNT];
 
/* static */ ReusableBuffer<SpriteLoader::CommonPixel> SpriteLoader::Sprite::buffer[ZOOM_LVL_END];
src/spriteloader/spriteloader.hpp
Show inline comments
 
@@ -62,7 +62,7 @@ public:
 
		void AllocateData(ZoomLevel zoom, size_t size) { this->data = Sprite::buffer[zoom].ZeroAllocate(size); }
 
	private:
 
		/** Allocated memory to pass sprite data around */
 
		static ReusableBuffer<SpriteLoader::CommonPixel> buffer[ZOOM_LVL_COUNT];
 
		static ReusableBuffer<SpriteLoader::CommonPixel> buffer[ZOOM_LVL_END];
 
	};
 

	
 
	/**
src/video/opengl.cpp
Show inline comments
 
@@ -1270,10 +1270,10 @@ void OpenGLBackend::ReleaseAnimBuffer(co
 
	Sprite *dest_sprite = (Sprite *)allocator(sizeof(*dest_sprite) + sizeof(OpenGLSprite));
 

	
 
	OpenGLSprite *gl_sprite = (OpenGLSprite *)dest_sprite->data;
 
	new (gl_sprite) OpenGLSprite(sprite->width, sprite->height, sprite->type == SpriteType::Font ? 1 : ZOOM_LVL_COUNT, sprite->colours);
 
	new (gl_sprite) OpenGLSprite(sprite->width, sprite->height, sprite->type == SpriteType::Font ? 1 : ZOOM_LVL_END, sprite->colours);
 

	
 
	/* Upload texture data. */
 
	for (int i = 0; i < (sprite->type == SpriteType::Font ? 1 : ZOOM_LVL_COUNT); i++) {
 
	for (int i = 0; i < (sprite->type == SpriteType::Font ? 1 : ZOOM_LVL_END); i++) {
 
		gl_sprite->Update(sprite[i].width, sprite[i].height, i, sprite[i].data);
 
	}
 

	
 
@@ -1323,7 +1323,7 @@ void OpenGLBackend::RenderOglSprite(Open
 
	Dimension dim = gl_sprite->GetSize(zoom);
 
	_glUseProgram(this->sprite_program);
 
	_glUniform4f(this->sprite_sprite_loc, (float)x, (float)y, (float)dim.width, (float)dim.height);
 
	_glUniform1f(this->sprite_zoom_loc, (float)(zoom - ZOOM_LVL_BEGIN));
 
	_glUniform1f(this->sprite_zoom_loc, (float)zoom);
 
	_glUniform2f(this->sprite_screen_loc, (float)_screen.width, (float)_screen.height);
 
	_glUniform1i(this->sprite_rgb_loc, rgb ? 1 : 0);
 
	_glUniform1i(this->sprite_crash_loc, pal == PALETTE_CRASH ? 1 : 0);
src/video/opengl.h
Show inline comments
 
@@ -108,7 +108,7 @@ public:
 
	/* SpriteEncoder */
 

	
 
	bool Is32BppSupported() override { return true; }
 
	uint GetSpriteAlignment() override { return 1u << (ZOOM_LVL_COUNT - 1); }
 
	uint GetSpriteAlignment() override { return 1u << (ZOOM_LVL_END - 1); }
 
	Sprite *Encode(const SpriteLoader::Sprite *sprite, AllocatorProc *allocator) override;
 
};
 

	
src/viewport.cpp
Show inline comments
 
@@ -1477,7 +1477,7 @@ void ViewportSign::UpdatePosition(int ce
 
 */
 
void ViewportSign::MarkDirty(ZoomLevel maxzoom) const
 
{
 
	Rect zoomlevels[ZOOM_LVL_COUNT];
 
	Rect zoomlevels[ZOOM_LVL_END];
 

	
 
	for (ZoomLevel zoom = ZOOM_LVL_BEGIN; zoom != ZOOM_LVL_END; zoom++) {
 
		/* FIXME: This doesn't switch to width_small when appropriate. */
src/zoom_type.h
Show inline comments
 
@@ -27,8 +27,6 @@ enum ZoomLevel : byte {
 
	ZOOM_LVL_OUT_32X,    ///< Zoomed 32 times out.
 
	ZOOM_LVL_END,        ///< End for iteration.
 

	
 
	ZOOM_LVL_COUNT = ZOOM_LVL_END - ZOOM_LVL_BEGIN, ///< Number of zoom levels.
 

	
 
	/* Here we define in which zoom viewports are */
 
	ZOOM_LVL_VIEWPORT = ZOOM_LVL_OUT_4X, ///< Default zoom level for viewports.
 
	ZOOM_LVL_NEWS     = ZOOM_LVL_OUT_4X, ///< Default zoom level for the news messages.
0 comments (0 inline, 0 general)