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

fingolfin at users.sourceforge.net fingolfin at users.sourceforge.net
Mon Apr 17 03:23:01 CEST 2006


Revision: 21966
Author:   fingolfin
Date:     2006-04-17 03:22:05 -0700 (Mon, 17 Apr 2006)
ViewCVS:  http://svn.sourceforge.net/scummvm/?rev=21966&view=rev

Log Message:
-----------
Moved ColorMasks to their own new header graphics/colormasks.h, so that both the scalers and the GUI code can access them. Also added (untested) entries for 1555, 444, 888 and 8888 modes

Modified Paths:
--------------
    scummvm/trunk/graphics/scaler/intern.h
    scummvm/trunk/gui/ThemeNew.cpp

Added Paths:
-----------
    scummvm/trunk/graphics/colormasks.h
Added: scummvm/trunk/graphics/colormasks.h
===================================================================
--- scummvm/trunk/graphics/colormasks.h	                        (rev 0)
+++ scummvm/trunk/graphics/colormasks.h	2006-04-17 10:22:05 UTC (rev 21966)
@@ -0,0 +1,221 @@
+/* ScummVM - Scumm Interpreter
+ * Copyright (C) 2001  Ludvig Strigeus
+ * Copyright (C) 2001-2006 The ScummVM project
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * $URL$
+ * $Id$
+ *
+ */
+
+#ifndef GRAPHICS_COLORMASKS_H
+#define GRAPHICS_COLORMASKS_H
+
+template<int bitFormat>
+struct ColorMasks {
+};
+
+/*
+The ColorMasks template can be used to map bit format values
+(like 555, 565, 1555, 4444) to corresponding bit masks and shift values.
+Currently this is only meant for 
+
+The meaning of these is masks is the following:
+ kBytesPerPixel
+    -> how many bytes per pixel for that format
+
+ kRedMask, kGreenMask, kBlueMask
+    -> bitmask, and this with the color to select only the bits of the corresponding color
+ 
+ The k*Bits and k*Shift values can be used to extract R,G,B. I.e. to get
+ the red color component of a pixel, as a 8-bit value, you would write
+ 
+ R = ((color & kRedMask) >> kRedShift) << (8-kRedBits)
+ 
+ Actually, instead of the simple left shift, one might want to use somewhat
+ more sophisticated code (which fills up the lower most bits.
+ 
+ 
+ The highBits / lowBits / qhighBits / qlowBits are special values that are
+ used in the super-optimized interpolation functions in scaler/intern.h
+ and scaler/aspect.cpp. Currently they are only available in 555 and 565 mode.
+ To be specific: They pack the masks for two 16 bit pixels at once. The pixels
+ are split into "high" and "low" bits, which are then separately interpolated
+ and finally re-composed. That way, 2x2 pixels or even 4x2 pixels can
+ be interpolated in one go.
+
+*/
+
+
+template<>
+struct ColorMasks<565> {
+	enum {
+		highBits    = 0xF7DEF7DE,
+		lowBits     = 0x08210821,
+		qhighBits   = 0xE79CE79C,
+		qlowBits    = 0x18631863,
+
+
+		kBytesPerPixel = 2,
+
+		kAlphaBits  = 0,
+		kRedBits    = 5,
+		kGreenBits  = 6,
+		kBlueBits   = 5,
+
+		kAlphaShift = kRedBits+kGreenBits+kBlueBits,
+		kRedShift   = kGreenBits+kBlueBits,
+		kGreenShift = kBlueBits,
+		kBlueShift  = 0,
+
+		kAlphaMask = ((1 << kAlphaBits) - 1) << kAlphaShift,
+		kRedMask   = ((1 << kRedBits) - 1) << kRedShift,
+		kGreenMask = ((1 << kGreenBits) - 1) << kGreenShift,
+		kBlueMask  = ((1 << kBlueBits) - 1) << kBlueShift,
+
+		kRedBlueMask = kRedMask | kBlueMask
+
+	};
+};
+
+template<>
+struct ColorMasks<555> {
+	enum {
+		highBits    = 0x7BDE7BDE,
+		lowBits     = 0x04210421,
+		qhighBits   = 0x739C739C,
+		qlowBits    = 0x0C630C63,
+
+
+		kBytesPerPixel = 2,
+
+		kAlphaBits  = 0,
+		kRedBits    = 5,
+		kGreenBits  = 5,
+		kBlueBits   = 5,
+
+		kAlphaShift = kRedBits+kGreenBits+kBlueBits,
+		kRedShift   = kGreenBits+kBlueBits,
+		kGreenShift = kBlueBits,
+		kBlueShift  = 0,
+
+		kAlphaMask = ((1 << kAlphaBits) - 1) << kAlphaShift,
+		kRedMask   = ((1 << kRedBits) - 1) << kRedShift,
+		kGreenMask = ((1 << kGreenBits) - 1) << kGreenShift,
+		kBlueMask  = ((1 << kBlueBits) - 1) << kBlueShift,
+
+		kRedBlueMask = kRedMask | kBlueMask
+	};
+};
+
+template<>
+struct ColorMasks<1555> {
+	enum {
+		kBytesPerPixel = 2,
+
+		kAlphaBits  = 1,
+		kRedBits    = 5,
+		kGreenBits  = 5,
+		kBlueBits   = 5,
+
+		kAlphaShift = kRedBits+kGreenBits+kBlueBits,
+		kRedShift   = kGreenBits+kBlueBits,
+		kGreenShift = kBlueBits,
+		kBlueShift  = 0,
+
+		kAlphaMask = ((1 << kAlphaBits) - 1) << kAlphaShift,
+		kRedMask   = ((1 << kRedBits) - 1) << kRedShift,
+		kGreenMask = ((1 << kGreenBits) - 1) << kGreenShift,
+		kBlueMask  = ((1 << kBlueBits) - 1) << kBlueShift,
+
+		kRedBlueMask = kRedMask | kBlueMask
+	};
+};
+
+template<>
+struct ColorMasks<4444> {
+	enum {
+		kBytesPerPixel = 2,
+
+		kAlphaBits  = 4,
+		kRedBits    = 4,
+		kGreenBits  = 4,
+		kBlueBits   = 4,
+
+		kAlphaShift = kRedBits+kGreenBits+kBlueBits,
+		kRedShift   = kGreenBits+kBlueBits,
+		kGreenShift = kBlueBits,
+		kBlueShift  = 0,
+
+		kAlphaMask = ((1 << kAlphaBits) - 1) << kAlphaShift,
+		kRedMask   = ((1 << kRedBits) - 1) << kRedShift,
+		kGreenMask = ((1 << kGreenBits) - 1) << kGreenShift,
+		kBlueMask  = ((1 << kBlueBits) - 1) << kBlueShift,
+
+		kRedBlueMask = kRedMask | kBlueMask
+	};
+};
+
+template<>
+struct ColorMasks<888> {
+	enum {
+		kBytesPerPixel = 4,
+
+		kAlphaBits  = 0,
+		kRedBits    = 8,
+		kGreenBits  = 8,
+		kBlueBits   = 8,
+
+		kAlphaShift = kRedBits+kGreenBits+kBlueBits,
+		kRedShift   = kGreenBits+kBlueBits,
+		kGreenShift = kBlueBits,
+		kBlueShift  = 0,
+
+		kAlphaMask = ((1 << kAlphaBits) - 1) << kAlphaShift,
+		kRedMask   = ((1 << kRedBits) - 1) << kRedShift,
+		kGreenMask = ((1 << kGreenBits) - 1) << kGreenShift,
+		kBlueMask  = ((1 << kBlueBits) - 1) << kBlueShift,
+
+		kRedBlueMask = kRedMask | kBlueMask
+	};
+};
+
+template<>
+struct ColorMasks<8888> {
+	enum {
+		kBytesPerPixel = 4,
+
+		kAlphaBits  = 8,
+		kRedBits    = 8,
+		kGreenBits  = 8,
+		kBlueBits   = 8,
+
+		kAlphaShift = kRedBits+kGreenBits+kBlueBits,
+		kRedShift   = kGreenBits+kBlueBits,
+		kGreenShift = kBlueBits,
+		kBlueShift  = 0,
+
+		kAlphaMask = ((1 << kAlphaBits) - 1) << kAlphaShift,
+		kRedMask   = ((1 << kRedBits) - 1) << kRedShift,
+		kGreenMask = ((1 << kGreenBits) - 1) << kGreenShift,
+		kBlueMask  = ((1 << kBlueBits) - 1) << kBlueShift,
+
+		kRedBlueMask = kRedMask | kBlueMask
+	};
+};
+
+
+#endif


Property changes on: scummvm/trunk/graphics/colormasks.h
___________________________________________________________________
Name: svn:mime-type
   + text/plain
Name: svn:keywords
   + Date Rev Author URL Id
Name: svn:eol-style
   + native

Modified: scummvm/trunk/graphics/scaler/intern.h
===================================================================
--- scummvm/trunk/graphics/scaler/intern.h	2006-04-17 09:45:18 UTC (rev 21965)
+++ scummvm/trunk/graphics/scaler/intern.h	2006-04-17 10:22:05 UTC (rev 21966)
@@ -21,47 +21,20 @@
  *
  */
 
+#ifndef GRAPHICS_SCALER_INTERN_H
+#define GRAPHICS_SCALER_INTERN_H
 
-#ifndef COMMON_SCALER_INTERN_H
-#define COMMON_SCALER_INTERN_H
-
 #include "common/stdafx.h"
 #include "common/scummsys.h"
+#include "graphics/colormasks.h"
 
-template<int bitFormat>
-struct ColorMasks {
-};
 
-template<>
-struct ColorMasks<565> {
-	enum {
-		highBits = 0xF7DEF7DE,
-		lowBits = 0x08210821,
-		qhighBits = 0xE79CE79C,
-		qlowBits = 0x18631863,
-		redblueMask = 0xF81F,
-		greenMask = 0x07E0
-	};
-};
-
-template<>
-struct ColorMasks<555> {
-	enum {
-		highBits = 0x7BDE7BDE,
-		lowBits = 0x04210421,
-		qhighBits = 0x739C739C,
-		qlowBits = 0x0C630C63,
-		redblueMask = 0x7C1F,
-		greenMask = 0x03E0
-	};
-};
-
 #define highBits	ColorMasks<bitFormat>::highBits
 #define lowBits		ColorMasks<bitFormat>::lowBits
 #define qhighBits	ColorMasks<bitFormat>::qhighBits
 #define qlowBits	ColorMasks<bitFormat>::qlowBits
-#define redblueMask	ColorMasks<bitFormat>::redblueMask
-#define greenMask	ColorMasks<bitFormat>::greenMask
+#define redblueMask	ColorMasks<bitFormat>::kRedBlueMask
+#define greenMask	ColorMasks<bitFormat>::kGreenMask
 
 
 /**

Modified: scummvm/trunk/gui/ThemeNew.cpp
===================================================================
--- scummvm/trunk/gui/ThemeNew.cpp	2006-04-17 09:45:18 UTC (rev 21965)
+++ scummvm/trunk/gui/ThemeNew.cpp	2006-04-17 10:22:05 UTC (rev 21966)
@@ -26,6 +26,7 @@
 
 #include "graphics/imageman.h"
 #include "graphics/imagedec.h"
+#include "graphics/colormasks.h"
 
 #include "common/config-manager.h"
 #include "common/file.h"
@@ -86,33 +87,7 @@
 #define getExtraValueFromConfig(x, y, z, a) getValueFromConfig(x, "extra", y, z, a)
 
 namespace GUI {
-// some of this stuff is allready in graphics/scaler/intern.h
-// maybe use the structs in graphics/scaler/intern.h then and add
-// there kBlueMask
-template<int bitFormat>
-struct ColorMasks {
-};
 
-template<>
-struct ColorMasks<555> {
-	enum {
-		kRBMask = 0x7C1F,
-		kRedMask = 0x7C00,
-		kGreenMask = 0x03E0,
-		kBlueMask = 0x001F
-	};
-};
-
-template<>
-struct ColorMasks<565> {
-	enum {
-		kRBMask = 0xF81F,
-		kRedMask = 0xF800,
-		kGreenMask = 0x07E0,
-		kBlueMask = 0x001F
-	};
-};
-
 OverlayColor getColorAlpha(OverlayColor col1, OverlayColor col2, int alpha);
 OverlayColor calcGradient(OverlayColor start, OverlayColor end, int pos, int max, uint factor);
 


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