Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

teletext: fixes #13515 transparent background issue on Windows systems #1906

Merged
merged 1 commit into from

3 participants

@margro

@opdenkamp: This pull request fixes

http://trac.xbmc.org/ticket/13515

This regression was introduced in commit 424a4d9: the removal of SDL for Windows.
This removed the HAS_SDL define and it turns out that the replacement SDL_memset4 define behaves different than the one from the SDL_stdinc.h header
This change implements the SDL_memset4 replacement to match the SDL original.

@elupus
Collaborator
@davilla
Collaborator

Comes direct from SDL source, http://www.libsdl.org/tmp/SDL-1.3-docs/SDL__stdinc_8h-source.html

Yes, very strange but valid code (except for the SDL_memcpy4 changes) :)

@margro margro teletext: fixes #13515 transparent background issue on Windows systems
This regression was introduced in commit 424a4d9: the removal of SDL for Windows.
This removed the HAS_SDL define and it turns out that the replacement SDL_memset4 define behaves different than the one from the SDL_stdinc.h header
This change implements the SDL_memset4 replacement to match the SDL original.
54dbf34
@margro

Oops.. fixed the << 4 part. A strange manual copy-code action from my side.

@elupus The weird while in switch code is called "duff's device". See wikipedia for the explanation.
It looks indeed strange. As davilla already indicated it comes directly from the original SDL header. That was the only difference I could find between Linux and Windows with respect to the teletext display.

I still don't know why the old SDL_memset4() implementation for Windows resulted in the transparent background as it looked like a valid implementation given how the SDL_memcpy4 is implemented.

@davilla
Collaborator

wow, it even has a name :)

@davilla davilla merged commit 7f49891 into from
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Dec 9, 2012
  1. @margro

    teletext: fixes #13515 transparent background issue on Windows systems

    margro authored
    This regression was introduced in commit 424a4d9: the removal of SDL for Windows.
    This removed the HAS_SDL define and it turns out that the replacement SDL_memset4 define behaves different than the one from the SDL_stdinc.h header
    This change implements the SDL_memset4 replacement to match the SDL original.
This page is out of date. Refresh to see the latest.
Showing with 16 additions and 4 deletions.
  1. +16 −4 xbmc/video/Teletext.cpp
View
20 xbmc/video/Teletext.cpp
@@ -36,10 +36,22 @@
#ifdef HAS_SDL
#include <SDL/SDL_stdinc.h>
#else
-#define SDL_memset4(dst, val, len) memset(dst, val, (len)*4)
-#define SDL_memcpy4(dst, src, len) memcpy(dst, src, (len)*4)
-#define SDL_memcpy4(dst, src, len) memcpy(dst, src, (len)*4)
-#define SDL_memset4(dst, val, len) memset(dst, val, (len)*4)
+#define SDL_memset4(dst, val, len) \
+do { \
+ uint32_t _count = (len); \
+ uint32_t _n = (_count + 3) / 4; \
+ uint32_t *_p = static_cast<uint32_t *>(dst); \
+ uint32_t _val = (val); \
+ if (len == 0) break; \
+ switch (_count % 4) { \
+ case 0: do { *_p++ = _val; \
+ case 3: *_p++ = _val; \
+ case 2: *_p++ = _val; \
+ case 1: *_p++ = _val; \
+ } while ( --_n ); \
+ } \
+} while(0)
+#define SDL_memcpy4(dst, src, len) memcpy(dst, src, (len) << 2)
#endif
using namespace std;
Something went wrong with that request. Please try again.