mirror of
https://github.com/libretro/scummvm.git
synced 2025-04-03 15:21:40 +00:00
Added an experimental screen transition dirty rect calculation code which should make background changes faster on slower devices or when scalers are active
svn-id: r44032
This commit is contained in:
parent
bb94053960
commit
4fc8fe8023
@ -330,4 +330,46 @@ void resetBitmap(uint8 *dataPtr, int32 dataSize) {
|
||||
memset(dataPtr, 0, dataSize);
|
||||
}
|
||||
|
||||
/**
|
||||
* This method compares a new background being switched in against the current background,
|
||||
* to figure out rectangles of changed areas for dirty rectangles
|
||||
*/
|
||||
void switchBackground(const byte *newBg) {
|
||||
const byte *bg = gfxModuleData.pPage00;
|
||||
int sliceXStart, sliceXEnd;
|
||||
|
||||
// If both the upper corners are different, presume it's a full screen change
|
||||
if ((*newBg != *bg) && (*(newBg + 319) != *(bg + 319))) {
|
||||
gfxModuleData_addDirtyRect(Common::Rect(0, 0, 320, 200));
|
||||
return;
|
||||
}
|
||||
|
||||
/* For an optimisation, any changes are stored as a series of slices than have a height of a single
|
||||
* line each. It is left up to the screen redraw code to automatically merge these together
|
||||
*/
|
||||
|
||||
for (int yp = 0; yp < 200; ++yp) {
|
||||
sliceXStart = -1; sliceXEnd = -1;
|
||||
for (int xp = 0; xp < 320; ++xp, ++bg, ++newBg) {
|
||||
if (*bg != *newBg) {
|
||||
if (sliceXStart == -1) {
|
||||
// Start of a new slice
|
||||
sliceXStart = xp;
|
||||
sliceXEnd = MIN(xp + 7, 320);
|
||||
} else
|
||||
// Carry on of changed area
|
||||
sliceXEnd = MAX(xp + 7, sliceXEnd);
|
||||
|
||||
} else if ((sliceXEnd != -1) && (xp >= (sliceXEnd + 10))) {
|
||||
// If more than 10 pixels have gone by without any changes, then end the slice
|
||||
gfxModuleData_addDirtyRect(Common::Rect(sliceXStart, yp, sliceXEnd, yp + 1));
|
||||
sliceXStart = sliceXEnd = -1;
|
||||
}
|
||||
}
|
||||
|
||||
if (sliceXStart != -1)
|
||||
gfxModuleData_addDirtyRect(Common::Rect(sliceXStart, yp, 320, yp + 1));
|
||||
}
|
||||
}
|
||||
|
||||
} // End of namespace Cruise
|
||||
|
@ -67,6 +67,8 @@ void flip(void);
|
||||
void drawSolidBox(int32 x1, int32 y1, int32 x2, int32 y2, uint8 colour);
|
||||
void resetBitmap(uint8 *dataPtr, int32 dataSize);
|
||||
|
||||
void switchBackground(const byte *newBg);
|
||||
|
||||
} // End of namespace Cruise
|
||||
|
||||
#endif
|
||||
|
@ -1415,7 +1415,7 @@ void mainDraw(int16 param) {
|
||||
gfxModuleData_gfxCopyScreen(bgPtr, gfxModuleData.pPage10);
|
||||
if (backgroundChanged[masterScreen]) {
|
||||
backgroundChanged[masterScreen] = false;
|
||||
gfxModuleData_addDirtyRect(Common::Rect(0, 0, 320, 200));
|
||||
switchBackground(bgPtr);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user