DIRECTOR: Fix rendering for kInkTypeBackgndTrans and kInkTypeCopy

I don't know what scenario was used as a basis for developing the existing
applyColor logic in inkDrawPixel(). As such, I've kept it for the uint32
pathway, and replaced the uint8 pathway with the logic documented in the
Director 4 manual.
This commit is contained in:
Scott Percival 2022-07-30 23:16:19 +08:00
parent 7ee474f070
commit ef03dbb92e

View File

@ -197,10 +197,10 @@ void inkDrawPixel(int x, int y, int src, void *data) {
if (!p->destRect.contains(x, y))
return;
T dst;
T *dst;
uint32 tmpDst;
dst = (T)p->dst->getBasePtr(x, y);
dst = (T *)p->dst->getBasePtr(x, y);
if (p->ms) {
if (p->ms->pd->thickness > 1) {
@ -255,28 +255,32 @@ void inkDrawPixel(int x, int y, int src, void *data) {
switch (p->ink) {
case kInkTypeBackgndTrans:
if ((uint32)src == p->backColor)
break;
// fall through
*dst = src == p->backColor ? *dst : src;
break;
case kInkTypeMatte:
// fall through
case kInkTypeMask:
// Only unmasked pixels make it here, so copy them straight
case kInkTypeCopy: {
if (p->applyColor) {
// TODO: Improve the efficiency of this composition
byte rSrc, gSrc, bSrc;
byte rDst, gDst, bDst;
byte rFor, gFor, bFor;
byte rBak, gBak, bBak;
if (sizeof(T) == 1) {
*dst = src == 0x00 ? p->foreColor : (src == 0xff ? p->backColor : *dst);
} else {
// TODO: Improve the efficiency of this composition
byte rSrc, gSrc, bSrc;
byte rDst, gDst, bDst;
byte rFor, gFor, bFor;
byte rBak, gBak, bBak;
wm->decomposeColor(src, rSrc, gSrc, bSrc);
wm->decomposeColor(*dst, rDst, gDst, bDst);
wm->decomposeColor(p->foreColor, rFor, gFor, bFor);
wm->decomposeColor(p->backColor, rBak, gBak, bBak);
wm->decomposeColor(src, rSrc, gSrc, bSrc);
wm->decomposeColor(*dst, rDst, gDst, bDst);
wm->decomposeColor(p->foreColor, rFor, gFor, bFor);
wm->decomposeColor(p->backColor, rBak, gBak, bBak);
*dst = wm->findBestColor((rSrc | rFor) & (~rSrc | rBak),
(gSrc | gFor) & (~gSrc | gBak),
(bSrc | bFor) & (~bSrc | bBak));
*dst = wm->findBestColor((rSrc | rFor) & (~rSrc | rBak),
(gSrc | gFor) & (~gSrc | gBak),
(bSrc | bFor) & (~bSrc | bBak));
}
} else {
*dst = src;
}
@ -284,20 +288,24 @@ void inkDrawPixel(int x, int y, int src, void *data) {
}
case kInkTypeNotCopy:
if (p->applyColor) {
// TODO: Improve the efficiency of this composition
byte rSrc, gSrc, bSrc;
byte rDst, gDst, bDst;
byte rFor, gFor, bFor;
byte rBak, gBak, bBak;
if (sizeof(T) == 1) {
*dst = src == 0x00 ? p->backColor : (src == 0xff ? p->foreColor : src);
} else {
// TODO: Improve the efficiency of this composition
byte rSrc, gSrc, bSrc;
byte rDst, gDst, bDst;
byte rFor, gFor, bFor;
byte rBak, gBak, bBak;
wm->decomposeColor(src, rSrc, gSrc, bSrc);
wm->decomposeColor(*dst, rDst, gDst, bDst);
wm->decomposeColor(p->foreColor, rFor, gFor, bFor);
wm->decomposeColor(p->backColor, rBak, gBak, bBak);
wm->decomposeColor(src, rSrc, gSrc, bSrc);
wm->decomposeColor(*dst, rDst, gDst, bDst);
wm->decomposeColor(p->foreColor, rFor, gFor, bFor);
wm->decomposeColor(p->backColor, rBak, gBak, bBak);
*dst = wm->findBestColor((~rSrc | rFor) & (rSrc | rBak),
(~gSrc | gFor) & (gSrc | gBak),
(~bSrc | bFor) & (bSrc | bBak));
*dst = wm->findBestColor((~rSrc | rFor) & (rSrc | rBak),
(~gSrc | gFor) & (gSrc | gBak),
(~bSrc | bFor) & (bSrc | bBak));
}
} else {
*dst = src;
}
@ -361,9 +369,9 @@ void inkDrawPixel(int x, int y, int src, void *data) {
Graphics::MacDrawPixPtr DirectorEngine::getInkDrawPixel() {
if (_pixelformat.bytesPerPixel == 1)
return &inkDrawPixel<byte *>;
return &inkDrawPixel<byte>;
else
return &inkDrawPixel<uint32 *>;
return &inkDrawPixel<uint32>;
}
void DirectorPlotData::setApplyColor() {