author | frosch |
Sat, 29 Nov 2008 21:27:15 +0000 | |
changeset 10392 | 306d24c840f4 |
parent 9925 | e6abeb1fc804 |
permissions | -rw-r--r-- |
6937
40c760fcf1f6
(svn r10190) -Codechange: merged renderer and blitter to one single class API: blitter
truelight
parents:
diff
changeset
|
1 |
/* $Id$ */ |
40c760fcf1f6
(svn r10190) -Codechange: merged renderer and blitter to one single class API: blitter
truelight
parents:
diff
changeset
|
2 |
|
9111
48ce04029fe4
(svn r12971) -Documentation: add @file in files that missed them and add something more than whitespace as description of files that don't have a description.
rubidium
parents:
8969
diff
changeset
|
3 |
/** @file 32bpp_base.hpp Base for all 32 bits blitters. */ |
6937
40c760fcf1f6
(svn r10190) -Codechange: merged renderer and blitter to one single class API: blitter
truelight
parents:
diff
changeset
|
4 |
|
40c760fcf1f6
(svn r10190) -Codechange: merged renderer and blitter to one single class API: blitter
truelight
parents:
diff
changeset
|
5 |
#ifndef BLITTER_32BPP_BASE_HPP |
40c760fcf1f6
(svn r10190) -Codechange: merged renderer and blitter to one single class API: blitter
truelight
parents:
diff
changeset
|
6 |
#define BLITTER_32BPP_BASE_HPP |
40c760fcf1f6
(svn r10190) -Codechange: merged renderer and blitter to one single class API: blitter
truelight
parents:
diff
changeset
|
7 |
|
40c760fcf1f6
(svn r10190) -Codechange: merged renderer and blitter to one single class API: blitter
truelight
parents:
diff
changeset
|
8 |
#include "base.hpp" |
8113
31b7784db761
(svn r11674) -Codechange: refactor some functions out of macros.h into more logical locations.
rubidium
parents:
7552
diff
changeset
|
9 |
#include "../core/bitmath_func.hpp" |
6937
40c760fcf1f6
(svn r10190) -Codechange: merged renderer and blitter to one single class API: blitter
truelight
parents:
diff
changeset
|
10 |
|
40c760fcf1f6
(svn r10190) -Codechange: merged renderer and blitter to one single class API: blitter
truelight
parents:
diff
changeset
|
11 |
class Blitter_32bppBase : public Blitter { |
40c760fcf1f6
(svn r10190) -Codechange: merged renderer and blitter to one single class API: blitter
truelight
parents:
diff
changeset
|
12 |
public: |
40c760fcf1f6
(svn r10190) -Codechange: merged renderer and blitter to one single class API: blitter
truelight
parents:
diff
changeset
|
13 |
/* virtual */ uint8 GetScreenDepth() { return 32; } |
40c760fcf1f6
(svn r10190) -Codechange: merged renderer and blitter to one single class API: blitter
truelight
parents:
diff
changeset
|
14 |
// /* virtual */ void Draw(Blitter::BlitterParams *bp, BlitterMode mode, ZoomLevel zoom); |
40c760fcf1f6
(svn r10190) -Codechange: merged renderer and blitter to one single class API: blitter
truelight
parents:
diff
changeset
|
15 |
// /* virtual */ void DrawColorMappingRect(void *dst, int width, int height, int pal); |
40c760fcf1f6
(svn r10190) -Codechange: merged renderer and blitter to one single class API: blitter
truelight
parents:
diff
changeset
|
16 |
// /* virtual */ Sprite *Encode(SpriteLoader::Sprite *sprite, Blitter::AllocatorProc *allocator); |
40c760fcf1f6
(svn r10190) -Codechange: merged renderer and blitter to one single class API: blitter
truelight
parents:
diff
changeset
|
17 |
/* virtual */ void *MoveTo(const void *video, int x, int y); |
40c760fcf1f6
(svn r10190) -Codechange: merged renderer and blitter to one single class API: blitter
truelight
parents:
diff
changeset
|
18 |
/* virtual */ void SetPixel(void *video, int x, int y, uint8 color); |
40c760fcf1f6
(svn r10190) -Codechange: merged renderer and blitter to one single class API: blitter
truelight
parents:
diff
changeset
|
19 |
/* virtual */ void SetPixelIfEmpty(void *video, int x, int y, uint8 color); |
6947
2e14760f63f9
(svn r10201) -Codechange: Replace Blitter::SetHorizontalLine with Blitter::DrawRect, as the former was only used by the rectangle drawing code anyway. This lets us draw rectangles in one go.
peter1138
parents:
6940
diff
changeset
|
20 |
/* virtual */ void DrawRect(void *video, int width, int height, uint8 color); |
6948
d7d326482813
(svn r10203) -Codechange: more moving things to blitter-layer: DrawLine
truelight
parents:
6947
diff
changeset
|
21 |
/* virtual */ void DrawLine(void *video, int x, int y, int x2, int y2, int screen_width, int screen_height, uint8 color); |
6985
d50d59dca7c1
(svn r10241) -Codechange: CopyToBuffer now produces a buffer that is unreadable from outside the blitter, so the blitter can store anything he likes
truelight
parents:
6969
diff
changeset
|
22 |
/* virtual */ void CopyFromBuffer(void *video, const void *src, int width, int height); |
d50d59dca7c1
(svn r10241) -Codechange: CopyToBuffer now produces a buffer that is unreadable from outside the blitter, so the blitter can store anything he likes
truelight
parents:
6969
diff
changeset
|
23 |
/* virtual */ void CopyToBuffer(const void *video, void *dst, int width, int height); |
d50d59dca7c1
(svn r10241) -Codechange: CopyToBuffer now produces a buffer that is unreadable from outside the blitter, so the blitter can store anything he likes
truelight
parents:
6969
diff
changeset
|
24 |
/* virtual */ void CopyImageToBuffer(const void *video, void *dst, int width, int height, int dst_pitch); |
6951
b24e0f108ede
(svn r10206) -Codechange: more moving things to blitter-layer: ScrollBuffer
truelight
parents:
6948
diff
changeset
|
25 |
/* virtual */ void ScrollBuffer(void *video, int &left, int &top, int &width, int &height, int scroll_x, int scroll_y); |
6937
40c760fcf1f6
(svn r10190) -Codechange: merged renderer and blitter to one single class API: blitter
truelight
parents:
diff
changeset
|
26 |
/* virtual */ int BufferSize(int width, int height); |
6960
356d856462b6
(svn r10216) -Fix: palette animation always redid all palette entries, where in fact only a few indexes were needed
truelight
parents:
6951
diff
changeset
|
27 |
/* virtual */ void PaletteAnimate(uint start, uint count); |
356d856462b6
(svn r10216) -Fix: palette animation always redid all palette entries, where in fact only a few indexes were needed
truelight
parents:
6951
diff
changeset
|
28 |
/* virtual */ Blitter::PaletteAnimation UsePaletteAnimation(); |
9925
e6abeb1fc804
(svn r14080) -Fix (r14052): assert triggered when drawing chat window with 32bpp-anim blitter (backup buffer was too small)
glx
parents:
9654
diff
changeset
|
29 |
/* virtual */ int GetBytesPerPixel() { return 4; } |
6937
40c760fcf1f6
(svn r10190) -Codechange: merged renderer and blitter to one single class API: blitter
truelight
parents:
diff
changeset
|
30 |
|
6969
3d6722f0e3bd
(svn r10225) -Codechange: move common Colour routines for 32bpp to the base class (and nick it colour, not color)
truelight
parents:
6960
diff
changeset
|
31 |
/** |
3d6722f0e3bd
(svn r10225) -Codechange: move common Colour routines for 32bpp to the base class (and nick it colour, not color)
truelight
parents:
6960
diff
changeset
|
32 |
* Compose a colour based on RGB values. |
3d6722f0e3bd
(svn r10225) -Codechange: move common Colour routines for 32bpp to the base class (and nick it colour, not color)
truelight
parents:
6960
diff
changeset
|
33 |
*/ |
9597
825e5483799b
(svn r13639) -Codechange: rewrite 32bpp-anim and 32bpp-optimized drawing and encoding so it uses similiar scheme as 8bpp-optimized
smatz
parents:
9551
diff
changeset
|
34 |
static inline uint32 ComposeColour(uint a, uint r, uint g, uint b) |
6969
3d6722f0e3bd
(svn r10225) -Codechange: move common Colour routines for 32bpp to the base class (and nick it colour, not color)
truelight
parents:
6960
diff
changeset
|
35 |
{ |
3d6722f0e3bd
(svn r10225) -Codechange: move common Colour routines for 32bpp to the base class (and nick it colour, not color)
truelight
parents:
6960
diff
changeset
|
36 |
return (((a) << 24) & 0xFF000000) | (((r) << 16) & 0x00FF0000) | (((g) << 8) & 0x0000FF00) | ((b) & 0x000000FF); |
3d6722f0e3bd
(svn r10225) -Codechange: move common Colour routines for 32bpp to the base class (and nick it colour, not color)
truelight
parents:
6960
diff
changeset
|
37 |
} |
3d6722f0e3bd
(svn r10225) -Codechange: move common Colour routines for 32bpp to the base class (and nick it colour, not color)
truelight
parents:
6960
diff
changeset
|
38 |
|
3d6722f0e3bd
(svn r10225) -Codechange: move common Colour routines for 32bpp to the base class (and nick it colour, not color)
truelight
parents:
6960
diff
changeset
|
39 |
/** |
3d6722f0e3bd
(svn r10225) -Codechange: move common Colour routines for 32bpp to the base class (and nick it colour, not color)
truelight
parents:
6960
diff
changeset
|
40 |
* Look up the colour in the current palette. |
9551
6f60dca6c566
(svn r13571) -Codechange: define channels in struct Colour in different order on LE and BE machines
smatz
parents:
9111
diff
changeset
|
41 |
*/ |
6f60dca6c566
(svn r13571) -Codechange: define channels in struct Colour in different order on LE and BE machines
smatz
parents:
9111
diff
changeset
|
42 |
static inline uint32 LookupColourInPalette(uint index) |
6969
3d6722f0e3bd
(svn r10225) -Codechange: move common Colour routines for 32bpp to the base class (and nick it colour, not color)
truelight
parents:
6960
diff
changeset
|
43 |
{ |
9551
6f60dca6c566
(svn r13571) -Codechange: define channels in struct Colour in different order on LE and BE machines
smatz
parents:
9111
diff
changeset
|
44 |
return _cur_palette[index]; |
6969
3d6722f0e3bd
(svn r10225) -Codechange: move common Colour routines for 32bpp to the base class (and nick it colour, not color)
truelight
parents:
6960
diff
changeset
|
45 |
} |
3d6722f0e3bd
(svn r10225) -Codechange: move common Colour routines for 32bpp to the base class (and nick it colour, not color)
truelight
parents:
6960
diff
changeset
|
46 |
|
3d6722f0e3bd
(svn r10225) -Codechange: move common Colour routines for 32bpp to the base class (and nick it colour, not color)
truelight
parents:
6960
diff
changeset
|
47 |
/** |
3d6722f0e3bd
(svn r10225) -Codechange: move common Colour routines for 32bpp to the base class (and nick it colour, not color)
truelight
parents:
6960
diff
changeset
|
48 |
* Compose a colour based on RGBA values and the current pixel value. |
3d6722f0e3bd
(svn r10225) -Codechange: move common Colour routines for 32bpp to the base class (and nick it colour, not color)
truelight
parents:
6960
diff
changeset
|
49 |
*/ |
9597
825e5483799b
(svn r13639) -Codechange: rewrite 32bpp-anim and 32bpp-optimized drawing and encoding so it uses similiar scheme as 8bpp-optimized
smatz
parents:
9551
diff
changeset
|
50 |
static inline uint32 ComposeColourRGBANoCheck(uint r, uint g, uint b, uint a, uint32 current) |
825e5483799b
(svn r13639) -Codechange: rewrite 32bpp-anim and 32bpp-optimized drawing and encoding so it uses similiar scheme as 8bpp-optimized
smatz
parents:
9551
diff
changeset
|
51 |
{ |
825e5483799b
(svn r13639) -Codechange: rewrite 32bpp-anim and 32bpp-optimized drawing and encoding so it uses similiar scheme as 8bpp-optimized
smatz
parents:
9551
diff
changeset
|
52 |
uint cr = GB(current, 16, 8); |
825e5483799b
(svn r13639) -Codechange: rewrite 32bpp-anim and 32bpp-optimized drawing and encoding so it uses similiar scheme as 8bpp-optimized
smatz
parents:
9551
diff
changeset
|
53 |
uint cg = GB(current, 8, 8); |
825e5483799b
(svn r13639) -Codechange: rewrite 32bpp-anim and 32bpp-optimized drawing and encoding so it uses similiar scheme as 8bpp-optimized
smatz
parents:
9551
diff
changeset
|
54 |
uint cb = GB(current, 0, 8); |
825e5483799b
(svn r13639) -Codechange: rewrite 32bpp-anim and 32bpp-optimized drawing and encoding so it uses similiar scheme as 8bpp-optimized
smatz
parents:
9551
diff
changeset
|
55 |
|
825e5483799b
(svn r13639) -Codechange: rewrite 32bpp-anim and 32bpp-optimized drawing and encoding so it uses similiar scheme as 8bpp-optimized
smatz
parents:
9551
diff
changeset
|
56 |
/* The 256 is wrong, it should be 255, but 256 is much faster... */ |
825e5483799b
(svn r13639) -Codechange: rewrite 32bpp-anim and 32bpp-optimized drawing and encoding so it uses similiar scheme as 8bpp-optimized
smatz
parents:
9551
diff
changeset
|
57 |
return ComposeColour(0xFF, |
9654
11fb7b19b64b
(svn r13721) -Codechange: one less multiplication for colour mixing in 32bpp blitters (GeekToo)
smatz
parents:
9598
diff
changeset
|
58 |
((int)(r - cr) * a) / 256 + cr, |
11fb7b19b64b
(svn r13721) -Codechange: one less multiplication for colour mixing in 32bpp blitters (GeekToo)
smatz
parents:
9598
diff
changeset
|
59 |
((int)(g - cg) * a) / 256 + cg, |
11fb7b19b64b
(svn r13721) -Codechange: one less multiplication for colour mixing in 32bpp blitters (GeekToo)
smatz
parents:
9598
diff
changeset
|
60 |
((int)(b - cb) * a) / 256 + cb); |
9597
825e5483799b
(svn r13639) -Codechange: rewrite 32bpp-anim and 32bpp-optimized drawing and encoding so it uses similiar scheme as 8bpp-optimized
smatz
parents:
9551
diff
changeset
|
61 |
} |
825e5483799b
(svn r13639) -Codechange: rewrite 32bpp-anim and 32bpp-optimized drawing and encoding so it uses similiar scheme as 8bpp-optimized
smatz
parents:
9551
diff
changeset
|
62 |
|
825e5483799b
(svn r13639) -Codechange: rewrite 32bpp-anim and 32bpp-optimized drawing and encoding so it uses similiar scheme as 8bpp-optimized
smatz
parents:
9551
diff
changeset
|
63 |
/** |
825e5483799b
(svn r13639) -Codechange: rewrite 32bpp-anim and 32bpp-optimized drawing and encoding so it uses similiar scheme as 8bpp-optimized
smatz
parents:
9551
diff
changeset
|
64 |
* Compose a colour based on RGBA values and the current pixel value. |
825e5483799b
(svn r13639) -Codechange: rewrite 32bpp-anim and 32bpp-optimized drawing and encoding so it uses similiar scheme as 8bpp-optimized
smatz
parents:
9551
diff
changeset
|
65 |
* Handles fully transparent and solid pixels in a special (faster) way. |
825e5483799b
(svn r13639) -Codechange: rewrite 32bpp-anim and 32bpp-optimized drawing and encoding so it uses similiar scheme as 8bpp-optimized
smatz
parents:
9551
diff
changeset
|
66 |
*/ |
825e5483799b
(svn r13639) -Codechange: rewrite 32bpp-anim and 32bpp-optimized drawing and encoding so it uses similiar scheme as 8bpp-optimized
smatz
parents:
9551
diff
changeset
|
67 |
static inline uint32 ComposeColourRGBA(uint r, uint g, uint b, uint a, uint32 current) |
6969
3d6722f0e3bd
(svn r10225) -Codechange: move common Colour routines for 32bpp to the base class (and nick it colour, not color)
truelight
parents:
6960
diff
changeset
|
68 |
{ |
7552
56aa62dba204
(svn r11076) -Fix: MakeTransparent of 32bpp blitter used 0..100; using 0..255 makes it much faster (frosch)
truelight
parents:
6985
diff
changeset
|
69 |
if (a == 0) return current; |
56aa62dba204
(svn r11076) -Fix: MakeTransparent of 32bpp blitter used 0..100; using 0..255 makes it much faster (frosch)
truelight
parents:
6985
diff
changeset
|
70 |
if (a >= 255) return ComposeColour(0xFF, r, g, b); |
56aa62dba204
(svn r11076) -Fix: MakeTransparent of 32bpp blitter used 0..100; using 0..255 makes it much faster (frosch)
truelight
parents:
6985
diff
changeset
|
71 |
|
9597
825e5483799b
(svn r13639) -Codechange: rewrite 32bpp-anim and 32bpp-optimized drawing and encoding so it uses similiar scheme as 8bpp-optimized
smatz
parents:
9551
diff
changeset
|
72 |
return ComposeColourRGBANoCheck(r, g, b, a, current); |
825e5483799b
(svn r13639) -Codechange: rewrite 32bpp-anim and 32bpp-optimized drawing and encoding so it uses similiar scheme as 8bpp-optimized
smatz
parents:
9551
diff
changeset
|
73 |
} |
825e5483799b
(svn r13639) -Codechange: rewrite 32bpp-anim and 32bpp-optimized drawing and encoding so it uses similiar scheme as 8bpp-optimized
smatz
parents:
9551
diff
changeset
|
74 |
|
825e5483799b
(svn r13639) -Codechange: rewrite 32bpp-anim and 32bpp-optimized drawing and encoding so it uses similiar scheme as 8bpp-optimized
smatz
parents:
9551
diff
changeset
|
75 |
/** |
825e5483799b
(svn r13639) -Codechange: rewrite 32bpp-anim and 32bpp-optimized drawing and encoding so it uses similiar scheme as 8bpp-optimized
smatz
parents:
9551
diff
changeset
|
76 |
* Compose a colour based on Pixel value, alpha value, and the current pixel value. |
825e5483799b
(svn r13639) -Codechange: rewrite 32bpp-anim and 32bpp-optimized drawing and encoding so it uses similiar scheme as 8bpp-optimized
smatz
parents:
9551
diff
changeset
|
77 |
*/ |
825e5483799b
(svn r13639) -Codechange: rewrite 32bpp-anim and 32bpp-optimized drawing and encoding so it uses similiar scheme as 8bpp-optimized
smatz
parents:
9551
diff
changeset
|
78 |
static inline uint32 ComposeColourPANoCheck(uint32 colour, uint a, uint32 current) |
825e5483799b
(svn r13639) -Codechange: rewrite 32bpp-anim and 32bpp-optimized drawing and encoding so it uses similiar scheme as 8bpp-optimized
smatz
parents:
9551
diff
changeset
|
79 |
{ |
825e5483799b
(svn r13639) -Codechange: rewrite 32bpp-anim and 32bpp-optimized drawing and encoding so it uses similiar scheme as 8bpp-optimized
smatz
parents:
9551
diff
changeset
|
80 |
uint r = GB(colour, 16, 8); |
825e5483799b
(svn r13639) -Codechange: rewrite 32bpp-anim and 32bpp-optimized drawing and encoding so it uses similiar scheme as 8bpp-optimized
smatz
parents:
9551
diff
changeset
|
81 |
uint g = GB(colour, 8, 8); |
825e5483799b
(svn r13639) -Codechange: rewrite 32bpp-anim and 32bpp-optimized drawing and encoding so it uses similiar scheme as 8bpp-optimized
smatz
parents:
9551
diff
changeset
|
82 |
uint b = GB(colour, 0, 8); |
6969
3d6722f0e3bd
(svn r10225) -Codechange: move common Colour routines for 32bpp to the base class (and nick it colour, not color)
truelight
parents:
6960
diff
changeset
|
83 |
|
9654
11fb7b19b64b
(svn r13721) -Codechange: one less multiplication for colour mixing in 32bpp blitters (GeekToo)
smatz
parents:
9598
diff
changeset
|
84 |
return ComposeColourRGBANoCheck(r, g, b, a, current); |
6969
3d6722f0e3bd
(svn r10225) -Codechange: move common Colour routines for 32bpp to the base class (and nick it colour, not color)
truelight
parents:
6960
diff
changeset
|
85 |
} |
3d6722f0e3bd
(svn r10225) -Codechange: move common Colour routines for 32bpp to the base class (and nick it colour, not color)
truelight
parents:
6960
diff
changeset
|
86 |
|
3d6722f0e3bd
(svn r10225) -Codechange: move common Colour routines for 32bpp to the base class (and nick it colour, not color)
truelight
parents:
6960
diff
changeset
|
87 |
/** |
9597
825e5483799b
(svn r13639) -Codechange: rewrite 32bpp-anim and 32bpp-optimized drawing and encoding so it uses similiar scheme as 8bpp-optimized
smatz
parents:
9551
diff
changeset
|
88 |
* Compose a colour based on Pixel value, alpha value, and the current pixel value. |
825e5483799b
(svn r13639) -Codechange: rewrite 32bpp-anim and 32bpp-optimized drawing and encoding so it uses similiar scheme as 8bpp-optimized
smatz
parents:
9551
diff
changeset
|
89 |
* Handles fully transparent and solid pixels in a special (faster) way. |
825e5483799b
(svn r13639) -Codechange: rewrite 32bpp-anim and 32bpp-optimized drawing and encoding so it uses similiar scheme as 8bpp-optimized
smatz
parents:
9551
diff
changeset
|
90 |
*/ |
825e5483799b
(svn r13639) -Codechange: rewrite 32bpp-anim and 32bpp-optimized drawing and encoding so it uses similiar scheme as 8bpp-optimized
smatz
parents:
9551
diff
changeset
|
91 |
static inline uint32 ComposeColourPA(uint32 colour, uint a, uint32 current) |
6969
3d6722f0e3bd
(svn r10225) -Codechange: move common Colour routines for 32bpp to the base class (and nick it colour, not color)
truelight
parents:
6960
diff
changeset
|
92 |
{ |
7552
56aa62dba204
(svn r11076) -Fix: MakeTransparent of 32bpp blitter used 0..100; using 0..255 makes it much faster (frosch)
truelight
parents:
6985
diff
changeset
|
93 |
if (a == 0) return current; |
56aa62dba204
(svn r11076) -Fix: MakeTransparent of 32bpp blitter used 0..100; using 0..255 makes it much faster (frosch)
truelight
parents:
6985
diff
changeset
|
94 |
if (a >= 255) return (colour | 0xFF000000); |
56aa62dba204
(svn r11076) -Fix: MakeTransparent of 32bpp blitter used 0..100; using 0..255 makes it much faster (frosch)
truelight
parents:
6985
diff
changeset
|
95 |
|
9597
825e5483799b
(svn r13639) -Codechange: rewrite 32bpp-anim and 32bpp-optimized drawing and encoding so it uses similiar scheme as 8bpp-optimized
smatz
parents:
9551
diff
changeset
|
96 |
return ComposeColourPANoCheck(colour, a, current); |
6969
3d6722f0e3bd
(svn r10225) -Codechange: move common Colour routines for 32bpp to the base class (and nick it colour, not color)
truelight
parents:
6960
diff
changeset
|
97 |
} |
3d6722f0e3bd
(svn r10225) -Codechange: move common Colour routines for 32bpp to the base class (and nick it colour, not color)
truelight
parents:
6960
diff
changeset
|
98 |
|
3d6722f0e3bd
(svn r10225) -Codechange: move common Colour routines for 32bpp to the base class (and nick it colour, not color)
truelight
parents:
6960
diff
changeset
|
99 |
/** |
3d6722f0e3bd
(svn r10225) -Codechange: move common Colour routines for 32bpp to the base class (and nick it colour, not color)
truelight
parents:
6960
diff
changeset
|
100 |
* Make a pixel looks like it is transparent. |
3d6722f0e3bd
(svn r10225) -Codechange: move common Colour routines for 32bpp to the base class (and nick it colour, not color)
truelight
parents:
6960
diff
changeset
|
101 |
* @param colour the colour already on the screen. |
9598
101174f1c2b8
(svn r13640) -Codechange: make colours behind not fully solid objects less darker for BM_TRANSPARENT (for 32bpp blitters)
smatz
parents:
9597
diff
changeset
|
102 |
* @param nom the amount of transparency, nominator, makes colour lighter. |
101174f1c2b8
(svn r13640) -Codechange: make colours behind not fully solid objects less darker for BM_TRANSPARENT (for 32bpp blitters)
smatz
parents:
9597
diff
changeset
|
103 |
* @param denom denominator, makes colour darker. |
6969
3d6722f0e3bd
(svn r10225) -Codechange: move common Colour routines for 32bpp to the base class (and nick it colour, not color)
truelight
parents:
6960
diff
changeset
|
104 |
* @return the new colour for the screen. |
3d6722f0e3bd
(svn r10225) -Codechange: move common Colour routines for 32bpp to the base class (and nick it colour, not color)
truelight
parents:
6960
diff
changeset
|
105 |
*/ |
9598
101174f1c2b8
(svn r13640) -Codechange: make colours behind not fully solid objects less darker for BM_TRANSPARENT (for 32bpp blitters)
smatz
parents:
9597
diff
changeset
|
106 |
static inline uint32 MakeTransparent(uint32 colour, uint nom, uint denom = 256) |
6969
3d6722f0e3bd
(svn r10225) -Codechange: move common Colour routines for 32bpp to the base class (and nick it colour, not color)
truelight
parents:
6960
diff
changeset
|
107 |
{ |
9597
825e5483799b
(svn r13639) -Codechange: rewrite 32bpp-anim and 32bpp-optimized drawing and encoding so it uses similiar scheme as 8bpp-optimized
smatz
parents:
9551
diff
changeset
|
108 |
uint r = GB(colour, 16, 8); |
825e5483799b
(svn r13639) -Codechange: rewrite 32bpp-anim and 32bpp-optimized drawing and encoding so it uses similiar scheme as 8bpp-optimized
smatz
parents:
9551
diff
changeset
|
109 |
uint g = GB(colour, 8, 8); |
825e5483799b
(svn r13639) -Codechange: rewrite 32bpp-anim and 32bpp-optimized drawing and encoding so it uses similiar scheme as 8bpp-optimized
smatz
parents:
9551
diff
changeset
|
110 |
uint b = GB(colour, 0, 8); |
6969
3d6722f0e3bd
(svn r10225) -Codechange: move common Colour routines for 32bpp to the base class (and nick it colour, not color)
truelight
parents:
6960
diff
changeset
|
111 |
|
9598
101174f1c2b8
(svn r13640) -Codechange: make colours behind not fully solid objects less darker for BM_TRANSPARENT (for 32bpp blitters)
smatz
parents:
9597
diff
changeset
|
112 |
return ComposeColour(0xFF, r * nom / denom, g * nom / denom, b * nom / denom); |
6969
3d6722f0e3bd
(svn r10225) -Codechange: move common Colour routines for 32bpp to the base class (and nick it colour, not color)
truelight
parents:
6960
diff
changeset
|
113 |
} |
3d6722f0e3bd
(svn r10225) -Codechange: move common Colour routines for 32bpp to the base class (and nick it colour, not color)
truelight
parents:
6960
diff
changeset
|
114 |
|
3d6722f0e3bd
(svn r10225) -Codechange: move common Colour routines for 32bpp to the base class (and nick it colour, not color)
truelight
parents:
6960
diff
changeset
|
115 |
/** |
8969
6d1c74e0e2cd
(svn r12761) -Codechange: lots of minor whitespace coding style fixes around operators.
rubidium
parents:
8113
diff
changeset
|
116 |
* Make a colour grey - based. |
6969
3d6722f0e3bd
(svn r10225) -Codechange: move common Colour routines for 32bpp to the base class (and nick it colour, not color)
truelight
parents:
6960
diff
changeset
|
117 |
* @param colour the colour to make grey. |
3d6722f0e3bd
(svn r10225) -Codechange: move common Colour routines for 32bpp to the base class (and nick it colour, not color)
truelight
parents:
6960
diff
changeset
|
118 |
* @return the new colour, now grey. |
3d6722f0e3bd
(svn r10225) -Codechange: move common Colour routines for 32bpp to the base class (and nick it colour, not color)
truelight
parents:
6960
diff
changeset
|
119 |
*/ |
9597
825e5483799b
(svn r13639) -Codechange: rewrite 32bpp-anim and 32bpp-optimized drawing and encoding so it uses similiar scheme as 8bpp-optimized
smatz
parents:
9551
diff
changeset
|
120 |
static inline uint32 MakeGrey(uint32 colour) |
6969
3d6722f0e3bd
(svn r10225) -Codechange: move common Colour routines for 32bpp to the base class (and nick it colour, not color)
truelight
parents:
6960
diff
changeset
|
121 |
{ |
9597
825e5483799b
(svn r13639) -Codechange: rewrite 32bpp-anim and 32bpp-optimized drawing and encoding so it uses similiar scheme as 8bpp-optimized
smatz
parents:
9551
diff
changeset
|
122 |
uint r = GB(colour, 16, 8); |
825e5483799b
(svn r13639) -Codechange: rewrite 32bpp-anim and 32bpp-optimized drawing and encoding so it uses similiar scheme as 8bpp-optimized
smatz
parents:
9551
diff
changeset
|
123 |
uint g = GB(colour, 8, 8); |
825e5483799b
(svn r13639) -Codechange: rewrite 32bpp-anim and 32bpp-optimized drawing and encoding so it uses similiar scheme as 8bpp-optimized
smatz
parents:
9551
diff
changeset
|
124 |
uint b = GB(colour, 0, 8); |
6969
3d6722f0e3bd
(svn r10225) -Codechange: move common Colour routines for 32bpp to the base class (and nick it colour, not color)
truelight
parents:
6960
diff
changeset
|
125 |
|
3d6722f0e3bd
(svn r10225) -Codechange: move common Colour routines for 32bpp to the base class (and nick it colour, not color)
truelight
parents:
6960
diff
changeset
|
126 |
/* To avoid doubles and stuff, multiple it with a total of 65536 (16bits), then |
3d6722f0e3bd
(svn r10225) -Codechange: move common Colour routines for 32bpp to the base class (and nick it colour, not color)
truelight
parents:
6960
diff
changeset
|
127 |
* divide by it to normalize the value to a byte again. See heightmap.cpp for |
3d6722f0e3bd
(svn r10225) -Codechange: move common Colour routines for 32bpp to the base class (and nick it colour, not color)
truelight
parents:
6960
diff
changeset
|
128 |
* information about the formula. */ |
3d6722f0e3bd
(svn r10225) -Codechange: move common Colour routines for 32bpp to the base class (and nick it colour, not color)
truelight
parents:
6960
diff
changeset
|
129 |
colour = ((r * 19595) + (g * 38470) + (b * 7471)) / 65536; |
3d6722f0e3bd
(svn r10225) -Codechange: move common Colour routines for 32bpp to the base class (and nick it colour, not color)
truelight
parents:
6960
diff
changeset
|
130 |
|
3d6722f0e3bd
(svn r10225) -Codechange: move common Colour routines for 32bpp to the base class (and nick it colour, not color)
truelight
parents:
6960
diff
changeset
|
131 |
return ComposeColour(0xFF, colour, colour, colour); |
6937
40c760fcf1f6
(svn r10190) -Codechange: merged renderer and blitter to one single class API: blitter
truelight
parents:
diff
changeset
|
132 |
} |
40c760fcf1f6
(svn r10190) -Codechange: merged renderer and blitter to one single class API: blitter
truelight
parents:
diff
changeset
|
133 |
}; |
40c760fcf1f6
(svn r10190) -Codechange: merged renderer and blitter to one single class API: blitter
truelight
parents:
diff
changeset
|
134 |
|
40c760fcf1f6
(svn r10190) -Codechange: merged renderer and blitter to one single class API: blitter
truelight
parents:
diff
changeset
|
135 |
#endif /* BLITTER_32BPP_BASE_HPP */ |