Example #1
0
static bool nsico_redraw(struct content *c, struct content_redraw_data *data,
		const struct rect *clip, const struct redraw_context *ctx)
{
	nsico_content *ico = (nsico_content *)c;
	struct bmp_image *bmp;

	/* select most appropriate sized icon for size */
	bmp = ico_find(ico->ico, data->width, data->height);
	if (bmp == NULL) {
		/* return error */
		LOG("Failed to select icon");
		return false;
	}

	/* ensure its decided */
	if (bmp->decoded == false) {
		if (bmp_decode(bmp) != BMP_OK) {
			return false;
		} else {
			LOG("Decoding bitmap");
			guit->bitmap->modified(bmp->bitmap);
		}

	}

	return image_bitmap_plot(bmp->bitmap, data, clip, ctx);
}
Example #2
0
static bool nsgif_redraw(struct content *c, struct content_redraw_data *data,
		const struct rect *clip, const struct redraw_context *ctx)
{
	nsgif_content *gif = (nsgif_content *) c;

	if (gif->current_frame != gif->gif->decoded_frame) {
		if (nsgif_get_frame(gif) != GIF_OK) {
			return false;
		}
	}

	return image_bitmap_plot(gif->gif->frame_image, data, clip, ctx);
}
Example #3
0
/* exported interface documented in image_cache.h */
bool image_cache_redraw(struct content *c,
			struct content_redraw_data *data,
			const struct rect *clip,
			const struct redraw_context *ctx)
{
	struct image_cache_entry_s *centry;

	/* get the cache entry */
	centry = image_cache__find(c);
	if (centry == NULL) {
		LOG(("Could not find cache entry for content (%p)", c));
		return false;
	}

	if (centry->bitmap == NULL) {
		if (centry->convert != NULL) {
			centry->bitmap = centry->convert(centry->content);
		}

		if (centry->bitmap != NULL) {
			image_cache_stats_bitmap_add(centry);
			image_cache->miss_count++;
			image_cache->miss_size += centry->bitmap_size;
		} else {
			image_cache->fail_count++;
			image_cache->fail_size += centry->bitmap_size;
			return false;
		}
	} else {
		image_cache->hit_count++;
		image_cache->hit_size += centry->bitmap_size;
	}


	/* update statistics */
	centry->redraw_count++;
	centry->redraw_age = image_cache->current_age;

	return image_bitmap_plot(centry->bitmap, data, clip, ctx);
}