mirror of
https://github.com/libretro/scummvm.git
synced 2025-01-26 12:48:16 +00:00
GRAPHICS: MACGUI: Made MacDrawPixel bpp-aware
This commit is contained in:
parent
43c3407557
commit
e604c97607
@ -847,7 +847,7 @@ void inkDrawPixel(int x, int y, int src, void *data) {
|
||||
// Get the pixel that macDrawPixel will give us, but store it to apply the
|
||||
// ink later.
|
||||
tmpDst = *dst;
|
||||
Graphics::macDrawPixel(x, y, src, p->ms->pd);
|
||||
(p->_wm->getDrawPixel())(x, y, src, p->ms->pd);
|
||||
src = *dst;
|
||||
|
||||
*dst = tmpDst;
|
||||
|
@ -1020,10 +1020,10 @@ void Window::transZoom(TransParams &t, Common::Rect &clipRect, Graphics::Managed
|
||||
r.moveTo(t.xStepSize * (i - s), t.yStepSize * (i - s));
|
||||
}
|
||||
|
||||
Graphics::drawLine(r.left, r.top, r.right, r.top, 0xffff, Graphics::macDrawPixel, &pd);
|
||||
Graphics::drawLine(r.right, r.top, r.right, r.bottom, 0xffff, Graphics::macDrawPixel, &pd);
|
||||
Graphics::drawLine(r.left, r.bottom, r.right, r.bottom, 0xffff, Graphics::macDrawPixel, &pd);
|
||||
Graphics::drawLine(r.left, r.top, r.left, r.bottom, 0xffff, Graphics::macDrawPixel, &pd);
|
||||
Graphics::drawLine(r.left, r.top, r.right, r.top, 0xffff, _wm->getDrawPixel(), &pd);
|
||||
Graphics::drawLine(r.right, r.top, r.right, r.bottom, 0xffff, _wm->getDrawPixel(), &pd);
|
||||
Graphics::drawLine(r.left, r.bottom, r.right, r.bottom, 0xffff, _wm->getDrawPixel(), &pd);
|
||||
Graphics::drawLine(r.left, r.top, r.left, r.bottom, 0xffff, _wm->getDrawPixel(), &pd);
|
||||
}
|
||||
|
||||
r.setHeight(t.yStepSize * i * 2);
|
||||
|
@ -74,14 +74,14 @@ void MacButton::invertOuter() {
|
||||
switch (_buttonType) {
|
||||
case kCheckBox: {
|
||||
Common::Rect c = Common::Rect(r.left + 1, r.top + 3, r.left + 9, r.top + 11);
|
||||
Graphics::drawRect(c, 0, Graphics::macDrawPixel, &_pd);
|
||||
Graphics::drawRect(c, 0, _wm->getDrawPixel(), &_pd);
|
||||
}
|
||||
break;
|
||||
case kRound:
|
||||
Graphics::drawRoundRect(r, 4, 0, true, Graphics::macDrawPixel, &_pd);
|
||||
Graphics::drawRoundRect(r, 4, 0, true, _wm->getDrawPixel(), &_pd);
|
||||
break;
|
||||
case kRadio:
|
||||
Graphics::drawEllipse(r.left + 1, r.top + 3, r.left + 10, r.top + 12, 0, false, Graphics::macDrawPixel, &_pd);
|
||||
Graphics::drawEllipse(r.left + 1, r.top + 3, r.left + 10, r.top + 12, 0, false, _wm->getDrawPixel(), &_pd);
|
||||
break;
|
||||
}
|
||||
|
||||
@ -93,14 +93,14 @@ void MacButton::invertInner() {
|
||||
|
||||
switch (_buttonType) {
|
||||
case kCheckBox:
|
||||
Graphics::drawLine(r.left + 1, r.top + 3, r.left + 9, r.top + 11, 0, Graphics::macDrawPixel, &_pd);
|
||||
Graphics::drawLine(r.left + 1, r.top + 11, r.left + 9, r.top + 3, 0, Graphics::macDrawPixel, &_pd);
|
||||
Graphics::macDrawPixel(5, 7, 0, &_pd);
|
||||
Graphics::drawLine(r.left + 1, r.top + 3, r.left + 9, r.top + 11, 0, _wm->getDrawPixel(), &_pd);
|
||||
Graphics::drawLine(r.left + 1, r.top + 11, r.left + 9, r.top + 3, 0, _wm->getDrawPixel(), &_pd);
|
||||
(_wm->getDrawPixel())(5, 7, 0, &_pd);
|
||||
break;
|
||||
case kRound:
|
||||
break;
|
||||
case kRadio:
|
||||
Graphics::drawEllipse(r.left + 3, r.top + 5, r.left + 8, r.top + 10, 0, true, Graphics::macDrawPixel, &_pd);
|
||||
Graphics::drawEllipse(r.left + 3, r.top + 5, r.left + 8, r.top + 10, 0, true, _wm->getDrawPixel(), &_pd);
|
||||
break;
|
||||
}
|
||||
|
||||
@ -119,14 +119,14 @@ bool MacButton::draw(bool forceRedraw) {
|
||||
switch (_buttonType) {
|
||||
case kCheckBox: {
|
||||
Common::Rect c = Common::Rect(r.left, r.top + 2, r.left + 10, r.top + 2 + 10);
|
||||
Graphics::drawRect(c, 0, Graphics::macDrawPixel, &pd);
|
||||
Graphics::drawRect(c, 0, _wm->getDrawPixel(), &pd);
|
||||
break;
|
||||
}
|
||||
case kRound:
|
||||
Graphics::drawRoundRect(r, 4, 0, _active, Graphics::macDrawPixel, &pd);
|
||||
Graphics::drawRoundRect(r, 4, 0, _active, _wm->getDrawPixel(), &pd);
|
||||
break;
|
||||
case kRadio:
|
||||
Graphics::drawEllipse(r.left, r.top + 2, r.left + 11, r.top + 13, 0, false, Graphics::macDrawPixel, &pd);
|
||||
Graphics::drawEllipse(r.left, r.top + 2, r.left + 11, r.top + 13, 0, false, _wm->getDrawPixel(), &pd);
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -374,7 +374,7 @@ void MacWindow::drawSimpleBorder(ManagedSurface *g) {
|
||||
Common::Rect rr(rx1, ry1, rx2, ry2);
|
||||
|
||||
MacPlotData pd(g, nullptr, &_wm->getPatterns(), 1, 0, 0, 1, _wm->_colorBlack, true);
|
||||
Graphics::drawFilledRect(rr, _wm->_colorBlack, Graphics::macDrawPixel, &pd);
|
||||
Graphics::drawFilledRect(rr, _wm->_colorBlack, _wm->getDrawPixel(), &pd);
|
||||
}
|
||||
}
|
||||
if (closeable) {
|
||||
|
@ -401,6 +401,7 @@ void MacWindowManager::removeWindow(MacWindow *target) {
|
||||
_activeWindow = -1;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
void macDrawPixel(int x, int y, int color, void *data) {
|
||||
MacPlotData *p = (MacPlotData *)data;
|
||||
|
||||
@ -414,11 +415,11 @@ void macDrawPixel(int x, int y, int color, void *data) {
|
||||
uint xu = (uint)x; // for letting compiler optimize it
|
||||
uint yu = (uint)y;
|
||||
|
||||
*((byte *)p->surface->getBasePtr(xu, yu)) = p->invert ? ~(*((byte *)p->surface->getBasePtr(xu, yu))) :
|
||||
*((T)p->surface->getBasePtr(xu, yu)) = p->invert ? ~(*((T)p->surface->getBasePtr(xu, yu))) :
|
||||
(pat[(yu - p->fillOriginY) % 8] & (1 << (7 - (xu - p->fillOriginX) % 8))) ? color : p->bgColor;
|
||||
|
||||
if (p->mask)
|
||||
*((byte *)p->mask->getBasePtr(xu, yu)) = 0xff;
|
||||
*((T)p->mask->getBasePtr(xu, yu)) = 0xff;
|
||||
}
|
||||
} else {
|
||||
int x1 = x;
|
||||
@ -431,15 +432,22 @@ void macDrawPixel(int x, int y, int color, void *data) {
|
||||
if (x >= 0 && x < p->surface->w && y >= 0 && y < p->surface->h) {
|
||||
uint xu = (uint)x; // for letting compiler optimize it
|
||||
uint yu = (uint)y;
|
||||
*((byte *)p->surface->getBasePtr(xu, yu)) = p->invert ? ~(*((byte *)p->surface->getBasePtr(xu, yu))) :
|
||||
*((T)p->surface->getBasePtr(xu, yu)) = p->invert ? ~(*((T)p->surface->getBasePtr(xu, yu))) :
|
||||
(pat[(yu - p->fillOriginY) % 8] & (1 << (7 - (xu - p->fillOriginX) % 8))) ? color : p->bgColor;
|
||||
|
||||
if (p->mask)
|
||||
*((byte *)p->mask->getBasePtr(xu, yu)) = 0xff;
|
||||
*((T)p->mask->getBasePtr(xu, yu)) = 0xff;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
MacWindowManager::DrawPixPtr MacWindowManager::getDrawPixel() {
|
||||
if (_pixelformat.bytesPerPixel == 1)
|
||||
return &macDrawPixel<byte *>;
|
||||
else
|
||||
return &macDrawPixel<uint32 *>;
|
||||
}
|
||||
|
||||
void MacWindowManager::loadDesktop() {
|
||||
Common::SeekableReadStream *file = getFile("scummvm_background.bmp");
|
||||
if (!file)
|
||||
@ -481,7 +489,7 @@ void MacWindowManager::drawDesktop() {
|
||||
|
||||
MacPlotData pd(_desktop, nullptr, &_patterns, kPatternCheckers, 0, 0, 1, _colorWhite);
|
||||
|
||||
Graphics::drawRoundRect(r, kDesktopArc, _colorBlack, true, macDrawPixel, &pd);
|
||||
Graphics::drawRoundRect(r, kDesktopArc, _colorBlack, true, getDrawPixel(), &pd);
|
||||
}
|
||||
}
|
||||
|
||||
@ -549,19 +557,24 @@ void MacWindowManager::draw() {
|
||||
if (w->isDirty() || forceRedraw) {
|
||||
w->draw(forceRedraw);
|
||||
|
||||
Surface *surface = g_system->lockScreen();
|
||||
ManagedSurface *border = w->getBorderSurface();
|
||||
|
||||
adjustDimensions(clip, outerDims, adjWidth, adjHeight);
|
||||
for (int y = 0; y < adjHeight; y++) {
|
||||
const byte *src = (const byte *)border->getBasePtr(clip.left - outerDims.left, y);
|
||||
byte *dst = (byte *)surface->getBasePtr(clip.left, y + clip.top);
|
||||
for (int x = 0; x < adjWidth; x++, src++, dst++)
|
||||
if (*src != _colorGreen2 && *src != _colorGreen)
|
||||
*dst = *src;
|
||||
}
|
||||
|
||||
g_system->unlockScreen();
|
||||
if (_pixelformat.bytesPerPixel == 1) {
|
||||
Surface *surface = g_system->lockScreen();
|
||||
ManagedSurface *border = w->getBorderSurface();
|
||||
|
||||
for (int y = 0; y < adjHeight; y++) {
|
||||
const byte *src = (const byte *)border->getBasePtr(clip.left - outerDims.left, y);
|
||||
byte *dst = (byte *)surface->getBasePtr(clip.left, y + clip.top);
|
||||
for (int x = 0; x < adjWidth; x++, src++, dst++)
|
||||
if (*src != _colorGreen2 && *src != _colorGreen)
|
||||
*dst = *src;
|
||||
}
|
||||
|
||||
g_system->unlockScreen();
|
||||
} else {
|
||||
g_system->copyRectToScreen(w->getBorderSurface()->getBasePtr(MAX(clip.left - outerDims.left, 0), MAX(clip.top - outerDims.top, 0)), w->getBorderSurface()->pitch, clip.left, clip.top, adjWidth, adjHeight);
|
||||
}
|
||||
}
|
||||
|
||||
adjustDimensions(clip, innerDims, adjWidth, adjHeight);
|
||||
@ -789,10 +802,10 @@ void MacWindowManager::renderZoomBox(bool redraw) {
|
||||
}
|
||||
|
||||
void MacWindowManager::zoomBoxInner(Common::Rect &r, Graphics::MacPlotData &pd) {
|
||||
Graphics::drawLine(r.left, r.top, r.right, r.top, 0xff, Graphics::macDrawPixel, &pd);
|
||||
Graphics::drawLine(r.right, r.top, r.right, r.bottom, 0xff, Graphics::macDrawPixel, &pd);
|
||||
Graphics::drawLine(r.left, r.bottom, r.right, r.bottom, 0xff, Graphics::macDrawPixel, &pd);
|
||||
Graphics::drawLine(r.left, r.top, r.left, r.bottom, 0xff, Graphics::macDrawPixel, &pd);
|
||||
Graphics::drawLine(r.left, r.top, r.right, r.top, 0xff, getDrawPixel(), &pd);
|
||||
Graphics::drawLine(r.right, r.top, r.right, r.bottom, 0xff, getDrawPixel(), &pd);
|
||||
Graphics::drawLine(r.left, r.bottom, r.right, r.bottom, 0xff, getDrawPixel(), &pd);
|
||||
Graphics::drawLine(r.left, r.top, r.left, r.bottom, 0xff, getDrawPixel(), &pd);
|
||||
}
|
||||
|
||||
/////////////////
|
||||
|
@ -131,8 +131,6 @@ struct ZoomBox {
|
||||
uint32 nextTime;
|
||||
};
|
||||
|
||||
void macDrawPixel(int x, int y, int color, void *data);
|
||||
|
||||
/**
|
||||
* A manager class to handle window creation, destruction,
|
||||
* drawing, moving and event handling.
|
||||
@ -142,6 +140,9 @@ public:
|
||||
MacWindowManager(uint32 mode = 0, MacPatterns *patterns = nullptr);
|
||||
~MacWindowManager();
|
||||
|
||||
typedef void (* DrawPixPtr)(int, int, int, void *);
|
||||
DrawPixPtr getDrawPixel();
|
||||
|
||||
/**
|
||||
* Mutator to indicate the surface onto which the desktop will be drawn.
|
||||
* Note that this method should be called as soon as the WM is created.
|
||||
|
Loading…
x
Reference in New Issue
Block a user