ACCESS: Changed engine to use Graphics::ManagedSurface

This commit is contained in:
Paul Gilbert 2016-03-10 21:51:06 -05:00
parent 433a2daa6a
commit 9c7569b74b
12 changed files with 157 additions and 358 deletions

View file

@ -69,8 +69,6 @@ void Screen::clearScreen() {
clearBuffer();
if (_vesaMode)
_vm->_clearSummaryFlag = true;
addDirtyRect(Common::Rect(0, 0, this->w, this->h));
}
void Screen::setDisplayScan() {
@ -89,28 +87,14 @@ void Screen::setPanel(int num) {
_msVirtualOffset = _virtualOffsetsTable[num];
}
void Screen::updateScreen() {
void Screen::update() {
if (_vm->_startup >= 0) {
if (--_vm->_startup == -1)
_fadeIn = true;
return;
}
// Merge the dirty rects
mergeDirtyRects();
// Loop through copying dirty areas to the physical screen
Common::List<Common::Rect>::iterator i;
for (i = _dirtyRects.begin(); i != _dirtyRects.end(); ++i) {
const Common::Rect &r = *i;
const byte *srcP = (const byte *)getBasePtr(r.left, r.top);
g_system->copyRectToScreen(srcP, this->pitch, r.left, r.top,
r.width(), r.height());
}
// Signal the physical screen to update
g_system->updateScreen();
_dirtyRects.clear();
markAllDirty();//****DEBUG****
Graphics::Screen::update();
}
void Screen::setInitialPalettte() {
@ -153,7 +137,7 @@ void Screen::loadRawPalette(Common::SeekableReadStream *stream) {
void Screen::updatePalette() {
g_system->getPaletteManager()->setPalette(&_tempPalette[0], 0, PALETTE_COUNT);
updateScreen();
update();
}
void Screen::savePalette() {
@ -293,22 +277,7 @@ void Screen::drawBox() {
ASurface::drawBox();
}
void Screen::transBlitFrom(ASurface *src, const Common::Point &destPos) {
addDirtyRect(Common::Rect(destPos.x, destPos.y, destPos.x + src->w, destPos.y + src->h));
ASurface::transBlitFrom(src, destPos);
}
void Screen::transBlitFrom(ASurface *src, const Common::Rect &bounds) {
addDirtyRect(bounds);
ASurface::transBlitFrom(src, bounds);
}
void Screen::blitFrom(const Graphics::Surface &src) {
addDirtyRect(Common::Rect(0, 0, src.w, src.h));
ASurface::blitFrom(src);
}
void Screen::copyBuffer(Graphics::Surface *src) {
void Screen::copyBuffer(Graphics::ManagedSurface *src) {
addDirtyRect(Common::Rect(0, 0, src->w, src->h));
ASurface::copyBuffer(src);
}
@ -349,51 +318,7 @@ void Screen::cyclePaletteBackwards() {
}
void Screen::flashPalette(int count) {
warning("TODO: Implement flashPalette");
// No implementation needed in ScummVM
}
void Screen::addDirtyRect(const Common::Rect &r) {
_dirtyRects.push_back(r);
assert(r.isValidRect() && r.width() > 0 && r.height() > 0);
}
void Screen::mergeDirtyRects() {
Common::List<Common::Rect>::iterator rOuter, rInner;
// Ensure dirty rect list has at least two entries
rOuter = _dirtyRects.begin();
for (int i = 0; i < 2; ++i, ++rOuter) {
if (rOuter == _dirtyRects.end())
return;
}
// Process the dirty rect list to find any rects to merge
for (rOuter = _dirtyRects.begin(); rOuter != _dirtyRects.end(); ++rOuter) {
rInner = rOuter;
while (++rInner != _dirtyRects.end()) {
if ((*rOuter).intersects(*rInner)) {
// these two rectangles overlap or
// are next to each other - merge them
unionRectangle(*rOuter, *rOuter, *rInner);
// remove the inner rect from the list
_dirtyRects.erase(rInner);
// move back to beginning of list
rInner = rOuter;
}
}
}
}
bool Screen::unionRectangle(Common::Rect &destRect, const Common::Rect &src1, const Common::Rect &src2) {
destRect = src1;
destRect.extend(src2);
return !destRect.isEmpty();
}
} // End of namespace Access