buffer: cache downscale 2x2 dispatch functions in zoom handler

parent a718c59f
...@@ -60,7 +60,8 @@ static inline void set_blank (GeglTile *dst_tile, ...@@ -60,7 +60,8 @@ static inline void set_blank (GeglTile *dst_tile,
} }
} }
static inline void set_half (GeglTile * dst_tile, static inline void set_half (GeglTileHandlerZoom *zoom,
GeglTile * dst_tile,
GeglTile * src_tile, GeglTile * src_tile,
gint width, gint width,
gint height, gint height,
...@@ -75,7 +76,10 @@ static inline void set_half (GeglTile * dst_tile, ...@@ -75,7 +76,10 @@ static inline void set_half (GeglTile * dst_tile,
if (i) dst_data += bpp * width / 2; if (i) dst_data += bpp * width / 2;
if (j) dst_data += bpp * width * height / 2; if (j) dst_data += bpp * width * height / 2;
gegl_downscale_2x2 (format, width, height, src_data, width * bpp, dst_data, width * bpp); if (!zoom->downscale_2x2)
zoom->downscale_2x2 = gegl_downscale_2x2_get_fun (format);
zoom->downscale_2x2 (format, width, height, src_data, width * bpp, dst_data, width * bpp);
} }
static GeglTile * static GeglTile *
...@@ -139,7 +143,7 @@ get_tile (GeglTileSource *gegl_tile_source, ...@@ -139,7 +143,7 @@ get_tile (GeglTileSource *gegl_tile_source,
{ {
if (source_tile[i][j]) if (source_tile[i][j])
{ {
set_half (tile, source_tile[i][j], tile_width, tile_height, format, i, j); set_half (zoom, tile, source_tile[i][j], tile_width, tile_height, format, i, j);
gegl_tile_unref (source_tile[i][j]); gegl_tile_unref (source_tile[i][j]);
} }
else else
......
...@@ -39,18 +39,20 @@ G_BEGIN_DECLS ...@@ -39,18 +39,20 @@ G_BEGIN_DECLS
typedef struct _GeglTileHandlerZoom GeglTileHandlerZoom; typedef struct _GeglTileHandlerZoom GeglTileHandlerZoom;
typedef struct _GeglTileHandlerZoomClass GeglTileHandlerZoomClass; typedef struct _GeglTileHandlerZoomClass GeglTileHandlerZoomClass;
typedef void (*GeglDownscale2x2Fun) (const Babl *format,
gint src_width,
gint src_height,
guchar *src_data,
gint src_rowstride,
guchar *dst_data,
gint dst_rowstride);
struct _GeglTileHandlerZoom struct _GeglTileHandlerZoom
{ {
GeglTileHandler parent_instance; GeglTileHandler parent_instance;
GeglTileBackend *backend; GeglTileBackend *backend;
GeglTileStorage *tile_storage; GeglTileStorage *tile_storage;
void (*downscale_2x2) (gint bpp, GeglDownscale2x2Fun downscale_2x2;
gint src_width,
gint dst_dst_width,
guchar *src_data,
gint src_rowstride,
guchar *dst_data,
gint dst_rowstride);
}; };
struct _GeglTileHandlerZoomClass struct _GeglTileHandlerZoomClass
......
...@@ -41,15 +41,8 @@ gegl_downscale_2x2_generic (const Babl *format, ...@@ -41,15 +41,8 @@ gegl_downscale_2x2_generic (const Babl *format,
guchar *dst_data, guchar *dst_data,
gint dst_rowstride); gint dst_rowstride);
typedef void (*GeglDownscale2x2Fun) (const Babl *format,
gint src_width, GeglDownscale2x2Fun gegl_downscale_2x2_get_fun (const Babl *format)
gint src_height,
guchar *src_data,
gint src_rowstride,
guchar *dst_data,
gint dst_rowstride);
static GeglDownscale2x2Fun gegl_downscale_2x2_get_fun (const Babl *format)
{ {
const Babl *comp_type = babl_format_get_type (format, 0); const Babl *comp_type = babl_format_get_type (format, 0);
const Babl *model = babl_format_get_model (format); const Babl *model = babl_format_get_model (format);
...@@ -90,7 +83,7 @@ void gegl_downscale_2x2 (const Babl *format, ...@@ -90,7 +83,7 @@ void gegl_downscale_2x2 (const Babl *format,
{ {
gegl_downscale_2x2_get_fun (format)(format, src_width, src_height, gegl_downscale_2x2_get_fun (format)(format, src_width, src_height,
src_data, src_rowstride, src_data, src_rowstride,
src_data, dst_rowstride);; dst_data, dst_rowstride);;
} }
#include <stdio.h> #include <stdio.h>
......
...@@ -31,6 +31,7 @@ void gegl_downscale_2x2 (const Babl *format, ...@@ -31,6 +31,7 @@ void gegl_downscale_2x2 (const Babl *format,
guchar *dst_data, guchar *dst_data,
gint dst_rowstride); gint dst_rowstride);
void gegl_downscale_2x2_double (const Babl *format, void gegl_downscale_2x2_double (const Babl *format,
gint src_width, gint src_width,
gint src_height, gint src_height,
...@@ -47,6 +48,14 @@ void gegl_downscale_2x2_float (const Babl *format, ...@@ -47,6 +48,14 @@ void gegl_downscale_2x2_float (const Babl *format,
guchar *dst_data, guchar *dst_data,
gint dst_rowstride); gint dst_rowstride);
typedef void (*GeglDownscale2x2Fun) (const Babl *format,
gint src_width,
gint src_height,
guchar *src_data,
gint src_rowstride,
guchar *dst_data,
gint dst_rowstride);
void gegl_downscale_2x2_u32 (const Babl *format, void gegl_downscale_2x2_u32 (const Babl *format,
gint src_width, gint src_width,
gint src_height, gint src_height,
...@@ -203,6 +212,7 @@ void gegl_resample_nearest (guchar *dst, ...@@ -203,6 +212,7 @@ void gegl_resample_nearest (guchar *dst,
gint bpp, gint bpp,
gint dst_stride); gint dst_stride);
GeglDownscale2x2Fun gegl_downscale_2x2_get_fun (const Babl *format);
G_END_DECLS G_END_DECLS
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment