Changeset 532
- Timestamp:
- Apr 22, 2011, 7:32:09 PM (11 years ago)
- Location:
- abuse/trunk/src
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
abuse/trunk/src/go.cpp
r494 r532 107 107 108 108 for (i=sy1; i<=sy2; i++) 109 p-> put_scan_line(screen,sx,i,0);109 p->PutScanLine(screen,sx,i,0); 110 110 } 111 111 } -
abuse/trunk/src/imlib/timage.cpp
r531 r532 106 106 } 107 107 108 void trans_image::put_scan_line(image *screen, int x, int y, int line) // always transparent109 {110 int x1, y1, x2, y2;111 screen->GetClip(x1, y1, x2, y2);112 if (y + line < y1 || y + line >= y2 || x >= x2 || x + m_size.x - 1 < x1)113 return; // clipped off completely?114 115 uint8_t *datap=m_data;116 int ix;117 while (line) // skip scan line data until we get to the line of interest118 {119 for (ix=0; ix<m_size.x; )120 {121 ix+=*datap; // skip blank space122 datap++;123 if (ix<m_size.x)124 {125 int run_length=*datap; // skip run126 ix+=run_length;127 datap+=run_length+1;128 }129 }130 line--;131 y++;132 }133 134 135 // now slam this list of runs to the screen136 screen->Lock();137 uint8_t *screen_line=screen->scan_line(y)+x;138 139 for (ix=0; ix<m_size.x; )140 {141 int skip=*datap; // how much space to skip?142 datap++;143 screen_line+=skip;144 ix+=skip;145 146 if (ix<m_size.x)147 {148 int run_length=*datap;149 datap++;150 151 if (x+ix+run_length-1<x1) // is this run clipped out totally?152 {153 datap+=run_length;154 ix+=run_length;155 screen_line+=run_length;156 }157 else158 {159 if (x+ix<x1) // is the run clipped partially?160 {161 int clip=(x1-(x+ix));162 datap+=clip;163 run_length-=clip;164 screen_line+=clip;165 ix+=clip;166 }167 168 if (x + ix >= x2) // clipped totally on the right?169 {170 screen->Unlock();171 return ; // we are done, return!172 }173 else if (x + ix + run_length > x2) // partially clipped?174 {175 memcpy(screen_line, datap, x + ix + run_length - x2); // slam what we can176 screen->Unlock();177 return ; // and return 'cause we are done with the line178 } else179 {180 memcpy(screen_line,datap,run_length);181 screen_line+=run_length;182 datap+=run_length;183 ix+=run_length;184 }185 }186 }187 }188 screen->Unlock();189 }190 191 192 108 uint8_t *trans_image::ClipToLine(image *screen, int x1, int y1, int x2, int y2, 193 109 int x, int &y, int &ysteps) … … 219 135 screen->AddDirty(Max(x, x1), y, Min(x + m_size.x, x2), y + m_size.y); 220 136 return parser; 221 }222 223 void trans_image::PutFilled(image *screen, int x, int y, uint8_t color)224 {225 PutImageGeneric<FILLED>(screen, x, y, color, NULL, 0, 0, NULL, NULL,226 0, 1, NULL, NULL, NULL);227 137 } 228 138 … … 238 148 239 149 screen->GetClip(x1, y1, x2, y2); 150 151 if (N == SCANLINE) 152 { 153 y1 = Max(y1, y + amount); 154 y2 = Min(y2, y + amount + 1); 155 if (y1 >= y2) 156 return; 157 } 158 240 159 uint8_t *datap = ClipToLine(screen, x1, y1, x2, y2, x, y, ysteps), 241 160 *screen_line, *blend_line = NULL, *paddr = NULL; … … 294 213 int count = Min(todo, Max(x2 - ix, 0)); 295 214 296 if (N == NORMAL )215 if (N == NORMAL || N == SCANLINE) 297 216 { 298 217 memcpy(screen_line, datap, count); … … 312 231 *sl++ = remap[*sl2++]; 313 232 } 314 else if (N == DOUBLE_REMAP)233 else if (N == REMAP2) 315 234 { 316 235 uint8_t *sl = screen_line, *sl2 = datap; … … 361 280 uint8_t *remap, uint8_t *remap2) 362 281 { 363 PutImageGeneric< DOUBLE_REMAP>(screen, x, y, 0, NULL, 0, 0, remap, remap2,364 282 PutImageGeneric<REMAP2>(screen, x, y, 0, NULL, 0, 0, remap, remap2, 283 0, 1, NULL, NULL, NULL); 365 284 } 366 285 … … 398 317 } 399 318 319 void trans_image::PutFilled(image *screen, int x, int y, uint8_t color) 320 { 321 PutImageGeneric<FILLED>(screen, x, y, color, NULL, 0, 0, NULL, NULL, 322 0, 1, NULL, NULL, NULL); 323 } 324 400 325 void trans_image::PutPredator(image *screen, int x, int y) 401 326 { … … 404 329 } 405 330 331 void trans_image::PutScanLine(image *screen, int x, int y, int line) 332 { 333 PutImageGeneric<SCANLINE>(screen, x, y, 0, NULL, 0, 0, NULL, NULL, 334 line, 1, NULL, NULL, NULL); 335 } 336 406 337 size_t trans_image::MemUsage() 407 338 { -
abuse/trunk/src/imlib/timage.h
r531 r532 9 9 */ 10 10 11 #ifndef __TIMAGE_HPP_ 12 #define __TIMAGE_HPP_ 11 #ifndef __TIMAGE_HPP__ 12 #define __TIMAGE_HPP__ 13 13 14 14 #include "image.h" … … 16 16 #include "filter.h" 17 17 18 /* data is stored in the following format 18 /* Data is stored in the following format: 19 * 20 * uint8_t skip; // transparent pixel count 21 * uint8_t size; // solid pixel count 22 * uint8_t data[size]; // solid pixel values 23 * ... 24 * (no scan line wraps allowed, there can be a last skip value) 25 */ 19 26 20 skip amount, data size, data // no scan line wraps allowed 21 22 */ 23 24 25 class trans_image // transpernet image 27 class trans_image // transparent image 26 28 { 27 29 public: 28 trans_image(image *im, char const *name);29 ~trans_image();30 trans_image(image *im, char const *name); 31 ~trans_image(); 30 32 31 inline vec2i Size() { return m_size; }32 inline uint8_t *Data() { return m_data; }33 inline vec2i Size() { return m_size; } 34 inline uint8_t *Data() { return m_data; } 33 35 34 image *ToImage();36 image *ToImage(); 35 37 36 void PutImage(image *screen, int x, int y); // always transparent 37 void PutRemap(image *screen, int x, int y, uint8_t *remap); 38 void PutDoubleRemap(image *screen, int x, int y, 39 uint8_t *remap, uint8_t *remap2); 40 void PutFade(image *screen, int x, int y, int amount, int total_frames, 41 color_filter *f, palette *pal); 42 void PutFadeTint(image *screen, int x, int y, int amount, int total_frames, 43 uint8_t *tint, color_filter *f, palette *pal); 44 void PutColor(image *screen, int x, int y, uint8_t color); 45 void PutFilled(image *screen, int x, int y, uint8_t color); 46 void PutPredator(image *screen, int x, int y); 47 void PutBlend(image *screen, int x, int y, image *blend, int bx, int by, 48 int blend_amount, color_filter *f, palette *pal); 38 void PutImage(image *screen, int x, int y); // always transparent 39 void PutRemap(image *screen, int x, int y, uint8_t *remap); 40 void PutDoubleRemap(image *screen, int x, int y, 41 uint8_t *remap, uint8_t *remap2); 42 void PutFade(image *screen, int x, int y, int amount, int total_frames, 43 color_filter *f, palette *pal); 44 void PutFadeTint(image *screen, int x, int y, int amount, int total_frames, 45 uint8_t *tint, color_filter *f, palette *pal); 46 void PutColor(image *screen, int x, int y, uint8_t color); 47 void PutFilled(image *screen, int x, int y, uint8_t color); 48 void PutPredator(image *screen, int x, int y); 49 void PutBlend(image *screen, int x, int y, image *blend, int bx, int by, 50 int blend_amount, color_filter *f, palette *pal); 51 void PutScanLine(image *screen, int x, int y, int line); 49 52 50 void put_scan_line(image *screen, int x, int y, int line); // always transparent 51 size_t MemUsage(); 53 size_t MemUsage(); 52 54 53 55 private: 54 uint8_t *ClipToLine(image *screen, int x1, int y1, int x2, int y2,55 int x, int &y, int &ysteps);56 uint8_t *ClipToLine(image *screen, int x1, int y1, int x2, int y2, 57 int x, int &y, int &ysteps); 56 58 57 enum PutMode { NORMAL, REMAP, DOUBLE_REMAP, FADE, FADE_TINT, COLOR,58 FILLED, PREDATOR, BLEND};59 template<int N>60 void PutImageGeneric(image *dest, int x, int y, uint8_t color,61 image *blend, int bx, int by,62 uint8_t *map1, uint8_t *map2, int amount,63 int total_frames, uint8_t *tint,64 color_filter *f, palette *pal);59 enum PutMode { NORMAL, REMAP, REMAP2, FADE, FADE_TINT, COLOR, 60 FILLED, PREDATOR, BLEND, SCANLINE }; 61 template<int N> 62 void PutImageGeneric(image *dest, int x, int y, uint8_t color, 63 image *blend, int bx, int by, 64 uint8_t *map1, uint8_t *map2, int amount, 65 int total_frames, uint8_t *tint, 66 color_filter *f, palette *pal); 65 67 66 vec2i m_size;67 uint8_t *m_data;68 vec2i m_size; 69 uint8_t *m_data; 68 70 }; 69 71 -
abuse/trunk/src/objects.cpp
r528 r532 399 399 400 400 for (i=sy1; i<=sy2; i++) 401 p-> put_scan_line(screen,sx,i,0);401 p->PutScanLine(screen,sx,i,0); 402 402 } 403 403 }
Note: See TracChangeset
for help on using the changeset viewer.