Skip to content

Commit

Permalink
GUI: Prefer getBasePtr instead of 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 19fa89b commit 103e926
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion gui/EventRecorder.cpp
Expand Up @@ -522,7 +522,7 @@ bool EventRecorder::grabScreenAndComputeMD5(Graphics::Surface &screen, uint8 md5
warning("Can't save screenshot");
return false;
}
Common::MemoryReadStream bitmapStream((const byte*)screen.pixels, screen.w * screen.h * screen.format.bytesPerPixel);
Common::MemoryReadStream bitmapStream((const byte*)screen.getBasePtr(0, 0), screen.w * screen.h * screen.format.bytesPerPixel);
computeStreamMD5(bitmapStream, md5);
return true;
}
Expand Down
6 changes: 3 additions & 3 deletions gui/ThemeEngine.cpp
Expand Up @@ -389,7 +389,7 @@ bool ThemeEngine::init() {
_overlayFormat = _system->getOverlayFormat();
setGraphicsMode(_graphicsMode);

if (_screen.pixels && _backBuffer.pixels) {
if (_screen.getBasePtr(0, 0) && _backBuffer.getBasePtr(0, 0)) {
_initOk = true;
}

Expand Down Expand Up @@ -439,7 +439,7 @@ bool ThemeEngine::init() {
void ThemeEngine::clearAll() {
if (_initOk) {
_system->clearOverlay();
_system->grabOverlay(_screen.pixels, _screen.pitch);
_system->grabOverlay(_screen.getBasePtr(0, 0), _screen.pitch);
}
}

Expand Down Expand Up @@ -1326,7 +1326,7 @@ bool ThemeEngine::createCursor(const Common::String &filename, int hotspotX, int
// to 8 bit mode, and have to create a suitable palette on the fly.
uint colorsFound = 0;
Common::HashMap<int, int> colorToIndex;
const OverlayColor *src = (const OverlayColor *)cursor->pixels;
const OverlayColor *src = (const OverlayColor *)cursor->getBasePtr(0, 0);
for (uint y = 0; y < _cursorHeight; ++y) {
for (uint x = 0; x < _cursorWidth; ++x) {
byte r, g, b;
Expand Down
8 changes: 4 additions & 4 deletions gui/widget.cpp
Expand Up @@ -396,7 +396,7 @@ PicButtonWidget::~PicButtonWidget() {
void PicButtonWidget::setGfx(const Graphics::Surface *gfx) {
_gfx.free();

if (!gfx || !gfx->pixels)
if (!gfx || !gfx->getBasePtr(0, 0))
return;

if (gfx->format.bytesPerPixel == 1) {
Expand Down Expand Up @@ -429,7 +429,7 @@ void PicButtonWidget::setGfx(int w, int h, int r, int g, int b) {
void PicButtonWidget::drawWidget() {
g_gui.theme()->drawButton(Common::Rect(_x, _y, _x+_w, _y+_h), "", _state, getFlags());

if (_gfx.pixels) {
if (_gfx.getBasePtr(0, 0)) {
// Check whether the set up surface needs to be converted to the GUI
// color format.
const Graphics::PixelFormat &requiredFormat = g_gui.theme()->getPixelFormat();
Expand Down Expand Up @@ -646,7 +646,7 @@ GraphicsWidget::~GraphicsWidget() {
void GraphicsWidget::setGfx(const Graphics::Surface *gfx) {
_gfx.free();

if (!gfx || !gfx->pixels)
if (!gfx || !gfx->getBasePtr(0, 0))
return;

if (gfx->format.bytesPerPixel == 1) {
Expand Down Expand Up @@ -676,7 +676,7 @@ void GraphicsWidget::setGfx(int w, int h, int r, int g, int b) {
}

void GraphicsWidget::drawWidget() {
if (_gfx.pixels) {
if (_gfx.getBasePtr(0, 0)) {
// Check whether the set up surface needs to be converted to the GUI
// color format.
const Graphics::PixelFormat &requiredFormat = g_gui.theme()->getPixelFormat();
Expand Down

0 comments on commit 103e926

Please sign in to comment.