2 * \brief DOpE gfx YUV420 image handler module
4 * \author Norman Feske <nf2@inf.tu-dresden.de>
8 * Copyright (C) 2002-2004 Norman Feske <nf2@os.inf.tu-dresden.de>
9 * Technische Universitaet Dresden, Operating Systems Research Group
11 * This file is part of the DOpE package, which is distributed under
12 * the terms of the GNU General Public Licence 2. Please see the
13 * COPYING file for details.
17 #include "sharedmem.h"
18 #include "gfx_handler.h"
21 static struct sharedmem_services *shmem;
24 s32 w,h; /* width and height of the image */
25 SHAREDMEM *smb; /* shared memory block */
26 u8 *pixels; /* YUV420 data color values of the pixels */
29 int init_gfximgyuv420(struct dope_services *d);
31 /*****************************
32 *** GFX HANDLER FUNCTIONS ***
33 *****************************/
35 static s32 img_get_width(struct gfx_ds_data *img) {
39 static s32 img_get_height(struct gfx_ds_data *img) {
43 static s32 img_get_type(struct gfx_ds_data *img) {
45 return GFX_IMG_TYPE_YUV420;
48 static void img_destroy(struct gfx_ds_data *img) {
52 static void *img_map(struct gfx_ds_data *img) {
56 static s32 img_share(struct gfx_ds_data *img, THREAD *dst_thread) {
57 return shmem->share(img->smb, dst_thread);
60 static s32 img_get_ident(struct gfx_ds_data *img, char *dst_ident) {
61 shmem->get_ident(img->smb, dst_ident);
65 /*************************
66 *** SERVICE FUNCTIONS ***
67 *************************/
70 static struct gfx_ds_data *create(s32 width, s32 height, struct gfx_ds_handler **handler) {
72 struct gfx_ds_data *new;
73 new = zalloc(sizeof(struct gfx_ds_data));
74 if (!new) return NULL;
77 new->smb = shmem->alloc(width*height + (width*height/2));
78 new->pixels = (u8 *)(shmem->get_address(new->smb));
82 static s32 register_gfx_handler(struct gfx_ds_handler *handler) {
83 handler->get_width = img_get_width;
84 handler->get_height = img_get_height;
85 handler->get_type = img_get_type;
86 handler->destroy = img_destroy;
87 handler->map = img_map;
88 handler->share = img_share;
89 handler->get_ident = img_get_ident;
94 /****************************************
95 *** SERVICE STRUCTURE OF THIS MODULE ***
96 ****************************************/
98 static struct gfx_handler_services services = {
100 register_gfx_handler,
104 /**************************
105 *** MODULE ENTRY POINT ***
106 **************************/
108 int init_gfximgyuv420(struct dope_services *d) {
109 shmem = d->get_module("SharedMemory 1.0");
110 d->register_module("GfxImageYUV420 1.0",&services);