in the middle of hacking the bitmap module so it can directly
[neuro.git] / src / video / pixels.c
blob5b535fb519af4cd49cd88ec310e53ea07dcfc74e
2 /*
3 * libneuro, a light weight abstraction of high or lower libraries
4 * and toolkit for applications.
5 * Copyright (C) 2005-2006 Nicholas Niro, Robert Lemay
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
22 /* pixels.c
23 * Module : Pixels
25 * not yet included in the main stream, this is a dormant module
28 /*-------------------- Extern Headers Including --------------------*/
31 /*-------------------- Local Headers Including ---------------------*/
33 /*-------------------- Main Module Header --------------------------*/
34 #include "video.h"
37 /*-------------------- Other ----------------------------*/
39 /*-------------------- Global Variables ----------------------------*/
41 /*-------------------- Static Variables ----------------------------*/
43 /* 1 is that the pixels will be cleaned during this cycle and 0 is no it won't */
44 static u8 clean_pixel_in_this_cycle;
46 /* the pixels buffer */
47 static EBUF *_Pixel;
49 typedef struct PIXEL_ENGINE
51 u32 x, y;
52 }PIXEL_ENGINE;
54 /*-------------------- Static Prototypes ---------------------------*/
58 /*-------------------- Static Functions ----------------------------*/
60 static void
61 cleanPixels()
63 EBUF *tmp;
64 Rectan buf;
65 PIXEL_ENGINE *pix;
66 u32 current;
68 tmp = _Pixel;
70 current = Neuro_GiveEBufCount(tmp);
72 if (current <= 0)
73 return;
76 if (!Neuro_EBufIsEmpty(tmp))
78 while (current-- > 0)
80 pix = Neuro_GiveEBuf(tmp, current);
81 buf.x = pix->x;
82 buf.y = pix->y;
84 buf.w = 1;
85 buf.h = 1;
88 Neuro_CleanEBuf(&_Pixel);
91 /*-------------------- Global Functions ----------------------------*/
93 void
94 Neuro_PutPixel(v_object *vobj, u32 x, u32 y, u32 pixel)
96 /*EBUF *tmp;
97 PIXEL_ENGINE *buf;
98 u32 current;
99 Rectan check;
102 check.x = x;
103 check.y = y;
104 check.h = 1;
105 check.w = 1;
107 if (secureBoundsCheck(&check))
109 printf("Unsecure Pixel position have been catched, dropping the instruction\n");
110 return;
113 tmp = _Pixel;
114 Neuro_AllocEBuf(tmp, sizeof(PIXEL_ENGINE*), sizeof(PIXEL_ENGINE));
116 current = Neuro_GiveEBufCount(tmp);
117 buf = Neuro_GiveEBuf(tmp, current);*/
119 Lib_PutPixel(vobj, x, y, pixel);
121 buf->x = x;
122 buf->y = y;
127 Neuro_GetPixel(v_object *vobj, u32 x, u32 y)
129 return Lib_GetPixel(vobj, x, y);
132 void
133 Neuro_CleanPixels()
135 clean_pixel_in_this_cycle = 1;
138 /*-------------------- Poll ----------------------------------------*/
140 void
141 Pixels_Poll()
146 /*-------------------- Constructor Destructor ----------------------*/
149 Pixels_Init()
151 Neuro_CreateEBuf(&_Pixel);
153 return 0;
156 void
157 Pixels_Clean()
159 Neuro_CleanEBuf(&_Pixel);