[Scummvm-cvs-logs] SF.net SVN: scummvm:[38909] scummvm/trunk/engines/sci/gfx

fingolfin at users.sourceforge.net fingolfin at users.sourceforge.net
Thu Feb 26 17:16:54 CET 2009


Revision: 38909
          http://scummvm.svn.sourceforge.net/scummvm/?rev=38909&view=rev
Author:   fingolfin
Date:     2009-02-26 16:16:53 +0000 (Thu, 26 Feb 2009)

Log Message:
-----------
SCI: Modified gfx_new_mode to take a Graphics::PixelFormat

Modified Paths:
--------------
    scummvm/trunk/engines/sci/gfx/gfx_driver.cpp
    scummvm/trunk/engines/sci/gfx/gfx_tools.cpp
    scummvm/trunk/engines/sci/gfx/gfx_tools.h
    scummvm/trunk/engines/sci/gfx/resource/sci_pic_0.cpp

Modified: scummvm/trunk/engines/sci/gfx/gfx_driver.cpp
===================================================================
--- scummvm/trunk/engines/sci/gfx/gfx_driver.cpp	2009-02-26 16:16:46 UTC (rev 38908)
+++ scummvm/trunk/engines/sci/gfx/gfx_driver.cpp	2009-02-26 16:16:53 UTC (rev 38909)
@@ -44,8 +44,7 @@
 
 int _modifierStates;
 
-static int
-scummvm_init_specific(gfx_driver_t *drv, int xfact, int yfact, int bytespp) {
+static int scummvm_init_specific(gfx_driver_t *drv, int xfact, int yfact, int bytespp) {
 	int i;
 
 	if (!drv->state) // = S
@@ -77,7 +76,8 @@
 		memset(S->visual[i], 0, S->xsize * S->ysize);
 	}
 
-	drv->mode = gfx_new_mode(xfact, yfact, bytespp, 0, 0, 0, 0, 0, 0, 0, 0, 256, 0);
+	Graphics::PixelFormat format = { bytespp, 0, 0, 0, 0, 0, 0, 0, 0 };
+	drv->mode = gfx_new_mode(xfact, yfact, format, 256, 0);
 
 	return GFX_OK;
 }

Modified: scummvm/trunk/engines/sci/gfx/gfx_tools.cpp
===================================================================
--- scummvm/trunk/engines/sci/gfx/gfx_tools.cpp	2009-02-26 16:16:46 UTC (rev 38908)
+++ scummvm/trunk/engines/sci/gfx/gfx_tools.cpp	2009-02-26 16:16:53 UTC (rev 38909)
@@ -44,22 +44,26 @@
 		box->yl = maxy - box->y + 1;
 }
 
-gfx_mode_t *gfx_new_mode(int xfact, int yfact, int bytespp, unsigned int red_mask, unsigned int green_mask,
-	unsigned int blue_mask, unsigned int alpha_mask, int red_shift, int green_shift,
-	int blue_shift, int alpha_shift, int palette, int flags) {
+gfx_mode_t *gfx_new_mode(int xfact, int yfact, const Graphics::PixelFormat &format, int palette, int flags) {
 	gfx_mode_t *mode = (gfx_mode_t *)sci_malloc(sizeof(gfx_mode_t));
 
 	mode->xfact = xfact;
 	mode->yfact = yfact;
-	mode->bytespp = bytespp;
-	mode->red_mask = red_mask;
-	mode->green_mask = green_mask;
-	mode->blue_mask = blue_mask;
-	mode->alpha_mask = alpha_mask;
-	mode->red_shift = red_shift;
-	mode->green_shift = green_shift;
-	mode->blue_shift = blue_shift;
-	mode->alpha_shift = alpha_shift;
+	mode->bytespp = format.bytesPerPixel;
+	
+	// FIXME: I am not sure whether the following assignments are quite right.
+	// The only code using these are the built-in scalers of the SCI engine.
+	// And those are pretty weird, so I am not sure I interpreted them correctly.
+	// They also seem somewhat inefficient and and should probably just be
+	// replaced resp. rewritten from scratch.
+	mode->red_mask = format.ARGBToColor(0, 0xFF, 0, 0);
+	mode->green_mask = format.ARGBToColor(0, 0, 0xFF, 0);
+	mode->blue_mask = format.ARGBToColor(0, 0, 0, 0xFF);
+	mode->alpha_mask = format.ARGBToColor(0xFF, 0, 0, 0);
+	mode->red_shift = format.rLoss;
+	mode->green_shift = format.gLoss;
+	mode->blue_shift = format.bLoss;
+	mode->alpha_shift = format.aLoss;
 	mode->flags = flags;
 
 	if (palette) {

Modified: scummvm/trunk/engines/sci/gfx/gfx_tools.h
===================================================================
--- scummvm/trunk/engines/sci/gfx/gfx_tools.h	2009-02-26 16:16:46 UTC (rev 38908)
+++ scummvm/trunk/engines/sci/gfx/gfx_tools.h	2009-02-26 16:16:53 UTC (rev 38909)
@@ -29,6 +29,8 @@
 #ifndef SCI_GFX_GFX_TOOLS_H
 #define SCI_GFX_GFX_TOOLS_H
 
+#include "graphics/pixelformat.h"
+
 #include "sci/gfx/gfx_system.h"
 #include "sci/gfx/gfx_driver.h"
 
@@ -45,20 +47,10 @@
 					  ** for distinguishing between transparent and opaque
 					  ** wrt alpha values */
 
-gfx_mode_t *gfx_new_mode(int xfact, int yfact, int bytespp, unsigned int red_mask, unsigned int green_mask,
-	unsigned int blue_mask, unsigned int alpha_mask, int red_shift, int green_shift,
-	int blue_shift, int alpha_shift, int palette, int flags);
+gfx_mode_t *gfx_new_mode(int xfact, int yfact, const Graphics::PixelFormat &format, int palette, int flags);
 /* Allocates a new gfx_mode_t structure with the specified parameters
 ** Parameters: (int x int) xfact x yfact: Horizontal and vertical scaling factors
-**             (int) bytespp: Bytes per pixel
-**             (unsigned int) red_mask: Red bit mask
-**             (unsigned int) green_mask: Green bit mask
-**             (unsigned int) blue_mask: Blue bit mask
-**             (unsigned int) Alpha_mask: Alpha bit mask, or 0 if the alpha channel is not supported
-**             (int) red_shift: Red shift value
-**             (int) green_shift: Green shift value
-**             (int) blue_shift: Blue shift value
-**             (int) alpha_shift: Alpha shift value
+**             (Graphics::PixelFormat) format: pixel format description
 **             (int) palette: Number of palette colors, 0 if we're not in palette mode
 **             (int) flags: GFX_MODE_FLAG_* values ORred together, or just 0
 ** Returns   : (gfx_mode_t *) A newly allocated gfx_mode_t structure

Modified: scummvm/trunk/engines/sci/gfx/resource/sci_pic_0.cpp
===================================================================
--- scummvm/trunk/engines/sci/gfx/resource/sci_pic_0.cpp	2009-02-26 16:16:46 UTC (rev 38908)
+++ scummvm/trunk/engines/sci/gfx/resource/sci_pic_0.cpp	2009-02-26 16:16:53 UTC (rev 38909)
@@ -1647,9 +1647,9 @@
 				p0printf("Embedded view @%d\n", pos);
 
 				// Set up mode structure for resizing the view
+				Graphics::PixelFormat format = { 1, 0, 0, 0, 0, 0, 0, 0, 0 }; // 1bpp, which handles masks and the rest for us
 				mode = gfx_new_mode(pic->visual_map->index_xl / 320,
-				           pic->visual_map->index_yl / 200, 1, // 1bpp, which handles masks and the rest for us
-				           0, 0, 0, 0, 0, 0, 0, 0, 16, 0);
+				           pic->visual_map->index_yl / 200, format, 16, 0);
 
 				GET_ABS_COORDS(posx, posy);
 				bytesize = (*(resource + pos)) + (*(resource + pos + 1) << 8);
@@ -1779,9 +1779,9 @@
 	gfx_mode_t *mode;
 	gfx_pixmap_t *view = NULL;
 	// Set up mode structure for resizing the view
+	Graphics::PixelFormat format = { 1, 0, 0, 0, 0, 0, 0, 0, 0 }; // 1bpp, which handles masks and the rest for us
 	mode = gfx_new_mode(pic->visual_map->index_xl / 320, pic->visual_map->index_yl / 200,
-	           1, // 1bpp, which handles masks and the rest for us
-	           0, 0, 0, 0, 0, 0, 0, 0, 16, 0);
+	           format, 16, 0);
 
 	pic->visual_map->colors = gfxr_read_pal11(-1, &(pic->visual_map->colors_nr), resource + palette_data_ptr, 1284);
 


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