Get rid of some redundant code =)

This commit is contained in:
Pavel Krajcevski 2013-10-08 20:30:31 -04:00
parent f502e2bd0e
commit 9911d5edc5
2 changed files with 11 additions and 25 deletions

View file

@ -146,15 +146,7 @@ namespace PVRTCC {
}
}
Pixel result;
for(uint32 c = 0; c < 4; c++) {
uint16 va = static_cast<uint16>(pa.Component(c));
uint16 vb = static_cast<uint16>(pb.Component(c));
uint16 res = (va * (8 - lerpVal) + vb * lerpVal) / 8;
result.Component(c) = static_cast<uint8>(res);
}
Pixel result = (pa * (8 - lerpVal) + pb * lerpVal) / 8;
if(punchThrough) {
result.A() = 0;
}
@ -259,15 +251,7 @@ namespace PVRTCC {
const Pixel &pa = imgA(i, j);
const Pixel &pb = imgB(i, j);
Pixel result;
for(uint32 c = 0; c < 4; c++) {
uint16 va = static_cast<uint16>(pa.Component(c));
uint16 vb = static_cast<uint16>(pb.Component(c));
uint16 res = (va * (8 - lerpVal) + vb * lerpVal) / 8;
result.Component(c) = static_cast<uint8>(res);
}
Pixel result = (pa * (8 - lerpVal) + pb * lerpVal) / 8;
uint32 *outPixels = reinterpret_cast<uint32 *>(outBuf);
outPixels[(j * w) + i] = result.Pack();
}

View file

@ -196,15 +196,17 @@ void Image::BilinearUpscale(uint32 xtimes, uint32 ytimes,
for(uint32 c = 0; c < 4; c++) fpDepths[c] = xtimes + ytimes;
fp.ChangeBitDepth(fpDepths);
const FasTC::Pixel tl = topLeft * topLeftWeight;
const FasTC::Pixel tr = topRight * topRightWeight;
const FasTC::Pixel bl = bottomLeft * bottomLeftWeight;
const FasTC::Pixel br = bottomRight * bottomRightWeight;
const FasTC::Pixel sum = tl + tr + bl + br;
for(uint32 c = 0; c < 4; c++) {
const uint32 tl = topLeft.Component(c) * topLeftWeight;
const uint32 tr = topRight.Component(c) * topRightWeight;
const uint32 bl = bottomLeft.Component(c) * bottomLeftWeight;
const uint32 br = bottomRight.Component(c) * bottomRightWeight;
const uint32 sum = tl + tr + bl + br;
fp.Component(c) = sum & scaleMask;
p.Component(c) = sum / (xscale * yscale);
fp.Component(c) = sum.Component(c) & scaleMask;
}
p = sum / (xscale * yscale);
}
}