diff options
author | Jesse Hall <jessehall@google.com> | 2012-07-17 15:51:53 -0700 |
---|---|---|
committer | Jesse Hall <jessehall@google.com> | 2012-07-22 00:35:08 -0700 |
commit | 74b55003f76dbca96e4a26d98fe464081ca5341f (patch) | |
tree | 510572781982f652f95f9f28669928f3a3a6657f /android/skin/scaler.c | |
parent | 3dcbebfd43e409c3bbff7fc79288e40666a947fd (diff) | |
download | external_qemu-74b55003f76dbca96e4a26d98fe464081ca5341f.zip external_qemu-74b55003f76dbca96e4a26d98fe464081ca5341f.tar.gz external_qemu-74b55003f76dbca96e4a26d98fe464081ca5341f.tar.bz2 |
Handle SDL windows with BGRA color
The switch to CoreGraphics on OSX (instead of QuickDraw) in SDL 1.2.15
means the SDL-created window now has BGRA color order instead of ARGB.
This change makes the r5g6b5 and xbgr32 format converters handle
whatever channel ordering the main SDL surface has. Skin regions don't
need to change, since we draw them into auxiliary surfaces we created
with ARGB order, and SDL does the conversion when we blit them into
the main window.
Change-Id: I2ae0529c66c11b60b3ade7a7a742368a2ab614bd
Diffstat (limited to 'android/skin/scaler.c')
-rw-r--r-- | android/skin/scaler.c | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/android/skin/scaler.c b/android/skin/scaler.c index 5672869..bafd84e 100644 --- a/android/skin/scaler.c +++ b/android/skin/scaler.c @@ -150,6 +150,34 @@ skin_scaler_scale( SkinScaler* scaler, else scale_generic( &op ); } + + // The optimized scale functions in argb.h assume the destination is ARGB. + // If that's not the case, do a channel reorder now. + if (dst_surface->format->Rshift != 16 || + dst_surface->format->Gshift != 8 || + dst_surface->format->Bshift != 0) + { + uint32_t rshift = dst_surface->format->Rshift; + uint32_t gshift = dst_surface->format->Gshift; + uint32_t bshift = dst_surface->format->Bshift; + uint32_t ashift = dst_surface->format->Ashift; + uint32_t amask = dst_surface->format->Amask; // may be 0x00 + int x, y; + + for (y = 0; y < op.rd.h; y++) + { + uint32_t* line = (uint32_t*)(op.dst_line + y*op.dst_pitch); + for (x = 0; x < op.rd.w; x++) { + uint32_t r = (line[x] & 0x00ff0000) >> 16; + uint32_t g = (line[x] & 0x0000ff00) >> 8; + uint32_t b = (line[x] & 0x000000ff) >> 0; + uint32_t a = (line[x] & 0xff000000) >> 24; + line[x] = (r << rshift) | (g << gshift) | (b << bshift) | + ((a << ashift) & amask); + } + } + } + SDL_UnlockSurface( dst_surface ); SDL_UnlockSurface( src_surface ); |