mirror of
https://github.com/libretro/scummvm.git
synced 2025-03-06 10:17:14 +00:00
TESTBED: Use OSystem::copyRectToScreen() and fillScreen() where possible
Also fixed invalid use of screen surface after unlocking
This commit is contained in:
parent
9905e32960
commit
2b3521dc87
@ -112,17 +112,17 @@ char EventTests::keystrokeToChar() {
|
||||
}
|
||||
|
||||
Common::Rect EventTests::drawFinishZone() {
|
||||
Graphics::Surface *screen = g_system->lockScreen();
|
||||
const Graphics::Font &font(*FontMan.getFontByUsage(Graphics::FontManager::kBigGUIFont));
|
||||
int width = 35;
|
||||
int height = 20;
|
||||
int right = g_system->getWidth();
|
||||
Common::Rect rect(0, 0, right, height);
|
||||
Common::Rect rect2(0, 0, right - width, height);
|
||||
screen->fillRect(rect, kColorSpecial);
|
||||
screen->fillRect(rect2, kColorBlack);
|
||||
g_system->unlockScreen();
|
||||
g_system->fillScreen(rect, kColorSpecial);
|
||||
g_system->fillScreen(rect2, kColorBlack);
|
||||
Graphics::Surface *screen = g_system->lockScreen();
|
||||
font.drawString(screen, "Close", rect.left, rect.top, screen->w, kColorBlack, Graphics::kTextAlignRight);
|
||||
g_system->unlockScreen();
|
||||
g_system->updateScreen();
|
||||
return Common::Rect(right - width, 0, right, height);
|
||||
}
|
||||
|
@ -335,10 +335,8 @@ void GFXtests::setupMouseLoop(bool disableCursorPalette, const char *gfxModeName
|
||||
// Move estimated rect to (20, 20)
|
||||
estimatedCursorRect.moveTo(20, 20);
|
||||
|
||||
Graphics::Surface *screen = g_system->lockScreen();
|
||||
GFXTestSuite::setCustomColor(255, 0, 0);
|
||||
screen->fillRect(estimatedCursorRect, 2);
|
||||
g_system->unlockScreen();
|
||||
g_system->fillScreen(estimatedCursorRect, 2);
|
||||
g_system->updateScreen();
|
||||
}
|
||||
|
||||
@ -1040,11 +1038,9 @@ TestExitStatus GFXtests::mouseMovements() {
|
||||
}
|
||||
|
||||
// Draw Rectangle
|
||||
Graphics::Surface *screen = g_system->lockScreen();
|
||||
// Ensure that 2 represents red in current palette
|
||||
GFXTestSuite::setCustomColor(255, 0, 0);
|
||||
screen->fillRect(Common::Rect::center(106, 106, 14, 14), 2);
|
||||
g_system->unlockScreen();
|
||||
g_system->fillScreen(Common::Rect::center(106, 106, 14, 14), 2);
|
||||
|
||||
// Testing Mouse Movements now!
|
||||
Common::Point pt(0, 10);
|
||||
@ -1364,7 +1360,6 @@ TestExitStatus GFXtests::focusRectangle() {
|
||||
|
||||
const Graphics::Font &font(*FontMan.getFontByUsage(Graphics::FontManager::kConsoleFont));
|
||||
|
||||
Graphics::Surface *screen = g_system->lockScreen();
|
||||
int screenHeight = g_system->getHeight();
|
||||
int screenWidth = g_system->getWidth();
|
||||
|
||||
@ -1372,11 +1367,13 @@ TestExitStatus GFXtests::focusRectangle() {
|
||||
int width = screenWidth / 2;
|
||||
|
||||
Common::Rect rectLeft(0, 0, width, height * 2);
|
||||
screen->fillRect(rectLeft, kColorWhite);
|
||||
font.drawString(screen, "Focus 1", rectLeft.left, rectLeft.top, width, kColorBlack, Graphics::kTextAlignLeft);
|
||||
g_system->fillScreen(rectLeft, kColorWhite);
|
||||
|
||||
Common::Rect rectRight(screenWidth - width, screenHeight - height * 2 , screenWidth, screenHeight);
|
||||
screen->fillRect(rectRight, kColorWhite);
|
||||
g_system->fillScreen(rectRight, kColorWhite);
|
||||
|
||||
Graphics::Surface *screen = g_system->lockScreen();
|
||||
font.drawString(screen, "Focus 1", rectLeft.left, rectLeft.top, width, kColorBlack, Graphics::kTextAlignLeft);
|
||||
font.drawString(screen, "Focus 2", rectRight.left, rectRight.top, width, kColorBlack, Graphics::kTextAlignRight);
|
||||
g_system->unlockScreen();
|
||||
g_system->updateScreen();
|
||||
@ -1732,6 +1729,7 @@ void GFXtests::showPixelFormat(const Graphics::PixelFormat &pf, uint aLoss) {
|
||||
Graphics::Surface *screen = g_system->lockScreen();
|
||||
Graphics::ManagedSurface dstSurface(screen->w, screen->h, screen->format);
|
||||
dstSurface.blitFrom(*screen);
|
||||
g_system->unlockScreen();
|
||||
|
||||
|
||||
// Init palette, if we are demonstating a CLUT8 preview
|
||||
@ -1838,7 +1836,6 @@ void GFXtests::showPixelFormat(const Graphics::PixelFormat &pf, uint aLoss) {
|
||||
|
||||
g_system->copyRectToScreen(dstSurface.getPixels(), dstSurface.pitch, 0, 0,
|
||||
dstSurface.w, dstSurface.h);
|
||||
g_system->unlockScreen();
|
||||
g_system->updateScreen();
|
||||
}
|
||||
|
||||
|
@ -126,10 +126,8 @@ Common::Rect Testsuite::writeOnScreen(const Common::String &textToDisplay, const
|
||||
uint fillColor = kColorBlack;
|
||||
uint textColor = kColorWhite;
|
||||
|
||||
Graphics::Surface *screen = g_system->lockScreen();
|
||||
|
||||
int height = font.getFontHeight();
|
||||
int width = screen->w;
|
||||
int width = g_system->getWidth();
|
||||
|
||||
Common::Rect rect(pt.x, pt.y, pt.x + width, pt.y + height);
|
||||
|
||||
@ -139,9 +137,10 @@ Common::Rect Testsuite::writeOnScreen(const Common::String &textToDisplay, const
|
||||
textColor = pf.RGBToColor(255, 255, 255);
|
||||
}
|
||||
|
||||
screen->fillRect(rect, fillColor);
|
||||
font.drawString(screen, textToDisplay, rect.left, rect.top, screen->w, textColor, Graphics::kTextAlignCenter);
|
||||
g_system->fillScreen(rect, fillColor);
|
||||
|
||||
Graphics::Surface *screen = g_system->lockScreen();
|
||||
font.drawString(screen, textToDisplay, rect.left, rect.top, screen->w, textColor, Graphics::kTextAlignCenter);
|
||||
g_system->unlockScreen();
|
||||
g_system->updateScreen();
|
||||
|
||||
@ -149,11 +148,7 @@ Common::Rect Testsuite::writeOnScreen(const Common::String &textToDisplay, const
|
||||
}
|
||||
|
||||
void Testsuite::clearScreen(const Common::Rect &rect) {
|
||||
Graphics::Surface *screen = g_system->lockScreen();
|
||||
|
||||
screen->fillRect(rect, kColorBlack);
|
||||
|
||||
g_system->unlockScreen();
|
||||
g_system->fillScreen(rect, kColorBlack);
|
||||
g_system->updateScreen();
|
||||
}
|
||||
|
||||
@ -170,16 +165,13 @@ void Testsuite::clearScreen() {
|
||||
}
|
||||
|
||||
void Testsuite::clearScreen(bool flag) {
|
||||
Graphics::Surface *screen = g_system->lockScreen();
|
||||
uint fillColor = kColorBlack;
|
||||
|
||||
if (flag) {
|
||||
fillColor = g_system->getScreenFormat().RGBToColor(0, 0, 0);
|
||||
}
|
||||
|
||||
screen->fillRect(Common::Rect(0, 0, g_system->getWidth(), g_system->getHeight()), fillColor);
|
||||
|
||||
g_system->unlockScreen();
|
||||
g_system->fillScreen(fillColor);
|
||||
g_system->updateScreen();
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user