[Scummvm-cvs-logs] SF.net SVN: scummvm: [21850] scummvm/trunk/gui

lordhoto at users.sourceforge.net lordhoto at users.sourceforge.net
Thu Apr 13 15:21:00 CEST 2006


Revision: 21850
Author:   lordhoto
Date:     2006-04-13 15:20:50 -0700 (Thu, 13 Apr 2006)
ViewCVS:  http://svn.sourceforge.net/scummvm/?rev=21850&view=rev

Log Message:
-----------
Deletes color cache and custom dialog shading.

Modified Paths:
--------------
    scummvm/trunk/gui/ThemeNew.cpp
    scummvm/trunk/gui/theme.h
Modified: scummvm/trunk/gui/ThemeNew.cpp
===================================================================
--- scummvm/trunk/gui/ThemeNew.cpp	2006-04-13 21:52:23 UTC (rev 21849)
+++ scummvm/trunk/gui/ThemeNew.cpp	2006-04-13 22:20:50 UTC (rev 21850)
@@ -265,22 +265,14 @@
 	getExtraValueFromConfig(_configFile, "shadow_bottom_height", _shadowBottomHeight, 4);
 	
 	// inactive dialog shading stuff
-	_numCacheColors = 0;
-	_colorCacheTable = 0;
-	_usingColorCache = false;
 	_dialogShadingCallback = 0;
-	_shadingEpxressionR = _shadingEpxressionG = _shadingEpxressionB = "";
-	_shadingEffect = kShadingEffectNothing;
 	
 	if (_configFile.hasKey("inactive_dialog_shading", "extra")) {
 		_configFile.getKey("inactive_dialog_shading", "extra", temp);
-		bool createCacheTable = false;
-		
 		if (temp == "no_effect") {
 			// nothing
 		} else if (temp == "luminance") {
 			_dialogShadingCallback = &ThemeNew::calcLuminance;
-			_shadingEffect = kShadingEffectLuminance;
 			// don't cache colors for the luminance effect
 			//createCacheTable = true;
 		} else if (temp == "dim") {
@@ -298,38 +290,15 @@
 				if (_dimPercentValue != 0) {
 					_dimPercentValue = 256 * (100 - _dimPercentValue) / 100;
 					_dialogShadingCallback = &ThemeNew::calcDimColor;
-					createCacheTable = true;
-					_shadingEffect = kShadingEffectDim;
 				}
 			}
-		} else if (temp == "custom") {
-			if (_configFile.hasKey("shading_custom_r", "extra") && _configFile.hasKey("shading_custom_g", "extra")
-				&& _configFile.hasKey("shading_custom_b", "extra")) {
-					_configFile.getKey("shading_custom_r", "extra", _shadingEpxressionR);
-					_configFile.getKey("shading_custom_g", "extra", _shadingEpxressionG);
-					_configFile.getKey("shading_custom_b", "extra", _shadingEpxressionB);
-
-					_dialogShadingCallback = &ThemeNew::calcCustomColor;
-					createCacheTable = true;
-					_shadingEffect = kShadingEffectCustom;
-			} else {
-				warning("not all custom shading expressions are defined, please check for 'shading_custom_r', 'shading_custom_g' and 'shading_custom_b'");
-			}
 		} else {
 			warning("no valid 'inactive_dialog_shading' specified");
 		}
-		
-		if (createCacheTable) {
-			_numCacheColors = 65536;
-			_usingColorCache = true;
-			_colorCacheTable = new OverlayColor[_numCacheColors];
-			assert(_colorCacheTable);
-		}
 	}
 	
 	// load the colors from the config file
 	setupColors();
-	clearColorCache();
 
 	_imageHandles = imageHandlesTable;
 
@@ -400,7 +369,6 @@
 
 void ThemeNew::enable() {
 	init();
-	setupColorCache();
 	resetupGuiRenderer();
 	resetDrawArea();
 	_system->showOverlay();
@@ -408,7 +376,6 @@
 }
 
 void ThemeNew::disable() {
-	clearColorCache();
 	_system->hideOverlay();
 }
 
@@ -420,32 +387,19 @@
 		_dialog->screen.create(_screen.w, _screen.h, sizeof(OverlayColor));
 	}
 	
-	if (_colorCacheTable && topDialog) {
+	if (_dialogShadingCallback && topDialog) {
 		OverlayColor *col = (OverlayColor*)_screen.pixels;
-		uint8 r, g, b;
 		for (int y = 0; y < _screen.h; ++y) {
 			for (int x = 0; x < _screen.w; ++x) {
-				_system->colorToRGB(col[x], r, g, b);
-				r = (r >> 3) & 0x1F;
-				g = (g >> 2) & 0x3F;
-				b = (b >> 3) & 0x1F;
-				col[x] = _colorCacheTable[(r << 11) | (g << 5) | b];
+				col[x] = (this->*(_dialogShadingCallback))(col[x]);
 			}
 			col += _screen.w;
 		}
-	} else if (_dialogShadingCallback && topDialog) {
-		OverlayColor *col = (OverlayColor*)_screen.pixels;
-		for (int y = 0; y < _screen.h; ++y) {
-			for (int x = 0; x < _screen.w; ++x) {
-				col[x] = (this->*(_dialogShadingCallback))(col[x], false);
-			}
-			col += _screen.w;
-		}
 	}
 	
 	memcpy(_dialog->screen.pixels, _screen.pixels, _screen.pitch*_screen.h);
 	
-	if ((_colorCacheTable || _dialogShadingCallback) && topDialog)
+	if ((_dialogShadingCallback) && topDialog)
 		addDirtyRect(Common::Rect(0, 0, _screen.w, _screen.h), false, false);
 }
 
@@ -1331,181 +1285,22 @@
 	getColorFromConfig(_configFile, "scrollbar_slider_highlight_end", _colors[kScrollbarSliderHighlightEnd]);
 	
 	getColorFromConfig(_configFile, "caret_color", _colors[kCaretColor]);
-	
-	setupColorCache();
 }
 
 #pragma mark -
 
-void ThemeNew::setupColorCache() {
-	if (!_usingColorCache)
-		return;
-	if (!_colorCacheTable) {
-		_colorCacheTable = new OverlayColor[_numCacheColors];
-		assert(_colorCacheTable);
-	}
-	// TODO: show process bar?
-	if (!loadCacheFile()) {
-		// inactive dialog cache
-		if (_dialogShadingCallback) {
-			memset(_colorCacheTable, 0, sizeof(OverlayColor)*_numCacheColors);
-			for (uint i = 0; i < _numCacheColors; ++i) {
-				_colorCacheTable[i] = (this->*(_dialogShadingCallback))(i, true);
-			}
-		}
-		createCacheFile();
-	}
-}
-
-void ThemeNew::clearColorCache() {
-	delete [] _colorCacheTable;
-	_colorCacheTable = 0;
-}
-
-static uint32 hashString(const Common::String &string) {
-	uint32 hash = 0;
-	for (uint i = 0; i < string.size(); ++i) {
-		int offset = (hash % 30);
-		hash ^= (uint32)(string[i]) << offset;
-	}
-	return hash;
-}
-
-bool ThemeNew::loadCacheFile() {
-	if (sizeof(OverlayColor) != 2) {
-		warning("color cache only supported for 15/16 bpp mode");
-		return false;
-	}
-
-	if (!_colorCacheTable || _shadingEffect == kShadingEffectNothing)
-		return false;
-
-	Common::File cacheFile;
-	if (!cacheFile.open(cacheFileName().c_str()))
-		return false;
-
-	if (cacheFile.readUint32BE() != _numCacheColors)
-		return false;
-
-	switch (_shadingEffect) {
-	case kShadingEffectDim: {
-		int cachedDim = cacheFile.readUint32BE();
-		if (cachedDim != _dimPercentValue)
-			return false;
-		} break;
-
-	case kShadingEffectCustom: {
-		uint32 size = 0;
-		uint32 hash = 0;
-
-		size = cacheFile.readUint32BE();
-		hash = cacheFile.readUint32BE();
-		if (size != _shadingEpxressionR.size() || hash != hashString(_shadingEpxressionR))
-			return false;
-
-		size = cacheFile.readUint32BE();
-		hash = cacheFile.readUint32BE();
-		if (size != _shadingEpxressionG.size() || hash != hashString(_shadingEpxressionG))
-			return false;
-
-		size = cacheFile.readUint32BE();
-		hash = cacheFile.readUint32BE();
-		if (size != _shadingEpxressionB.size() || hash != hashString(_shadingEpxressionB))
-			return false;
-		} break;
-
-	default:
-		break;
-	}
-
-	for (uint i = 0; i < _numCacheColors; ++i) {
-		_colorCacheTable[i] = cacheFile.readUint16BE();
-	}
-
-	return !cacheFile.ioFailed();
-}
-
-bool ThemeNew::createCacheFile() {
-	if (sizeof(OverlayColor) != 2) {
-		warning("color cache only supported for 15/16 bpp mode");
-		return false;
-	}
-
-	if (!_colorCacheTable || _shadingEffect == kShadingEffectNothing)
-		return false;
-
-	Common::File cacheFile;
-	if (!cacheFile.open(cacheFileName().c_str(), Common::File::kFileWriteMode))
-		return false;
-
-	cacheFile.writeUint32BE(_numCacheColors);
-
-	switch (_shadingEffect) {
-	case kShadingEffectDim: {
-		cacheFile.writeUint32BE(_dimPercentValue);
-		} break;
-
-	case kShadingEffectCustom: {
-		uint32 size = 0;
-		uint32 hash = 0;
-
-		size = _shadingEpxressionR.size();
-		hash = hashString(_shadingEpxressionR);
-		cacheFile.writeUint32BE(size);
-		cacheFile.writeUint32BE(hash);
-
-		size = _shadingEpxressionG.size();
-		hash = hashString(_shadingEpxressionG);
-		cacheFile.writeUint32BE(size);
-		cacheFile.writeUint32BE(hash);
-
-		size = _shadingEpxressionB.size();
-		hash = hashString(_shadingEpxressionB);
-		cacheFile.writeUint32BE(size);
-		cacheFile.writeUint32BE(hash);
-		} break;
-
-	default:
-		break;
-	}
-
-	for (uint i = 0; i < _numCacheColors; ++i) {
-		cacheFile.writeUint16BE(_colorCacheTable[i]);
-	}
-
-	return !cacheFile.ioFailed();
-}
-
-Common::String ThemeNew::cacheFileName() {
-	char filebuf[128];
-	snprintf(filebuf, 128, "theme-colorcache-%d-%d.raw", gBitFormat, _shadingEffect);
-	return filebuf;
-}
-
-OverlayColor ThemeNew::calcLuminance(OverlayColor col, bool cache) {
+OverlayColor ThemeNew::calcLuminance(OverlayColor col) {
 	uint8 r, g, b;
-	if (cache) {
-		r = ((col & 0xF800) >> 11) << 3;
-		g = ((col & 0x07E0) >> 5) << 2;
-		b = (col & 0x001F) << 3;
-	} else {
-		_system->colorToRGB(col, r, g, b);
-	}
+	_system->colorToRGB(col, r, g, b);
 
 	uint lum = (r >> 2) + (g >> 1) + (b >> 3);
 	
 	return _system->RGBToColor(lum, lum, lum);
 }
 
-OverlayColor ThemeNew::calcDimColor(OverlayColor col, bool cache) {
+OverlayColor ThemeNew::calcDimColor(OverlayColor col) {
 	uint8 r, g, b;
-	if (cache) {
-		r = ((col & 0xF800) >> 11) << 3;
-		g = ((col & 0x07E0) >> 5) << 2;
-		b = (col & 0x001F) << 3;
-	} else {
-		_system->colorToRGB(col, r, g, b);
-	}
+	_system->colorToRGB(col, r, g, b);
 	
 	r = r * _dimPercentValue >> 8;
 	g = g * _dimPercentValue >> 8;
@@ -1514,27 +1309,6 @@
 	return _system->RGBToColor(r, g, b);
 }
 
-OverlayColor ThemeNew::calcCustomColor(OverlayColor col, bool cache) {
-	uint8 r, g, b;
-	if (cache) {
-		r = ((col & 0xF800) >> 11) << 3;
-		g = ((col & 0x07E0) >> 5) << 2;
-		b = (col & 0x001F) << 3;
-	} else {
-		_system->colorToRGB(col, r, g, b);
-	}
-	
-	_evaluator->setVar("r", r);
-	_evaluator->setVar("g", g);
-	_evaluator->setVar("b", b);
-	
-	r = _evaluator->eval(_shadingEpxressionR, "extra", "shading_custom_r", 0);
-	g = _evaluator->eval(_shadingEpxressionG, "extra", "shading_custom_g", 0);
-	b = _evaluator->eval(_shadingEpxressionB, "extra", "shading_custom_b", 0);
-	
-	return _system->RGBToColor(r, g, b);
-}
-
 #pragma mark -
 
 template<class T>

Modified: scummvm/trunk/gui/theme.h
===================================================================
--- scummvm/trunk/gui/theme.h	2006-04-13 21:52:23 UTC (rev 21849)
+++ scummvm/trunk/gui/theme.h	2006-04-13 22:20:50 UTC (rev 21850)
@@ -413,38 +413,13 @@
 	};
 
 private:
-	// inactive dialog effects
-	enum kShadingEffects {
-		kShadingEffectNothing = 0,
-		kShadingEffectLuminance = 1,
-		kShadingEffectDim = 2,
-		kShadingEffectCustom = 3
-	};
-
-	// used for the (yet) unimplemented cache file
-	int _shadingEffect;
-
 	int _dimPercentValue;
-	Common::String _shadingEpxressionR, _shadingEpxressionG, _shadingEpxressionB;
-	
-	uint _numCacheColors;
-	bool _usingColorCache;
-	OverlayColor *_colorCacheTable;
-	void setupColorCache();
-	void clearColorCache();
-
-	Common::String cacheFileName();
-	bool loadCacheFile();
-	bool createCacheFile();
-
-	typedef OverlayColor (ThemeNew::*InactiveDialogCallback)(OverlayColor col, bool cache);
-	
+	typedef OverlayColor (ThemeNew::*InactiveDialogCallback)(OverlayColor col);	
 	InactiveDialogCallback _dialogShadingCallback;
 	
 	// cache means input is 16 bpp mode
-	OverlayColor calcLuminance(OverlayColor col, bool cache);
-	OverlayColor calcDimColor(OverlayColor col, bool cache);
-	OverlayColor calcCustomColor(OverlayColor col, bool cache);
+	OverlayColor calcLuminance(OverlayColor col);
+	OverlayColor calcDimColor(OverlayColor col);
 
 private:
 	const String *_imageHandles;


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.





More information about the Scummvm-git-logs mailing list