Files
@ r9583:b6e25a00b908
Branch filter:
Location: cpp/openttd-patchpack/source/src/blitter/32bpp_base.hpp - annotation
r9583:b6e25a00b908
4.2 KiB
text/x-c++hdr
(svn r13621) -Fix: building roadbits in the wrong direction on bridges or building roadbits from underneath the bridge to the bridgehead is impossible, so don't silently ignore that error when building over houses and industries is not ignored.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 | r6937:bea726150bf3 r6937:bea726150bf3 r9111:983de9c5a848 r6937:bea726150bf3 r6937:bea726150bf3 r6937:bea726150bf3 r6937:bea726150bf3 r6937:bea726150bf3 r8113:7815c26d7612 r6937:bea726150bf3 r6937:bea726150bf3 r6937:bea726150bf3 r6937:bea726150bf3 r6937:bea726150bf3 r6937:bea726150bf3 r6937:bea726150bf3 r6937:bea726150bf3 r6937:bea726150bf3 r6937:bea726150bf3 r6947:c5e531edca92 r6948:a40a825a4044 r6985:c27a9a2405aa r6985:c27a9a2405aa r6985:c27a9a2405aa r6951:4f69e3e27c06 r6937:bea726150bf3 r6960:e903748e34e4 r6960:e903748e34e4 r6937:bea726150bf3 r6969:c3926a150708 r6969:c3926a150708 r6969:c3926a150708 r6969:c3926a150708 r6969:c3926a150708 r6969:c3926a150708 r6969:c3926a150708 r6969:c3926a150708 r6969:c3926a150708 r6969:c3926a150708 r9551:5cfb47d30fe1 r9551:5cfb47d30fe1 r6969:c3926a150708 r9551:5cfb47d30fe1 r6969:c3926a150708 r6969:c3926a150708 r6969:c3926a150708 r6969:c3926a150708 r6969:c3926a150708 r6969:c3926a150708 r6969:c3926a150708 r7552:47c4bace5157 r7552:47c4bace5157 r7552:47c4bace5157 r6969:c3926a150708 r6969:c3926a150708 r6969:c3926a150708 r6969:c3926a150708 r6969:c3926a150708 r7552:47c4bace5157 r6969:c3926a150708 r7552:47c4bace5157 r7552:47c4bace5157 r7552:47c4bace5157 r6969:c3926a150708 r6969:c3926a150708 r6969:c3926a150708 r6969:c3926a150708 r6969:c3926a150708 r6969:c3926a150708 r6969:c3926a150708 r7552:47c4bace5157 r7552:47c4bace5157 r7552:47c4bace5157 r6969:c3926a150708 r7552:47c4bace5157 r7552:47c4bace5157 r7552:47c4bace5157 r6969:c3926a150708 r6969:c3926a150708 r6969:c3926a150708 r6969:c3926a150708 r7552:47c4bace5157 r6969:c3926a150708 r7552:47c4bace5157 r7552:47c4bace5157 r7552:47c4bace5157 r6969:c3926a150708 r6969:c3926a150708 r6969:c3926a150708 r6969:c3926a150708 r6969:c3926a150708 r7552:47c4bace5157 r6969:c3926a150708 r6969:c3926a150708 r6969:c3926a150708 r6969:c3926a150708 r6969:c3926a150708 r6969:c3926a150708 r6969:c3926a150708 r6969:c3926a150708 r6969:c3926a150708 r7552:47c4bace5157 r6969:c3926a150708 r6969:c3926a150708 r6969:c3926a150708 r8969:a12996f56447 r6969:c3926a150708 r6969:c3926a150708 r6969:c3926a150708 r6969:c3926a150708 r6969:c3926a150708 r6969:c3926a150708 r6969:c3926a150708 r6969:c3926a150708 r6969:c3926a150708 r6969:c3926a150708 r6969:c3926a150708 r6969:c3926a150708 r6969:c3926a150708 r6969:c3926a150708 r6969:c3926a150708 r6969:c3926a150708 r6937:bea726150bf3 r6937:bea726150bf3 r6937:bea726150bf3 r6937:bea726150bf3 | /* $Id$ */
/** @file 32bpp_base.hpp Base for all 32 bits blitters. */
#ifndef BLITTER_32BPP_BASE_HPP
#define BLITTER_32BPP_BASE_HPP
#include "base.hpp"
#include "../core/bitmath_func.hpp"
class Blitter_32bppBase : public Blitter {
public:
/* virtual */ uint8 GetScreenDepth() { return 32; }
// /* virtual */ void Draw(Blitter::BlitterParams *bp, BlitterMode mode, ZoomLevel zoom);
// /* virtual */ void DrawColorMappingRect(void *dst, int width, int height, int pal);
// /* virtual */ Sprite *Encode(SpriteLoader::Sprite *sprite, Blitter::AllocatorProc *allocator);
/* virtual */ void *MoveTo(const void *video, int x, int y);
/* virtual */ void SetPixel(void *video, int x, int y, uint8 color);
/* virtual */ void SetPixelIfEmpty(void *video, int x, int y, uint8 color);
/* virtual */ void DrawRect(void *video, int width, int height, uint8 color);
/* virtual */ void DrawLine(void *video, int x, int y, int x2, int y2, int screen_width, int screen_height, uint8 color);
/* virtual */ void CopyFromBuffer(void *video, const void *src, int width, int height);
/* virtual */ void CopyToBuffer(const void *video, void *dst, int width, int height);
/* virtual */ void CopyImageToBuffer(const void *video, void *dst, int width, int height, int dst_pitch);
/* virtual */ void ScrollBuffer(void *video, int &left, int &top, int &width, int &height, int scroll_x, int scroll_y);
/* virtual */ int BufferSize(int width, int height);
/* virtual */ void PaletteAnimate(uint start, uint count);
/* virtual */ Blitter::PaletteAnimation UsePaletteAnimation();
/**
* Compose a colour based on RGB values.
*/
static inline uint ComposeColour(uint a, uint r, uint g, uint b)
{
return (((a) << 24) & 0xFF000000) | (((r) << 16) & 0x00FF0000) | (((g) << 8) & 0x0000FF00) | ((b) & 0x000000FF);
}
/**
* Look up the colour in the current palette.
*/
static inline uint32 LookupColourInPalette(uint index)
{
return _cur_palette[index];
}
/**
* Compose a colour based on RGBA values and the current pixel value.
*/
static inline uint ComposeColourRGBA(uint r, uint g, uint b, uint a, uint current)
{
if (a == 0) return current;
if (a >= 255) return ComposeColour(0xFF, r, g, b);
uint cr, cg, cb;
cr = GB(current, 16, 8);
cg = GB(current, 8, 8);
cb = GB(current, 0, 8);
/* The 256 is wrong, it should be 255, but 256 is much faster... */
return ComposeColour(0xFF,
(r * a + cr * (256 - a)) / 256,
(g * a + cg * (256 - a)) / 256,
(b * a + cb * (256 - a)) / 256);
}
/**
* Compose a colour based on Pixel value, alpha value, and the current pixel value.
*/
static inline uint ComposeColourPA(uint colour, uint a, uint current)
{
if (a == 0) return current;
if (a >= 255) return (colour | 0xFF000000);
uint r, g, b, cr, cg, cb;
r = GB(colour, 16, 8);
g = GB(colour, 8, 8);
b = GB(colour, 0, 8);
cr = GB(current, 16, 8);
cg = GB(current, 8, 8);
cb = GB(current, 0, 8);
/* The 256 is wrong, it should be 255, but 256 is much faster... */
return ComposeColour(0xFF,
(r * a + cr * (256 - a)) / 256,
(g * a + cg * (256 - a)) / 256,
(b * a + cb * (256 - a)) / 256);
}
/**
* Make a pixel looks like it is transparent.
* @param colour the colour already on the screen.
* @param amount the amount of transparency, times 256.
* @return the new colour for the screen.
*/
static inline uint MakeTransparent(uint colour, uint amount)
{
uint r, g, b;
r = GB(colour, 16, 8);
g = GB(colour, 8, 8);
b = GB(colour, 0, 8);
return ComposeColour(0xFF, r * amount / 256, g * amount / 256, b * amount / 256);
}
/**
* Make a colour grey - based.
* @param colour the colour to make grey.
* @return the new colour, now grey.
*/
static inline uint MakeGrey(uint colour)
{
uint r, g, b;
r = GB(colour, 16, 8);
g = GB(colour, 8, 8);
b = GB(colour, 0, 8);
/* To avoid doubles and stuff, multiple it with a total of 65536 (16bits), then
* divide by it to normalize the value to a byte again. See heightmap.cpp for
* information about the formula. */
colour = ((r * 19595) + (g * 38470) + (b * 7471)) / 65536;
return ComposeColour(0xFF, colour, colour, colour);
}
};
#endif /* BLITTER_32BPP_BASE_HPP */
|