void fractFunc::draw_aa(float min_progress, float max_progress) { int w = im->Xres(); int h = im->Yres(); reset_counts(); float delta = (max_progress - min_progress)/2.0; // if we have multiple threads,make sure they don't modify // pixels the other thread will look at - that wouldn't be // an error per se but would make drawing nondeterministic, // which I'm trying to avoid // We do this by drawing every even line, then every odd one. for(int i = 0; i < 2 ; ++i) { set_progress_range( min_progress + delta * i, min_progress + delta * (i+1)); reset_progress(0.0); last_update_y = 0; for(int y = i; y < h ; y+= 2) { worker->row_aa(0,y,w); if(update_image(y)) { break; } } reset_progress(1.0); } }
static void raft_peer_init(raft_peer_t *p) { p->up = false; p->seqno = 0; reset_progress(&p->acked); p->applied = 0; p->host = DEFAULT_LISTENHOST; p->port = DEFAULT_LISTENPORT; p->silent_ms = 0; }
void fractFunc::draw( int rsize, int drawsize, float min_progress, float max_progress) { if(debug_flags & DEBUG_QUICK_TRACE) { printf("drawing: %d\n", render_type); } reset_counts(); // init RNG based on time before generating image time_t now; time(&now); srand((unsigned int)now); int x,y; int w = im->Xres(); int h = im->Yres(); /* reset progress indicator & clear screen */ last_update_y = 0; reset_progress(min_progress); float mid_progress = (max_progress + min_progress)/2.0; set_progress_range(min_progress, mid_progress); // first pass - big blocks and edges for (y = 0 ; y < h - rsize ; y += rsize) { // main large blocks for ( x = 0 ; x< w - rsize ; x += rsize) { worker->pixel ( x, y, drawsize, drawsize); } // extra pixels at end of lines for(int y2 = y; y2 < y + rsize; ++y2) { worker->row (x, y2, w-x); } if(update_image(y)) { goto done; } } // remaining lines for ( ; y < h ; y++) { worker->row(0,y,w); if(update_image(y)) { goto done; } } last_update_y = 0; reset_progress(0.0); set_progress_range(mid_progress, max_progress); // fill in gaps in the rsize-blocks for ( y = 0; y < h - rsize; y += rsize) { for(x = 0; x < w - rsize ; x += rsize) { worker->box(x,y,rsize); } if(update_image(y)) { goto done; } } done: /* refresh entire image & reset progress bar */ reset_progress(1.0); }
/* This routine reads data from stream and writes out complete frames until * either the sample count is reached or the read is interrupted. */ static bool capture_data(FILE *stream, uint64_t *frames_written) { /* Size of line of data. */ size_t line_size = count_data_bits(data_mask) * count_mask_bits(&capture_mask, fa_entry_count) * FA_ENTRY_SIZE; /* If matlab_format is set we need to read timestamp frames interleaved * in the data stream. These two variables keep track of this. */ unsigned int timestamp_offset = timestamp_header.offset; size_t lines_to_timestamp = 0; /* Track state and number of frames written. */ *frames_written = 0; bool ok = true; /* Read until write error, interruption, end of input, or requested number * of frames has been captured. */ do { /* Read the extended timestamp if appropriate. */ if (matlab_format && lines_to_timestamp == 0) { if (!read_timestamp_block(stream)) break; // End of input timestamps_count += 1; lines_to_timestamp = timestamp_header.block_size - timestamp_offset; timestamp_offset = 0; } /* Figure out how many lines we can read in one chunk. Can't read past * the next timestamp, can't read more than a buffer full, can't be more * than we're waiting for. */ size_t lines_to_read = BUFFER_SIZE / line_size; if (matlab_format && lines_to_read > lines_to_timestamp) lines_to_read = lines_to_timestamp; if (sample_count > 0 && lines_to_read > sample_count - *frames_written) lines_to_read = (size_t) (sample_count - *frames_written); /* Read lines of data. */ char buffer[BUFFER_SIZE]; size_t lines_read = fread(buffer, line_size, lines_to_read, stream); if (lines_read == 0) break; // End of input lines_to_timestamp -= lines_read; /* Ship out lines as read. */ ok = TEST_OK( fwrite(buffer, line_size, lines_read, output_file) == lines_read); *frames_written += lines_read; if (show_progress) update_progress(*frames_written, line_size); } while (ok && running && (sample_count == 0 || *frames_written < sample_count)); if (show_progress) reset_progress(); return ok; }