Permalink
Browse files

Absorb tilehelper into grid

  • Loading branch information...
1 parent d447f7e commit fe42ba2a305c4f0b2c415be36c83b06216a8a66f @bgilbert bgilbert committed Aug 8, 2013
View
@@ -43,7 +43,7 @@ advice.
except for the cache (which takes locks) and libtiff (which is sort
of a disaster).
- * Avoid the midlayer mistake. The tilehelper and cache are there for
+ * Avoid the midlayer mistake. The grid helpers and cache are there for
you.
* Have fun! Graphics are a joy.
View
@@ -16,7 +16,7 @@ src_libopenslide_la_LIBADD = $(GLIB2_LIBS) $(CAIRO_LIBS) $(LIBXML2_LIBS) \
$(OPENJPEG_LIBS) $(LIBTIFF_LIBS) $(ZLIB_LIBS)
src_libopenslide_la_SOURCES = src/openslide.c src/openslide-grid.c \
- src/openslide-cache.c src/openslide-tilehelper.c \
+ src/openslide-cache.c \
src/openslide-hash.c src/openslide-error.c src/openslide-util.c \
src/openslide-ops-jpeg.c \
src/openslide-vendor-hamamatsu.c \
@@ -42,7 +42,7 @@ src_libopenslide_la_LDFLAGS = -version-info 3:3:3 -no-undefined
pkginclude_HEADERS = src/openslide.h src/openslide-features.h
-noinst_HEADERS = src/openslide-private.h src/openslide-cache.h src/openslide-tilehelper.h src/openslide-hash.h src/openslide-cairo.h src/openslide-tiffdump.h tools/openslide-tools-common.h
+noinst_HEADERS = src/openslide-private.h src/openslide-cache.h src/openslide-hash.h src/openslide-cairo.h src/openslide-tiffdump.h tools/openslide-tools-common.h
View
@@ -19,10 +19,11 @@
*
*/
+#include <stdint.h>
#include <math.h>
#include <glib.h>
+#include <cairo.h>
#include "openslide-private.h"
-#include "openslide-tilehelper.h"
struct _openslide_grid_simple {
openslide_t *osr;
@@ -76,6 +77,54 @@ struct tilemap_read_tile_args {
int32_t region_h;
};
+static void read_tiles(cairo_t *cr,
+ struct _openslide_level *level,
+ int64_t start_tile_x, int64_t start_tile_y,
+ int64_t end_tile_x, int64_t end_tile_y,
+ double offset_x, double offset_y,
+ double advance_x, double advance_y,
+ openslide_t *osr,
+ void *arg,
+ _openslide_tileread_fn read_tile) {
+ //g_debug("offset: %g %g, advance: %g %g", offset_x, offset_y, advance_x, advance_y);
+ if (fabs(offset_x) >= advance_x) {
+ _openslide_set_error(osr, "internal error: fabs(offset_x) >= advance_x");
+ return;
+ }
+ if (fabs(offset_y) >= advance_y) {
+ _openslide_set_error(osr, "internal error: fabs(offset_y) >= advance_y");
+ return;
+ }
+
+ // cairo_set_source_rgb(cr, 0, 1, 0);
+ // cairo_paint(cr);
+ //g_debug("offset: %d %d", offset_x, offset_y);
+
+ //g_debug("start: %" G_GINT64_FORMAT " %" G_GINT64_FORMAT, start_tile_x, start_tile_y);
+ //g_debug("end: %" G_GINT64_FORMAT " %" G_GINT64_FORMAT, end_tile_x, end_tile_y);
+
+ cairo_matrix_t matrix;
+ cairo_get_matrix(cr, &matrix);
+
+ int64_t tile_y = end_tile_y - 1;
+
+ while (tile_y >= start_tile_y) {
+ double translate_y = ((tile_y - start_tile_y) * advance_y) - offset_y;
+ int64_t tile_x = end_tile_x - 1;
+
+ while (tile_x >= start_tile_x) {
+ double translate_x = ((tile_x - start_tile_x) * advance_x) - offset_x;
+ // g_debug("read_tiles %" G_GINT64_FORMAT " %" G_GINT64_FORMAT, tile_x, tile_y);
+ cairo_translate(cr, translate_x, translate_y);
+ read_tile(osr, cr, level, tile_x, tile_y, arg);
+ cairo_set_matrix(cr, &matrix);
+ tile_x--;
+ }
+
+ tile_y--;
+ }
+}
+
struct _openslide_grid_simple *_openslide_grid_simple_create(openslide_t *osr,
int64_t tiles_across,
int64_t tiles_down,
@@ -117,12 +166,12 @@ void _openslide_grid_simple_paint_region(struct _openslide_grid_simple *grid,
end_tile_x = MIN(end_tile_x, grid->tiles_across);
end_tile_y = MIN(end_tile_y, grid->tiles_down);
- _openslide_read_tiles(cr, level,
- start_tile_x, start_tile_y,
- end_tile_x, end_tile_y,
- offset_x, offset_y,
- grid->tile_w, grid->tile_h,
- grid->osr, arg, grid->read_tile);
+ read_tiles(cr, level,
+ start_tile_x, start_tile_y,
+ end_tile_x, end_tile_y,
+ offset_x, offset_y,
+ grid->tile_w, grid->tile_h,
+ grid->osr, arg, grid->read_tile);
}
void _openslide_grid_simple_destroy(struct _openslide_grid_simple *grid) {
@@ -293,14 +342,14 @@ void _openslide_grid_tilemap_paint_region(struct _openslide_grid_tilemap *grid,
-grid->extra_tiles_left * grid->tile_advance_x,
-grid->extra_tiles_top * grid->tile_advance_y);
- _openslide_read_tiles(cr, level,
- start_tile_x - grid->extra_tiles_left,
- start_tile_y - grid->extra_tiles_top,
- end_tile_x + grid->extra_tiles_right,
- end_tile_y + grid->extra_tiles_bottom,
- offset_x, offset_y,
- grid->tile_advance_x, grid->tile_advance_y,
- grid->osr, &args, grid_tilemap_read_tile);
+ read_tiles(cr, level,
+ start_tile_x - grid->extra_tiles_left,
+ start_tile_y - grid->extra_tiles_top,
+ end_tile_x + grid->extra_tiles_right,
+ end_tile_y + grid->extra_tiles_bottom,
+ offset_x, offset_y,
+ grid->tile_advance_x, grid->tile_advance_y,
+ grid->osr, &args, grid_tilemap_read_tile);
}
void _openslide_grid_tilemap_destroy(struct _openslide_grid_tilemap *grid) {
View
@@ -44,7 +44,6 @@
#include <cairo.h>
#include "openslide-cache.h"
-#include "openslide-tilehelper.h"
struct one_jpeg {
char *filename;
View
@@ -24,7 +24,6 @@
#include "openslide-private.h"
#include "openslide-cache.h"
-#include "openslide-tilehelper.h"
#include <string.h>
#include <stdint.h>
View
@@ -33,7 +33,6 @@
#include <cairo.h>
#include "openslide-cache.h"
-#include "openslide-tilehelper.h"
#include "openslide-hash.h"
#define HANDLE_CACHE_MAX 32
View
@@ -1,78 +0,0 @@
-/*
- * OpenSlide, a library for reading whole slide image files
- *
- * Copyright (c) 2007-2009 Carnegie Mellon University
- * All rights reserved.
- *
- * OpenSlide is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation, version 2.1.
- *
- * OpenSlide is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with OpenSlide. If not, see
- * <http://www.gnu.org/licenses/>.
- *
- */
-
-#include <config.h>
-
-#include "openslide-private.h"
-#include "openslide-tilehelper.h"
-
-#include <glib.h>
-#include <string.h>
-#include <math.h>
-#include <cairo.h>
-
-void _openslide_read_tiles(cairo_t *cr,
- struct _openslide_level *level,
- int64_t start_tile_x, int64_t start_tile_y,
- int64_t end_tile_x, int64_t end_tile_y,
- double offset_x, double offset_y,
- double advance_x, double advance_y,
- openslide_t *osr,
- void *arg,
- _openslide_tileread_fn read_tile) {
- //g_debug("offset: %g %g, advance: %g %g", offset_x, offset_y, advance_x, advance_y);
- if (fabs(offset_x) >= advance_x) {
- _openslide_set_error(osr, "internal error: fabs(offset_x) >= advance_x");
- return;
- }
- if (fabs(offset_y) >= advance_y) {
- _openslide_set_error(osr, "internal error: fabs(offset_y) >= advance_y");
- return;
- }
-
- // cairo_set_source_rgb(cr, 0, 1, 0);
- // cairo_paint(cr);
- //g_debug("offset: %d %d", offset_x, offset_y);
-
- //g_debug("start: %" G_GINT64_FORMAT " %" G_GINT64_FORMAT, start_tile_x, start_tile_y);
- //g_debug("end: %" G_GINT64_FORMAT " %" G_GINT64_FORMAT, end_tile_x, end_tile_y);
-
- cairo_matrix_t matrix;
- cairo_get_matrix(cr, &matrix);
-
- int64_t tile_y = end_tile_y - 1;
-
- while (tile_y >= start_tile_y) {
- double translate_y = ((tile_y - start_tile_y) * advance_y) - offset_y;
- int64_t tile_x = end_tile_x - 1;
-
- while (tile_x >= start_tile_x) {
- double translate_x = ((tile_x - start_tile_x) * advance_x) - offset_x;
- // g_debug("read_tiles %" G_GINT64_FORMAT " %" G_GINT64_FORMAT, tile_x, tile_y);
- cairo_translate(cr, translate_x, translate_y);
- read_tile(osr, cr, level, tile_x, tile_y, arg);
- cairo_set_matrix(cr, &matrix);
- tile_x--;
- }
-
- tile_y--;
- }
-}
View
@@ -1,42 +0,0 @@
-/*
- * OpenSlide, a library for reading whole slide image files
- *
- * Copyright (c) 2007-2009 Carnegie Mellon University
- * All rights reserved.
- *
- * OpenSlide is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation, version 2.1.
- *
- * OpenSlide is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with OpenSlide. If not, see
- * <http://www.gnu.org/licenses/>.
- *
- */
-
-#ifndef OPENSLIDE_OPENSLIDE_TILEHELPER_H_
-#define OPENSLIDE_OPENSLIDE_TILEHELPER_H_
-
-#include <config.h>
-
-#include "openslide-private.h"
-
-#include <stdbool.h>
-#include <stdint.h>
-#include <cairo.h>
-
-void _openslide_read_tiles(cairo_t *cr,
- struct _openslide_level *level,
- int64_t start_tile_x, int64_t start_tile_y,
- int64_t end_tile_x, int64_t end_tile_y,
- double offset_x, double offset_y,
- double advance_x, double advance_y,
- openslide_t *osr,
- void *arg,
- _openslide_tileread_fn read_tile);
-#endif
View
@@ -30,7 +30,6 @@
#include <libxml/parser.h>
#include "openslide-cache.h"
-#include "openslide-tilehelper.h"
#include "openslide-cairo.h"
const char _openslide_release_info[] = "OpenSlide " PACKAGE_VERSION ", copyright (C) 2007-2013 Carnegie Mellon University and others.\nLicensed under the GNU Lesser General Public License, version 2.1.";

0 comments on commit fe42ba2

Please sign in to comment.