Changeset 520 for abuse/trunk/src/imlib
- Timestamp:
- Apr 21, 2011, 9:03:02 PM (12 years ago)
- Location:
- abuse/trunk/src/imlib
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
abuse/trunk/src/imlib/timage.cpp
r518 r520 221 221 222 222 223 inline uint8_t *trans_image::clip_y(image *screen, int x1, int y1, int x2, int y2, 224 int x, int &y, int &ysteps) 225 { 226 // check to see if it is total clipped out first 227 if (y+h<=y1 || y>y2 || x>x2 || x+w<=x1) 228 return NULL; 229 230 uint8_t *datap=data; 231 232 233 ysteps=height(); 234 235 if (y<y1) // check to see if the image gets clipped at the top 236 { 237 238 239 // because data is stored in runs, we need to skip over the top clipped portion 240 int skips=(y1-y); // how many lines do we need to skip? 241 ysteps-=skips; // reduce h (number of lines to draw) 242 y=y1; // start drawing here now 243 while (skips--) 244 { 245 int ix=0; 246 while (ix<w) 247 { 248 ix+=(*datap); // skip over empty space 249 datap++; 250 if (ix<w) 251 { ix+=*datap; 252 datap+=(*datap)+1; // skip over data 253 } 254 } 255 } 256 } 257 258 if (y+ysteps>y2) // check to see if it gets clipped at the bottom 259 ysteps-=(y+ysteps-y2-1); 260 261 screen->AddDirty(Max(x, x1), y, Min(x + width(), x2 + 1), y + h); 262 return datap; 223 uint8_t *trans_image::ClipToLine(image *screen, int x1, int y1, int x2, int y2, 224 int x, int &y, int &ysteps) 225 { 226 // check to see if it is totally clipped out first 227 if (y + h <= y1 || y >= y2 || x >= x2 || x + w <= x1) 228 return NULL; 229 230 uint8_t *parser = data; 231 232 int skiplines = Max(y1 - y, 0); // number of lines to skip 233 ysteps = Min(y2 - y, height() - skiplines); // number of lines to draw 234 y += skiplines; // first line to draw 235 236 while (skiplines--) 237 { 238 for (int ix = 0; ix < w; ) 239 { 240 ix += *parser++; // skip over empty space 241 242 if (ix >= w) 243 break; 244 245 ix += *parser; 246 parser += *parser + 1; // skip over data 247 } 248 } 249 250 screen->AddDirty(Max(x, x1), y, Min(x + width(), x2), y + h); 251 return parser; 263 252 } 264 253 … … 270 259 271 260 screen->GetClip(x1, y1, x2, y2); 272 uint8_t *datap = clip_y(screen, x1, y1, x2 - 1, y2 - 1, x, y, ysteps),261 uint8_t *datap = ClipToLine(screen, x1, y1, x2, y2, x, y, ysteps), 273 262 *screen_line; 274 if (!datap) return ; // if clip_y says nothing to draw, return 263 if (!datap) 264 return; // if ClipToLine says nothing to draw, return 275 265 276 266 screen->Lock(); … … 384 374 385 375 screen->GetClip(x1, y1, x2, y2); 386 uint8_t *datap = clip_y(screen, x1, y1, x2 - 1, y2 - 1, x, y, ysteps),376 uint8_t *datap = ClipToLine(screen, x1, y1, x2, y2, x, y, ysteps), 387 377 *screen_line; 388 if (!datap) return ; // if clip_ysays nothing to draw, return378 if (!datap) return; // if ClipToLine says nothing to draw, return 389 379 390 380 screen->Lock(); … … 450 440 451 441 screen->GetClip(x1, y1, x2, y2); 452 uint8_t *datap = clip_y(screen, x1, y1, x2 - 1, y2 - 1, x, y, ysteps),442 uint8_t *datap = ClipToLine(screen, x1, y1, x2, y2, x, y, ysteps), 453 443 *screen_line; 454 if (!datap) return ; // if clip_ysays nothing to draw, return444 if (!datap) return; // if ClipToLine says nothing to draw, return 455 445 456 446 screen->Lock(); … … 529 519 530 520 screen->GetClip(x1, y1, x2, y2); 531 uint8_t *datap = clip_y(screen, x1, y1, x2 - 1, y2 - 1, x, y, ysteps),521 uint8_t *datap = ClipToLine(screen, x1, y1, x2, y2, x, y, ysteps), 532 522 *screen_line; 533 if (!datap) return ; // if clip_ysays nothing to draw, return523 if (!datap) return; // if ClipToLine says nothing to draw, return 534 524 535 525 screen->Lock(); … … 610 600 611 601 screen->GetClip(x1, y1, x2, y2); 612 uint8_t *datap = clip_y(screen, x1, y1, x2 - 1, y2 - 1, x, y, ysteps),602 uint8_t *datap = ClipToLine(screen, x1, y1, x2, y2, x, y, ysteps), 613 603 *screen_line; 614 if (!datap) return 604 if (!datap) return; 615 605 616 606 uint8_t *screen_run,*paddr=(uint8_t *)pal->addr(), … … 705 695 706 696 screen->GetClip(x1, y1, x2, y2); 707 uint8_t *datap = clip_y(screen, x1, y1, x2 - 1, y2 - 1, x, y, ysteps),697 uint8_t *datap = ClipToLine(screen, x1, y1, x2, y2, x, y, ysteps), 708 698 *screen_line; 709 if (!datap) return 699 if (!datap) return; 710 700 711 701 screen->Lock(); … … 793 783 794 784 screen->GetClip(x1, y1, x2, y2); 795 uint8_t *datap = clip_y(screen, x1, y1, x2, y2, x, y, ysteps),785 uint8_t *datap = ClipToLine(screen, x1, y1, x2, y2, x, y, ysteps), 796 786 *screen_line; 797 if (!datap) return 787 if (!datap) return; 798 788 799 789 screen->Lock(); … … 861 851 862 852 screen->GetClip(x1, y1, x2, y2); 863 uint8_t *datap =clip_y(screen, x1, y1, x2 - 1, y2 - 1, x, y, ysteps),853 uint8_t *datap = ClipToLine(screen, x1, y1, x2, y2, x, y, ysteps), 864 854 *blend_line, *screen_line; 865 if (!datap) return 855 if (!datap) return; 866 856 CONDITION(y>=blendy && y+ysteps<blendy+blend->Size().y+1,"Blend doesn't fit on trans_image"); 867 857 … … 961 951 962 952 screen->GetClip(x1, y1, x2, y2); 963 uint8_t *datap = clip_y(screen, x1, y1, x2 - 1, y2 - 1, x, y, ysteps),953 uint8_t *datap = ClipToLine(screen, x1, y1, x2, y2, x, y, ysteps), 964 954 *screen_line; 965 if (!datap) return ; // if clip_ysays nothing to draw, return955 if (!datap) return; // if ClipToLine says nothing to draw, return 966 956 967 957 // see if the last scanline is clipped off -
abuse/trunk/src/imlib/timage.h
r494 r520 48 48 color_filter *f, palette *pal); 49 49 void put_color(image *screen, int x, int y, int color); 50 unsigned char *clip_y(image *screen, int x1, int y1, int x2, int y2,51 int x, int &y, int &ysteps);52 50 53 51 void put_blend16(image *screen, image *blend, int x, int y, … … 62 60 image *make_image(); 63 61 ~trans_image() { free(data); } 62 63 private: 64 uint8_t *ClipToLine(image *screen, int x1, int y1, int x2, int y2, 65 int x, int &y, int &ysteps); 64 66 } ; 65 67
Note: See TracChangeset
for help on using the changeset viewer.