Пример #1
0
/*============================================================================*
 *                                  Local                                     *
 *============================================================================*/
static void _egueb_svg_renderable_check_new_bounds(Egueb_Svg_Renderable *thiz)
{
	Egueb_Svg_Pointer_Events pevents;
	Egueb_Svg_Element *e;
	Egueb_Dom_Node *doc;
	Egueb_Dom_Node *topmost;

	e = EGUEB_SVG_ELEMENT(thiz);
	/* do not inform about a geometry change if we can not handle the input */
	egueb_dom_attr_final_get(e->pointer_events, &pevents);
	if (pevents == EGUEB_SVG_POINTER_EVENTS_NONE)
		return;

	/* get the previous/current bounds, if it is now inside the mouse, make sure
	 * to inform about it
	 */
	doc = egueb_dom_node_owner_document_get(EGUEB_DOM_NODE(thiz));
	if (doc)
	{
		topmost = egueb_dom_document_document_element_get(doc);
		if (topmost)
		{
			Eina_Rectangle bounds;
			Egueb_Dom_Input *input;

			/* only notify the input in case the bounds are different */
			enesim_renderer_destination_bounds_get(thiz->proxy, &bounds, 0, 0, NULL);
			if (thiz->last_processed_bounds.x != bounds.x ||
				thiz->last_processed_bounds.y != bounds.y ||
				thiz->last_processed_bounds.w != bounds.w ||
				thiz->last_processed_bounds.h != bounds.h)
			{
				Eina_Rectangle ibounds;
				Egueb_Dom_Feature *ifeature;
				int mx, my;

				ifeature = egueb_dom_node_feature_get(topmost, EGUEB_DOM_FEATURE_UI_NAME, NULL);
				input = egueb_dom_feature_ui_input_get(ifeature);

				egueb_dom_input_mouse_position_get(input, &mx, &my);
				eina_rectangle_coords_from(&ibounds, 0, 0, mx, my);
				if (eina_rectangles_intersect(&ibounds, &bounds))
				{
					egueb_svg_document_mouse_check(doc);
				}
				egueb_dom_input_unref(input);
				egueb_dom_feature_unref(ifeature);
				thiz->last_processed_bounds = bounds;
			}
			egueb_dom_node_unref(topmost);
		}
		egueb_dom_node_unref(doc);
	}
}
Пример #2
0
int main(void)
{
	Enesim_Renderer *r;
	Enesim_Surface *s;
	Enesim_Draw_Cache *cache;
	Enesim_Buffer_Sw_Data sw_data_cache;
	Eina_Rectangle area, geom;
	uint8_t *dst;
	uint8_t *src;
	size_t stride;
	int i;

	enesim_init();
	r = enesim_renderer_circle_new();
	enesim_renderer_circle_x_set(r, 128);
	enesim_renderer_circle_y_set(r, 128);
	enesim_renderer_circle_radius_set(r, 64);
	enesim_renderer_shape_fill_color_set(r, 0xffff0000);
	enesim_renderer_shape_draw_mode_set(r, ENESIM_RENDERER_SHAPE_DRAW_MODE_FILL);

	cache = enesim_draw_cache_new();
	enesim_draw_cache_renderer_set(cache, r);

	/* try to map the area at 0, 0, 64, 64 */
	eina_rectangle_coords_from(&area, 0, 0, 64, 64);
	if (!enesim_draw_cache_map_sw(cache, &area, &sw_data_cache, ENESIM_FORMAT_ARGB8888, NULL))
		goto failed_mapping;

	/* try to map the area at 64, 64, 128, 128 */
	eina_rectangle_coords_from(&area, 64, 64, 128, 128);
	if (!enesim_draw_cache_map_sw(cache, &area, &sw_data_cache, ENESIM_FORMAT_ARGB8888, NULL))
		goto failed_mapping;

	/* now map again the first area, in theory we should not draw anymore */
	eina_rectangle_coords_from(&area, 0, 0, 64, 64);
	if (!enesim_draw_cache_map_sw(cache, &area, &sw_data_cache, ENESIM_FORMAT_ARGB8888, NULL))
		goto failed_mapping;
	src = sw_data_cache.argb8888.plane0;

	/* get the geometry */
	enesim_draw_cache_geometry_get(cache, &geom);
	printf("creating a surface of size %d %d\n", geom.w, geom.h);
	s = enesim_surface_new(ENESIM_FORMAT_ARGB8888,
			geom.w, geom.h);

	enesim_surface_sw_data_get(s, (void **)&dst, &stride);
	for (i = 0; i < 128; i++)
	{
		memcpy(dst, src, stride);
		dst += stride;
		src += stride;
	}


	enesim_image_file_save("enesim_draw_cache01_0x0_64x64.png", s, NULL);
	enesim_surface_unref(s);
failed_mapping:
	enesim_draw_cache_free(cache);
	enesim_shutdown();

	return 0;
}