00001
00002
00005 #ifndef BLITTER_32BPP_BASE_HPP
00006 #define BLITTER_32BPP_BASE_HPP
00007
00008 #include "base.hpp"
00009 #include "../core/bitmath_func.hpp"
00010
00011 class Blitter_32bppBase : public Blitter {
00012 public:
00013 uint8 GetScreenDepth() { return 32; }
00014
00015
00016
00017 void *MoveTo(const void *video, int x, int y);
00018 void SetPixel(void *video, int x, int y, uint8 color);
00019 void SetPixelIfEmpty(void *video, int x, int y, uint8 color);
00020 void DrawRect(void *video, int width, int height, uint8 color);
00021 void DrawLine(void *video, int x, int y, int x2, int y2, int screen_width, int screen_height, uint8 color);
00022 void CopyFromBuffer(void *video, const void *src, int width, int height);
00023 void CopyToBuffer(const void *video, void *dst, int width, int height);
00024 void CopyImageToBuffer(const void *video, void *dst, int width, int height, int dst_pitch);
00025 void ScrollBuffer(void *video, int &left, int &top, int &width, int &height, int scroll_x, int scroll_y);
00026 int BufferSize(int width, int height);
00027 void PaletteAnimate(uint start, uint count);
00028 Blitter::PaletteAnimation UsePaletteAnimation();
00029
00033 static inline uint ComposeColour(uint a, uint r, uint g, uint b)
00034 {
00035 return (((a) << 24) & 0xFF000000) | (((r) << 16) & 0x00FF0000) | (((g) << 8) & 0x0000FF00) | ((b) & 0x000000FF);
00036 }
00037
00041 static inline uint32 LookupColourInPalette(uint8 index)
00042 {
00043 if (index == 0) return 0x00000000;
00044 return ComposeColour(0xFF, _cur_palette[index].r, _cur_palette[index].g, _cur_palette[index].b);
00045 }
00046
00050 static inline uint ComposeColourRGBA(uint r, uint g, uint b, uint a, uint current)
00051 {
00052 if (a == 0) return current;
00053 if (a >= 255) return ComposeColour(0xFF, r, g, b);
00054
00055 uint cr, cg, cb;
00056 cr = GB(current, 16, 8);
00057 cg = GB(current, 8, 8);
00058 cb = GB(current, 0, 8);
00059
00060
00061 return ComposeColour(0xFF,
00062 (r * a + cr * (256 - a)) / 256,
00063 (g * a + cg * (256 - a)) / 256,
00064 (b * a + cb * (256 - a)) / 256);
00065 }
00066
00070 static inline uint ComposeColourPA(uint colour, uint a, uint current)
00071 {
00072 if (a == 0) return current;
00073 if (a >= 255) return (colour | 0xFF000000);
00074
00075 uint r, g, b, cr, cg, cb;
00076 r = GB(colour, 16, 8);
00077 g = GB(colour, 8, 8);
00078 b = GB(colour, 0, 8);
00079 cr = GB(current, 16, 8);
00080 cg = GB(current, 8, 8);
00081 cb = GB(current, 0, 8);
00082
00083
00084 return ComposeColour(0xFF,
00085 (r * a + cr * (256 - a)) / 256,
00086 (g * a + cg * (256 - a)) / 256,
00087 (b * a + cb * (256 - a)) / 256);
00088 }
00089
00096 static inline uint MakeTransparent(uint colour, uint amount)
00097 {
00098 uint r, g, b;
00099 r = GB(colour, 16, 8);
00100 g = GB(colour, 8, 8);
00101 b = GB(colour, 0, 8);
00102
00103 return ComposeColour(0xFF, r * amount / 256, g * amount / 256, b * amount / 256);
00104 }
00105
00111 static inline uint MakeGrey(uint colour)
00112 {
00113 uint r, g, b;
00114 r = GB(colour, 16, 8);
00115 g = GB(colour, 8, 8);
00116 b = GB(colour, 0, 8);
00117
00118
00119
00120
00121 colour = ((r * 19595) + (g * 38470) + (b * 7471)) / 65536;
00122
00123 return ComposeColour(0xFF, colour, colour, colour);
00124 }
00125 };
00126
00127 #endif