[Scummvm-git-logs] scummvm master -> 1f65be27d9546fd010cc69ea3feff8ef509e35ae

dreammaster noreply at scummvm.org
Sun Jun 2 17:55:13 UTC 2024


This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
1f65be27d9 GRAPHICS: Palette constants cleanup, added Palette methods to ManagedSurface


Commit: 1f65be27d9546fd010cc69ea3feff8ef509e35ae
    https://github.com/scummvm/scummvm/commit/1f65be27d9546fd010cc69ea3feff8ef509e35ae
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2024-06-02T10:55:01-07:00

Commit Message:
GRAPHICS: Palette constants cleanup, added Palette methods to ManagedSurface

Changed paths:
    graphics/palette.h
    graphics/paletteman.h
    graphics/screen.h


diff --git a/graphics/palette.h b/graphics/palette.h
index 99326333730..779f9f6633e 100644
--- a/graphics/palette.h
+++ b/graphics/palette.h
@@ -26,6 +26,12 @@
 
 namespace Graphics {
 
+/**
+ * Constants available for use in paletted code
+ */
+#define PALETTE_COUNT 256
+#define PALETTE_SIZE (256 * 3)
+
 /**
  * @brief Simple class for handling a palette data.
  *
diff --git a/graphics/paletteman.h b/graphics/paletteman.h
index c688826c0fd..f0e65b90a97 100644
--- a/graphics/paletteman.h
+++ b/graphics/paletteman.h
@@ -112,7 +112,7 @@ public:
 	virtual void grabPalette(byte *colors, uint start, uint num) const = 0;
 
 	Graphics::Palette grabPalette(uint start, uint num) {
-		byte tmp[256 * 3];
+		byte tmp[PALETTE_SIZE];
 		grabPalette(tmp, start, num);
 		return Graphics::Palette(tmp, num);
 	}
diff --git a/graphics/screen.h b/graphics/screen.h
index bd2dc677089..3aa9c751916 100644
--- a/graphics/screen.h
+++ b/graphics/screen.h
@@ -23,6 +23,7 @@
 #define GRAPHICS_SCREEN_H
 
 #include "graphics/managed_surface.h"
+#include "graphics/palette.h"
 #include "graphics/pixelformat.h"
 #include "common/list.h"
 #include "common/rect.h"
@@ -38,9 +39,6 @@ namespace Graphics {
  * @{
  */
 
-#define PALETTE_COUNT 256
-#define PALETTE_SIZE (256 * 3)
-
 /**
  * Implements a specialised surface that represents the screen.
  * It keeps track of any areas of itself that are updated by drawing
@@ -110,6 +108,15 @@ public:
 	 */
 	void getPalette(byte *palette, uint start, uint num);
 
+	/**
+	 * Return a portion of the currently active palette as a palette object
+	 */
+	Graphics::Palette getPalette(uint start = 0, uint num = PALETTE_COUNT) {
+		byte tmp[PALETTE_SIZE];
+		getPalette(tmp, start, num);
+		return Graphics::Palette(tmp, num);
+	}
+
 	/**
 	 * Set the palette
 	 */
@@ -120,6 +127,13 @@ public:
 	 */
 	void setPalette(const byte *palette, uint start, uint num);
 
+	/**
+	 * Set a palette based on a passed palette object
+	 */
+	void setPalette(const Graphics::Palette &pal, uint start = 0) {
+		setPalette(pal.data(), start, pal.size());
+	}
+
 	/**
 	 * Clears the current palette, setting all entries to black
 	 */




More information about the Scummvm-git-logs mailing list