summaryrefslogtreecommitdiffstats
path: root/libass/ass_rasterizer.h
diff options
context:
space:
mode:
authorDr.Smile <vabnick@gmail.com>2015-06-26 02:14:21 +0300
committerDr.Smile <vabnick@gmail.com>2015-06-26 02:14:21 +0300
commit38a175cad5a894467cb7187ad0187db1ae3f89ff (patch)
treea7262be6620f31c2f0d8df26218c6160c5354f56 /libass/ass_rasterizer.h
parent88f1fd37fe5785851f069e3dc6939f1ab905f4bc (diff)
downloadlibass-38a175cad5a894467cb7187ad0187db1ae3f89ff.tar.bz2
libass-38a175cad5a894467cb7187ad0187db1ae3f89ff.tar.xz
Switch to virtual function table
Use one pointer to table of functions instead of scattered bunch of function pointers. Different versions of these tables can be constructed in compile time. Also, bitmap memory alignment now depends only on SSE2/AVX2 support and is constant for every width. That simplifies code without noticeable performance penalty.
Diffstat (limited to 'libass/ass_rasterizer.h')
-rw-r--r--libass/ass_rasterizer.h46
1 files changed, 12 insertions, 34 deletions
diff --git a/libass/ass_rasterizer.h b/libass/ass_rasterizer.h
index d20feb3..73cdba4 100644
--- a/libass/ass_rasterizer.h
+++ b/libass/ass_rasterizer.h
@@ -22,7 +22,7 @@
#include <stddef.h>
#include <stdint.h>
-#include "ass.h"
+#include "ass_bitmap.h"
#include "ass_font.h"
@@ -42,48 +42,25 @@ struct segment {
int32_t x_min, x_max, y_min, y_max;
};
-
-typedef void (*FillSolidTileFunc)(uint8_t *buf, ptrdiff_t stride, int set);
-typedef void (*FillHalfplaneTileFunc)(uint8_t *buf, ptrdiff_t stride,
- int32_t a, int32_t b, int64_t c, int32_t scale);
-typedef void (*FillGenericTileFunc)(uint8_t *buf, ptrdiff_t stride,
- const struct segment *line, size_t n_lines,
- int winding);
-
-void ass_fill_solid_tile16_c(uint8_t *buf, ptrdiff_t stride, int set);
-void ass_fill_solid_tile32_c(uint8_t *buf, ptrdiff_t stride, int set);
-void ass_fill_halfplane_tile16_c(uint8_t *buf, ptrdiff_t stride,
- int32_t a, int32_t b, int64_t c, int32_t scale);
-void ass_fill_halfplane_tile32_c(uint8_t *buf, ptrdiff_t stride,
- int32_t a, int32_t b, int64_t c, int32_t scale);
-void ass_fill_generic_tile16_c(uint8_t *buf, ptrdiff_t stride,
- const struct segment *line, size_t n_lines,
- int winding);
-void ass_fill_generic_tile32_c(uint8_t *buf, ptrdiff_t stride,
- const struct segment *line, size_t n_lines,
- int winding);
-
-typedef struct ass_rasterizer {
+typedef struct {
int outline_error; // acceptable error (in 1/64 pixel units)
- int tile_order; // log2(tile_size)
- FillSolidTileFunc fill_solid;
- FillHalfplaneTileFunc fill_halfplane;
- FillGenericTileFunc fill_generic;
-
- int32_t x_min, x_max, y_min, y_max; // usable after rasterizer_set_outline
+ // usable after rasterizer_set_outline
+ int32_t x_min, x_max, y_min, y_max;
// internal buffers
struct segment *linebuf[2];
size_t size[2], capacity[2];
-} ASS_Rasterizer;
+} RasterizerData;
+
+void rasterizer_init(RasterizerData *rst, int outline_error);
+void rasterizer_done(RasterizerData *rst);
-void rasterizer_init(ASS_Rasterizer *rst);
-void rasterizer_done(ASS_Rasterizer *rst);
/**
* \brief Convert FreeType outline to polyline and calculate exact bounds
*/
-int rasterizer_set_outline(ASS_Rasterizer *rst, const ASS_Outline *path);
+int rasterizer_set_outline(RasterizerData *rst, const ASS_Outline *path);
+
/**
* \brief Polyline rasterization function
* \param x0, y0, width, height in: source window (full pixel units)
@@ -92,7 +69,8 @@ int rasterizer_set_outline(ASS_Rasterizer *rst, const ASS_Outline *path);
* \return zero on error
* Deletes preprocessed polyline after work.
*/
-int rasterizer_fill(ASS_Rasterizer *rst, uint8_t *buf, int x0, int y0,
+int rasterizer_fill(const BitmapEngine *engine, RasterizerData *rst,
+ uint8_t *buf, int x0, int y0,
int width, int height, ptrdiff_t stride);