Exemple #1
0
static void artworks_redraw(const drawable_choices *choices,
                            wimp_draw              *draw,
                            drawable_t             *drawable,
                            int                     x,
                            int                     y)
{
  os_trfm            *trfm;
  awrender_info_block info_block;
  int                 scale;
  int                 mul;
  artworks_handle     handle;

  info_block.dither_x = x;
  info_block.dither_y = y;

  /* Retrieve scale value from the transform set up in
   * vector_scaling. */
  trfm = &drawable->details.generic.trfm;
#define SCALE_100PC 100
  scale = (trfm->entries[0][0] * SCALE_100PC) >> 16;
  mul = draw_OS_UNIT * SCALE_100PC;

  info_block.clip_rect.x0 = (draw->clip.x0 - x) * mul / scale;
  info_block.clip_rect.y0 = (draw->clip.y0 - y) * mul / scale;
  info_block.clip_rect.x1 = (draw->clip.x1 - x) * mul / scale;
  info_block.clip_rect.y1 = (draw->clip.y1 - y) * mul / scale;

  trfm = &drawable->details.artworks.trfm;

  trfm->entries[2][0] = x * draw_OS_UNIT;
  trfm->entries[2][1] = y * draw_OS_UNIT;

  handle.resizable_block = &drawable->image->details.artworks.workspace;
  handle.fixed_block     = &drawable->image->image;

  /* Shouldn't report errors in redraw loops. */
  (void)    awrender_render(drawable->image->image,
                           &info_block,
                            trfm,
    (awrender_vdu_block *) &drawable->details.artworks.vdu_block,
                            drawable->image->details.artworks.workspace,
(awrender_callback_handler) artworks_callback,
                            choices->artworks.quality,
                            awrender_OutputToVDU,
                           &handle);
}
Exemple #2
0
bool artworks_redraw(struct content *c, struct content_redraw_data *data,
		const struct rect *clip, const struct redraw_context *ctx)
{
	static const ns_os_vdu_var_list vars = {
		os_MODEVAR_XEIG_FACTOR,
		{
			os_MODEVAR_YEIG_FACTOR,
			os_MODEVAR_LOG2_BPP,
			os_VDUVAR_END_LIST
		}
	};
	artworks_content *aw = (artworks_content *) c;
	struct awinfo_block info;
	const char *source_data;
	unsigned long source_size;
	os_error *error;
	os_trfm matrix;
	int vals[24];

	int clip_x0 = clip->x0;
	int clip_y0 = clip->y0;
	int clip_x1 = clip->x1;
	int clip_y1 = clip->y1;

	if (ctx->plot->flush && !ctx->plot->flush())
		return false;

	/* pick up render addresses again in case they've changed
	   (eg. newer AWRender module loaded since we first loaded this file) */
	(void)_swix(AWRender_RenderAddress, _OUT(0) | _OUT(1),
				&aw->render_routine,
				&aw->render_workspace);

	/* Scaled image. Transform units (65536*OS units) */
	matrix.entries[0][0] = data->width * 65536 / c->width;
	matrix.entries[0][1] = 0;
	matrix.entries[1][0] = 0;
	matrix.entries[1][1] = data->height * 65536 / c->height;
	/* Draw units. (x,y) = bottom left */
	matrix.entries[2][0] = ro_plot_origin_x * 256 + data->x * 512 -
			aw->x0 * data->width / c->width;
	matrix.entries[2][1] = ro_plot_origin_y * 256 -
			(data->y + data->height) * 512 -
			aw->y0 * data->height / c->height;

	info.ditherx = ro_plot_origin_x;
	info.dithery = ro_plot_origin_y;

	clip_x0 -= data->x;
	clip_y0 -= data->y;
	clip_x1 -= data->x;
	clip_y1 -= data->y;

	if (data->scale == 1.0) {
		info.clip_x0 = (clip_x0 * 512) + aw->x0 - 511;
		info.clip_y0 = ((c->height - clip_y1) * 512) + aw->y0 - 511;
		info.clip_x1 = (clip_x1 * 512) + aw->x0 + 511;
		info.clip_y1 = ((c->height - clip_y0) * 512) + aw->y0 + 511;
	}
	else {
		info.clip_x0 = (clip_x0 * 512 / data->scale) + aw->x0 - 511;
		info.clip_y0 = ((c->height - (clip_y1 / data->scale)) * 512) +
				aw->y0 - 511;
		info.clip_x1 = (clip_x1 * 512 / data->scale) + aw->x0 + 511;
		info.clip_y1 = ((c->height - (clip_y0 / data->scale)) * 512) +
				aw->y0 + 511;
	}

	info.print_lowx = 0;
	info.print_lowy = 0;
	info.print_handle = 0;
	info.bgcolour = 0x20000000 | data->background_colour;

	error = xos_read_vdu_variables(PTR_OS_VDU_VAR_LIST(&vars), vals);
	if (error) {
		LOG("xos_read_vdu_variables: 0x%x: %s", error->errnum, error->errmess);
		return false;
	}

	error = xwimp_read_palette((os_palette*)&vals[3]);
	if (error) {
		LOG("xwimp_read_palette: 0x%x: %s", error->errnum, error->errmess);
		return false;
	}

	source_data = content__get_source_data(c, &source_size);

	error = awrender_render(source_data,
			&info,
			&matrix,
			vals,
			&aw->block,
			&aw->size,
			110,	/* fully anti-aliased */
			0,
			source_size,
			aw->render_routine,
			aw->render_workspace);

	if (error) {
		LOG("awrender_render: 0x%x: %s", error->errnum, error->errmess);
		return false;
	}

	return true;
}