227 |
|
|
228 |
|
const int bytes_per_row = VideoMonitor.bytes_per_row; |
229 |
|
const int bytes_per_pixel = VideoMonitor.bytes_per_row / VideoMonitor.x; |
230 |
< |
int i, j; |
230 |
> |
int i = y1 * bytes_per_row, j; |
231 |
|
|
232 |
– |
// Check for first column from left and first column |
233 |
– |
// from right that have changed |
234 |
– |
int x1, x2, width; |
232 |
|
if (depth == 1) { |
233 |
|
|
237 |
– |
x1 = VideoMonitor.x - 1; |
238 |
– |
for (j = y1; j <= y2; j++) { |
239 |
– |
uint8 * const p1 = &the_buffer[j * bytes_per_row]; |
240 |
– |
uint8 * const p2 = &the_buffer_copy[j * bytes_per_row]; |
241 |
– |
for (i = 0; i < (x1>>3); i++) { |
242 |
– |
if (p1[i] != p2[i]) { |
243 |
– |
x1 = i << 3; |
244 |
– |
break; |
245 |
– |
} |
246 |
– |
} |
247 |
– |
} |
248 |
– |
|
249 |
– |
x2 = x1; |
250 |
– |
for (j = y2; j >= y1; j--) { |
251 |
– |
uint8 * const p1 = &the_buffer[j * bytes_per_row]; |
252 |
– |
uint8 * const p2 = &the_buffer_copy[j * bytes_per_row]; |
253 |
– |
for (i = (VideoMonitor.x>>3) - 1; i > (x2>>3); i--) { |
254 |
– |
if (p1[i] != p2[i]) { |
255 |
– |
x2 = (i << 3) + 7; |
256 |
– |
break; |
257 |
– |
} |
258 |
– |
} |
259 |
– |
} |
260 |
– |
width = x2 - x1 + 1; |
261 |
– |
|
234 |
|
// Update the_host_buffer and copy of the_buffer |
263 |
– |
i = y1 * bytes_per_row + (x1 >> 3); |
235 |
|
for (j = y1; j <= y2; j++) { |
236 |
< |
Screen_blit(the_host_buffer + i, the_buffer + i, width >> 3); |
266 |
< |
memcpy(the_buffer_copy + i, the_buffer + i, width >> 3); |
236 |
> |
Screen_blit(the_host_buffer + i, the_buffer + i, VideoMonitor.x >> 3); |
237 |
|
i += bytes_per_row; |
238 |
|
} |
239 |
|
|
240 |
|
} else { |
241 |
|
|
272 |
– |
x1 = VideoMonitor.x * bytes_per_pixel - 1; |
273 |
– |
for (j = y1; j <= y2; j++) { |
274 |
– |
uint8 * const p1 = &the_buffer[j * bytes_per_row]; |
275 |
– |
uint8 * const p2 = &the_buffer_copy[j * bytes_per_row]; |
276 |
– |
for (i = 0; i < x1; i++) { |
277 |
– |
if (p1[i] != p2[i]) { |
278 |
– |
x1 = i; |
279 |
– |
break; |
280 |
– |
} |
281 |
– |
} |
282 |
– |
} |
283 |
– |
x1 /= bytes_per_pixel; |
284 |
– |
|
285 |
– |
x2 = x1 * bytes_per_pixel; |
286 |
– |
for (j = y2; j >= y1; j--) { |
287 |
– |
uint8 * const p1 = &the_buffer[j * bytes_per_row]; |
288 |
– |
uint8 * const p2 = &the_buffer_copy[j * bytes_per_row]; |
289 |
– |
for (i = VideoMonitor.x * bytes_per_pixel - 1; i > x2; i--) { |
290 |
– |
if (p1[i] != p2[i]) { |
291 |
– |
x2 = i; |
292 |
– |
break; |
293 |
– |
} |
294 |
– |
} |
295 |
– |
} |
296 |
– |
x2 /= bytes_per_pixel; |
297 |
– |
width = x2 - x1 + 1; |
298 |
– |
|
242 |
|
// Update the_host_buffer and copy of the_buffer |
300 |
– |
i = y1 * bytes_per_row + x1 * bytes_per_pixel; |
243 |
|
for (j = y1; j <= y2; j++) { |
244 |
< |
Screen_blit(the_host_buffer + i, the_buffer + i, bytes_per_pixel * width); |
303 |
< |
memcpy(the_buffer_copy + i, the_buffer + i, bytes_per_pixel * width); |
244 |
> |
Screen_blit(the_host_buffer + i, the_buffer + i, bytes_per_pixel * VideoMonitor.x); |
245 |
|
i += bytes_per_row; |
246 |
|
} |
247 |
|
} |
248 |
< |
|
248 |
> |
|
249 |
|
if (have_shm) |
250 |
< |
XShmPutImage(x_display, the_win, the_gc, img, x1, y1, x1, y1, width, height, 0); |
250 |
> |
XShmPutImage(x_display, the_win, the_gc, img, 0, y1, 0, y1, VideoMonitor.x, height, 0); |
251 |
|
else |
252 |
< |
XPutImage(x_display, the_win, the_gc, img, x1, y1, x1, y1, width, height); |
252 |
> |
XPutImage(x_display, the_win, the_gc, img, 0, y1, 0, y1, VideoMonitor.x, height); |
253 |
|
} |
254 |
+ |
|
255 |
|
mainBuffer.dirty = false; |
256 |
|
} |
257 |
|
|