author | truelight |
Wed, 13 Jun 2007 10:31:40 +0000 | |
changeset 6889 | 2160bf28040b |
permissions | -rw-r--r-- |
6889
2160bf28040b
(svn r10132) -Codechange: split out the last direct video-buffer read access to the blitter-layer
truelight
parents:
diff
changeset
|
1 |
#include "../stdafx.h" |
2160bf28040b
(svn r10132) -Codechange: split out the last direct video-buffer read access to the blitter-layer
truelight
parents:
diff
changeset
|
2 |
#include "../gfx.h" |
2160bf28040b
(svn r10132) -Codechange: split out the last direct video-buffer read access to the blitter-layer
truelight
parents:
diff
changeset
|
3 |
#include "32bpp.hpp" |
2160bf28040b
(svn r10132) -Codechange: split out the last direct video-buffer read access to the blitter-layer
truelight
parents:
diff
changeset
|
4 |
|
2160bf28040b
(svn r10132) -Codechange: split out the last direct video-buffer read access to the blitter-layer
truelight
parents:
diff
changeset
|
5 |
static FRenderer_32bpp iFRenderer_32bpp; |
2160bf28040b
(svn r10132) -Codechange: split out the last direct video-buffer read access to the blitter-layer
truelight
parents:
diff
changeset
|
6 |
|
2160bf28040b
(svn r10132) -Codechange: split out the last direct video-buffer read access to the blitter-layer
truelight
parents:
diff
changeset
|
7 |
void *Renderer_32bpp::MoveTo(const void *video, int x, int y) |
2160bf28040b
(svn r10132) -Codechange: split out the last direct video-buffer read access to the blitter-layer
truelight
parents:
diff
changeset
|
8 |
{ |
2160bf28040b
(svn r10132) -Codechange: split out the last direct video-buffer read access to the blitter-layer
truelight
parents:
diff
changeset
|
9 |
return (uint32 *)video + x + y * _screen.pitch; |
2160bf28040b
(svn r10132) -Codechange: split out the last direct video-buffer read access to the blitter-layer
truelight
parents:
diff
changeset
|
10 |
} |
2160bf28040b
(svn r10132) -Codechange: split out the last direct video-buffer read access to the blitter-layer
truelight
parents:
diff
changeset
|
11 |
|
2160bf28040b
(svn r10132) -Codechange: split out the last direct video-buffer read access to the blitter-layer
truelight
parents:
diff
changeset
|
12 |
void Renderer_32bpp::SetPixel(void *video, int x, int y, uint8 color) |
2160bf28040b
(svn r10132) -Codechange: split out the last direct video-buffer read access to the blitter-layer
truelight
parents:
diff
changeset
|
13 |
{ |
2160bf28040b
(svn r10132) -Codechange: split out the last direct video-buffer read access to the blitter-layer
truelight
parents:
diff
changeset
|
14 |
*((uint32 *)video + x + y * _screen.pitch) = LookupColourInPalette(color); |
2160bf28040b
(svn r10132) -Codechange: split out the last direct video-buffer read access to the blitter-layer
truelight
parents:
diff
changeset
|
15 |
} |
2160bf28040b
(svn r10132) -Codechange: split out the last direct video-buffer read access to the blitter-layer
truelight
parents:
diff
changeset
|
16 |
|
2160bf28040b
(svn r10132) -Codechange: split out the last direct video-buffer read access to the blitter-layer
truelight
parents:
diff
changeset
|
17 |
void Renderer_32bpp::SetPixelIfEmpty(void *video, int x, int y, uint8 color) |
2160bf28040b
(svn r10132) -Codechange: split out the last direct video-buffer read access to the blitter-layer
truelight
parents:
diff
changeset
|
18 |
{ |
2160bf28040b
(svn r10132) -Codechange: split out the last direct video-buffer read access to the blitter-layer
truelight
parents:
diff
changeset
|
19 |
uint32 *dst = (uint32 *)video + x + y * _screen.pitch; |
2160bf28040b
(svn r10132) -Codechange: split out the last direct video-buffer read access to the blitter-layer
truelight
parents:
diff
changeset
|
20 |
if (*dst == 0) *dst = LookupColourInPalette(color); |
2160bf28040b
(svn r10132) -Codechange: split out the last direct video-buffer read access to the blitter-layer
truelight
parents:
diff
changeset
|
21 |
} |
2160bf28040b
(svn r10132) -Codechange: split out the last direct video-buffer read access to the blitter-layer
truelight
parents:
diff
changeset
|
22 |
|
2160bf28040b
(svn r10132) -Codechange: split out the last direct video-buffer read access to the blitter-layer
truelight
parents:
diff
changeset
|
23 |
void Renderer_32bpp::SetHorizontalLine(void *video, int width, uint8 color) |
2160bf28040b
(svn r10132) -Codechange: split out the last direct video-buffer read access to the blitter-layer
truelight
parents:
diff
changeset
|
24 |
{ |
2160bf28040b
(svn r10132) -Codechange: split out the last direct video-buffer read access to the blitter-layer
truelight
parents:
diff
changeset
|
25 |
uint32 *dst = (uint32 *)video; |
2160bf28040b
(svn r10132) -Codechange: split out the last direct video-buffer read access to the blitter-layer
truelight
parents:
diff
changeset
|
26 |
uint32 color32 = LookupColourInPalette(color); |
2160bf28040b
(svn r10132) -Codechange: split out the last direct video-buffer read access to the blitter-layer
truelight
parents:
diff
changeset
|
27 |
|
2160bf28040b
(svn r10132) -Codechange: split out the last direct video-buffer read access to the blitter-layer
truelight
parents:
diff
changeset
|
28 |
for (; width > 0; width--) { |
2160bf28040b
(svn r10132) -Codechange: split out the last direct video-buffer read access to the blitter-layer
truelight
parents:
diff
changeset
|
29 |
*dst = color32; |
2160bf28040b
(svn r10132) -Codechange: split out the last direct video-buffer read access to the blitter-layer
truelight
parents:
diff
changeset
|
30 |
dst++; |
2160bf28040b
(svn r10132) -Codechange: split out the last direct video-buffer read access to the blitter-layer
truelight
parents:
diff
changeset
|
31 |
} |
2160bf28040b
(svn r10132) -Codechange: split out the last direct video-buffer read access to the blitter-layer
truelight
parents:
diff
changeset
|
32 |
} |
2160bf28040b
(svn r10132) -Codechange: split out the last direct video-buffer read access to the blitter-layer
truelight
parents:
diff
changeset
|
33 |
|
2160bf28040b
(svn r10132) -Codechange: split out the last direct video-buffer read access to the blitter-layer
truelight
parents:
diff
changeset
|
34 |
void Renderer_32bpp::CopyFromBuffer(void *video, const void *src, int width, int height, int src_pitch) |
2160bf28040b
(svn r10132) -Codechange: split out the last direct video-buffer read access to the blitter-layer
truelight
parents:
diff
changeset
|
35 |
{ |
2160bf28040b
(svn r10132) -Codechange: split out the last direct video-buffer read access to the blitter-layer
truelight
parents:
diff
changeset
|
36 |
int direction = (height < 0) ? -1 : 1; |
2160bf28040b
(svn r10132) -Codechange: split out the last direct video-buffer read access to the blitter-layer
truelight
parents:
diff
changeset
|
37 |
uint32 *dst = (uint32 *)video; |
2160bf28040b
(svn r10132) -Codechange: split out the last direct video-buffer read access to the blitter-layer
truelight
parents:
diff
changeset
|
38 |
uint32 *usrc = (uint32 *)src; |
2160bf28040b
(svn r10132) -Codechange: split out the last direct video-buffer read access to the blitter-layer
truelight
parents:
diff
changeset
|
39 |
|
2160bf28040b
(svn r10132) -Codechange: split out the last direct video-buffer read access to the blitter-layer
truelight
parents:
diff
changeset
|
40 |
height = abs(height); |
2160bf28040b
(svn r10132) -Codechange: split out the last direct video-buffer read access to the blitter-layer
truelight
parents:
diff
changeset
|
41 |
for (; height > 0; height--) { |
2160bf28040b
(svn r10132) -Codechange: split out the last direct video-buffer read access to the blitter-layer
truelight
parents:
diff
changeset
|
42 |
memcpy(dst, usrc, width * sizeof(uint32)); |
2160bf28040b
(svn r10132) -Codechange: split out the last direct video-buffer read access to the blitter-layer
truelight
parents:
diff
changeset
|
43 |
usrc += src_pitch * direction; |
2160bf28040b
(svn r10132) -Codechange: split out the last direct video-buffer read access to the blitter-layer
truelight
parents:
diff
changeset
|
44 |
dst += _screen.pitch * direction; |
2160bf28040b
(svn r10132) -Codechange: split out the last direct video-buffer read access to the blitter-layer
truelight
parents:
diff
changeset
|
45 |
} |
2160bf28040b
(svn r10132) -Codechange: split out the last direct video-buffer read access to the blitter-layer
truelight
parents:
diff
changeset
|
46 |
} |
2160bf28040b
(svn r10132) -Codechange: split out the last direct video-buffer read access to the blitter-layer
truelight
parents:
diff
changeset
|
47 |
|
2160bf28040b
(svn r10132) -Codechange: split out the last direct video-buffer read access to the blitter-layer
truelight
parents:
diff
changeset
|
48 |
void Renderer_32bpp::CopyToBuffer(const void *video, void *dst, int width, int height, int dst_pitch) |
2160bf28040b
(svn r10132) -Codechange: split out the last direct video-buffer read access to the blitter-layer
truelight
parents:
diff
changeset
|
49 |
{ |
2160bf28040b
(svn r10132) -Codechange: split out the last direct video-buffer read access to the blitter-layer
truelight
parents:
diff
changeset
|
50 |
int direction = (height < 0) ? -1 : 1; |
2160bf28040b
(svn r10132) -Codechange: split out the last direct video-buffer read access to the blitter-layer
truelight
parents:
diff
changeset
|
51 |
uint32 *udst = (uint32 *)dst; |
2160bf28040b
(svn r10132) -Codechange: split out the last direct video-buffer read access to the blitter-layer
truelight
parents:
diff
changeset
|
52 |
uint32 *src = (uint32 *)video; |
2160bf28040b
(svn r10132) -Codechange: split out the last direct video-buffer read access to the blitter-layer
truelight
parents:
diff
changeset
|
53 |
|
2160bf28040b
(svn r10132) -Codechange: split out the last direct video-buffer read access to the blitter-layer
truelight
parents:
diff
changeset
|
54 |
height = abs(height); |
2160bf28040b
(svn r10132) -Codechange: split out the last direct video-buffer read access to the blitter-layer
truelight
parents:
diff
changeset
|
55 |
for (; height > 0; height--) { |
2160bf28040b
(svn r10132) -Codechange: split out the last direct video-buffer read access to the blitter-layer
truelight
parents:
diff
changeset
|
56 |
memcpy(udst, src, width * sizeof(uint32)); |
2160bf28040b
(svn r10132) -Codechange: split out the last direct video-buffer read access to the blitter-layer
truelight
parents:
diff
changeset
|
57 |
src += _screen.pitch * direction; |
2160bf28040b
(svn r10132) -Codechange: split out the last direct video-buffer read access to the blitter-layer
truelight
parents:
diff
changeset
|
58 |
udst += dst_pitch * direction; |
2160bf28040b
(svn r10132) -Codechange: split out the last direct video-buffer read access to the blitter-layer
truelight
parents:
diff
changeset
|
59 |
} |
2160bf28040b
(svn r10132) -Codechange: split out the last direct video-buffer read access to the blitter-layer
truelight
parents:
diff
changeset
|
60 |
} |
2160bf28040b
(svn r10132) -Codechange: split out the last direct video-buffer read access to the blitter-layer
truelight
parents:
diff
changeset
|
61 |
|
2160bf28040b
(svn r10132) -Codechange: split out the last direct video-buffer read access to the blitter-layer
truelight
parents:
diff
changeset
|
62 |
void Renderer_32bpp::MoveBuffer(void *video_dst, const void *video_src, int width, int height) |
2160bf28040b
(svn r10132) -Codechange: split out the last direct video-buffer read access to the blitter-layer
truelight
parents:
diff
changeset
|
63 |
{ |
2160bf28040b
(svn r10132) -Codechange: split out the last direct video-buffer read access to the blitter-layer
truelight
parents:
diff
changeset
|
64 |
uint32 *dst = (uint32 *)video_dst; |
2160bf28040b
(svn r10132) -Codechange: split out the last direct video-buffer read access to the blitter-layer
truelight
parents:
diff
changeset
|
65 |
uint32 *src = (uint32 *)video_src; |
2160bf28040b
(svn r10132) -Codechange: split out the last direct video-buffer read access to the blitter-layer
truelight
parents:
diff
changeset
|
66 |
|
2160bf28040b
(svn r10132) -Codechange: split out the last direct video-buffer read access to the blitter-layer
truelight
parents:
diff
changeset
|
67 |
for (; height > 0; height--) { |
2160bf28040b
(svn r10132) -Codechange: split out the last direct video-buffer read access to the blitter-layer
truelight
parents:
diff
changeset
|
68 |
memmove(dst, src, width * sizeof(uint32)); |
2160bf28040b
(svn r10132) -Codechange: split out the last direct video-buffer read access to the blitter-layer
truelight
parents:
diff
changeset
|
69 |
src += _screen.pitch; |
2160bf28040b
(svn r10132) -Codechange: split out the last direct video-buffer read access to the blitter-layer
truelight
parents:
diff
changeset
|
70 |
dst += _screen.pitch; |
2160bf28040b
(svn r10132) -Codechange: split out the last direct video-buffer read access to the blitter-layer
truelight
parents:
diff
changeset
|
71 |
} |
2160bf28040b
(svn r10132) -Codechange: split out the last direct video-buffer read access to the blitter-layer
truelight
parents:
diff
changeset
|
72 |
} |
2160bf28040b
(svn r10132) -Codechange: split out the last direct video-buffer read access to the blitter-layer
truelight
parents:
diff
changeset
|
73 |
|
2160bf28040b
(svn r10132) -Codechange: split out the last direct video-buffer read access to the blitter-layer
truelight
parents:
diff
changeset
|
74 |
int Renderer_32bpp::BufferSize(int width, int height) |
2160bf28040b
(svn r10132) -Codechange: split out the last direct video-buffer read access to the blitter-layer
truelight
parents:
diff
changeset
|
75 |
{ |
2160bf28040b
(svn r10132) -Codechange: split out the last direct video-buffer read access to the blitter-layer
truelight
parents:
diff
changeset
|
76 |
return width * height * sizeof(uint32); |
2160bf28040b
(svn r10132) -Codechange: split out the last direct video-buffer read access to the blitter-layer
truelight
parents:
diff
changeset
|
77 |
} |