/*============================================================================* * Global * *============================================================================*/ Egueb_Dom_Node * eon_theme_mars_radio_new(void) { Eon_Theme_Mars_Radio *thiz; Egueb_Dom_Node *n; Egueb_Dom_String *s; Enesim_Renderer_Compound_Layer *l; thiz = calloc(1, sizeof(Eon_Theme_Mars_Radio)); /* the radio button */ thiz->button = enesim_renderer_circle_new(); enesim_renderer_circle_radius_set(thiz->button, 3); enesim_renderer_shape_draw_mode_set(thiz->button, ENESIM_RENDERER_SHAPE_DRAW_MODE_FILL); thiz->border = enesim_renderer_circle_new(); enesim_renderer_circle_radius_set(thiz->border, 7); enesim_renderer_shape_stroke_weight_set(thiz->border, 2); enesim_renderer_shape_draw_mode_set(thiz->border, ENESIM_RENDERER_SHAPE_DRAW_MODE_STROKE_FILL); enesim_renderer_shape_fill_renderer_set(thiz->border, enesim_renderer_ref(thiz->button)); /* the button and the content */ thiz->radio = enesim_renderer_compound_new(); l = enesim_renderer_compound_layer_new(); enesim_renderer_compound_layer_renderer_set(l, enesim_renderer_ref(thiz->border)); enesim_renderer_compound_layer_rop_set(l, ENESIM_ROP_BLEND); enesim_renderer_compound_layer_add(thiz->radio, l); /* the widget area */ thiz->area = enesim_renderer_rectangle_new(); enesim_renderer_shape_draw_mode_set(thiz->area, ENESIM_RENDERER_SHAPE_DRAW_MODE_FILL); enesim_renderer_shape_fill_renderer_set(thiz->area, enesim_renderer_ref(thiz->radio)); /* the blur effect for disabled buttons */ thiz->blur = enesim_renderer_blur_new(); enesim_renderer_blur_radius_x_set(thiz->blur, 3); enesim_renderer_blur_radius_y_set(thiz->blur, 3); thiz->proxy = enesim_renderer_proxy_new(); enesim_renderer_proxy_proxied_set(thiz->proxy, enesim_renderer_ref(thiz->area)); n = eon_theme_element_button_new(&_descriptor, thiz); /* the attributes */ s = egueb_dom_string_new_with_static_chars("border-color"); thiz->border_color = egueb_css_attr_color_new(s, NULL, EINA_TRUE, EINA_TRUE, EINA_FALSE); s = egueb_dom_string_new_with_static_chars("button-color"); thiz->button_color = egueb_css_attr_color_new(s, NULL, EINA_TRUE, EINA_TRUE, EINA_FALSE); egueb_dom_element_attribute_node_set(n, egueb_dom_node_ref(thiz->border_color), NULL); egueb_dom_element_attribute_node_set(n, egueb_dom_node_ref(thiz->button_color), NULL); thiz->n = n; return n; }
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; }