Skip to content

Commit

Permalink
VIDEO: Take advantage of Surface::getPixels.
Browse files Browse the repository at this point in the history
  • Loading branch information
Johannes Schickel committed Aug 3, 2013
1 parent 5111746 commit e0c9c1d
Show file tree
Hide file tree
Showing 10 changed files with 24 additions and 24 deletions.
2 changes: 1 addition & 1 deletion video/codecs/cdtoons.cpp
Expand Up @@ -298,7 +298,7 @@ Graphics::Surface *CDToonsDecoder::decodeImage(Common::SeekableReadStream *strea
for (uint i = 0; i < actions.size(); i++) {
CDToonsAction &action = actions[i];
if (i == 0 && action.blockId == 0)
memset(_surface->getBasePtr(0, 0), backgroundColor, _surface->w * _surface->h);
memset(_surface->getPixels(), backgroundColor, _surface->w * _surface->h);
if (!_blocks.contains(action.blockId))
continue;
if (!action.rect.right)
Expand Down
6 changes: 3 additions & 3 deletions video/codecs/cinepak.cpp
Expand Up @@ -41,11 +41,11 @@ namespace Video {
byte b = _clipTable[lum + (u << 1)]; \
\
if (_pixelFormat.bytesPerPixel == 2) \
*((uint16 *)_curFrame.surface->getBasePtr(0, 0) + offset) = _pixelFormat.RGBToColor(r, g, b); \
*((uint16 *)_curFrame.surface->getPixels() + offset) = _pixelFormat.RGBToColor(r, g, b); \
else \
*((uint32 *)_curFrame.surface->getBasePtr(0, 0) + offset) = _pixelFormat.RGBToColor(r, g, b); \
*((uint32 *)_curFrame.surface->getPixels() + offset) = _pixelFormat.RGBToColor(r, g, b); \
} else \
*((byte *)_curFrame.surface->getBasePtr(0, 0) + offset) = lum
*((byte *)_curFrame.surface->getPixels() + offset) = lum

CinepakDecoder::CinepakDecoder(int bitsPerPixel) : Codec() {
_curFrame.surface = NULL;
Expand Down
2 changes: 1 addition & 1 deletion video/codecs/msrle.cpp
Expand Up @@ -53,7 +53,7 @@ void MSRLEDecoder::decode8(Common::SeekableReadStream *stream) {
int x = 0;
int y = _surface->h - 1;

byte *data = (byte *) _surface->getBasePtr(0, 0);
byte *data = (byte *) _surface->getPixels();
uint16 width = _surface->w;
uint16 height = _surface->h;

Expand Down
2 changes: 1 addition & 1 deletion video/codecs/msvideo1.cpp
Expand Up @@ -48,7 +48,7 @@ MSVideo1Decoder::~MSVideo1Decoder() {

void MSVideo1Decoder::decode8(Common::SeekableReadStream *stream) {
byte colors[8];
byte *pixels = (byte *)_surface->getBasePtr(0, 0);
byte *pixels = (byte *)_surface->getPixels();
uint16 stride = _surface->w;

int skipBlocks = 0;
Expand Down
12 changes: 6 additions & 6 deletions video/codecs/qtrle.cpp
Expand Up @@ -61,7 +61,7 @@ QTRLEDecoder::QTRLEDecoder(uint16 width, uint16 height, byte bitsPerPixel) : Cod

void QTRLEDecoder::decode1(Common::SeekableReadStream *stream, uint32 rowPtr, uint32 linesToChange) {
uint32 pixelPtr = 0;
byte *rgb = (byte *)_surface->getBasePtr(0, 0);
byte *rgb = (byte *)_surface->getPixels();

while (linesToChange) {
CHECK_STREAM_PTR(2);
Expand Down Expand Up @@ -105,7 +105,7 @@ void QTRLEDecoder::decode1(Common::SeekableReadStream *stream, uint32 rowPtr, ui

void QTRLEDecoder::decode2_4(Common::SeekableReadStream *stream, uint32 rowPtr, uint32 linesToChange, byte bpp) {
uint32 pixelPtr = 0;
byte *rgb = (byte *)_surface->getBasePtr(0, 0);
byte *rgb = (byte *)_surface->getPixels();
byte numPixels = (bpp == 4) ? 8 : 16;

while (linesToChange--) {
Expand Down Expand Up @@ -165,7 +165,7 @@ void QTRLEDecoder::decode2_4(Common::SeekableReadStream *stream, uint32 rowPtr,

void QTRLEDecoder::decode8(Common::SeekableReadStream *stream, uint32 rowPtr, uint32 linesToChange) {
uint32 pixelPtr = 0;
byte *rgb = (byte *)_surface->getBasePtr(0, 0);
byte *rgb = (byte *)_surface->getPixels();

while (linesToChange--) {
CHECK_STREAM_PTR(2);
Expand Down Expand Up @@ -210,7 +210,7 @@ void QTRLEDecoder::decode8(Common::SeekableReadStream *stream, uint32 rowPtr, ui

void QTRLEDecoder::decode16(Common::SeekableReadStream *stream, uint32 rowPtr, uint32 linesToChange) {
uint32 pixelPtr = 0;
uint16 *rgb = (uint16 *)_surface->getBasePtr(0, 0);
uint16 *rgb = (uint16 *)_surface->getPixels();

while (linesToChange--) {
CHECK_STREAM_PTR(2);
Expand Down Expand Up @@ -248,7 +248,7 @@ void QTRLEDecoder::decode16(Common::SeekableReadStream *stream, uint32 rowPtr, u

void QTRLEDecoder::decode24(Common::SeekableReadStream *stream, uint32 rowPtr, uint32 linesToChange) {
uint32 pixelPtr = 0;
uint32 *rgb = (uint32 *)_surface->getBasePtr(0, 0);
uint32 *rgb = (uint32 *)_surface->getPixels();

while (linesToChange--) {
CHECK_STREAM_PTR(2);
Expand Down Expand Up @@ -294,7 +294,7 @@ void QTRLEDecoder::decode24(Common::SeekableReadStream *stream, uint32 rowPtr, u

void QTRLEDecoder::decode32(Common::SeekableReadStream *stream, uint32 rowPtr, uint32 linesToChange) {
uint32 pixelPtr = 0;
uint32 *rgb = (uint32 *)_surface->getBasePtr(0, 0);
uint32 *rgb = (uint32 *)_surface->getPixels();

while (linesToChange--) {
CHECK_STREAM_PTR(2);
Expand Down
2 changes: 1 addition & 1 deletion video/codecs/rpza.cpp
Expand Up @@ -58,7 +58,7 @@ RPZADecoder::~RPZADecoder() {

#define PUT_PIXEL(color) \
if ((int32)blockPtr < _surface->w * _surface->h) \
WRITE_UINT16((uint16 *)_surface->getBasePtr(0, 0) + blockPtr, color); \
WRITE_UINT16((uint16 *)_surface->getPixels() + blockPtr, color); \
blockPtr++

const Graphics::Surface *RPZADecoder::decodeImage(Common::SeekableReadStream *stream) {
Expand Down
2 changes: 1 addition & 1 deletion video/codecs/smc.cpp
Expand Up @@ -56,7 +56,7 @@ SMCDecoder::~SMCDecoder() {
}

const Graphics::Surface *SMCDecoder::decodeImage(Common::SeekableReadStream *stream) {
byte *pixels = (byte *)_surface->getBasePtr(0, 0);
byte *pixels = (byte *)_surface->getPixels();

uint32 numBlocks = 0;
uint32 colorFlags = 0;
Expand Down
8 changes: 4 additions & 4 deletions video/coktel_decoder.cpp
Expand Up @@ -122,7 +122,7 @@ const Graphics::Surface *CoktelDecoder::getSurface() const {
}

bool CoktelDecoder::hasSurface() {
return _surface.getBasePtr(0, 0);
return _surface.getPixels();
}

void CoktelDecoder::createSurface() {
Expand Down Expand Up @@ -1458,7 +1458,7 @@ bool IMDDecoder::renderFrame(Common::Rect &rect) {
const int offsetY = (_y + rect.top) * _surface.pitch;
const int offset = offsetX + offsetY;

if (deLZ77((byte *)_surface.getBasePtr(0, 0) + offset, dataPtr, dataSize,
if (deLZ77((byte *)_surface.getPixels() + offset, dataPtr, dataSize,
_surface.w * _surface.h * _surface.format.bytesPerPixel - offset))
return true;
}
Expand Down Expand Up @@ -2277,7 +2277,7 @@ bool VMDDecoder::renderFrame(Common::Rect &rect) {
rect = Common::Rect(_x, _y, _x + codecSurf->w, _y + codecSurf->h);
rect.clip(Common::Rect(_x, _y, _x + _width, _y + _height));

renderBlockWhole(_surface, (const byte *)codecSurf->getBasePtr(0, 0), rect);
renderBlockWhole(_surface, (const byte *)codecSurf->getPixels(), rect);
return true;
}

Expand All @@ -2298,7 +2298,7 @@ bool VMDDecoder::renderFrame(Common::Rect &rect) {
const int offsetY = (_y + rect.top) * _surface.pitch;
const int offset = offsetX + offsetY;

if (deLZ77((byte *)_surface.getBasePtr(0, 0) + offset, dataPtr, dataSize,
if (deLZ77((byte *)_surface.getPixels() + offset, dataPtr, dataSize,
_surface.w * _surface.h * _surface.format.bytesPerPixel - offset))
return true;
}
Expand Down
6 changes: 3 additions & 3 deletions video/flic_decoder.cpp
Expand Up @@ -252,16 +252,16 @@ void FlicDecoder::FlicVideoTrack::copyDirtyRectsToBuffer(uint8 *dst, uint pitch)
}

void FlicDecoder::FlicVideoTrack::copyFrame(uint8 *data) {
memcpy((byte *)_surface->getBasePtr(0, 0), data, getWidth() * getHeight());
memcpy((byte *)_surface->getPixels(), data, getWidth() * getHeight());

// Redraw
_dirtyRects.clear();
_dirtyRects.push_back(Common::Rect(0, 0, getWidth(), getHeight()));
}

void FlicDecoder::FlicVideoTrack::decodeByteRun(uint8 *data) {
byte *ptr = (byte *)_surface->getBasePtr(0, 0);
while ((int32)(ptr - (byte *)_surface->getBasePtr(0, 0)) < (getWidth() * getHeight())) {
byte *ptr = (byte *)_surface->getPixels();
while ((int32)(ptr - (byte *)_surface->getPixels()) < (getWidth() * getHeight())) {
int chunks = *data++;
while (chunks--) {
int count = (int8)*data++;
Expand Down
6 changes: 3 additions & 3 deletions video/smk_decoder.cpp
Expand Up @@ -580,7 +580,7 @@ void SmackerDecoder::SmackerVideoTrack::decodeFrame(Common::BitStream &bs) {
while (run-- && block < blocks) {
clr = _MClrTree->getCode(bs);
map = _MMapTree->getCode(bs);
out = (byte *)_surface->getBasePtr(0, 0) + (block / bw) * (stride * 4 * doubleY) + (block % bw) * 4;
out = (byte *)_surface->getPixels() + (block / bw) * (stride * 4 * doubleY) + (block % bw) * 4;
hi = clr >> 8;
lo = clr & 0xff;
for (i = 0; i < 4; i++) {
Expand Down Expand Up @@ -613,7 +613,7 @@ void SmackerDecoder::SmackerVideoTrack::decodeFrame(Common::BitStream &bs) {
}

while (run-- && block < blocks) {
out = (byte *)_surface->getBasePtr(0, 0) + (block / bw) * (stride * 4 * doubleY) + (block % bw) * 4;
out = (byte *)_surface->getPixels() + (block / bw) * (stride * 4 * doubleY) + (block % bw) * 4;
switch (mode) {
case 0:
for (i = 0; i < 4; ++i) {
Expand Down Expand Up @@ -679,7 +679,7 @@ void SmackerDecoder::SmackerVideoTrack::decodeFrame(Common::BitStream &bs) {
uint32 col;
mode = type >> 8;
while (run-- && block < blocks) {
out = (byte *)_surface->getBasePtr(0, 0) + (block / bw) * (stride * 4 * doubleY) + (block % bw) * 4;
out = (byte *)_surface->getPixels() + (block / bw) * (stride * 4 * doubleY) + (block % bw) * 4;
col = mode * 0x01010101;
for (i = 0; i < 4 * doubleY; ++i) {
out[0] = out[1] = out[2] = out[3] = col;
Expand Down

0 comments on commit e0c9c1d

Please sign in to comment.