Skip to content

Commit

Permalink
SCI: Prefer getBasePtr over direct Surface::pixels access.
Browse files Browse the repository at this point in the history
  • Loading branch information
Johannes Schickel committed Aug 3, 2013
1 parent 8617ede commit dd67e9f
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 11 deletions.
4 changes: 2 additions & 2 deletions engines/sci/engine/kvideo.cpp
Expand Up @@ -103,10 +103,10 @@ void playVideo(Video::VideoDecoder *videoDecoder, VideoState videoState) {
if (frame) {
if (scaleBuffer) {
// TODO: Probably should do aspect ratio correction in e.g. GK1 Windows
g_sci->_gfxScreen->scale2x((byte *)frame->pixels, scaleBuffer, videoDecoder->getWidth(), videoDecoder->getHeight(), bytesPerPixel);
g_sci->_gfxScreen->scale2x((const byte *)frame->getBasePtr(0, 0), scaleBuffer, videoDecoder->getWidth(), videoDecoder->getHeight(), bytesPerPixel);
g_system->copyRectToScreen(scaleBuffer, pitch, x, y, width, height);
} else {
g_system->copyRectToScreen(frame->pixels, frame->pitch, x, y, width, height);
g_system->copyRectToScreen(frame->getBasePtr(0, 0), frame->pitch, x, y, width, height);
}

if (videoDecoder->hasDirtyPalette()) {
Expand Down
2 changes: 1 addition & 1 deletion engines/sci/graphics/frameout.cpp
Expand Up @@ -532,7 +532,7 @@ void GfxFrameout::showVideo() {
if (videoDecoder->needsUpdate()) {
const Graphics::Surface *frame = videoDecoder->decodeNextFrame();
if (frame) {
g_system->copyRectToScreen(frame->pixels, frame->pitch, x, y, frame->w, frame->h);
g_system->copyRectToScreen(frame->getBasePtr(0, 0), frame->pitch, x, y, frame->w, frame->h);

if (videoDecoder->hasDirtyPalette())
g_system->getPaletteManager()->setPalette(videoDecoder->getPalette(), 0, 256);
Expand Down
6 changes: 3 additions & 3 deletions engines/sci/graphics/maciconbar.cpp
Expand Up @@ -129,7 +129,7 @@ void GfxMacIconBar::drawIcon(uint16 iconIndex, bool selected) {

void GfxMacIconBar::drawEnabledImage(Graphics::Surface *surface, const Common::Rect &rect) {
if (surface)
g_system->copyRectToScreen(surface->pixels, surface->pitch, rect.left, rect.top, rect.width(), rect.height());
g_system->copyRectToScreen(surface->getBasePtr(0, 0), surface->pitch, rect.left, rect.top, rect.width(), rect.height());
}

void GfxMacIconBar::drawDisabledImage(Graphics::Surface *surface, const Common::Rect &rect) {
Expand All @@ -153,7 +153,7 @@ void GfxMacIconBar::drawDisabledImage(Graphics::Surface *surface, const Common::
*((byte *)newSurf.getBasePtr(j, i)) = 0;
}

g_system->copyRectToScreen(newSurf.pixels, newSurf.pitch, rect.left, rect.top, rect.width(), rect.height());
g_system->copyRectToScreen(newSurf.getBasePtr(0, 0), newSurf.pitch, rect.left, rect.top, rect.width(), rect.height());
newSurf.free();
}

Expand Down Expand Up @@ -224,7 +224,7 @@ Graphics::Surface *GfxMacIconBar::createImage(uint32 iconIndex, bool isSelected)
}

void GfxMacIconBar::remapColors(Graphics::Surface *surf, const byte *palette) {
byte *pixels = (byte *)surf->pixels;
byte *pixels = (byte *)surf->getBasePtr(0, 0);

// Remap to the screen palette
for (uint16 i = 0; i < surf->w * surf->h; i++) {
Expand Down
4 changes: 2 additions & 2 deletions engines/sci/graphics/screen.cpp
Expand Up @@ -170,14 +170,14 @@ void GfxScreen::copyToScreen() {
void GfxScreen::copyFromScreen(byte *buffer) {
// TODO this ignores the pitch
Graphics::Surface *screen = g_system->lockScreen();
memcpy(buffer, screen->pixels, _displayPixels);
memcpy(buffer, screen->getBasePtr(0, 0), _displayPixels);
g_system->unlockScreen();
}

void GfxScreen::kernelSyncWithFramebuffer() {
// TODO this ignores the pitch
Graphics::Surface *screen = g_system->lockScreen();
memcpy(_displayScreen, screen->pixels, _displayPixels);
memcpy(_displayScreen, screen->getBasePtr(0, 0), _displayPixels);
g_system->unlockScreen();
}

Expand Down
2 changes: 1 addition & 1 deletion engines/sci/video/robot_decoder.cpp
Expand Up @@ -210,7 +210,7 @@ void RobotDecoder::readNextPacket() {

// Copy over the decompressed frame
byte *inFrame = decompressedFrame;
byte *outFrame = (byte *)surface->pixels;
byte *outFrame = (byte *)surface->getBasePtr(0, 0);

// Black out the surface
memset(outFrame, 0, surface->w * surface->h);
Expand Down
4 changes: 2 additions & 2 deletions engines/sci/video/seq_decoder.cpp
Expand Up @@ -119,7 +119,7 @@ const Graphics::Surface *SEQDecoder::SEQVideoTrack::decodeNextFrame() {
_fileStream->seek(offset);

if (frameType == kSeqFrameFull) {
byte *dst = (byte *)_surface->pixels + frameTop * SEQ_SCREEN_WIDTH + frameLeft;
byte *dst = (byte *)_surface->getBasePtr(frameLeft, frameTop);

byte *linebuf = new byte[frameWidth];

Expand All @@ -133,7 +133,7 @@ const Graphics::Surface *SEQDecoder::SEQVideoTrack::decodeNextFrame() {
} else {
byte *buf = new byte[frameSize];
_fileStream->read(buf, frameSize);
decodeFrame(buf, rleSize, buf + rleSize, frameSize - rleSize, (byte *)_surface->pixels + SEQ_SCREEN_WIDTH * frameTop, frameLeft, frameWidth, frameHeight, colorKey);
decodeFrame(buf, rleSize, buf + rleSize, frameSize - rleSize, (byte *)_surface->getBasePtr(0, frameTop), frameLeft, frameWidth, frameHeight, colorKey);
delete[] buf;
}

Expand Down

0 comments on commit dd67e9f

Please sign in to comment.