raised the version
[neuro.git] / src / video / pixels.c
blobad9ac7536ae0290e09cbc26d8722f6d002cabade
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 ---------------------*/
32 #include <extlib.h> /* Lib_PutPixel and Lib_GetPixel */
34 /*-------------------- Main Module Header --------------------------*/
35 #include "video.h"
38 /*-------------------- Other ----------------------------*/
40 /*-------------------- Global Variables ----------------------------*/
42 /*-------------------- Static Variables ----------------------------*/
44 /* 1 is that the pixels will be cleaned during this cycle and 0 is no it won't */
45 static u8 clean_pixel_in_this_cycle;
47 /* the pixels buffer */
48 static EBUF *_Pixel;
50 typedef struct PIXEL_ENGINE
52 u32 x, y;
53 }PIXEL_ENGINE;
55 /*-------------------- Static Prototypes ---------------------------*/
59 /*-------------------- Static Functions ----------------------------*/
61 static void
62 cleanPixels()
64 EBUF *tmp;
65 Rectan buf;
66 PIXEL_ENGINE *pix;
67 u32 current;
69 tmp = _Pixel;
71 current = Neuro_GiveEBufCount(tmp);
73 if (current <= 0)
74 return;
77 if (!Neuro_EBufIsEmpty(tmp))
79 while (current-- > 0)
81 pix = Neuro_GiveEBuf(tmp, current);
82 buf.x = pix->x;
83 buf.y = pix->y;
85 buf.w = 1;
86 buf.h = 1;
89 Neuro_CleanEBuf(&_Pixel);
92 /*-------------------- Global Functions ----------------------------*/
94 void
95 Neuro_PutPixel(v_object *vobj, u32 x, u32 y, u32 pixel)
97 /*EBUF *tmp;
98 PIXEL_ENGINE *buf;
99 u32 current;
100 Rectan check;
103 check.x = x;
104 check.y = y;
105 check.h = 1;
106 check.w = 1;
108 if (secureBoundsCheck(&check))
110 printf("Unsecure Pixel position have been catched, dropping the instruction\n");
111 return;
114 tmp = _Pixel;
115 Neuro_AllocEBuf(tmp, sizeof(PIXEL_ENGINE*), sizeof(PIXEL_ENGINE));
117 current = Neuro_GiveEBufCount(tmp);
118 buf = Neuro_GiveEBuf(tmp, current);*/
120 Lib_PutPixel(vobj, x, y, pixel);
122 buf->x = x;
123 buf->y = y;
128 Neuro_GetPixel(v_object *vobj, u32 x, u32 y)
130 return Lib_GetPixel(vobj, x, y);
133 void
134 Neuro_CleanPixels()
136 clean_pixel_in_this_cycle = 1;
139 /*-------------------- Poll ----------------------------------------*/
141 void
142 Pixels_Poll()
147 /*-------------------- Constructor Destructor ----------------------*/
150 Pixels_Init()
152 Neuro_CreateEBuf(&_Pixel);
154 return 0;
157 void
158 Pixels_Clean()
160 Neuro_CleanEBuf(&_Pixel);