unsigned get_texture_image_size( mesa_format format, unsigned rowStride, unsigned height, unsigned depth, unsigned tiling) { if (_mesa_is_format_compressed(format)) { unsigned blockWidth, blockHeight; _mesa_get_format_block_size(format, &blockWidth, &blockHeight); return rowStride * ((height + blockHeight - 1) / blockHeight) * depth; } else if (tiling) { /* Need to align height to tile height */ unsigned tileWidth, tileHeight; get_tile_size(format, &tileWidth, &tileHeight); tileHeight--; height = (height + tileHeight) & ~tileHeight; } return rowStride * height * depth; }
static gboolean preview_draw (GtkWidget *widget, cairo_t *cr, SoliPrintPreview *preview) { GdkWindow *bin_window; gint tile_width; gint page_num; gint n_pages; gint col; bin_window = gtk_layout_get_bin_window (preview->layout); if (!gtk_cairo_should_draw_window (cr, bin_window)) { return GDK_EVENT_STOP; } cairo_save (cr); gtk_cairo_transform_to_window (cr, widget, bin_window); get_tile_size (preview, &tile_width, NULL); n_pages = get_n_pages (preview); col = 0; page_num = get_first_page_displayed (preview); while (col < preview->n_columns && page_num < n_pages) { if (!gtk_print_operation_preview_is_selected (preview->gtk_preview, page_num)) { page_num++; continue; } draw_page (cr, col * tile_width, 0, page_num, preview); col++; page_num++; } cairo_restore (cr); return GDK_EVENT_STOP; }
static void update_layout_size (SoliPrintPreview *preview) { gint tile_width; gint tile_height; get_tile_size (preview, &tile_width, &tile_height); /* force size of the drawing area to make the scrolled window work */ gtk_layout_set_size (preview->layout, tile_width * preview->n_columns, tile_height); gtk_widget_queue_draw (GTK_WIDGET (preview->layout)); }
unsigned get_texture_image_row_stride(radeonContextPtr rmesa, mesa_format format, unsigned width, unsigned tiling, GLuint target) { if (_mesa_is_format_compressed(format)) { return get_aligned_compressed_row_stride(format, width, rmesa->texture_compressed_row_align); } else { unsigned row_align; if (!_mesa_is_pow_two(width) || target == GL_TEXTURE_RECTANGLE) { row_align = rmesa->texture_rect_row_align - 1; } else if (tiling) { unsigned tileWidth, tileHeight; get_tile_size(format, &tileWidth, &tileHeight); row_align = tileWidth * _mesa_get_format_bytes(format) - 1; } else { row_align = rmesa->texture_row_align - 1; } return (_mesa_format_row_stride(format, width) + row_align) & ~row_align; } }
/* Returns the page number (starting from 0) or -1 if no page. */ static gint get_page_at_coords (SoliPrintPreview *preview, gint x, gint y) { gint tile_width, tile_height; GtkAdjustment *hadj, *vadj; gint col, page; get_tile_size (preview, &tile_width, &tile_height); if (tile_height <= 0 || tile_width <= 0) { return -1; } get_adjustments (preview, &hadj, &vadj); x += gtk_adjustment_get_value (hadj); y += gtk_adjustment_get_value (vadj); col = x / tile_width; if (col >= preview->n_columns || y > tile_height) { return -1; } page = get_first_page_displayed (preview) + col; if (page >= get_n_pages (preview)) { return -1; } /* FIXME: we could try to be picky and check if we actually are inside * the page (i.e. not in the padding or shadow). */ return page; }