Usermode/AxWin4 - Working in shared memory usage
[tpg/acess2.git] / Usermode / Libraries / libaxwin4.so_src / window_drawing.cpp
1 /*
2  * AxWin4 Interface Library
3  * - By John Hodge (thePowersGang)
4  *
5  * window_drawing.cpp
6  * - Window drawing code
7  */
8 #include <axwin4/axwin.h>
9 #include "include/common.hpp"
10 #include <ipc_proto.hpp>
11 #include <algorithm>    // min
12
13 namespace AxWin {
14
15 void _push_data(tAxWin4_Window *Window, int X, int Y, unsigned int W, unsigned int H, const void *Data)
16 {
17         CSerialiser     message;
18         //_SysDebug("_push_data - (%i,%i), %ix%i %p", X, Y, W, H, Data);
19         message.WriteU8(IPCMSG_PUSHDATA);
20         message.WriteU16(Window->m_id);
21         message.WriteU16(X);
22         message.WriteU16(Y);
23         message.WriteU16(W);
24         message.WriteU16(H);
25         message.WriteBuffer(H*W*4, Data);
26         ::AxWin::SendMessage(message);
27 }
28
29 extern "C" void AxWin4_DrawBitmap(tAxWin4_Window *Window, int X, int Y, unsigned int W, unsigned int H, void *Data)
30 {
31         // TODO: Split message up into blocks such that it can be dispatched
32         if( W > 128 )
33         {
34                 const uint32_t* data32 = static_cast<uint32_t*>(Data);
35                 const unsigned int rows_per_message = 1;        // 2048 / W;
36                 for( unsigned int row = 0; row < H; row += rows_per_message )
37                 {
38                         _push_data(Window, X, Y+row, W, ::std::min(rows_per_message,H-row), data32);
39                         data32 += W*rows_per_message;
40                 }
41         }
42         else
43         {
44                 _push_data(Window, X, Y, W, H, Data);
45         }
46 }
47
48 };      // namespace AxWin
49

UCC git Repository :: git.ucc.asn.au