Ticket #8934: pixelformat_v1.patch
File pixelformat_v1.patch, 8.3 KB (added by , 16 years ago) |
---|
-
common/system.h
31 31 #include "common/noncopyable.h" 32 32 #include "common/rect.h" 33 33 34 #include "graphics/colormasks.h" 35 34 36 namespace Audio { 35 37 class Mixer; 36 38 } … … 571 573 virtual void hideOverlay() = 0; 572 574 573 575 /** 576 * Returns the pixel format description of the overlay. 577 * @see Graphics::PixelFormat 578 */ 579 virtual Graphics::PixelFormat getOverlayFormat() const = 0; 580 581 /** 574 582 * Reset the overlay. 575 583 * 576 584 * After calling this method while the overlay mode is active, the user -
common/system.cpp
62 62 } 63 63 64 64 OverlayColor OSystem::RGBToColor(uint8 r, uint8 g, uint8 b) { 65 return ::RGBToColor<ColorMasks<565> >(r, g, b);65 return Graphics::RGBToColor<Graphics::ColorMasks<565> >(r, g, b); 66 66 } 67 67 68 68 void OSystem::colorToRGB(OverlayColor color, uint8 &r, uint8 &g, uint8 &b) { 69 ::colorToRGB<ColorMasks<565> >(color, r, g, b);69 Graphics::colorToRGB<Graphics::ColorMasks<565> >(color, r, g, b); 70 70 } 71 71 72 72 OverlayColor OSystem::ARGBToColor(uint8 a, uint8 r, uint8 g, uint8 b) { -
graphics/scaler.cpp
105 105 gBitFormat = BitFormat; 106 106 #ifndef DISABLE_HQ_SCALERS 107 107 if (gBitFormat == 555) 108 InitLUT< ColorMasks<555> >();108 InitLUT<Graphics::ColorMasks<555> >(); 109 109 if (gBitFormat == 565) 110 InitLUT< ColorMasks<565> >();110 InitLUT<Graphics::ColorMasks<565> >(); 111 111 #endif 112 112 } 113 113 -
graphics/scaler/thumbnail_intern.cpp
118 118 g = palette[((uint8*)screen->pixels)[y * screen->pitch + x] * 4 + 1]; 119 119 b = palette[((uint8*)screen->pixels)[y * screen->pitch + x] * 4 + 2]; 120 120 121 ((uint16*)surf->pixels)[y * surf->w + x] = RGBToColor<ColorMasks<565> >(r, g, b);121 ((uint16*)surf->pixels)[y * surf->w + x] = Graphics::RGBToColor<Graphics::ColorMasks<565> >(r, g, b); 122 122 } 123 123 } 124 124 … … 209 209 g = palette[pixels[y * w + x] * 3 + 1]; 210 210 b = palette[pixels[y * w + x] * 3 + 2]; 211 211 212 ((uint16 *)screen.pixels)[y * screen.w + x] = RGBToColor<ColorMasks<565> >(r, g, b);212 ((uint16 *)screen.pixels)[y * screen.w + x] = Graphics::RGBToColor<Graphics::ColorMasks<565> >(r, g, b); 213 213 } 214 214 } 215 215 -
graphics/scaler/intern.h
30 30 #include "graphics/colormasks.h" 31 31 32 32 33 #define highBits ColorMasks<bitFormat>::highBits34 #define lowBits ColorMasks<bitFormat>::lowBits35 #define qhighBits ColorMasks<bitFormat>::qhighBits36 #define qlowBits ColorMasks<bitFormat>::qlowBits37 #define redblueMask ColorMasks<bitFormat>::kRedBlueMask38 #define greenMask ColorMasks<bitFormat>::kGreenMask33 #define highBits Graphics::ColorMasks<bitFormat>::highBits 34 #define lowBits Graphics::ColorMasks<bitFormat>::lowBits 35 #define qhighBits Graphics::ColorMasks<bitFormat>::qhighBits 36 #define qlowBits Graphics::ColorMasks<bitFormat>::qlowBits 37 #define redblueMask Graphics::ColorMasks<bitFormat>::kRedBlueMask 38 #define greenMask Graphics::ColorMasks<bitFormat>::kGreenMask 39 39 40 40 41 41 /** -
graphics/colormasks.h
26 26 #ifndef GRAPHICS_COLORMASKS_H 27 27 #define GRAPHICS_COLORMASKS_H 28 28 29 namespace Graphics { 30 29 31 template<int bitFormat> 30 32 struct ColorMasks { 31 33 }; … … 251 253 b = ((color & T::kBlueMask) >> T::kBlueShift) << (8 - T::kBlueBits); 252 254 } 253 255 256 /** 257 * A pixel format description. 258 * 259 * Like ColorMasks it includes the given values to create colors from RGB 260 * values and to retrieve RGB values from colors. 261 * 262 * Unlike ColorMasks it is not dependend on knowing the exact pixel format 263 * on compile time. 264 * 265 * A minor difference between ColorMasks and PixelFormat is that ColorMasks 266 * stores the bit count per channel in 'kFooBits', while PixelFormat stores 267 * the loss compared to 8 bits per channel in '#Loss'. 268 */ 269 struct PixelFormat { 270 PixelFormat() {} 271 272 template<class Mask> 273 PixelFormat() { 274 bytesPerPixel = Mask::kBytesPerPixel; 275 276 rLoss = 8 - Mask::kRedBits; 277 gLoss = 8 - Mask::kGreenBits; 278 bLoss = 8 - Mask::kBlueBits; 279 aLoss = 8 - Mask::kAlphaBits; 280 281 rShift = Mask::kRedShift; 282 gShift = Mask::kGreenShift; 283 bShift = Mask::kBlueShift; 284 aShift = Mask::kAlphaShift; 285 286 rMask = Mask::kRedMask; 287 gMask = Mask::kGreenMask; 288 bMask = Mask::kBlueMask; 289 aMask = Mask::kAlphaMask; 290 } 291 292 byte bytesPerPixel; /**< Number of bytes used in the pixel format. */ 293 294 byte rLoss, gLoss, bLoss, aLoss; /**< Precision loss of each color component. */ 295 byte rShift, gShift, bShift, aShift; /**< Binary left shift of each color component in the pixel value. */ 296 297 uint32 rMask, gMask, bMask, aMask; /**< Binary mask used to retrieve individual color values. */ 298 }; 299 300 inline uint32 RGBToColor(uint8 r, uint8 g, uint8 b, const PixelFormat &fmt) { 301 return fmt.aMask | 302 (((r >> fmt.rLoss) << fmt.rShift) & fmt.rMask) | 303 (((g >> fmt.gLoss) << fmt.gShift) & fmt.gMask) | 304 (((b >> fmt.bLoss) << fmt.bShift) & fmt.bMask); 305 } 306 307 inline uint32 ARGBToColor(uint8 a, uint8 r, uint8 g, uint8 b, const PixelFormat &fmt) { 308 return 309 (((a >> fmt.aLoss) << fmt.aShift) & fmt.aMask) | 310 (((r >> fmt.rLoss) << fmt.rShift) & fmt.rMask) | 311 (((g >> fmt.gLoss) << fmt.gShift) & fmt.gMask) | 312 (((b >> fmt.bLoss) << fmt.bShift) & fmt.bMask); 313 } 314 315 inline void colorToRGB(uint32 color, uint8 &r, uint8 &g, uint8 &b, const PixelFormat &fmt) { 316 r = ((color & fmt.rMask) >> fmt.rShift) << fmt.rLoss; 317 g = ((color & fmt.gMask) >> fmt.gShift) << fmt.gLoss; 318 b = ((color & fmt.bMask) >> fmt.bShift) << fmt.bLoss; 319 } 320 321 inline void colorToARGB(uint32 color, uint8 &a, uint8 &r, uint8 &g, uint8 &b, const PixelFormat &fmt) { 322 a = ((color & fmt.aMask) >> fmt.aShift) << fmt.aLoss; 323 r = ((color & fmt.rMask) >> fmt.rShift) << fmt.rLoss; 324 g = ((color & fmt.gMask) >> fmt.gShift) << fmt.gLoss; 325 b = ((color & fmt.bMask) >> fmt.bShift) << fmt.bLoss; 326 } 327 328 } // end of namespace Graphics 329 254 330 #endif -
backends/platform/sdl/graphics.cpp
396 396 if (_overlayscreen == NULL) 397 397 error("allocating _overlayscreen failed"); 398 398 399 _overlayFormat.bytesPerPixel = _overlayscreen->format->BytesPerPixel; 400 401 _overlayFormat.rMask = _overlayscreen->format->Rmask; 402 _overlayFormat.gMask = _overlayscreen->format->Gmask; 403 _overlayFormat.bMask = _overlayscreen->format->Bmask; 404 _overlayFormat.aMask = _overlayscreen->format->Amask; 405 406 _overlayFormat.rLoss = _overlayscreen->format->Rloss; 407 _overlayFormat.gLoss = _overlayscreen->format->Gloss; 408 _overlayFormat.bLoss = _overlayscreen->format->Bloss; 409 _overlayFormat.aLoss = _overlayscreen->format->Aloss; 410 411 _overlayFormat.rShift = _overlayscreen->format->Rshift; 412 _overlayFormat.gShift = _overlayscreen->format->Gshift; 413 _overlayFormat.bShift = _overlayscreen->format->Bshift; 414 _overlayFormat.aShift = _overlayscreen->format->Ashift; 415 399 416 _tmpscreen2 = SDL_CreateRGBSurface(SDL_SWSURFACE, _overlayWidth + 3, _overlayHeight + 3, 400 417 16, 401 418 _hwscreen->format->Rmask, -
backends/platform/sdl/sdl.h
176 176 void deleteMutex(MutexRef mutex); 177 177 178 178 // Overlay 179 virtual Graphics::PixelFormat getOverlayFormat() const { return _overlayFormat; } 179 180 virtual void showOverlay(); 180 181 virtual void hideOverlay(); 181 182 virtual void clearOverlay(); … … 246 247 SDL_Surface *_overlayscreen; 247 248 int _overlayWidth, _overlayHeight; 248 249 bool _overlayVisible; 250 Graphics::PixelFormat _overlayFormat; 249 251 250 252 // Audio 251 253 int _samplesPerSec;