Usermode/AxWin4 - PushData implemented
[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         message.WriteU8(IPCMSG_PUSHDATA);
19         message.WriteU16(Window->m_id);
20         message.WriteU16(X);
21         message.WriteU16(Y);
22         message.WriteU16(W);
23         message.WriteU16(H);
24         message.WriteBuffer(H*W*4, Data);
25         ::AxWin::SendMessage(message);
26 }
27
28 extern "C" void AxWin4_DrawBitmap(tAxWin4_Window *Window, int X, int Y, unsigned int W, unsigned int H, void *Data)
29 {
30         // TODO: Split message up into blocks such that it can be dispatched
31         if( W > 128 )
32         {
33                 const uint32_t* data32 = static_cast<uint32_t*>(Data);
34                 const unsigned int rows_per_message = 1;        // 2048 / W;
35                 for( unsigned int row = 0; row < H; row += rows_per_message )
36                 {
37                         _push_data(Window, X, Y+row, W, ::std::min(rows_per_message,H-row), data32);
38                         data32 += W*rows_per_message;
39                 }
40         }
41         else
42         {
43                 _push_data(Window, X, Y, W, H, Data);
44         }
45 }
46
47 };      // namespace AxWin
48

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