1 /* DirectFB presentation app
3 * Copyright (C) 2001 convergence integrated media
4 * Authors: Sven Neumann <sven@convergence.de>
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
27 #include <glib-object.h>
37 #include "resources.h"
44 static void render_bullet (Context *context,
49 render_bg (Context *context)
53 color = context_get_bgcolor (context);
54 context->surface->SetColor (context->surface,
55 color[0], color[1], color[2], color[3]);
56 context->surface->FillRectangle (context->surface,
57 0, 0, context->w, context->h);
61 render_bgimage (Context *context)
65 image = context_get_bgimage (context);
68 IDirectFBSurface *src;
71 src = resources_get_surface (image);
75 src->GetSize (src, &w, &h);
77 if (w == context->w && h == context->h)
79 context->surface->Blit (context->surface, src, NULL, 0, 0);
83 DFBRectangle rect = { 0, 0, context->w, context->h };
85 context->surface->StretchBlit (context->surface,
89 resources_release_surface (image);
94 render_image (Context *context,
98 IDirectFBSurface *src;
100 DFBSurfacePixelFormat format;
103 if (IS_VIDEO (image))
107 video = (Video *) image;
108 video->dest_surface = context->surface;
113 src = resources_get_surface (ITEM (image)->value);
118 src->GetSize (src, &w, &h);
119 src->GetPixelFormat (src, &format);
121 if (format == DSPF_ARGB)
122 context->surface->SetBlittingFlags (context->surface,
123 DSBLIT_BLEND_ALPHACHANNEL);
125 ratio = (w * 1024) / h;
126 item = (Item *) image;
128 rect.w = item->flags & WIDTH ?
129 item->width : (item->flags & HEIGHT ? (item->height * ratio) / 1024 : w);
130 rect.h = item->flags & HEIGHT ?
131 item->height : (item->flags & WIDTH ? (item->width * 1024) / ratio : h);
133 rect.x = item->flags & XOFFSET ? item->x : 0;
134 rect.y = item->flags & YOFFSET ? item->y : 0;
136 if (format == DSPF_ARGB)
137 context->surface->SetBlittingFlags (context->surface,
138 DSBLIT_BLEND_ALPHACHANNEL);
140 if (w == rect.w || h == rect.h)
141 context->surface->Blit (context->surface, src, NULL, rect.x, rect.y);
143 context->surface->StretchBlit (context->surface, src, NULL, &rect);
145 context->surface->SetBlittingFlags (context->surface, DSBLIT_NOFX);
147 resources_release_surface (ITEM (image)->value);
151 render_text (Context *context,
161 context_push (context, (Item *) text);
163 color = context_get_fgcolor (context);
164 context->surface->SetColor (context->surface,
165 color[0], color[1], color[2], color[3]);
167 face = context_get_face (context);
168 size = context_get_size (context);
170 g_return_if_fail (face != NULL);
171 g_return_if_fail (size > 0);
175 if (IS_HEADER (text))
176 size = (size * 64) / 52;
177 else if (IS_LISTITEM (text))
178 size = (size * 48) / 64;
182 font = resources_get_font (face, size);
184 if (IS_LISTITEM (text))
188 font->GetAscender (font, &asc);
189 render_bullet (context, &offx, *offy + asc);
192 context->surface->SetFont (context->surface, font);
193 context->surface->DrawString (context->surface,
194 ITEM (text)->value, -1,
195 offx, *offy, DSTF_TOPLEFT);
197 *offy += (size * 64) / 48;
199 context_pop (context, (Item *) text);
203 render_bullet (Context *context,
207 IDirectFBSurface *src;
211 image = context_get_bullet (context);
214 src = resources_get_surface (image);
218 src->GetSize (src, &w, &h);
220 context->surface->SetBlittingFlags (context->surface,
221 DSBLIT_BLEND_ALPHACHANNEL);
222 context->surface->Blit (context->surface,
223 src, NULL, *offx + 20, offy - h);
224 context->surface->SetBlittingFlags (context->surface, DSBLIT_NOFX);
226 resources_release_surface (image);