Changeset 3583
- Timestamp:
- Jul 26, 2009, 9:17:35 PM (14 years ago)
- Location:
- libcaca/trunk
- Files:
-
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
libcaca/trunk/caca/attr.c
r3494 r3583 157 157 } 158 158 159 caca_add_dirty_rect(cv, xmin, y, xmax - xmin + 1, 1); 159 if(!cv->dirty_disabled) 160 caca_add_dirty_rect(cv, xmin, y, xmax - xmin + 1, 1); 160 161 161 162 return 0; -
libcaca/trunk/caca/caca.h
r3495 r3583 241 241 * These functions manipulate dirty rectangles for optimised blitting. 242 242 * @{ */ 243 __extern int caca_disable_dirty_rect(caca_canvas_t *); 244 __extern int caca_enable_dirty_rect(caca_canvas_t *); 243 245 __extern int caca_get_dirty_rect_count(caca_canvas_t *); 244 246 __extern int caca_get_dirty_rect(caca_canvas_t *, int, int *, int *, -
libcaca/trunk/caca/caca_internals.h
r3580 r3583 61 61 62 62 /* Dirty rectangles */ 63 int ndirty ;63 int ndirty, dirty_disabled; 64 64 struct 65 65 { -
libcaca/trunk/caca/canvas.c
r3568 r3583 434 434 } 435 435 436 caca_add_dirty_rect(cv, old_width, 0, width - old_width, old_height); 436 if(!cv->dirty_disabled) 437 caca_add_dirty_rect(cv, old_width, 0, 438 width - old_width, old_height); 437 439 } 438 440 else … … 475 477 } 476 478 477 caca_add_dirty_rect(cv, 0, old_height, old_width, height - old_height); 479 if(!cv->dirty_disabled) 480 caca_add_dirty_rect(cv, 0, old_height, 481 old_width, height - old_height); 478 482 } 479 483 480 484 /* If both width and height are larger, there is a new dirty rectangle 481 485 * that needs to be created in the lower right corner. */ 482 if(width > old_width && height > old_height) 486 if(!cv->dirty_disabled && 487 width > old_width && height > old_height) 483 488 caca_add_dirty_rect(cv, old_width, old_height, 484 489 width - old_width, height - old_height); -
libcaca/trunk/caca/dirty.c
r3580 r3583 36 36 37 37 static void merge_new_rect(caca_canvas_t *cv, int n); 38 39 /** \brief Disable dirty rectangles. 40 * 41 * Disable dirty rectangle handling for all \e libcaca graphic calls. This 42 * is handy when the calling application needs to do slow operations within 43 * a known area. Just call caca_add_dirty_rect() afterwards. 44 * 45 * This function is recursive. Dirty rectangles are only reenabled when 46 * caca_enable_dirty_rect() is called as many times. 47 * 48 * This function never fails. 49 * 50 * \param cv A libcaca canvas. 51 * \return This function always returns 0. 52 */ 53 int caca_disable_dirty_rect(caca_canvas_t *cv) 54 { 55 cv->dirty_disabled++; 56 57 return 0; 58 } 59 60 /** \brief Enable dirty rectangles. 61 * 62 * This function can only be called after caca_disable_dirty_rect() was 63 * called. 64 * 65 * If an error occurs, -1 is returned and \b errno is set accordingly: 66 * - \c EINVAL Dirty rectangles were not disabled. 67 * 68 * \param cv A libcaca canvas. 69 * \return 0 in case of success, -1 if an error occurred. 70 */ 71 int caca_enable_dirty_rect(caca_canvas_t *cv) 72 { 73 if(cv->dirty_disabled <= 0) 74 { 75 seterrno(EINVAL); 76 return -1; 77 } 78 79 cv->dirty_disabled--; 80 81 return 0; 82 } 38 83 39 84 /** \brief Get the number of dirty rectangles in the canvas. -
libcaca/trunk/caca/frame.c
r3494 r3583 73 73 _caca_load_frame_info(cv); 74 74 75 caca_add_dirty_rect(cv, 0, 0, cv->width, cv->height); 75 if(!cv->dirty_disabled) 76 caca_add_dirty_rect(cv, 0, 0, cv->width, cv->height); 76 77 77 78 return 0; … … 237 238 cv->frame = 0; 238 239 _caca_load_frame_info(cv); 239 caca_add_dirty_rect(cv, 0, 0, cv->width, cv->height); 240 if(!cv->dirty_disabled) 241 caca_add_dirty_rect(cv, 0, 0, cv->width, cv->height); 240 242 } 241 243 -
libcaca/trunk/caca/string.c
r3581 r3583 181 181 * in the canvas, ie. if CACA_MAGIC_FULLWIDTH lies at illegal places, 182 182 * but it's the caller's responsibility not to corrupt the contents. */ 183 if(curchar[0] != ch || curattr[0] != attr) 183 if(!cv->dirty_disabled 184 && (curchar[0] != ch || curattr[0] != attr)) 184 185 caca_add_dirty_rect(cv, xmin, y, xmax - xmin + 1, 1); 185 186 … … 328 329 } 329 330 330 caca_add_dirty_rect(cv, 0, 0, cv->width, cv->height); 331 if(!cv->dirty_disabled) 332 caca_add_dirty_rect(cv, 0, 0, cv->width, cv->height); 331 333 332 334 return 0; … … 454 456 dst->chars[dstix + i] = src->chars[srcix + i]; 455 457 dst->attrs[dstix + i] = src->attrs[srcix + i]; 456 caca_add_dirty_rect(dst, x + starti + i, y + j, 1, 1); 458 if(!dst->dirty_disabled) 459 caca_add_dirty_rect(dst, x + starti + i, y + j, 1, 1); 457 460 } 458 461 } … … 466 469 memcpy(dst->chars + dstix, src->chars + srcix, stride * 4); 467 470 memcpy(dst->attrs + dstix, src->attrs + srcix, stride * 4); 468 caca_add_dirty_rect(dst, x + starti, y + j, stride, 1); 471 if(!dst->dirty_disabled) 472 caca_add_dirty_rect(dst, x + starti, y + j, stride, 1); 469 473 } 470 474 } … … 543 547 544 548 /* FIXME: this may be optimised somewhat */ 545 caca_add_dirty_rect(cv, 0, 0, cv->width, cv->height); 549 if(!cv->dirty_disabled) 550 caca_add_dirty_rect(cv, 0, 0, cv->width, cv->height); 546 551 547 552 return 0; -
libcaca/trunk/caca/transform.c
r3542 r3583 55 55 } 56 56 57 caca_add_dirty_rect(cv, 0, 0, cv->width, cv->height); 57 if(!cv->dirty_disabled) 58 caca_add_dirty_rect(cv, 0, 0, cv->width, cv->height); 58 59 59 60 return 0; … … 116 117 } 117 118 118 caca_add_dirty_rect(cv, 0, 0, cv->width, cv->height); 119 if(!cv->dirty_disabled) 120 caca_add_dirty_rect(cv, 0, 0, cv->width, cv->height); 119 121 120 122 return 0; … … 163 165 } 164 166 165 caca_add_dirty_rect(cv, 0, 0, cv->width, cv->height); 167 if(!cv->dirty_disabled) 168 caca_add_dirty_rect(cv, 0, 0, cv->width, cv->height); 166 169 167 170 return 0; … … 222 225 } 223 226 224 caca_add_dirty_rect(cv, 0, 0, cv->width, cv->height); 227 if(!cv->dirty_disabled) 228 caca_add_dirty_rect(cv, 0, 0, cv->width, cv->height); 225 229 226 230 return 0; … … 341 345 _caca_load_frame_info(cv); 342 346 343 caca_add_dirty_rect(cv, 0, 0, cv->width, cv->height); 347 if(!cv->dirty_disabled) 348 caca_add_dirty_rect(cv, 0, 0, cv->width, cv->height); 344 349 345 350 return 0; … … 460 465 _caca_load_frame_info(cv); 461 466 462 caca_add_dirty_rect(cv, 0, 0, cv->width, cv->height); 467 if(!cv->dirty_disabled) 468 caca_add_dirty_rect(cv, 0, 0, cv->width, cv->height); 463 469 464 470 return 0; -
libcaca/trunk/tests/.gitignore
r2824 r3583 1 bench 2 caca-test 1 3 simple 2 caca-test -
libcaca/trunk/tests/bench.c
r3582 r3583 48 48 } 49 49 50 static void putchars( void)50 static void putchars(int optim) 51 51 { 52 52 caca_canvas_t *cv; 53 53 int i; 54 54 cv = caca_create_canvas(40, 40); 55 if(optim) 56 caca_disable_dirty_rect(cv); 55 57 for (i = 0; i < PUTCHAR_LOOPS; i++) 56 58 { 57 59 caca_put_char(cv, 1, 1, 'x'); 58 60 caca_put_char(cv, 1, 1, 'o'); 61 } 62 if(optim) 63 { 64 caca_enable_dirty_rect(cv); 65 caca_add_dirty_rect(cv, 1, 1, 1, 1); 59 66 } 60 67 caca_free_canvas(cv); … … 67 74 TIME("blit mask, no clear", blit(1, 0)); 68 75 TIME("blit mask, clear", blit(1, 1)); 69 TIME("putchars", putchars()); 76 TIME("putchars, no optim", putchars(0)); 77 TIME("putchars, optim", putchars(1)); 70 78 return 0; 71 79 }
Note: See TracChangeset
for help on using the changeset viewer.