Mercurial > geeqie.yaz
comparison src/pan-view.c @ 32:96ac60a9c0f1
Wed Apr 6 02:43:40 2005 John Ellis <johne@verizon.net>
* pan-view.c: Reimplement pixbuf_draw_triangle for efficiency.
* pixbuf-renderer.c: Fix pr_queue_to_tiles only_existing argument to
only have effect on tiles that not currently visible. Remove use of
hard coded PR_TILE_SIZE from tile size calculations, as it is only
supposed to be used as the default value.
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
##### an offical release when making enhancements and translation updates. #####
author | gqview |
---|---|
date | Wed, 06 Apr 2005 06:49:23 +0000 |
parents | a310e31fc513 |
children | a41ecbb26a96 |
comparison
equal
deleted
inserted
replaced
31:c42544f31030 | 32:96ac60a9c0f1 |
---|---|
433 gint fx2, fy2; | 433 gint fx2, fy2; |
434 gint fw, fh; | 434 gint fw, fh; |
435 guchar *p_pix; | 435 guchar *p_pix; |
436 guchar *pp; | 436 guchar *pp; |
437 gint p_step; | 437 gint p_step; |
438 gint i, j; | 438 gdouble slope1, slope2; |
439 gint slope1_x, slope1_y; | |
440 gint y; | |
441 gint t; | |
442 gint middle = FALSE; | |
439 | 443 |
440 if (!pb) return; | 444 if (!pb) return; |
441 | 445 |
442 pw = gdk_pixbuf_get_width(pb); | 446 pw = gdk_pixbuf_get_width(pb); |
443 ph = gdk_pixbuf_get_height(pb); | 447 ph = gdk_pixbuf_get_height(pb); |
458 p_alpha = gdk_pixbuf_get_has_alpha(pb); | 462 p_alpha = gdk_pixbuf_get_has_alpha(pb); |
459 prs = gdk_pixbuf_get_rowstride(pb); | 463 prs = gdk_pixbuf_get_rowstride(pb); |
460 p_pix = gdk_pixbuf_get_pixels(pb); | 464 p_pix = gdk_pixbuf_get_pixels(pb); |
461 | 465 |
462 p_step = (p_alpha) ? 4 : 3; | 466 p_step = (p_alpha) ? 4 : 3; |
463 for (i = fy1; i < fy2; i++) | 467 |
464 { | 468 if (y1 > y2) |
465 pp = p_pix + i * prs + (fx1 * p_step); | 469 { |
466 for (j = fx1; j < fx2; j++) | 470 t = x1; x1 = x2; x2 = t; |
467 { | 471 t = y1; y1 = y2; y2 = t; |
468 gint z1, z2; | 472 } |
469 | 473 if (y2 > y3) |
470 z1 = (y1 - y2)*(j - x2) + (x2 - x1)*(i - y2); | 474 { |
471 z2 = (y2 - y3)*(j - x3) + (x3 - x2)*(i - y3); | 475 t = x2; x2 = x3; x3 = t; |
472 if ((z1 ^ z2) >= 0) | 476 t = y2; y2 = y3; y3 = t; |
473 { | 477 } |
474 z2 = (y3 - y1)*(j - x1) + (x1 - x3)*(i - y1); | 478 if (y1 > y2) |
475 if ((z1 ^ z2) >= 0) | 479 { |
476 { | 480 t = x1; x1 = x2; x2 = t; |
477 pp[0] = (r * a + pp[0] * (256-a)) >> 8; | 481 t = y1; y1 = y2; y2 = t; |
478 pp[1] = (g * a + pp[1] * (256-a)) >> 8; | 482 } |
479 pp[2] = (b * a + pp[2] * (256-a)) >> 8; | 483 |
480 } | 484 slope1 = (gdouble)(y2 - y1); |
481 } | 485 if (slope1) slope1 = (gdouble)(x2 - x1) / slope1; |
482 pp += p_step; | 486 slope1_x = x1; |
487 slope1_y = y1; | |
488 slope2 = (gdouble)(y3 - y1); | |
489 if (slope2) slope2 = (gdouble)(x3 - x1) / slope2; | |
490 | |
491 for (y = fy1; y < fy2; y++) | |
492 { | |
493 gint xa, xb; | |
494 | |
495 if (!middle && y > y2) | |
496 { | |
497 slope1 = (gdouble)(y3 - y2); | |
498 if (slope1) slope1 = (gdouble)(x3 - x2) / slope1; | |
499 slope1_x = x2; | |
500 slope1_y = y2; | |
501 | |
502 middle = TRUE; | |
503 } | |
504 | |
505 xa = slope1_x + ((gdouble)slope1 * (y - slope1_y) + 0.5); | |
506 xb = x1 + ((gdouble)slope2 * (y - y1) + 0.5); | |
507 | |
508 if (xa > xb) | |
509 { | |
510 t = xa; xa = xb; xb = t; | |
511 } | |
512 | |
513 xa = CLAMP(xa, fx1, fx2); | |
514 xb = CLAMP(xb, fx1, fx2); | |
515 | |
516 pp = p_pix + y * prs + xa * p_step; | |
517 | |
518 while (xa < xb) | |
519 { | |
520 *pp = (r * a + *pp * (256-a)) >> 8; | |
521 pp++; | |
522 *pp = (g * a + *pp * (256-a)) >> 8; | |
523 pp++; | |
524 *pp = (b * a + *pp * (256-a)) >> 8; | |
525 pp++; | |
526 if (p_alpha) pp++; | |
527 | |
528 xa++; | |
483 } | 529 } |
484 } | 530 } |
485 } | 531 } |
486 | 532 |
487 static gint util_clip_line(gdouble clip_x, gdouble clip_y, gdouble clip_w, gdouble clip_h, | 533 static gint util_clip_line(gdouble clip_x, gdouble clip_y, gdouble clip_w, gdouble clip_h, |
493 | 539 |
494 if (x1 > x2) | 540 if (x1 > x2) |
495 { | 541 { |
496 gdouble t; | 542 gdouble t; |
497 | 543 |
498 t = x1; | 544 t = x1; x1 = x2; x2 = t; |
499 x1 = x2; | 545 t = y1; y1 = y2; y2 = t; |
500 x2 = t; | |
501 | |
502 t = y1; | |
503 y1 = y2; | |
504 y2 = t; | |
505 | |
506 flip = TRUE; | 546 flip = TRUE; |
507 } | 547 } |
508 | 548 |
509 if (x2 < clip_x || x1 > clip_x + clip_w) return FALSE; | 549 if (x2 < clip_x || x1 > clip_x + clip_w) return FALSE; |
510 | 550 |
557 { | 597 { |
558 gdouble t; | 598 gdouble t; |
559 | 599 |
560 if (y1 < clip_y || y2 > clip_y + clip_h) return FALSE; | 600 if (y1 < clip_y || y2 > clip_y + clip_h) return FALSE; |
561 | 601 |
562 t = x1; | 602 t = x1; x1 = x2; x2 = t; |
563 x1 = x2; | 603 t = y1; y1 = y2; y2 = t; |
564 x2 = t; | |
565 | |
566 t = y1; | |
567 y1 = y2; | |
568 y2 = t; | |
569 | |
570 flip = !flip; | 604 flip = !flip; |
571 } | 605 } |
572 | 606 |
573 d = y2 - y1; | 607 d = y2 - y1; |
574 if (d > 0.0) | 608 if (d > 0.0) |
3319 pan_window_zoom_limit(pw); | 3353 pan_window_zoom_limit(pw); |
3320 | 3354 |
3321 if (width > 0 && height > 0) | 3355 if (width > 0 && height > 0) |
3322 { | 3356 { |
3323 gdouble align; | 3357 gdouble align; |
3358 | |
3359 printf("Canvas size is %d x %d\n", width, height); | |
3324 | 3360 |
3325 pixbuf_renderer_set_tiles(PIXBUF_RENDERER(pw->imd->pr), width, height, | 3361 pixbuf_renderer_set_tiles(PIXBUF_RENDERER(pw->imd->pr), width, height, |
3326 PAN_TILE_SIZE, PAN_TILE_SIZE, 10, | 3362 PAN_TILE_SIZE, PAN_TILE_SIZE, 10, |
3327 pan_window_request_tile_cb, | 3363 pan_window_request_tile_cb, |
3328 pan_window_dispose_tile_cb, pw, 1.0); | 3364 pan_window_dispose_tile_cb, pw, 1.0); |