Changeset 661
- Timestamp:
- May 15, 2011, 5:31:42 PM (11 years ago)
- Location:
- abuse/trunk
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
abuse/trunk/TODO
r659 r661 57 57 -------- 58 58 - move to vec2i: 59 - PutPart 59 - PutPart -> changer le 2e arg. de la bbox 60 60 - AddDirty !! 61 61 - update_dirty 62 62 63 JCFont::tl,th -> m_size 64 sprite::x,y -> m_pos 63 65 console::draw_char : vec2i 64 66 VolumeWindow::draw_vol plus grand !! … … 71 73 jwindow::area 72 74 75 refactor image::Line to merge loops 76 -
abuse/trunk/src/common.h
r574 r661 39 39 static inline float Max(float a, float b) { return a > b ? a : b; } 40 40 41 static inline vec2i Min(vec2i a, vec2i b) { return vec2i(Min(a.x, b.x), Min(a.y, b.y)); } 42 static inline vec2i Max(vec2i a, vec2i b) { return vec2i(Max(a.x, b.x), Max(a.y, b.y)); } 43 41 44 // 42 45 // Byte swapping -
abuse/trunk/src/imlib/fonts.cpp
r644 r661 28 28 void texture_font::put_char(image *screen, int x, int y, char ch) 29 29 { if (fntpat) 30 screen->PutPartMasked(fntpat, let, x,y,31 ((int)ch%32)*tl,((int)ch/32)*th,0,0,tl-1,th-1);32 else screen->PutPart(let, x, y, ((int)ch%32)*tl, ((int)ch/32)*th,33 ((int)ch%32)*tl+tl-1, ((int)ch/32)*th+th-1, 1);30 screen->PutPartMasked(fntpat, vec2i(x, y), let, 31 vec2i(((int)ch%32)*tl,((int)ch/32)*th), vec2i(0,0), vec2i(tl-1,th-1)); 32 else screen->PutPart(let, vec2i(x, y), vec2i(((int)ch%32)*tl, ((int)ch/32)*th), 33 vec2i(((int)ch%32)*tl+tl-1, ((int)ch/32)*th+th-1), 1); 34 34 } 35 35 … … 74 74 { 75 75 tmp.clear(); 76 tmp.PutPart(letters, 0, 0, ((int)ch%32)*tl, ((int)ch/32)*th,77 ((int)ch%32)*tl+tl-1, ((int)ch/32)*th+th-1, 1);76 tmp.PutPart(letters, vec2i(0, 0), vec2i(((int)ch%32)*tl, ((int)ch/32)*th), 77 vec2i(((int)ch%32)*tl+tl-1, ((int)ch/32)*th+th-1), 1); 78 78 let[ch] = new TransImage(&tmp, "JCfont"); 79 79 } -
abuse/trunk/src/imlib/image.cpp
r655 r661 327 327 if(m_special) 328 328 { 329 PutPart(im, pos .x, pos.y, 0, 0, im->m_size.x-1, im->m_size.y-1, transparent);329 PutPart(im, pos, vec2i(0), im->m_size - vec2i(1), transparent); 330 330 return; 331 331 } … … 380 380 } 381 381 382 void image::fill_image(image *screen, int16_t x1, int16_t y1, int16_t x2, int16_t y2, int16_t align) 383 { 384 int16_t i, j, w, xx, start, xl, starty; 385 uint8_t *pg1, *pg2; 386 CHECK(x1<=x2 && y1<=y2); // we should have gotten this 387 388 if (screen->m_special) 389 { x1=screen->m_special->bound_x1(x1); 390 y1=screen->m_special->bound_y1(y1); 391 x2=screen->m_special->bound_x2(x2+1)-1; 392 y2=screen->m_special->bound_y2(y2+1)-1; 393 } 394 else 395 { if (x1<0) x1=0; 396 if (y2<0) y1=0; 397 if (x2>=screen->Size().x) x2=screen->Size().x-1; 398 if (y2>=screen->Size().y) y2=screen->Size().y-1; 399 } 400 if (x2<0 || y2<0 || x1>=screen->Size().x || y1>=screen->Size().y) 401 return ; 402 screen->AddDirty(x1, y1, x2 + 1, y2 + 1); 403 w=m_size.x; 404 if (align) 405 { 406 start=x1%w; 407 starty=y1%m_size.y; 408 } 409 else 410 { start=0; 411 starty=0; 412 } 413 screen->Lock(); 414 Lock(); 415 for (j=y1; j<=y2; j++) 416 { 417 pg1=screen->scan_line(j); 418 pg2=scan_line(starty++); 419 if (starty>=m_size.y) starty=0; 420 i=x1; 421 xx=start; 422 while (i<=x2) 423 { 424 xl=Min(w-xx, x2-i+1); 425 426 memcpy(&pg1[i], &pg2[xx], xl); 427 xx=0; 428 i+=xl; 429 } 430 } 431 Unlock(); 432 screen->Unlock(); 433 } 434 435 436 void image::PutPart(image *im, int16_t x, int16_t y, int16_t x1, int16_t y1, 437 int16_t x2, int16_t y2, char transparent) 438 { 439 int16_t xlen, ylen, j, i; 440 uint8_t *pg1, *pg2, *source, *dest; 441 CHECK(x1<=x2 && y1<=y2); 442 443 int cx1, cy1, cx2, cy2; 444 GetClip(cx1, cy1, cx2, cy2); 445 446 // see if the are to be put is outside of actual image, if so adjust 447 // to fit in the image 448 if (x1<0) { x+=-x1; x1=0; } 449 if (y1<0) { y+=-y1; y1=0; } 450 if (x2>=im->m_size.x) x2=im->m_size.x-1; 451 if (y2>=im->m_size.y) y2=im->m_size.y-1; 452 if (x1>x2 || y1>y2) return ; // return if it was adjusted so that nothing will be put 453 454 // see if the image gets clipped off the screen 455 if (x >= cx2 || y >= cy2 || x + (x2 - x1) < cx1 || y + (y2 - y1) < cy1) 456 return ; 457 458 if (x<cx1) 459 { x1+=(cx1-x); x=cx1; } 460 if (y<cy1) 461 { y1+=(cy1-y); y=cy1; } 462 463 if (x + x2 - x1 + 1 >= cx2) 464 { x2 = cx2 - 1 - x + x1; } 465 466 if (y + y2 - y1 + 1 >= cy2) 467 { y2 = cy2 - 1 - y + y1; } 468 if (x1>x2 || y1>y2) return ; 469 470 xlen=x2-x1+1; 471 ylen=y2-y1+1; 472 473 AddDirty(x, y, x + xlen, y + ylen); 474 475 Lock(); 476 im->Lock(); 477 478 if (transparent) 479 { 480 for (j=0; j<ylen; j++) 481 { 482 pg1 = scan_line(y + j); 483 pg2 = im->scan_line(y1 + j); 484 for (i=0, source=&pg2[x1], dest=&pg1[x]; i<xlen; i++, source++, dest++) 485 if (*source) *dest=*source; 486 } 487 } 488 else 489 for (j=0; j<ylen; j++) 490 { 491 pg1 = scan_line(y + j); 492 pg2 = im->scan_line(y1 + j); 493 memcpy(&pg1[x], &pg2[x1], xlen); // strait copy 494 } 495 im->Unlock(); 496 Unlock(); 497 } 498 499 void image::PutPartXrev(image *im, int16_t x, int16_t y, int16_t x1, 500 int16_t y1, int16_t x2, int16_t y2, char transparent) 501 { 502 int16_t xl, yl, j, i; 503 uint8_t *pg1, *pg2, *source, *dest; 504 CHECK(x1<=x2 && y1<=y2); 505 506 i=x1; x1=im->m_size.x-x2-1; // reverse the x locations 507 x2=im->m_size.x-i-1; 508 509 if (x1<0) 510 { x-=x1; x1=0; } 511 if (y1<0) 512 { y-=y1; y1=0; } 513 514 if (m_special) 515 { 382 void image::PutPart(image *im, vec2i pos, vec2i aa, vec2i bb, int transparent) 383 { 384 vec2i span; 385 CHECK(aa <= bb); 386 516 387 int cx1, cy1, cx2, cy2; 517 m_special->GetClip(cx1, cy1, cx2, cy2); 518 // FIXME: don't we need < cx1 instead of < 0 here? 519 if (x >= cx2 || y >= cy2 || x + (x2 - x1) < 0 || y + (y2 - y1) < 0) 520 return; 521 if (x<cx1) 522 { x1+=(cx1-x); x=cx1; } 523 if (y<cy1) 524 { y1+=(cy1-y); y=cy1; } 525 if (x + x2 - x1 + 1 >= cx2) 526 { x2 = cx2 - 1 - x + x1; } 527 if (y + y2 - y1 + 1 >= cy2) 528 { y2 = cy2 - 1 - y + y1; } 529 } 530 else if (x > m_size.x || y > m_size.y || x+x2<0 || y+y2<0) 531 return ; 532 533 if (x<m_size.x && y<m_size.y && x1<im->m_size.x && y1<im->m_size.y && 534 x1<=x2 && y1<=y2) 535 { 536 if (x2>=im->m_size.x) 537 x2=im->m_size.x-1; 538 if (y2>=im->m_size.y) 539 y2=im->m_size.y-1; 540 xl=x2-x1+1; 541 if (x+xl>m_size.x) 542 xl=m_size.x-x; 543 yl=y2-y1+1; 544 if (y+yl>m_size.y) 545 yl=m_size.y-y; 546 AddDirty(x, y, x + xl, y + yl); 388 GetClip(cx1, cy1, cx2, cy2); 389 390 // see if the are to be put is outside of actual image, if so adjust 391 // to fit in the image 392 pos += Min(aa, vec2i(0)); 393 aa += Min(aa, vec2i(0)); 394 bb = Min(bb, im->m_size - vec2i(1)); 395 // return if it was adjusted so that nothing will be put 396 if (!(aa <= bb)) 397 return; 398 399 // see if the image gets clipped off the screen 400 if (pos.x >= cx2 || pos.y >= cy2 || pos.x + (bb.x - aa.x) < cx1 || pos.y + (bb.y - aa.y) < cy1) 401 return; 402 403 aa += Max(vec2i(cx1, cy1) - pos, vec2i(0)); 404 pos += Max(vec2i(cx1, cy1) - pos, vec2i(0)); 405 bb = Min(bb, vec2i(cx2, cy2) - vec2i(1) - pos + aa); 406 if (!(aa <= bb)) 407 return; 408 409 span = bb - aa + vec2i(1); 410 411 AddDirty(pos.x, pos.y, pos.x + span.x, pos.y + span.y); 412 547 413 Lock(); 548 414 im->Lock(); 549 for (j=0; j<yl; j++) 550 { 551 pg1=scan_line(y+j); 552 pg2=im->scan_line(y1+j); 553 if (transparent) 554 { 555 for (i=0, source=&pg2[x1], dest=&pg1[x+xl-1]; i<xl; i++, source++, dest--) 556 if (*source) *dest=*source; 557 } 558 else 559 for (i=0, source=&pg2[x1], dest=&pg1[x+xl-1]; i<xl; i++, source++, dest++) 560 *dest=*source; 561 } 415 416 for (int j = 0; j < span.y; j++) 417 { 418 uint8_t *dst = scan_line(pos.y + j) + pos.x; 419 uint8_t *src = im->scan_line(aa.y + j) + aa.x; 420 if (transparent) 421 { 422 for (int i = 0; i < span.x; i++, src++, dst++) 423 if (*src) 424 *dst = *src; 425 } 426 else 427 memcpy(dst, src, span.x); 428 } 429 430 im->Unlock(); 562 431 Unlock(); 563 im->Unlock(); 564 } 565 } 566 567 void image::PutPartMasked(image *im, image *mask, int16_t x, int16_t y, 568 int16_t maskx, int16_t masky, 569 int16_t x1, int16_t y1, int16_t x2, int16_t y2) 570 { 571 int16_t xl, yl, j, i, ml, mh; 572 uint8_t *pg1, *pg2, *pg3; 573 CHECK(x1<=x2 && y1<=y2); 574 575 if (m_special) 576 { 577 int cx1, cy1, cx2, cy2; 578 m_special->GetClip(cx1, cy1, cx2, cy2); 579 if (x >= cx2 || y >= cy2 || x+(x2-x1)<0 || y+(y2-y1)<0) return ; 580 if (x<cx1) 581 { x1+=(cx1-x); x=cx1; } 582 if (y<cy1) 583 { y1+=(cy1-y); y=cy1; } 584 if (x + x2 - x1 >= cx2) 585 { x2 = cx2 - 1 + x1 - x; } 586 if (y + y2 - y1 >= cy2) 587 { y2 = cy2 - 1 + y1 - y; } 588 } 589 else if (x>m_size.x || y>m_size.y || x+x1<0 || y+y1<0) 590 return ; 591 592 ml=mask->Size().x; 593 mh=mask->Size().y; 594 if (x<m_size.x && y<m_size.y && x1<im->m_size.x && y1<im->m_size.y && 595 maskx<ml && masky<mh && x1<=x2 && y1<=y2) 596 { 597 598 if (x2>=im->m_size.x) 599 x2=im->m_size.x-1; 600 if (y2>=im->m_size.y) 601 y2=im->m_size.y-1; 602 xl=x2-x1+1; 603 if (x+xl>m_size.x) 604 xl=m_size.x-x-1; 605 yl=y2-y1+1; 606 if (y+yl>m_size.y) 607 yl=m_size.y-y-1; 608 AddDirty(x, y, x + xl, y + yl); 432 } 433 434 void image::PutPartMasked(image *im, vec2i pos, image *mask, vec2i mpos, 435 vec2i aa, vec2i bb) 436 { 437 CHECK(aa <= bb); 438 439 if (m_special) 440 { 441 int cx1, cy1, cx2, cy2; 442 m_special->GetClip(cx1, cy1, cx2, cy2); 443 444 if (!(pos < vec2i(cx2, cy2) && pos >= aa - bb)) 445 return; 446 447 aa += Max(vec2i(cx1, cy1) - pos, vec2i(0)); 448 pos += Max(vec2i(cx1, cy1) - pos, vec2i(0)); 449 bb = Min(bb, vec2i(cx2, cy2) - vec2i(1) - pos + aa); 450 } 451 else if (!(pos <= m_size && pos >= -aa)) 452 return; 453 454 vec2i mask_size = mask->Size(); 455 456 if (!(pos < m_size && aa < im->m_size && mpos < mask_size && aa <= bb)) 457 return; 458 459 bb = Min(bb, im->m_size - vec2i(1)); 460 461 vec2i span = bb - aa + vec2i(1); 462 span = Min(span, m_size - pos - vec2i(1)); 463 AddDirty(pos.x, pos.y, pos.x + span.x, pos.y + span.y); 464 609 465 Lock(); 610 466 mask->Lock(); 611 467 im->Lock(); 612 for (j=0; j<yl; j++) 613 { 614 pg1=scan_line(y+j); 615 pg2=im->scan_line(y1+j); 616 pg3=mask->scan_line(masky++); 617 if (masky>=mh) // wrap the mask around if out of bounds 618 masky=0; 619 for (i=0; i<xl; i++) 620 { 621 if (pg3[maskx+i]) // check to make sure not 0 before putting 622 pg1[x+i]=pg2[x1+i]; 623 if (maskx>=ml) // wrap x around if it goes to far 624 maskx=0; 625 } 626 } 468 469 for (int j = 0; j < span.y; j++) 470 { 471 uint8_t *dst = scan_line(pos.y + j) + pos.x; 472 uint8_t *src = im->scan_line(aa.y + j) + aa.x; 473 uint8_t *pg3 = mask->scan_line(mpos.y) + mpos.x; 474 475 if (++mpos.y >= mask_size.y) // wrap mask y around 476 mpos.y = 0; 477 478 for (int i = 0; i < span.x; i++, dst++, src++, pg3++) 479 { 480 if (mpos.x + i >= mask_size.x) // wrap mask x around 481 pg3 -= mask_size.x; 482 483 if (pg3[mpos.x + i]) // check to make sure not 0 before putting 484 *dst = *src; 485 } 486 } 487 627 488 im->Unlock(); 628 489 mask->Unlock(); 629 490 Unlock(); 630 }631 491 } 632 492 -
abuse/trunk/src/imlib/image.h
r655 r661 113 113 void scroll(int16_t x1, int16_t y1, int16_t x2, int16_t y2, 114 114 int16_t xd, int16_t yd); 115 void fill_image(image *screen, int16_t x1, int16_t y1,116 int16_t x2, int16_t y2, int16_t align = 1);117 115 void PutImage(image *screen, vec2i pos, int transparent = 0); 118 void PutPart(image *screen, int16_t x, int16_t y, int16_t x1, int16_t y1, 119 int16_t x2, int16_t y2, char transparent = 0); 120 void PutPartXrev(image *screen, int16_t x, int16_t y, 121 int16_t x1, int16_t y1, int16_t x2, int16_t y2, 122 char transparent = 0); 123 void PutPartMasked(image *screen, image *mask, int16_t x, int16_t y, 124 int16_t maskx, int16_t masky, int16_t x1, int16_t y1, 125 int16_t x2, int16_t y2); 116 void PutPart(image *screen, vec2i pos, vec2i aa, vec2i bb, 117 int transparent = 0); 118 void PutPartMasked(image *screen, vec2i pos, image *mask, vec2i mpos, 119 vec2i aa, vec2i bb); 126 120 image *copy_part_dithered(int16_t x1, int16_t y1, int16_t x2, int16_t y2); 127 121 void Bar(vec2i p1, vec2i p2, uint8_t color); -
abuse/trunk/src/imlib/jwindow.cpp
r659 r661 336 336 vec2i m2 = m1 + m_sprite->visual->Size() - vec2i(1, 1); 337 337 338 m_sprite->save->PutPart(m_surf, 0, 0, m1.x, m1.y, m2.x, m2.y);338 m_sprite->save->PutPart(m_surf, vec2i(0, 0), m1, m2); 339 339 m_surf->PutImage(m_sprite->visual, m1, 1); 340 340 } … … 355 355 if (has_mouse()) 356 356 { 357 m_sprite->save->PutPart(p->m_surf, 0, 0, m1.x - p->m_pos.x, m1.y - p->m_pos.y, 358 m1.x - p->m_pos.x + m_sprite->visual->Size().x - 1, 359 m1.y - p->m_pos.y + m_sprite->visual->Size().y - 1); 357 m_sprite->save->PutPart(p->m_surf, vec2i(0, 0), m1 - p->m_pos, 358 m1 - p->m_pos + m_sprite->visual->Size() - vec2i(1, 1)); 360 359 p->m_surf->PutImage(m_sprite->visual, m1 - p->m_pos, 1); 361 360 } -
abuse/trunk/src/imlib/sprite.cpp
r650 r661 30 30 void sprite::get_background() 31 31 { if (x+visual->Size().x>=0 && y+visual->Size().y>=0 && x<=xres && y<=yres) 32 save->PutPart(screen, 0,0,x,y,x+save->Size().x-1,y+save->Size().y-1); }32 save->PutPart(screen,vec2i(0,0), vec2i(x,y), vec2i(x+save->Size().x-1,y+save->Size().y-1)); } 33 33 34 34 void sprite::draw() -
abuse/trunk/src/imlib/video.h
r643 r661 28 28 void set_mode(int mode, int argc=0, char **argv=NULL); 29 29 void close_graphics(); 30 void fill_image(image *im, int x1, int y1, int x2, int y2);31 30 void update_window_done(); 32 31 -
abuse/trunk/src/menu.cpp
r656 r661 237 237 int by2=by1+bh-1; 238 238 239 save->PutPart(main_screen, 0, 0, mx + 1, by1, mx + mw - 2, by2);239 save->PutPart(main_screen, vec2i(0, 0), vec2i(mx + 1, by1), vec2i(mx + mw - 2, by2)); 240 240 tint_area(mx+1,by1,mx+mw-2,by2,63,63,63,color); 241 241
Note: See TracChangeset
for help on using the changeset viewer.