RCS file: /cvsroot/scummvm/scummvm/backends/sdl/events.cpp,v
retrieving revision 1.16
diff -u -r1.16 events.cpp
|
|
|
68 | 68 | _km.y = y; |
69 | 69 | |
70 | 70 | // Adjust for the screen scaling |
71 | | event.mouse.x /= _scaleFactor; |
72 | | event.mouse.y /= _scaleFactor; |
| 71 | if (!_overlayVisible) { |
| 72 | event.mouse.x /= _scaleFactor; |
| 73 | event.mouse.y /= _scaleFactor; |
| 74 | } else { |
| 75 | event.mouse.x = event.mouse.x / _scaleFactor * _overlayScale; |
| 76 | event.mouse.y = event.mouse.y / _scaleFactor * _overlayScale; |
| 77 | } |
73 | 78 | |
74 | 79 | // Optionally perform aspect ratio adjusting |
75 | 80 | if (_adjustAspectRatio) |
RCS file: /cvsroot/scummvm/scummvm/backends/sdl/graphics.cpp,v
retrieving revision 1.29
diff -u -r1.29 graphics.cpp
|
|
|
66 | 66 | _transactionMode = kTransactionActive; |
67 | 67 | |
68 | 68 | _transactionDetails.modeChanged = false; |
69 | | _transactionDetails.wChanged = false; |
70 | | _transactionDetails.hChanged = false; |
| 69 | _transactionDetails.sizeChanged = false; |
71 | 70 | _transactionDetails.arChanged = false; |
72 | 71 | _transactionDetails.fsChanged = false; |
73 | 72 | |
… |
… |
|
83 | 82 | if (_transactionDetails.modeChanged) |
84 | 83 | setGraphicsMode(_transactionDetails.mode); |
85 | 84 | |
86 | | if (_transactionDetails.wChanged || _transactionDetails.hChanged) |
87 | | initSize(_transactionDetails.w, _transactionDetails.h); |
| 85 | if (_transactionDetails.sizeChanged) |
| 86 | initSize(_transactionDetails.w, _transactionDetails.h, |
| 87 | _transactionDetails.overlayScale); |
88 | 88 | |
89 | 89 | if (_transactionDetails.arChanged) |
90 | 90 | setAspectRatioCorrection(_transactionDetails.ar); |
… |
… |
|
92 | 92 | if (_transactionDetails.needUnload) { |
93 | 93 | unloadGFXMode(); |
94 | 94 | loadGFXMode(); |
| 95 | clearOverlay(); |
95 | 96 | } else { |
96 | 97 | if (!_transactionDetails.fsChanged) |
97 | 98 | if (_transactionDetails.needHotswap) |
… |
… |
|
168 | 169 | return false; |
169 | 170 | } |
170 | 171 | |
| 172 | // Do not let switch to lesser than overlay size resolutions |
| 173 | if (_screenWidth * newScaleFactor < _overlayWidth) { |
| 174 | if (_scaleFactor == 1) { // Force 2x mode |
| 175 | mode = GFX_DOUBLESIZE; |
| 176 | newScaleFactor = 2; |
| 177 | newScalerProc = Normal2x; |
| 178 | } else |
| 179 | return false; |
| 180 | } |
| 181 | |
171 | 182 | _mode = mode; |
172 | 183 | _scalerProc = newScalerProc; |
173 | 184 | |
… |
… |
|
226 | 237 | return _mode; |
227 | 238 | } |
228 | 239 | |
229 | | void OSystem_SDL::initSize(uint w, uint h) { |
| 240 | void OSystem_SDL::initSize(uint w, uint h, int overlayScale) { |
230 | 241 | // Avoid redundant res changes |
231 | 242 | if ((int)w == _screenWidth && (int)h == _screenHeight && |
| 243 | (int)overlayScale == _overlayScale && |
232 | 244 | _transactionMode != kTransactionCommit) |
233 | 245 | return; |
234 | 246 | |
… |
… |
|
238 | 250 | if (h != 200) |
239 | 251 | _adjustAspectRatio = false; |
240 | 252 | |
| 253 | if (overlayScale != -1) { |
| 254 | _overlayScale = overlayScale; |
| 255 | if (w != 320) |
| 256 | _overlayScale = 1; |
| 257 | |
| 258 | _overlayWidth = w * _overlayScale; |
| 259 | _overlayHeight = h * _overlayScale; |
| 260 | } |
| 261 | |
241 | 262 | _cksumNum = (_screenWidth * _screenHeight / (8 * 8)); |
242 | 263 | |
243 | 264 | if (_transactionMode == kTransactionActive) { |
244 | 265 | _transactionDetails.w = w; |
245 | | _transactionDetails.wChanged = true; |
246 | 266 | _transactionDetails.h = h; |
247 | | _transactionDetails.hChanged = true; |
| 267 | _transactionDetails.overlayScale = _overlayScale; |
| 268 | _transactionDetails.sizeChanged = true; |
248 | 269 | |
249 | 270 | _transactionDetails.needUnload = true; |
250 | 271 | |
… |
… |
|
257 | 278 | if (_transactionMode != kTransactionCommit) { |
258 | 279 | unloadGFXMode(); |
259 | 280 | loadGFXMode(); |
| 281 | |
| 282 | // if initSize() gets called in the middle, overlay is not transparent |
| 283 | clearOverlay(); |
260 | 284 | } |
261 | 285 | } |
262 | 286 | |
… |
… |
|
264 | 288 | _forceFull = true; |
265 | 289 | _modeFlags |= DF_UPDATE_EXPAND_1_PIXEL; |
266 | 290 | |
267 | | _tmpscreen = NULL; |
268 | | |
269 | 291 | // |
270 | 292 | // Create the surface that contains the 8 bit game data |
271 | 293 | // |
… |
… |
|
312 | 334 | InitScalers(565); |
313 | 335 | |
314 | 336 | // Need some extra bytes around when using 2xSaI |
315 | | _tmpscreen = SDL_CreateRGBSurface(SDL_SWSURFACE, |
316 | | _screenWidth + 3, |
317 | | _screenHeight + 3, |
318 | | 16, |
319 | | _hwscreen->format->Rmask, |
320 | | _hwscreen->format->Gmask, |
321 | | _hwscreen->format->Bmask, |
322 | | _hwscreen->format->Amask); |
| 337 | _tmpscreen = SDL_CreateRGBSurface(SDL_SWSURFACE, _screenWidth + 3, _screenHeight + 3, 16, 0, 0, 0, 0); |
323 | 338 | |
324 | 339 | if (_tmpscreen == NULL) |
325 | 340 | error("allocating _tmpscreen failed"); |
326 | | |
| 341 | |
| 342 | _overlayscreen = SDL_CreateRGBSurface(SDL_SWSURFACE, _overlayWidth, _overlayHeight, 16, 0, 0, 0, 0); |
| 343 | |
| 344 | if (_overlayscreen == NULL) |
| 345 | error("allocating _overlayscreen failed"); |
| 346 | |
| 347 | _tmpscreen2 = SDL_CreateRGBSurface(SDL_SWSURFACE, _overlayWidth + 3, _overlayHeight + 3, 16, 0, 0, 0, 0); |
| 348 | |
| 349 | if (_tmpscreen2 == NULL) |
| 350 | error("allocating _tmpscreen2 failed"); |
| 351 | |
327 | 352 | #ifdef USE_OSD |
328 | 353 | _osdSurface = SDL_CreateRGBSurface(SDL_SWSURFACE | SDL_RLEACCEL | SDL_SRCCOLORKEY | SDL_SRCALPHA, |
329 | 354 | _hwscreen->w, |
… |
… |
|
361 | 386 | _tmpscreen = NULL; |
362 | 387 | } |
363 | 388 | |
| 389 | if (_tmpscreen2) { |
| 390 | SDL_FreeSurface(_tmpscreen2); |
| 391 | _tmpscreen2 = NULL; |
| 392 | } |
| 393 | |
| 394 | if (_overlayscreen) { |
| 395 | SDL_FreeSurface(_overlayscreen); |
| 396 | _overlayscreen = NULL; |
| 397 | } |
| 398 | |
364 | 399 | #ifdef USE_OSD |
365 | 400 | if (_osdSurface) { |
366 | 401 | SDL_FreeSurface(_osdSurface); |
… |
… |
|
373 | 408 | if (!_screen) |
374 | 409 | return; |
375 | 410 | |
376 | | // Keep around the old _screen & _tmpscreen so we can restore the screen data |
| 411 | // Keep around the old _screen & _overlayscreen so we can restore the screen data |
377 | 412 | // after the mode switch. |
378 | 413 | SDL_Surface *old_screen = _screen; |
379 | | SDL_Surface *old_tmpscreen = _tmpscreen; |
| 414 | SDL_Surface *old_overlayscreen = _overlayscreen; |
380 | 415 | |
381 | 416 | // Release the HW screen surface |
382 | 417 | SDL_FreeSurface(_hwscreen); |
383 | 418 | |
| 419 | SDL_FreeSurface(_tmpscreen); |
| 420 | SDL_FreeSurface(_tmpscreen2); |
| 421 | |
384 | 422 | #ifdef USE_OSD |
385 | 423 | // Release the OSD surface |
386 | 424 | SDL_FreeSurface(_osdSurface); |
… |
… |
|
394 | 432 | |
395 | 433 | // Restore old screen content |
396 | 434 | SDL_BlitSurface(old_screen, NULL, _screen, NULL); |
397 | | SDL_BlitSurface(old_tmpscreen, NULL, _tmpscreen, NULL); |
398 | | |
| 435 | SDL_BlitSurface(old_overlayscreen, NULL, _overlayscreen, NULL); |
| 436 | |
399 | 437 | // Free the old surfaces |
400 | 438 | SDL_FreeSurface(old_screen); |
401 | | SDL_FreeSurface(old_tmpscreen); |
| 439 | SDL_FreeSurface(old_overlayscreen); |
402 | 440 | |
403 | 441 | // Update cursor to new scale |
404 | 442 | blitCursor(); |
… |
… |
|
419 | 457 | } |
420 | 458 | |
421 | 459 | void OSystem_SDL::internUpdateScreen() { |
| 460 | SDL_Surface *srcSurf, *origSurf; |
| 461 | int height, width; |
| 462 | ScalerProc *scalerProc; |
| 463 | int scale1, scale2; |
| 464 | |
422 | 465 | assert(_hwscreen != NULL); |
423 | 466 | |
424 | 467 | // If the shake position changed, fill the dirty area with blackness |
… |
… |
|
467 | 510 | } |
468 | 511 | #endif |
469 | 512 | |
470 | | undrawMouse(); |
| 513 | if (!_overlayVisible) { |
| 514 | origSurf = _screen; |
| 515 | srcSurf = _tmpscreen; |
| 516 | width = _screenWidth; |
| 517 | height = _screenHeight; |
| 518 | scalerProc = _scalerProc; |
| 519 | scale1 = _scaleFactor; |
| 520 | scale2 = 1; |
| 521 | } else { |
| 522 | origSurf = _overlayscreen; |
| 523 | srcSurf = _tmpscreen2; |
| 524 | width = _overlayWidth; |
| 525 | height = _overlayHeight; |
| 526 | scalerProc = scalersMagn[_overlayScale-1][_scaleFactor-1]; |
| 527 | |
| 528 | scale1 = _scaleFactor; |
| 529 | scale2 = _overlayScale; |
| 530 | } |
471 | 531 | |
472 | 532 | // Force a full redraw if requested |
473 | 533 | if (_forceFull) { |
474 | 534 | _numDirtyRects = 1; |
475 | 535 | _dirtyRectList[0].x = 0; |
476 | 536 | _dirtyRectList[0].y = 0; |
477 | | _dirtyRectList[0].w = _screenWidth; |
478 | | _dirtyRectList[0].h = _screenHeight; |
479 | | } |
| 537 | _dirtyRectList[0].w = width; |
| 538 | _dirtyRectList[0].h = height; |
| 539 | } else |
| 540 | undrawMouse(); |
480 | 541 | |
481 | 542 | // Only draw anything if necessary |
482 | 543 | if (_numDirtyRects > 0) { |
… |
… |
|
486 | 547 | uint32 srcPitch, dstPitch; |
487 | 548 | SDL_Rect *lastRect = _dirtyRectList + _numDirtyRects; |
488 | 549 | |
489 | | if (_scalerProc == Normal1x && !_adjustAspectRatio) { |
490 | | SDL_Surface *target = _overlayVisible ? _tmpscreen : _screen; |
| 550 | if (scalerProc == Normal1x && !_adjustAspectRatio && 0) { |
491 | 551 | for (r = _dirtyRectList; r != lastRect; ++r) { |
492 | 552 | dst = *r; |
493 | 553 | |
494 | | if (_overlayVisible) { |
495 | | // FIXME: I don't understand why this is necessary... |
496 | | dst.x--; |
497 | | dst.y--; |
498 | | } |
499 | 554 | dst.y += _currentShakePos; |
500 | | if (SDL_BlitSurface(target, r, _hwscreen, &dst) != 0) |
| 555 | if (SDL_BlitSurface(origSurf, r, _hwscreen, &dst) != 0) |
501 | 556 | error("SDL_BlitSurface failed: %s", SDL_GetError()); |
502 | 557 | } |
503 | 558 | } else { |
504 | | if (!_overlayVisible) { |
505 | | for (r = _dirtyRectList; r != lastRect; ++r) { |
506 | | dst = *r; |
507 | | dst.x++; // Shift rect by one since 2xSai needs to acces the data around |
508 | | dst.y++; // any pixel to scale it, and we want to avoid mem access crashes. |
509 | | if (SDL_BlitSurface(_screen, r, _tmpscreen, &dst) != 0) |
510 | | error("SDL_BlitSurface failed: %s", SDL_GetError()); |
511 | | } |
| 559 | for (r = _dirtyRectList; r != lastRect; ++r) { |
| 560 | dst = *r; |
| 561 | dst.x++; // Shift rect by one since 2xSai needs to acces the data around |
| 562 | dst.y++; // any pixel to scale it, and we want to avoid mem access crashes. |
| 563 | |
| 564 | if (SDL_BlitSurface(origSurf, r, srcSurf, &dst) != 0) |
| 565 | error("SDL_BlitSurface failed: %s", SDL_GetError()); |
512 | 566 | } |
513 | 567 | |
514 | | SDL_LockSurface(_tmpscreen); |
| 568 | SDL_LockSurface(srcSurf); |
515 | 569 | SDL_LockSurface(_hwscreen); |
516 | 570 | |
517 | | srcPitch = _tmpscreen->pitch; |
| 571 | srcPitch = srcSurf->pitch; |
518 | 572 | dstPitch = _hwscreen->pitch; |
519 | 573 | |
520 | 574 | for (r = _dirtyRectList; r != lastRect; ++r) { |
521 | 575 | register int dst_y = r->y + _currentShakePos; |
522 | 576 | register int dst_h = 0; |
523 | 577 | register int orig_dst_y = 0; |
| 578 | register int rx1 = r->x * scale1 / scale2; |
524 | 579 | |
525 | | if (dst_y < _screenHeight) { |
| 580 | if (dst_y < height) { |
526 | 581 | dst_h = r->h; |
527 | | if (dst_h > _screenHeight - dst_y) |
528 | | dst_h = _screenHeight - dst_y; |
| 582 | if (dst_h > height - dst_y) |
| 583 | dst_h = height - dst_y; |
529 | 584 | |
530 | | dst_y *= _scaleFactor; |
| 585 | orig_dst_y = dst_y; |
| 586 | dst_y = dst_y * scale1 / scale2; |
531 | 587 | |
532 | | if (_adjustAspectRatio) { |
533 | | orig_dst_y = dst_y; |
| 588 | if (_adjustAspectRatio) |
534 | 589 | dst_y = real2Aspect(dst_y); |
| 590 | |
| 591 | if (scale1 == 3 && scale2 == 2 && _overlayVisible) { |
| 592 | if (r->y % 2) |
| 593 | r->y--; |
| 594 | dst_y -= dst_y % 3; |
535 | 595 | } |
536 | 596 | |
537 | | _scalerProc((byte *)_tmpscreen->pixels + (r->x * 2 + 2) + (r->y + 1) * srcPitch, srcPitch, |
538 | | (byte *)_hwscreen->pixels + r->x * 2 * _scaleFactor + dst_y * dstPitch, dstPitch, r->w, dst_h); |
| 597 | scalerProc((byte *)srcSurf->pixels + (r->x * 2 + 2) + (r->y + 1) * srcPitch, srcPitch, |
| 598 | (byte *)_hwscreen->pixels + rx1 * 2 + dst_y * dstPitch, dstPitch, r->w, dst_h); |
539 | 599 | } |
540 | | |
541 | | r->x *= _scaleFactor; |
| 600 | |
| 601 | r->x = rx1; |
542 | 602 | r->y = dst_y; |
543 | | r->w *= _scaleFactor; |
544 | | r->h = dst_h * _scaleFactor; |
| 603 | r->w = r->w * scale1 / scale2; |
| 604 | r->h = dst_h * scale1 / scale2; |
545 | 605 | |
546 | | if (_adjustAspectRatio && orig_dst_y / _scaleFactor < _screenHeight) |
547 | | r->h = stretch200To240((uint8 *) _hwscreen->pixels, dstPitch, r->w, r->h, r->x, r->y, orig_dst_y); |
| 606 | if (_adjustAspectRatio && orig_dst_y < height) |
| 607 | r->h = stretch200To240((uint8 *) _hwscreen->pixels, dstPitch, r->w, r->h, r->x, r->y, orig_dst_y * scale1 / scale2); |
548 | 608 | } |
549 | | SDL_UnlockSurface(_tmpscreen); |
| 609 | SDL_UnlockSurface(srcSurf); |
550 | 610 | SDL_UnlockSurface(_hwscreen); |
551 | 611 | } |
552 | 612 | |
… |
… |
|
564 | 624 | SDL_BlitSurface(_osdSurface, 0, _hwscreen, 0); |
565 | 625 | } |
566 | 626 | #endif |
567 | | |
568 | 627 | // Finally, blit all our changes to the screen |
569 | 628 | SDL_UpdateRects(_hwscreen, _numDirtyRects, _dirtyRectList); |
570 | 629 | } else { |
… |
… |
|
730 | 789 | if (_forceFull) |
731 | 790 | return; |
732 | 791 | |
733 | | if (mouseRect) { |
734 | | SDL_Rect *r = &_dirtyRectList[_numDirtyRects++]; |
735 | | r->x = x; |
736 | | r->y = y; |
737 | | r->w = w; |
738 | | r->h = h; |
739 | | return; |
740 | | } |
| 792 | if (mouseRect) { |
| 793 | SDL_Rect *r = &_dirtyRectList[_numDirtyRects++]; |
| 794 | r->x = x; |
| 795 | r->y = y; |
| 796 | r->w = w; |
| 797 | r->h = h; |
| 798 | return; |
| 799 | } |
| 800 | |
| 801 | int height, width; |
| 802 | |
| 803 | if (!_overlayVisible) { |
| 804 | width = _screenWidth; |
| 805 | height = _screenHeight; |
| 806 | } else { |
| 807 | width = _overlayWidth; |
| 808 | height = _overlayHeight; |
| 809 | } |
741 | 810 | |
742 | 811 | if (_numDirtyRects == NUM_DIRTY_RECT) |
743 | 812 | _forceFull = true; |
… |
… |
|
762 | 831 | y=0; |
763 | 832 | } |
764 | 833 | |
765 | | if (w > _screenWidth - x) { |
766 | | w = _screenWidth - x; |
| 834 | if (w > width - x) { |
| 835 | w = width - x; |
767 | 836 | } |
768 | 837 | |
769 | | if (h > _screenHeight - y) { |
770 | | h = _screenHeight - y; |
| 838 | if (h > height - y) { |
| 839 | h = height - y; |
771 | 840 | } |
772 | 841 | |
773 | | if (_adjustAspectRatio) |
| 842 | if (_adjustAspectRatio) { |
774 | 843 | makeRectStretchable(x, y, w, h); |
| 844 | if (_scaleFactor == 3 && _overlayScale == 2 && _overlayVisible) { |
| 845 | if (y % 2) |
| 846 | y++; |
| 847 | } |
| 848 | } |
775 | 849 | |
776 | 850 | r->x = x; |
777 | 851 | r->y = y; |
… |
… |
|
931 | 1005 | assert (_transactionMode == kTransactionNone); |
932 | 1006 | |
933 | 1007 | _overlayVisible = false; |
| 1008 | clearOverlay(); |
934 | 1009 | _forceFull = true; |
935 | 1010 | } |
936 | 1011 | |
937 | 1012 | void OSystem_SDL::clearOverlay() { |
938 | | assert (_transactionMode == kTransactionNone); |
| 1013 | //assert (_transactionMode == kTransactionNone); |
939 | 1014 | |
940 | | if (!_overlayVisible) |
941 | | return; |
942 | | |
943 | 1015 | Common::StackLock lock(_graphicsMutex); // Lock the mutex until this function ends |
944 | 1016 | |
| 1017 | if (!_overlayVisible) |
| 1018 | return; |
| 1019 | |
945 | 1020 | // Clear the overlay by making the game screen "look through" everywhere. |
946 | 1021 | SDL_Rect src, dst; |
947 | 1022 | src.x = src.y = 0; |
… |
… |
|
951 | 1026 | if (SDL_BlitSurface(_screen, &src, _tmpscreen, &dst) != 0) |
952 | 1027 | error("SDL_BlitSurface failed: %s", SDL_GetError()); |
953 | 1028 | |
| 1029 | SDL_LockSurface(_tmpscreen); |
| 1030 | SDL_LockSurface(_overlayscreen); |
| 1031 | if (_overlayScale == _scaleFactor) { |
| 1032 | _scalerProc((byte *)(_tmpscreen->pixels) + _tmpscreen->pitch + 2, |
| 1033 | _tmpscreen->pitch, (byte *)_overlayscreen->pixels, _overlayscreen->pitch, _screenWidth, _screenHeight); |
| 1034 | } else { |
| 1035 | // Quality is degraded here. It is possible to run one-less scaler here, but is it |
| 1036 | // really needed? Quality will anyway be degraded because of 1.5x scaler. |
| 1037 | (scalersMagn[0][_overlayScale-1])((byte *)(_tmpscreen->pixels) + _tmpscreen->pitch + 2, |
| 1038 | _tmpscreen->pitch, (byte *)_overlayscreen->pixels, _overlayscreen->pitch, _screenWidth, _screenHeight); |
| 1039 | } |
| 1040 | SDL_UnlockSurface(_tmpscreen); |
| 1041 | SDL_UnlockSurface(_overlayscreen); |
| 1042 | |
954 | 1043 | _forceFull = true; |
955 | 1044 | } |
956 | 1045 | |
957 | 1046 | void OSystem_SDL::grabOverlay(OverlayColor *buf, int pitch) { |
958 | 1047 | assert (_transactionMode == kTransactionNone); |
959 | 1048 | |
960 | | if (!_overlayVisible) |
961 | | return; |
962 | | |
963 | | if (_tmpscreen == NULL) |
| 1049 | if (_overlayscreen == NULL) |
964 | 1050 | return; |
965 | 1051 | |
966 | | if (SDL_LockSurface(_tmpscreen) == -1) |
| 1052 | if (SDL_LockSurface(_overlayscreen) == -1) |
967 | 1053 | error("SDL_LockSurface failed: %s", SDL_GetError()); |
968 | 1054 | |
969 | | byte *src = (byte *)_tmpscreen->pixels + _tmpscreen->pitch + 2; // Offset by one row, one column |
970 | | int h = _screenHeight; |
| 1055 | byte *src = (byte *)_overlayscreen->pixels; |
| 1056 | int h = _overlayHeight; |
971 | 1057 | do { |
972 | | memcpy(buf, src, _screenWidth*2); |
973 | | src += _tmpscreen->pitch; |
| 1058 | memcpy(buf, src, _overlayWidth*2); |
| 1059 | src += _overlayscreen->pitch; |
974 | 1060 | buf += pitch; |
975 | 1061 | } while (--h); |
976 | 1062 | |
977 | | SDL_UnlockSurface(_tmpscreen); |
| 1063 | SDL_UnlockSurface(_overlayscreen); |
978 | 1064 | } |
979 | 1065 | |
980 | 1066 | void OSystem_SDL::copyRectToOverlay(const OverlayColor *buf, int pitch, int x, int y, int w, int h) { |
981 | 1067 | assert (_transactionMode == kTransactionNone); |
982 | 1068 | |
983 | | if (!_overlayVisible) |
984 | | return; |
985 | | |
986 | | if (_tmpscreen == NULL) |
| 1069 | if (_overlayscreen == NULL) |
987 | 1070 | return; |
988 | 1071 | |
989 | 1072 | // Clip the coordinates |
… |
… |
|
998 | 1081 | y = 0; |
999 | 1082 | } |
1000 | 1083 | |
1001 | | if (w > _screenWidth - x) { |
1002 | | w = _screenWidth - x; |
| 1084 | if (w > _overlayWidth - x) { |
| 1085 | w = _overlayWidth - x; |
1003 | 1086 | } |
1004 | 1087 | |
1005 | | if (h > _screenHeight-y) { |
1006 | | h = _screenHeight - y; |
| 1088 | if (h > _overlayHeight - y) { |
| 1089 | h = _overlayHeight - y; |
1007 | 1090 | } |
1008 | 1091 | |
1009 | 1092 | if (w <= 0 || h <= 0) |
… |
… |
|
1013 | 1096 | _cksumValid = false; |
1014 | 1097 | addDirtyRect(x, y, w, h); |
1015 | 1098 | |
1016 | | if (SDL_LockSurface(_tmpscreen) == -1) |
| 1099 | if (SDL_LockSurface(_overlayscreen) == -1) |
1017 | 1100 | error("SDL_LockSurface failed: %s", SDL_GetError()); |
1018 | 1101 | |
1019 | | byte *dst = (byte *)_tmpscreen->pixels + (y + 1) * _tmpscreen->pitch + (x + 1) * 2; |
| 1102 | byte *dst = (byte *)_overlayscreen->pixels + y * _overlayscreen->pitch + x * 2; |
1020 | 1103 | do { |
1021 | 1104 | memcpy(dst, buf, w * 2); |
1022 | | dst += _tmpscreen->pitch; |
| 1105 | dst += _overlayscreen->pitch; |
1023 | 1106 | buf += pitch; |
1024 | 1107 | } while (--h); |
1025 | 1108 | |
1026 | | SDL_UnlockSurface(_tmpscreen); |
| 1109 | SDL_UnlockSurface(_overlayscreen); |
1027 | 1110 | } |
1028 | 1111 | |
1029 | 1112 | OverlayColor OSystem_SDL::RGBToColor(uint8 r, uint8 g, uint8 b) { |
1030 | | return SDL_MapRGB(_tmpscreen->format, r, g, b); |
| 1113 | return SDL_MapRGB(_overlayscreen->format, r, g, b); |
1031 | 1114 | } |
1032 | 1115 | |
1033 | 1116 | void OSystem_SDL::colorToRGB(OverlayColor color, uint8 &r, uint8 &g, uint8 &b) { |
1034 | | SDL_GetRGB(color, _tmpscreen->format, &r, &g, &b); |
| 1117 | SDL_GetRGB(color, _overlayscreen->format, &r, &g, &b); |
1035 | 1118 | } |
1036 | 1119 | |
1037 | 1120 | |
… |
… |
|
1061 | 1144 | |
1062 | 1145 | void OSystem_SDL::warpMouse(int x, int y) { |
1063 | 1146 | if (_mouseCurState.x != x || _mouseCurState.y != y) { |
1064 | | SDL_WarpMouse(x * _scaleFactor, y * _scaleFactor); |
| 1147 | if (_overlayVisible) |
| 1148 | SDL_WarpMouse(x * _scaleFactor / _overlayScale, y * _scaleFactor / _overlayScale); |
| 1149 | else |
| 1150 | SDL_WarpMouse(x * _scaleFactor, y * _scaleFactor); |
1065 | 1151 | |
1066 | 1152 | // SDL_WarpMouse() generates a mouse movement event, so |
1067 | 1153 | // setMousePos() would be called eventually. However, the |
… |
… |
|
1235 | 1321 | } |
1236 | 1322 | |
1237 | 1323 | void OSystem_SDL::undrawMouse() { |
| 1324 | // When we switch bigger overlay off mouse jumps. Argh! |
| 1325 | // this intended to prevent undrawing offscreen mouse |
| 1326 | if (!_overlayVisible) |
| 1327 | if (_adjustAspectRatio) { |
| 1328 | if (_mouseBackup.x > _screenWidth || aspect2Real(_mouseBackup.y) > _screenHeight) |
| 1329 | return; |
| 1330 | } else { |
| 1331 | if (_mouseBackup.x > _screenWidth || _mouseBackup.y > _screenHeight) |
| 1332 | return; |
| 1333 | } |
| 1334 | |
1238 | 1335 | if (_mouseBackup.w) { |
1239 | 1336 | if (_adjustAspectRatio) |
1240 | 1337 | addDirtyRect(_mouseBackup.x, aspect2Real(_mouseBackup.y), _mouseBackup.w, |
1241 | | _mouseBackup.h); |
| 1338 | _mouseBackup.h); |
1242 | 1339 | else |
1243 | 1340 | addDirtyRect(_mouseBackup.x, _mouseBackup.y, _mouseBackup.w, |
1244 | | _mouseBackup.h); |
| 1341 | _mouseBackup.h); |
1245 | 1342 | } |
1246 | 1343 | } |
1247 | 1344 | |
… |
… |
|
1250 | 1347 | _mouseBackup.x = _mouseBackup.y = _mouseBackup.w = _mouseBackup.h = 0; |
1251 | 1348 | return; |
1252 | 1349 | } |
1253 | | |
| 1350 | |
1254 | 1351 | SDL_Rect src, dst; |
1255 | 1352 | bool scale; |
| 1353 | int scale1, scale2; |
| 1354 | int width, height; |
| 1355 | |
| 1356 | if (!_overlayVisible) { |
| 1357 | scale1 = _scaleFactor; |
| 1358 | scale2 = 1; |
| 1359 | width = _screenWidth; |
| 1360 | height = _screenHeight; |
| 1361 | } else { |
| 1362 | scale1 = _scaleFactor; |
| 1363 | scale2 = _overlayScale; |
| 1364 | width = _overlayWidth; |
| 1365 | height = _overlayHeight; |
| 1366 | } |
1256 | 1367 | |
1257 | 1368 | scale = (_scaleFactor > _cursorTargetScale); |
1258 | 1369 | |
… |
… |
|
1267 | 1378 | int dx, dy; |
1268 | 1379 | |
1269 | 1380 | dx = dst.x; dy = dst.y; |
1270 | | dx = scale ? dst.x * _scaleFactor / _cursorTargetScale : dst.x; |
1271 | | dy = scale ? dst.y * _scaleFactor / _cursorTargetScale : dst.y; |
1272 | | if (_adjustAspectRatio) |
1273 | | dy = real2Aspect(dy); |
| 1381 | dx = scale ? dst.x * scale1 / scale2 / _cursorTargetScale : dst.x; |
| 1382 | dy = scale ? dst.y * scale1 / scale2 / _cursorTargetScale : dst.y; |
1274 | 1383 | |
1275 | 1384 | if (dst.x < 0) { |
1276 | 1385 | dst.w += dx; |
… |
… |
|
1284 | 1393 | } |
1285 | 1394 | |
1286 | 1395 | // Quick check to see if anything has to be drawn at all |
1287 | | if (dst.w <= 0 || dst.h <= 0) |
| 1396 | if (dst.w <= 0 || dst.h <= 0 || dst.x >= width || dst.y >= height) |
1288 | 1397 | return; |
1289 | 1398 | |
1290 | 1399 | src.w = dst.w; |
… |
… |
|
1292 | 1401 | |
1293 | 1402 | if (_adjustAspectRatio) |
1294 | 1403 | dst.y = real2Aspect(dst.y); |
1295 | | |
| 1404 | |
| 1405 | // special case for 1o5x scaler to prevent backgound shaking |
| 1406 | if (scale1 == 3 && scale2 == 2) { |
| 1407 | if (dst.x % 2) |
| 1408 | dst.x--; |
| 1409 | if (dst.y % 2) |
| 1410 | dst.y--; |
| 1411 | } |
| 1412 | |
1296 | 1413 | _mouseBackup.x = dst.x; |
1297 | 1414 | _mouseBackup.y = dst.y; |
1298 | 1415 | _mouseBackup.w = dst.w; |
1299 | 1416 | _mouseBackup.h = dst.h; |
1300 | | |
1301 | | dst.x *= _scaleFactor; |
1302 | | dst.y *= _scaleFactor; |
1303 | | |
| 1417 | |
| 1418 | dst.x = dst.x * scale1 / scale2; |
| 1419 | dst.y = dst.y * scale1 / scale2; |
| 1420 | |
1304 | 1421 | if (SDL_BlitSurface(_mouseSurface, &src, _hwscreen, &dst) != 0) |
1305 | 1422 | error("SDL_BlitSurface failed: %s", SDL_GetError()); |
1306 | | |
| 1423 | |
1307 | 1424 | addDirtyRect(dst.x, dst.y, dst.w, dst.h, true); |
1308 | 1425 | } |
1309 | 1426 | |
RCS file: /cvsroot/scummvm/scummvm/backends/sdl/sdl-common.h,v
retrieving revision 1.74
diff -u -r1.74 sdl-common.h
|
|
|
58 | 58 | |
59 | 59 | // Set the size of the video bitmap. |
60 | 60 | // Typically, 320x200 |
61 | | virtual void initSize(uint w, uint h); // overloaded by CE backend |
| 61 | virtual void initSize(uint w, uint h, int overlayScale); // overloaded by CE backend |
62 | 62 | |
63 | 63 | // Set colors of the palette |
64 | 64 | void setPalette(const byte *colors, uint start, uint num); |
… |
… |
|
142 | 142 | virtual void copyRectToOverlay(const OverlayColor *buf, int pitch, int x, int y, int w, int h); |
143 | 143 | virtual int16 getHeight(); |
144 | 144 | virtual int16 getWidth(); |
| 145 | virtual int16 getOverlayHeight() { return _overlayHeight; } |
| 146 | virtual int16 getOverlayWidth() { return _overlayWidth; } |
| 147 | virtual int ScreenToOverlayX(int x) { return x * _overlayScale; } |
| 148 | virtual int ScreenToOverlayY(int y) { return y * _overlayScale; } |
| 149 | virtual int OverlayToScreenX(int x) { return x / _overlayScale; } |
| 150 | virtual int OverlayToScreenY(int y) { return y / _overlayScale; } |
145 | 151 | |
146 | 152 | // Methods that convert RGB to/from colors suitable for the overlay. |
147 | 153 | virtual OverlayColor RGBToColor(uint8 r, uint8 g, uint8 b); |
… |
… |
|
187 | 193 | SDL_Surface *_screen; |
188 | 194 | int _screenWidth, _screenHeight; |
189 | 195 | |
190 | | // temporary screen (for scalers/overlay) |
| 196 | // temporary screen (for scalers) |
191 | 197 | SDL_Surface *_tmpscreen; |
| 198 | SDL_Surface *_tmpscreen2; |
| 199 | |
| 200 | // overlay |
| 201 | SDL_Surface *_overlayscreen; |
| 202 | int _overlayWidth, _overlayHeight; |
| 203 | int _overlayScale; |
192 | 204 | bool _overlayVisible; |
193 | 205 | |
194 | 206 | // Audio |
… |
… |
|
214 | 226 | int mode; |
215 | 227 | bool modeChanged; |
216 | 228 | int w; |
217 | | bool wChanged; |
218 | 229 | int h; |
219 | | bool hChanged; |
| 230 | int overlayScale; |
| 231 | bool sizeChanged; |
220 | 232 | bool fs; |
221 | 233 | bool fsChanged; |
222 | 234 | bool ar; |
RCS file: /cvsroot/scummvm/scummvm/backends/sdl/sdl.cpp,v
retrieving revision 1.80
diff -u -r1.80 sdl.cpp
|
|
|
97 | 97 | _osdSurface(0), _osdAlpha(SDL_ALPHA_TRANSPARENT), _osdFadeStartTime(0), |
98 | 98 | #endif |
99 | 99 | _hwscreen(0), _screen(0), _screenWidth(0), _screenHeight(0), |
100 | | _tmpscreen(0), _overlayVisible(false), |
| 100 | _tmpscreen(0), _overlayVisible(false), _overlayScale(1), |
| 101 | _overlayscreen(0), _tmpscreen2(0), |
101 | 102 | _samplesPerSec(0), |
102 | 103 | _cdrom(0), _scalerProc(0), _modeChanged(false), _dirtyChecksums(0), |
103 | 104 | _mouseVisible(false), _mouseDrawn(false), _mouseData(0), _mouseSurface(0), |
RCS file: /cvsroot/scummvm/scummvm/base/main.cpp,v
retrieving revision 1.70
diff -u -r1.70 main.cpp
|
|
|
223 | 223 | // Set the user specified graphics mode (if any). |
224 | 224 | system.setGraphicsMode(ConfMan.get("gfx_mode").c_str()); |
225 | 225 | |
226 | | // GUI is (currently) always running at 320x200 |
227 | | system.initSize(320, 200); |
| 226 | // Make GUI 640 x 400 |
| 227 | system.initSize(320, 200, 2); |
228 | 228 | system.endGFXTransaction(); |
229 | 229 | |
230 | 230 | |
RCS file: /cvsroot/scummvm/scummvm/common/system.h,v
retrieving revision 1.88
diff -u -r1.88 system.h
|
|
|
216 | 216 | * @param width the new virtual screen width |
217 | 217 | * @param height the new virtual screen height |
218 | 218 | */ |
219 | | virtual void initSize(uint width, uint height) = 0; |
| 219 | virtual void initSize(uint width, uint height, int overlayScale = -1) = 0; |
220 | 220 | |
221 | 221 | /** |
222 | 222 | * Begin a new GFX transaction, which is a sequence of GFX mode changes. |
… |
… |
|
351 | 351 | virtual void copyRectToOverlay(const OverlayColor *buf, int pitch, int x, int y, int w, int h) = 0; |
352 | 352 | virtual int16 getOverlayHeight() { return getHeight(); } |
353 | 353 | virtual int16 getOverlayWidth() { return getWidth(); } |
| 354 | virtual int ScreenToOverlayX(int x) { return x; } |
| 355 | virtual int ScreenToOverlayY(int y) { return y; } |
| 356 | virtual int OverlayToScreenX(int x) { return x; } |
| 357 | virtual int OverlayToScreenY(int y) { return y; } |
354 | 358 | |
355 | 359 | /** |
356 | 360 | * Convert the given RGB triplet into an OverlayColor. A OverlayColor can |
… |
… |
|
517 | 521 | /** |
518 | 522 | * The mouse coordinates, in virtual screen coordinates. Only valid |
519 | 523 | * for mouse events. |
520 | | * Virtual screen coordinatest means: the coordinate system of the |
| 524 | * Virtual screen coordinates means: the coordinate system of the |
521 | 525 | * screen area as defined by the most recent call to initSize(). |
522 | 526 | */ |
523 | 527 | Common::Point mouse; |
RCS file: /cvsroot/scummvm/scummvm/gui/newgui.cpp,v
retrieving revision 1.101
diff -u -r1.101 newgui.cpp
|
|
|
85 | 85 | kDefaultGUIHeight = 200 |
86 | 86 | }; |
87 | 87 | |
88 | | _scaleFactor = MIN(_system->getWidth() / kDefaultGUIWidth, _system->getHeight() / kDefaultGUIHeight); |
| 88 | _scaleFactor = MIN(_system->getOverlayWidth() / kDefaultGUIWidth, _system->getOverlayHeight() / kDefaultGUIHeight); |
89 | 89 | |
90 | 90 | // Pick the font depending on the scale factor. |
91 | 91 | if (_scaleFactor == 1) |
RCS file: /cvsroot/scummvm/scummvm/scumm/scumm.cpp,v
retrieving revision 1.345
diff -u -r1.345 scumm.cpp
|
|
|
1156 | 1156 | _system->beginGFXTransaction(); |
1157 | 1157 | initCommonGFX(detector); |
1158 | 1158 | if (_renderMode == Common::kRenderHercA || _renderMode == Common::kRenderHercG) { |
1159 | | _system->initSize(Common::kHercW, Common::kHercH); |
| 1159 | _system->initSize(Common::kHercW, Common::kHercH, 1); |
1160 | 1160 | _features |= GF_DEFAULT_TO_1X_SCALER; |
1161 | 1161 | _system->setGraphicsMode("1x"); |
1162 | 1162 | } else { |
1163 | | _system->initSize(_screenWidth, _screenHeight); |
| 1163 | _system->initSize(_screenWidth, _screenHeight, 2); |
| 1164 | if (_features & GF_DEFAULT_TO_1X_SCALER) |
| 1165 | _system->setGraphicsMode("1x"); |
1164 | 1166 | } |
1165 | 1167 | |
1166 | 1168 | // FIXME: All this seems a dirty hack to me. We already |
1167 | 1169 | // have this check in constructor |
1168 | 1170 | if (_heversion >= 71) { |
1169 | 1171 | _features |= GF_DEFAULT_TO_1X_SCALER; |
1170 | | _system->setGraphicsMode("1x"); |
1171 | 1172 | } |
| 1173 | |
1172 | 1174 | _system->endGFXTransaction(); |
1173 | 1175 | |
1174 | 1176 | int cd_num = ConfMan.getInt("cdrom"); |