2 * Copyright (C) 2014 Vabishchevich Nikolay <vabnick@gmail.com>
4 * This file is part of libass.
6 * Permission to use, copy, modify, and distribute this software for any
7 * purpose with or without fee is hereby granted, provided that the above
8 * copyright notice and this permission notice appear in all copies.
10 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
19 #ifndef LIBASS_RASTERIZER_H
20 #define LIBASS_RASTERIZER_H
26 #include "ass_bitmap.h"
32 SEGFLAG_EXACT_LEFT = 4,
33 SEGFLAG_EXACT_RIGHT = 8,
34 SEGFLAG_EXACT_TOP = 16,
35 SEGFLAG_EXACT_BOTTOM = 32,
38 // Polyline segment struct
41 int32_t a, b, scale, flags;
42 int32_t x_min, x_max, y_min, y_max;
46 int outline_error; // acceptable error (in 1/64 pixel units)
48 // usable after rasterizer_set_outline
52 struct segment *linebuf[2];
53 size_t size[2], capacity[2];
59 bool rasterizer_init(RasterizerData *rst, int tile_order, int outline_error);
60 void rasterizer_done(RasterizerData *rst);
63 * \brief Convert outline to polyline and calculate exact bounds
64 * \param path in: source outline
65 * \param extra in: true if path is second border outline
66 * \return false on error
68 bool rasterizer_set_outline(RasterizerData *rst,
69 const ASS_Outline *path, bool extra);
72 * \brief Polyline rasterization function
73 * \param x0, y0, width, height in: source window (full pixel units)
74 * \param buf out: aligned output buffer (size = stride * height)
75 * \param stride output buffer stride (aligned)
76 * \return false on error
77 * Deletes preprocessed polyline after work.
79 bool rasterizer_fill(const BitmapEngine *engine, RasterizerData *rst,
80 uint8_t *buf, int x0, int y0,
81 int width, int height, ptrdiff_t stride);
84 #endif /* LIBASS_RASTERIZER_H */