1 #include "evas_common.h"
2 #include "evas_engine.h"
4 #include <sys/utsname.h>
7 evas_fb_outbuf_fb_init(void)
12 evas_fb_outbuf_fb_free(Outbuf *buf)
14 /* FIXME: impliment */
15 printf("destroying fb info.. not implemented!!!! WARNING. LEAK!\n");
16 if (buf->priv.back_buf)
17 evas_cache_image_drop(&buf->priv.back_buf->cache_entry);
22 evas_fb_outbuf_fb_setup_fb(int w, int h, int rot, Outbuf_Depth depth, int vt_no, int dev_no, int refresh)
24 /* create outbuf struct */
25 /* setup window and/or fb */
26 /* if (dithered) create backbuf */
32 if (depth == OUTBUF_DEPTH_RGB_16BPP_565_565_DITHERED) fb_depth = 16;
33 else if (depth == OUTBUF_DEPTH_RGB_16BPP_555_555_DITHERED) fb_depth = 15;
34 else if (depth == OUTBUF_DEPTH_RGB_16BPP_565_444_DITHERED) fb_depth = 16;
35 else if (depth == OUTBUF_DEPTH_RGB_16BPP_444_444_DITHERED) fb_depth = 12;
36 else if (depth == OUTBUF_DEPTH_RGB_32BPP_888_8888) fb_depth = 32;
37 else if (depth == OUTBUF_DEPTH_INHERIT) fb_depth = 0;
38 buf = calloc(1, sizeof(Outbuf));
42 fb_init(vt_no, dev_no);
43 if (rot == 0 || rot == 180)
44 buf->priv.fb.fb = fb_setmode(w, h, fb_depth, refresh);
45 else if (rot == 90 || rot == 270)
46 buf->priv.fb.fb = fb_setmode(h, w, fb_depth, refresh);
47 if (!buf->priv.fb.fb) buf->priv.fb.fb = fb_getmode();
53 fb_fd = fb_postinit(buf->priv.fb.fb);
55 if (rot == 0 || rot == 180)
57 buf->w = buf->priv.fb.fb->width;
58 buf->h = buf->priv.fb.fb->height;
60 else if (rot == 90 || rot == 270)
62 buf->w = buf->priv.fb.fb->height;
63 buf->h = buf->priv.fb.fb->width;
70 Gfx_Func_Convert conv_func;
74 for (i = 0; i < (int)buf->priv.fb.fb->fb_var.red.length; i++)
75 buf->priv.mask.r |= (1 << (buf->priv.fb.fb->fb_var.red.offset + i));
77 for (i = 0; i < (int)buf->priv.fb.fb->fb_var.green.length; i++)
78 buf->priv.mask.g |= (1 << (buf->priv.fb.fb->fb_var.green.offset + i));
80 for (i = 0; i < (int)buf->priv.fb.fb->fb_var.blue.length; i++)
81 buf->priv.mask.b |= (1 << (buf->priv.fb.fb->fb_var.blue.offset + i));
84 if (buf->rot == 0 || buf->rot == 180)
85 conv_func = evas_common_convert_func_get(0, buf->w, buf->h,
86 buf->priv.fb.fb->fb_var.bits_per_pixel,
92 else if (buf->rot == 90 || buf->rot == 270)
93 conv_func = evas_common_convert_func_get(0, buf->h, buf->w,
94 buf->priv.fb.fb->fb_var.bits_per_pixel,
106 // if (buf->priv.fb.fb->fb_var.bits_per_pixel < 24)
107 // buf->priv.back_buf = evas_common_image_create(buf->w, buf->h);
113 evas_fb_outbuf_fb_blit(Outbuf *buf, int src_x, int src_y, int w, int h, int dst_x, int dst_y)
115 if (buf->priv.back_buf)
117 evas_common_blit_rectangle(buf->priv.back_buf, buf->priv.back_buf,
118 src_x, src_y, w, h, dst_x, dst_y);
119 evas_fb_outbuf_fb_update(buf, dst_x, dst_y, w, h);
125 /* FIXME: need to impliment an fb call for "copy area" */
131 evas_fb_outbuf_fb_update(Outbuf *buf, int x, int y, int w, int h)
133 if (!(buf->priv.back_buf)) return;
136 Gfx_Func_Convert conv_func;
143 data = (DATA8 *)buf->priv.fb.fb->mem + buf->priv.fb.fb->mem_offset +
144 buf->priv.fb.fb->bpp *
145 (x + (y * buf->priv.fb.fb->width));
146 conv_func = evas_common_convert_func_get(data, w, h, buf->priv.fb.fb->fb_var.bits_per_pixel,
147 buf->priv.mask.r, buf->priv.mask.g,
148 buf->priv.mask.b, PAL_MODE_NONE,
151 else if (buf->rot == 180)
153 data = (DATA8 *)buf->priv.fb.fb->mem + buf->priv.fb.fb->mem_offset +
154 buf->priv.fb.fb->bpp *
155 (buf->w - x - w + ((buf->h - y - h) * buf->priv.fb.fb->width));
156 conv_func = evas_common_convert_func_get(data, w, h, buf->priv.fb.fb->fb_var.bits_per_pixel,
157 buf->priv.mask.r, buf->priv.mask.g,
158 buf->priv.mask.b, PAL_MODE_NONE,
161 else if (buf->rot == 270)
163 data = (DATA8 *)buf->priv.fb.fb->mem + buf->priv.fb.fb->mem_offset +
164 buf->priv.fb.fb->bpp *
165 (buf->h - y - h + (x * buf->priv.fb.fb->width));
166 conv_func = evas_common_convert_func_get(data, h, w, buf->priv.fb.fb->fb_var.bits_per_pixel,
167 buf->priv.mask.r, buf->priv.mask.g,
168 buf->priv.mask.b, PAL_MODE_NONE,
171 else if (buf->rot == 90)
173 data = (DATA8 *)buf->priv.fb.fb->mem + buf->priv.fb.fb->mem_offset +
174 buf->priv.fb.fb->bpp *
175 (y + ((buf->w - x - w) * buf->priv.fb.fb->width));
176 conv_func = evas_common_convert_func_get(data, h, w, buf->priv.fb.fb->fb_var.bits_per_pixel,
177 buf->priv.mask.r, buf->priv.mask.g,
178 buf->priv.mask.b, PAL_MODE_NONE,
185 src_data = buf->priv.back_buf->image.data + (y * buf->w) + x;
186 if (buf->rot == 0 || buf->rot == 180)
188 conv_func(src_data, data,
190 buf->priv.fb.fb->width - w,
194 else if (buf->rot == 90 || buf->rot == 270)
196 conv_func(src_data, data,
198 buf->priv.fb.fb->width - h,
207 evas_fb_outbuf_fb_new_region_for_update(Outbuf *buf, int x, int y, int w, int h, int *cx, int *cy, int *cw, int *ch)
209 if (buf->priv.back_buf)
211 *cx = x; *cy = y; *cw = w; *ch = h;
212 return buf->priv.back_buf;
218 *cx = 0; *cy = 0; *cw = w; *ch = h;
219 im = (RGBA_Image *) evas_cache_image_empty(evas_common_image_cache_get());
220 im->cache_entry.flags.alpha = 1;
221 im = (RGBA_Image *) evas_cache_image_size_set(&im->cache_entry, w, h);
223 /* handle framebuffers with alpha channel */
224 if (buf->priv.fb.fb->fb_var.transp.length > 0) {
225 memset(im->image.data, 0, w * h * sizeof(DATA32));
233 evas_fb_outbuf_fb_free_region_for_update(Outbuf *buf, RGBA_Image *update)
235 if (update != buf->priv.back_buf) evas_cache_image_drop(&update->cache_entry);
239 evas_fb_outbuf_fb_push_updated_region(Outbuf *buf, RGBA_Image *update, int x, int y, int w, int h)
241 if (!buf->priv.fb.fb) return;
242 if (buf->priv.back_buf)
244 if (update != buf->priv.back_buf)
245 evas_common_blit_rectangle(update, buf->priv.back_buf,
247 evas_fb_outbuf_fb_update(buf, x, y, w, h);
251 Gfx_Func_Convert conv_func;
258 data = (DATA8 *)buf->priv.fb.fb->mem +
259 buf->priv.fb.fb->mem_offset +
260 buf->priv.fb.fb->bpp *
261 (x + (y * buf->priv.fb.fb->width));
262 conv_func = evas_common_convert_func_get(data, w, h,
263 buf->priv.fb.fb->fb_var.bits_per_pixel,
264 buf->priv.mask.r, buf->priv.mask.g,
265 buf->priv.mask.b, PAL_MODE_NONE,
268 else if (buf->rot == 180)
270 data = (DATA8 *)buf->priv.fb.fb->mem +
271 buf->priv.fb.fb->mem_offset +
272 buf->priv.fb.fb->bpp *
273 (buf->w - x - w + ((buf->h - y - h) * buf->priv.fb.fb->width));
274 conv_func = evas_common_convert_func_get(data, w, h,
275 buf->priv.fb.fb->fb_var.bits_per_pixel,
276 buf->priv.mask.r, buf->priv.mask.g,
277 buf->priv.mask.b, PAL_MODE_NONE,
280 else if (buf->rot == 270)
282 data = (DATA8 *)buf->priv.fb.fb->mem +
283 buf->priv.fb.fb->mem_offset +
284 buf->priv.fb.fb->bpp *
285 (buf->h - y - h + (x * buf->priv.fb.fb->width));
286 conv_func = evas_common_convert_func_get(data, h, w,
287 buf->priv.fb.fb->fb_var.bits_per_pixel,
288 buf->priv.mask.r, buf->priv.mask.g,
289 buf->priv.mask.b, PAL_MODE_NONE,
292 else if (buf->rot == 90)
294 data = (DATA8 *)buf->priv.fb.fb->mem +
295 buf->priv.fb.fb->mem_offset +
296 buf->priv.fb.fb->bpp *
297 (y + ((buf->w - x - w) * buf->priv.fb.fb->width));
298 conv_func = evas_common_convert_func_get(data, h, w,
299 buf->priv.fb.fb->fb_var.bits_per_pixel,
300 buf->priv.mask.r, buf->priv.mask.g,
301 buf->priv.mask.b, PAL_MODE_NONE,
308 src_data = update->image.data;
309 if (buf->rot == 0 || buf->rot == 180)
311 conv_func(src_data, data,
313 buf->priv.fb.fb->width - w,
317 else if (buf->rot == 90 || buf->rot == 270)
319 conv_func(src_data, data,
321 buf->priv.fb.fb->width - h,
330 evas_fb_outbuf_fb_reconfigure(Outbuf *buf, int w, int h, int rot, Outbuf_Depth depth)
332 if ((w == buf->w) && (h == buf->h) &&
333 (rot == buf->rot) && (depth == buf->depth))
335 if (buf->priv.back_buf)
337 evas_cache_image_drop(&buf->priv.back_buf->cache_entry);
338 buf->priv.back_buf = NULL;
342 /* FIXME: impliment this */
344 /* if backbuf delet it */
345 /* resize window or reset fb mode */
346 /* if (dithered) create new backbuf */
350 evas_fb_outbuf_fb_get_width(Outbuf *buf)
356 evas_fb_outbuf_fb_get_height(Outbuf *buf)
362 evas_fb_outbuf_fb_get_depth(Outbuf *buf)
368 evas_fb_outbuf_fb_get_rot(Outbuf *buf)
374 evas_fb_outbuf_fb_get_have_backbuf(Outbuf *buf)
376 if (buf->priv.back_buf) return 1;
381 evas_fb_outbuf_fb_set_have_backbuf(Outbuf *buf, int have_backbuf)
383 if (buf->priv.back_buf)
385 if (have_backbuf) return;
386 evas_cache_image_drop(&buf->priv.back_buf->cache_entry);
387 buf->priv.back_buf = NULL;
391 if (!have_backbuf) return;
394 if (buf->priv.fb.fb->fb_var.bits_per_pixel < 24)
396 buf->priv.back_buf = (RGBA_Image *) evas_cache_image_empty(evas_common_image_cache_get());
397 buf->priv.back_buf = (RGBA_Image *) evas_cache_image_size_set(&buf->priv.back_buf->cache_entry, buf->w, buf->h);