[Scummvm-git-logs] scummvm master -> 81f989be63132f8d1a9401c9d1613be304444277

sev- sev at scummvm.org
Thu Sep 17 20:21:28 UTC 2020


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

Summary:
ce2ad28477 GRAPHICS: Add a basic copyBlit() function
81f989be63 GUI: Use RGB cursors on supported platforms


Commit: ce2ad284771c7a1129b5bad2d6358e0658e3d7aa
    https://github.com/scummvm/scummvm/commit/ce2ad284771c7a1129b5bad2d6358e0658e3d7aa
Author: Cameron Cawley (ccawley2011 at gmail.com)
Date: 2020-09-17T22:21:23+02:00

Commit Message:
GRAPHICS: Add a basic copyBlit() function

Changed paths:
    graphics/conversion.cpp
    graphics/conversion.h


diff --git a/graphics/conversion.cpp b/graphics/conversion.cpp
index 8df8a53b9f..5dcf005459 100644
--- a/graphics/conversion.cpp
+++ b/graphics/conversion.cpp
@@ -29,6 +29,25 @@ namespace Graphics {
 
 // TODO: YUV to RGB conversion function
 
+// Function to blit a rect
+void copyBlit(byte *dst, const byte *src,
+               const uint dstPitch, const uint srcPitch,
+               const uint w, const uint h,
+               const uint bytesPerPixel) {
+	if (dst == src)
+		return;
+
+	if (dstPitch == srcPitch && ((w * bytesPerPixel) == dstPitch)) {
+		memcpy(dst, src, dstPitch * h);
+	} else {
+		for (uint i = 0; i < h; ++i) {
+			memcpy(dst, src, w * bytesPerPixel);
+			dst += dstPitch;
+			src += srcPitch;
+		}
+	}
+}
+
 namespace {
 
 template<typename SrcColor, typename DstColor, bool backward>
@@ -111,18 +130,7 @@ bool crossBlit(byte *dst, const byte *src,
 
 	// Don't perform unnecessary conversion
 	if (srcFmt == dstFmt) {
-		if (dst != src) {
-			if (dstPitch == srcPitch && ((w * dstFmt.bytesPerPixel) == dstPitch)) {
-				memcpy(dst, src, dstPitch * h);
-			} else {
-				for (uint i = 0; i < h; ++i) {
-					memcpy(dst, src, w * dstFmt.bytesPerPixel);
-					dst += dstPitch;
-					src += srcPitch;
-				}
-			}
-		}
-
+		copyBlit(dst, src, dstPitch, srcPitch, w, h, dstFmt.bytesPerPixel);
 		return true;
 	}
 
diff --git a/graphics/conversion.h b/graphics/conversion.h
index 1e5486864a..b0b376babd 100644
--- a/graphics/conversion.h
+++ b/graphics/conversion.h
@@ -45,6 +45,22 @@ inline static void RGB2YUV(byte r, byte g, byte b, byte &y, byte &u, byte &v) {
 
 // TODO: generic YUV to RGB blit
 
+/**
+ * Blits a rectangle.
+ *
+ * @param dst			the buffer which will recieve the converted graphics data
+ * @param src			the buffer containing the original graphics data
+ * @param dstPitch		width in bytes of one full line of the dest buffer
+ * @param srcPitch		width in bytes of one full line of the source buffer
+ * @param w				the width of the graphics data
+ * @param h				the height of the graphics data
+ * @param bytesPerPixel	the number of bytes per pixel
+ */
+void copyBlit(byte *dst, const byte *src,
+               const uint dstPitch, const uint srcPitch,
+               const uint w, const uint h,
+               const uint bytesPerPixel);
+
 /**
  * Blits a rectangle from one graphical format to another.
  *


Commit: 81f989be63132f8d1a9401c9d1613be304444277
    https://github.com/scummvm/scummvm/commit/81f989be63132f8d1a9401c9d1613be304444277
Author: Cameron Cawley (ccawley2011 at gmail.com)
Date: 2020-09-17T22:21:23+02:00

Commit Message:
GUI: Use RGB cursors on supported platforms

Changed paths:
    gui/ThemeEngine.cpp
    gui/ThemeEngine.h


diff --git a/gui/ThemeEngine.cpp b/gui/ThemeEngine.cpp
index 6d28dd4588..27b391071a 100644
--- a/gui/ThemeEngine.cpp
+++ b/gui/ThemeEngine.cpp
@@ -28,6 +28,7 @@
 #include "common/tokenizer.h"
 #include "common/translation.h"
 
+#include "graphics/conversion.h"
 #include "graphics/cursorman.h"
 #include "graphics/fontman.h"
 #include "graphics/surface.h"
@@ -224,7 +225,11 @@ ThemeEngine::ThemeEngine(Common::String id, GraphicsMode mode) :
 
 	_cursorHotspotX = _cursorHotspotY = 0;
 	_cursorWidth = _cursorHeight = 0;
+#ifndef USE_RGB_COLOR
+	_cursorFormat = Graphics::PixelFormat::createFormatCLUT8();
+	_cursorTransparent = 255;
 	_cursorPalSize = 0;
+#endif
 
 	// We prefer files in archive bundles over the common search paths.
 	_themeFiles.add("default", &SearchMan, 0, false);
@@ -398,8 +403,10 @@ void ThemeEngine::refresh() {
 		_system->showOverlay();
 
 		if (_useCursor) {
+#ifndef USE_RGB_COLOR
 			CursorMan.replaceCursorPalette(_cursorPal, 0, _cursorPalSize);
-			CursorMan.replaceCursor(_cursor, _cursorWidth, _cursorHeight, _cursorHotspotX, _cursorHotspotY, 255, true);
+#endif
+			CursorMan.replaceCursor(_cursor, _cursorWidth, _cursorHeight, _cursorHotspotX, _cursorHotspotY, _cursorTransparent, true, &_cursorFormat);
 		}
 	}
 }
@@ -1494,20 +1501,11 @@ void ThemeEngine::applyScreenShading(ShadingStyle style) {
 }
 
 bool ThemeEngine::createCursor(const Common::String &filename, int hotspotX, int hotspotY) {
-	if (!_system->hasFeature(OSystem::kFeatureCursorPalette))
-		return true;
-
 	// Try to locate the specified file among all loaded bitmaps
 	const Graphics::Surface *cursor = _bitmaps[filename];
 	if (!cursor)
 		return false;
 
-#ifdef USE_RGB_COLOR
-	_cursorFormat.bytesPerPixel = 1;
-	_cursorFormat.rLoss = _cursorFormat.gLoss = _cursorFormat.bLoss = _cursorFormat.aLoss = 8;
-	_cursorFormat.rShift = _cursorFormat.gShift = _cursorFormat.bShift = _cursorFormat.aShift = 0;
-#endif
-
 	// Set up the cursor parameters
 	_cursorHotspotX = hotspotX;
 	_cursorHotspotY = hotspotY;
@@ -1515,6 +1513,23 @@ bool ThemeEngine::createCursor(const Common::String &filename, int hotspotX, int
 	_cursorWidth = cursor->w;
 	_cursorHeight = cursor->h;
 
+#ifdef USE_RGB_COLOR
+	_cursorFormat = cursor->format;
+	_cursorTransparent = _cursorFormat.RGBToColor(0xFF, 0, 0xFF);
+
+	// Allocate a new buffer for the cursor
+	delete[] _cursor;
+	_cursor = new byte[_cursorWidth * _cursorHeight * _cursorFormat.bytesPerPixel];
+	assert(_cursor);
+	Graphics::copyBlit(_cursor, (const byte *)cursor->getPixels(),
+	                   _cursorWidth * _cursorFormat.bytesPerPixel, cursor->pitch,
+	                   _cursorWidth, _cursorHeight, _cursorFormat.bytesPerPixel);
+
+	_useCursor = true;
+#else
+	if (!_system->hasFeature(OSystem::kFeatureCursorPalette))
+		return true;
+
 	// Allocate a new buffer for the cursor
 	delete[] _cursor;
 	_cursor = new byte[_cursorWidth * _cursorHeight];
@@ -1572,6 +1587,7 @@ bool ThemeEngine::createCursor(const Common::String &filename, int hotspotX, int
 
 	_useCursor = true;
 	_cursorPalSize = colorsFound;
+#endif
 
 	return true;
 }
@@ -2021,15 +2037,19 @@ Common::String ThemeEngine::getThemeId(const Common::String &filename) {
 
 void ThemeEngine::showCursor() {
 	if (_useCursor) {
+#ifndef USE_RGB_COLOR
 		CursorMan.pushCursorPalette(_cursorPal, 0, _cursorPalSize);
-		CursorMan.pushCursor(_cursor, _cursorWidth, _cursorHeight, _cursorHotspotX, _cursorHotspotY, 255, true);
+#endif
+		CursorMan.pushCursor(_cursor, _cursorWidth, _cursorHeight, _cursorHotspotX, _cursorHotspotY, _cursorTransparent, true, &_cursorFormat);
 		CursorMan.showMouse(true);
 	}
 }
 
 void ThemeEngine::hideCursor() {
 	if (_useCursor) {
+#ifndef USE_RGB_COLOR
 		CursorMan.popCursorPalette();
+#endif
 		CursorMan.popCursor();
 	}
 }
diff --git a/gui/ThemeEngine.h b/gui/ThemeEngine.h
index 36ff902fb1..32492a8e31 100644
--- a/gui/ThemeEngine.h
+++ b/gui/ThemeEngine.h
@@ -744,9 +744,7 @@ protected:
 	ImagesMap _bitmaps;
 	AImagesMap _abitmaps;
 	Graphics::PixelFormat _overlayFormat;
-#ifdef USE_RGB_COLOR
 	Graphics::PixelFormat _cursorFormat;
-#endif
 
 	/** List of all the dirty screens that must be blitted to the overlay. */
 	Common::List<Common::Rect> _dirtyScreen;
@@ -763,13 +761,16 @@ protected:
 
 	bool _useCursor;
 	int _cursorHotspotX, _cursorHotspotY;
+	uint32 _cursorTransparent;
+	byte *_cursor;
+	uint _cursorWidth, _cursorHeight;
+#ifndef USE_RGB_COLOR
 	enum {
 		MAX_CURS_COLORS = 255
 	};
-	byte *_cursor;
-	uint _cursorWidth, _cursorHeight;
 	byte _cursorPal[3 * MAX_CURS_COLORS];
 	byte _cursorPalSize;
+#endif
 
 	Common::Rect _clip;
 };




More information about the Scummvm-git-logs mailing list