void stock_param(t_clist *param, t_clist *a, t_clist *b) { CONTENT(2) = ((t_int*)((t_clist *)a + 3)->bit + 1)->t_x; CONTENT(3) = ((t_int*)((t_clist *)a + 3)->bit + 2)->t_x; CONTENT(4) = ((t_int*)((t_clist *)b + 3)->bit + 1)->t_x; CONTENT(5) = ((t_int*)((t_clist *)b + 3)->bit + 2)->t_x; }
void write_param(int argc, char **argv, t_clist *param) { if (argc != 2) put_list(); if (ft_strequ(argv[1], "Mandelbrot")) CONTENT(0) = 1; else if (ft_strequ(argv[1], "Julia")) CONTENT(0) = 2; else if (ft_strequ(argv[1], "Chromosome")) CONTENT(0) = 3; else put_list(); }
static struct oio_url_s * _metacd_load_url (struct req_args_s *args) { const gchar *s; struct oio_url_s *url = oio_url_empty(); if (NULL != (s = NS())) oio_url_set (url, OIOURL_NS, s); if (NULL != (s = ACCOUNT())) oio_url_set (url, OIOURL_ACCOUNT, s); if (NULL != (s = REF())) oio_url_set (url, OIOURL_USER, s); if (NULL != (s = TYPE())) oio_url_set (url, OIOURL_TYPE, s); if (NULL != (s = PATH())) { oio_url_set (url, OIOURL_PATH, s); if (NULL != (s = VERSION())) oio_url_set (url, OIOURL_VERSION, s); } if (NULL != (s = CID())) oio_url_set (url, OIOURL_HEXID, s); if (NULL != (s = CONTENT())) oio_url_set (url, OIOURL_CONTENTID, s); return url; }
int share_mem_read_more ( share_mem_info_t *shm, void *buffer, int max_size, int *eos, int waiting) { int b_end = 0, b_eos = 0, read_size = 0; uint8_t *addr = (uint8_t *)buffer; while( b_end == 0 && max_size > 0 ) { share_mem_unit_t *u; int content_size; if( shm->current_read - shm->current_read_map >= shm->mapping_count || shm->current_read - shm->current_read_map < 0 ) //remapping { int i, i_max_unit; uint8_t *memory; shm->current_read_map = shm->current_read - shm->current_read % shm->mapping_count; if( shm->buffer_handle ) UnmapViewOfFile( shm->buffer_handle ); shm->buffer_handle = MapViewOfFile( shm->map_handle, FILE_MAP_ALL_ACCESS, 0, shm->current_read_map * (shm->unit_size + UNIT_HEADER_LENGTH), shm->mapping_count * (shm->unit_size + UNIT_HEADER_LENGTH) ); i_max_unit = shm->current_read_map + shm->mapping_count; i_max_unit = shm->unit_count > i_max_unit ? i_max_unit : shm->unit_count; memory = (uint8_t *)shm->buffer_handle; for( i = shm->current_read_map; i < i_max_unit; i ++ ) shm->share_unit[i] = (share_mem_unit_t *)(memory + (shm->unit_size + UNIT_HEADER_LENGTH) * (i - shm->current_read_map)); } u = shm->share_unit[shm->current_read]; while( u->has_content == 0 ) { if (waiting == 0) return 0; printf("in reading, wait for content, cursor: %d \n", shm->current_read); Sleep( 50 ); } content_size = u->content_size; if (max_size < content_size) { // should not change our content; user needs to increase max size return -1; } b_end = u->eob; b_eos = u->eos; memcpy( addr, CONTENT(u), content_size ); u->has_content = 0; printf("read a block: %d \n",shm->current_read); shm->current_read = (shm->current_read + 1) % shm->unit_count; addr += content_size; max_size -= content_size; read_size += content_size; } *eos = b_eos; return read_size; }
int share_mem_write( share_mem_info_t *shm, void *buffer, int size, int eos ) { int unit_size = shm->unit_size; uint8_t *addr = (uint8_t *)buffer; while( size >= 0 ) { int content_size = size > unit_size ? unit_size : size; share_mem_unit_t *u; if( shm->current_write - shm->current_write_map >= shm->mapping_count || shm->current_write - shm->current_write_map < 0 ) //remapping { int i, i_max_unit; uint8_t *memory; shm->current_write_map = shm->current_write - shm->current_write % shm->mapping_count; if( shm->buffer_handle ) UnmapViewOfFile( shm->buffer_handle ); shm->buffer_handle = MapViewOfFile( shm->map_handle, FILE_MAP_ALL_ACCESS, 0, shm->current_write_map * (shm->unit_size + UNIT_HEADER_LENGTH), shm->mapping_count * (shm->unit_size + UNIT_HEADER_LENGTH) ); i_max_unit = shm->current_write_map + shm->mapping_count; i_max_unit = shm->unit_count > i_max_unit ? i_max_unit : shm->unit_count; memory = (uint8_t *)shm->buffer_handle; for( i = shm->current_write_map; i < i_max_unit; i ++ ) shm->share_unit[i] = (share_mem_unit_t *)(memory + (shm->unit_size + UNIT_HEADER_LENGTH) * (i - shm->current_write_map) ); } u = shm->share_unit[shm->current_write]; while( u->has_content != 0 ) { printf("in writing, wait for space; cursor: %d \n", shm->current_write); Sleep( 50 ); } u->content_size = content_size; u->eob = size <= unit_size ? 1 : 0; u->eos = (u->eob && eos) ? 1 : 0; memcpy( CONTENT(u), addr, content_size ); printf("write a block %d, size %d \n",shm->current_write, content_size); u->has_content = 1; shm->current_write = (shm->current_write + 1) % shm->unit_count; addr += content_size; size -= content_size; if( size == 0 ) { // end of stream break; } } return 0; }
static void norm1(t_clist *param, int *dx, int *dy) { *dx = CONTENT(4) - CONTENT(2); *dy = CONTENT(5) - CONTENT(3); if (*dx > 0) CONTENT(6) = 1; else CONTENT(6) = -1; if (*dy > 0) CONTENT(7) = 1; else CONTENT(7) = -1; if (*dx < 0) *dx = *dx * (-1); if (*dy < 0) *dy = *dy * (-1); CONTENT(8) = 0; }
void tracer_bresenham(t_clist *param, t_clist *a, t_clist *b) { int dx; int dy; stock_param(param, a, b); CONTENT(9) = set_color(a, b); norm1(param, &dx, &dy); if (dx > dy) norm2(param, dx, dy); else norm3(param, dx, dy); }
void draw(t_content *axx, int nb_list) { t_clist *param; param = init_param(); CONTENT(0) = nb_list; PARAM(0) = mlx_init(); PARAM(1) = mlx_new_window(PARAM(0), LARGEUR, HAUTEUR, "fdf"); PARAM(2) = axx; mlx_key_hook(PARAM(1), key_hook, param); mlx_expose_hook(PARAM(1), expose_hook, param); mlx_loop(PARAM(0)); }
static void norm3(t_clist *param, int dx, int dy) { int cumul; cumul = dy / 2; while (CONTENT(8) < dy) { CONTENT(3) += CONTENT(7); cumul += dx; if (cumul >= dy) { cumul -= dy; CONTENT(2) += CONTENT(6); } mlx_pixel_put(PARAM(0), PARAM(1), CONTENT(2), CONTENT(3), (int)CONTENT(9)); CONTENT(8) += 1; } }
void main_mandelbrot(t_clist *param) { t_env e; e.d = 0; e.x = 0; e.y = 0; e.zoom = CONTENT(5); e.x1 = -1.8 * CONTENT(4); e.x2 = 1.8 * CONTENT(3); e.y1 = -1.2 * CONTENT(1); e.y2 = 1.2 * CONTENT(2); e.image_x = (e.x2 - e.x1) * e.zoom; e.image_y = (e.y2 - e.y1) * e.zoom; e.iteration_max = CONTENT(6); e.zoom_x = e.image_x / (e.x2 - e.x1); e.zoom_y = e.image_y / (e.y2 - e.y1); e.i = 0; norm(param, &e); }
k::ContentFrame * DockWidget::content() const { return CONTENT(widget()); }
void DockWidget::setContentWidth(int w) { ContentFrame * c = CONTENT(widget()); c->resize( w, c->height()); }