summaryrefslogtreecommitdiff
path: root/apps/codecs/libfaad/decoder.h
diff options
context:
space:
mode:
authorRobert Menes <rmenes@rockbox.org>2010-12-26 12:48:23 +0000
committerRobert Menes <rmenes@rockbox.org>2010-12-26 12:48:23 +0000
commit70dcb6aa055a7b4d534ba70d9e6d6d7efc3a0422 (patch)
tree30724988b5a42cb889703cdcb0c71ea9706840ca /apps/codecs/libfaad/decoder.h
parentf387cdef2131b2a0956ee8e4ff7221d3251b8f46 (diff)
downloadrockbox-70dcb6aa055a7b4d534ba70d9e6d6d7efc3a0422.zip
rockbox-70dcb6aa055a7b4d534ba70d9e6d6d7efc3a0422.tar.gz
rockbox-70dcb6aa055a7b4d534ba70d9e6d6d7efc3a0422.tar.bz2
rockbox-70dcb6aa055a7b4d534ba70d9e6d6d7efc3a0422.tar.xz
Remove a line in the iPod video manual that refers to two
separate builds to download. The iPod video build has been available as a unified build for some time now. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@28902 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/codecs/libfaad/decoder.h')
0 files changed, 0 insertions, 0 deletions
a> 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432
/*
 * ps.c: PostScript printing functions.
 */

#include <stdio.h>
#include <stdarg.h>
#include <string.h>
#include <assert.h>

#include "puzzles.h"

struct psdata {
    FILE *fp;
    bool colour;
    int ytop;
    bool clipped;
    float hatchthick, hatchspace;
    int gamewidth, gameheight;
    drawing *drawing;
};

static void ps_printf(psdata *ps, const char *fmt, ...)
{
    va_list ap;

    va_start(ap, fmt);
    vfprintf(ps->fp, fmt, ap);
    va_end(ap);
}

static void ps_fill(psdata *ps, int colour)
{
    int hatch;
    float r, g, b;

    print_get_colour(ps->drawing, colour, ps->colour, &hatch, &r, &g, &b);

    if (hatch < 0) {
	if (ps->colour)
	    ps_printf(ps, "%g %g %g setrgbcolor fill\n", r, g, b);
	else
	    ps_printf(ps, "%g setgray fill\n", r);
    } else {
	/* Clip to the region. */
	ps_printf(ps, "gsave clip\n");
	/* Hatch the entire game printing area. */
	ps_printf(ps, "newpath\n");
	if (hatch == HATCH_VERT || hatch == HATCH_PLUS)
	    ps_printf(ps, "0 %g %d {\n"
		      "  0 moveto 0 %d rlineto\n"
		      "} for\n", ps->hatchspace, ps->gamewidth,
		      ps->gameheight);
	if (hatch == HATCH_HORIZ || hatch == HATCH_PLUS)
	    ps_printf(ps, "0 %g %d {\n"
		      "  0 exch moveto %d 0 rlineto\n"
		      "} for\n", ps->hatchspace, ps->gameheight,
		      ps->gamewidth);
	if (hatch == HATCH_SLASH || hatch == HATCH_X)
	    ps_printf(ps, "%d %g %d {\n"
		      "  0 moveto %d dup rlineto\n"
		      "} for\n", -ps->gameheight, ps->hatchspace * ROOT2,
		      ps->gamewidth, max(ps->gamewidth, ps->gameheight));
	if (hatch == HATCH_BACKSLASH || hatch == HATCH_X)
	    ps_printf(ps, "0 %g %d {\n"
		      "  0 moveto %d neg dup neg rlineto\n"
		      "} for\n", ps->hatchspace * ROOT2,
		      ps->gamewidth+ps->gameheight,
		      max(ps->gamewidth, ps->gameheight));
	ps_printf(ps, "0 setgray %g setlinewidth stroke grestore\n",
		  ps->hatchthick);
    }
}

static void ps_setcolour_internal(psdata *ps, int colour, const char *suffix)
{
    int hatch;
    float r, g, b;

    print_get_colour(ps->drawing, colour, ps->colour, &hatch, &r, &g, &b);

    /*
     * Stroking in hatched colours is not permitted.
     */
    assert(hatch < 0);
    
    if (ps->colour)
	ps_printf(ps, "%g %g %g setrgbcolor%s\n", r, g, b, suffix);
    else
	ps_printf(ps, "%g setgray%s\n", r, suffix);
}

static void ps_setcolour(psdata *ps, int colour)
{
    ps_setcolour_internal(ps, colour, "");
}

static void ps_stroke(psdata *ps, int colour)
{
    ps_setcolour_internal(ps, colour, " stroke");
}

static void ps_draw_text(void *handle, int x, int y, int fonttype,
			 int fontsize, int align, int colour,
                         const char *text)
{
    psdata *ps = (psdata *)handle;

    y = ps->ytop - y;
    ps_setcolour(ps, colour);
    ps_printf(ps, "/%s findfont %d scalefont setfont\n",
	      fonttype == FONT_FIXED ? "Courier-L1" : "Helvetica-L1",
	      fontsize);
    if (align & ALIGN_VCENTRE) {
	ps_printf(ps, "newpath 0 0 moveto (X) true charpath flattenpath"
		  " pathbbox\n"
		  "3 -1 roll add 2 div %d exch sub %d exch moveto pop pop\n",
		  y, x);
    } else {
	ps_printf(ps, "%d %d moveto\n", x, y);
    }
    ps_printf(ps, "(");
    while (*text) {
	if (*text == '\\' || *text == '(' || *text == ')')
	    ps_printf(ps, "\\");
	ps_printf(ps, "%c", *text);
	text++;
    }
    ps_printf(ps, ") ");
    if (align & (ALIGN_HCENTRE | ALIGN_HRIGHT))
	ps_printf(ps, "dup stringwidth pop %sneg 0 rmoveto show\n",
		  (align & ALIGN_HCENTRE) ? "2 div " : "");
    else
	ps_printf(ps, "show\n");
}

static void ps_draw_rect(void *handle, int x, int y, int w, int h, int colour)
{
    psdata *ps = (psdata *)handle;

    y = ps->ytop - y;
    /*
     * Offset by half a pixel for the exactness requirement.
     */
    ps_printf(ps, "newpath %g %g moveto %d 0 rlineto 0 %d rlineto"
	      " %d 0 rlineto closepath\n", x - 0.5, y + 0.5, w, -h, -w);
    ps_fill(ps, colour);
}

static void ps_draw_line(void *handle, int x1, int y1, int x2, int y2,
			 int colour)
{
    psdata *ps = (psdata *)handle;

    y1 = ps->ytop - y1;
    y2 = ps->ytop - y2;
    ps_printf(ps, "newpath %d %d moveto %d %d lineto\n", x1, y1, x2, y2);
    ps_stroke(ps, colour);
}

static void ps_draw_polygon(void *handle, const int *coords, int npoints,
			    int fillcolour, int outlinecolour)
{
    psdata *ps = (psdata *)handle;

    int i;

    ps_printf(ps, "newpath %d %d moveto\n", coords[0], ps->ytop - coords[1]);

    for (i = 1; i < npoints; i++)
	ps_printf(ps, "%d %d lineto\n", coords[i*2], ps->ytop - coords[i*2+1]);

    ps_printf(ps, "closepath\n");

    if (fillcolour >= 0) {
	ps_printf(ps, "gsave\n");
	ps_fill(ps, fillcolour);
	ps_printf(ps, "grestore\n");
    }
    ps_stroke(ps, outlinecolour);
}

static void ps_draw_circle(void *handle, int cx, int cy, int radius,
			   int fillcolour, int outlinecolour)
{
    psdata *ps = (psdata *)handle;

    cy = ps->ytop - cy;

    ps_printf(ps, "newpath %d %d %d 0 360 arc closepath\n", cx, cy, radius);

    if (fillcolour >= 0) {
	ps_printf(ps, "gsave\n");
	ps_fill(ps, fillcolour);
	ps_printf(ps, "grestore\n");
    }
    ps_stroke(ps, outlinecolour);
}

static void ps_unclip(void *handle)
{
    psdata *ps = (psdata *)handle;

    assert(ps->clipped);
    ps_printf(ps, "grestore\n");
    ps->clipped = false;
}
 
static void ps_clip(void *handle, int x, int y, int w, int h)
{
    psdata *ps = (psdata *)handle;

    if (ps->clipped)
	ps_unclip(ps);

    y = ps->ytop - y;
    /*
     * Offset by half a pixel for the exactness requirement.
     */
    ps_printf(ps, "gsave\n");
    ps_printf(ps, "newpath %g %g moveto %d 0 rlineto 0 %d rlineto"
	      " %d 0 rlineto closepath\n", x - 0.5, y + 0.5, w, -h, -w);
    ps_printf(ps, "clip\n");
    ps->clipped = true;
}

static void ps_line_width(void *handle, float width)
{
    psdata *ps = (psdata *)handle;

    ps_printf(ps, "%g setlinewidth\n", width);
}

static void ps_line_dotted(void *handle, bool dotted)
{
    psdata *ps = (psdata *)handle;

    if (dotted) {
	ps_printf(ps, "[ currentlinewidth 3 mul ] 0 setdash\n");
    } else {
	ps_printf(ps, "[ ] 0 setdash\n");
    }
}

static char *ps_text_fallback(void *handle, const char *const *strings,
			      int nstrings)
{
    /*
     * We can handle anything in ISO 8859-1, and we'll manually
     * translate it out of UTF-8 for the purpose.
     */
    int i, maxlen;
    char *ret;

    maxlen = 0;
    for (i = 0; i < nstrings; i++) {
	int len = strlen(strings[i]);
	if (maxlen < len) maxlen = len;
    }

    ret = snewn(maxlen + 1, char);

    for (i = 0; i < nstrings; i++) {
	const char *p = strings[i];
	char *q = ret;

	while (*p) {
	    int c = (unsigned char)*p++;
	    if (c < 0x80) {
		*q++ = c;	       /* ASCII */
	    } else if ((c == 0xC2 || c == 0xC3) && (*p & 0xC0) == 0x80) {
		*q++ = (c << 6) | (*p++ & 0x3F);   /* top half of 8859-1 */
	    } else {
		break;
	    }
	}

	if (!*p) {
	    *q = '\0';
	    return ret;
	}
    }

    assert(!"Should never reach here");
    return NULL;
}

static void ps_begin_doc(void *handle, int pages)
{
    psdata *ps = (psdata *)handle;

    fputs("%!PS-Adobe-3.0\n", ps->fp);
    fputs("%%Creator: Simon Tatham's Portable Puzzle Collection\n", ps->fp);
    fputs("%%DocumentData: Clean7Bit\n", ps->fp);
    fputs("%%LanguageLevel: 1\n", ps->fp);
    fprintf(ps->fp, "%%%%Pages: %d\n", pages);
    fputs("%%DocumentNeededResources:\n", ps->fp);
    fputs("%%+ font Helvetica\n", ps->fp);
    fputs("%%+ font Courier\n", ps->fp);
    fputs("%%EndComments\n", ps->fp);
    fputs("%%BeginSetup\n", ps->fp);
    fputs("%%IncludeResource: font Helvetica\n", ps->fp);
    fputs("%%IncludeResource: font Courier\n", ps->fp);
    fputs("%%EndSetup\n", ps->fp);
    fputs("%%BeginProlog\n", ps->fp);
    /*
     * Re-encode Helvetica and Courier into ISO-8859-1, which gives
     * us times and divide signs - and also (according to the
     * Language Reference Manual) a bonus in that the ASCII '-' code
     * point now points to a minus sign instead of a hyphen.
     */
    fputs("/Helvetica findfont " /* get the font dictionary */
	  "dup maxlength dict dup begin " /* create and open a new dict */
	  "exch " /* move the original font to top of stack */
	  "{1 index /FID ne {def} {pop pop} ifelse} forall "
				       /* copy everything except FID */
	  "/Encoding ISOLatin1Encoding def "
			      /* set the thing we actually wanted to change */
	  "/FontName /Helvetica-L1 def " /* set a new font name */