Unrolled most inner loop of ColorRasterizer::MergePlaneBuffersToCurrentLine to gain a total speed up of about 5 percent.
git-svn-id: file:///srv/svn/repos/haiku/trunk/current@11440 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -182,30 +182,75 @@ ColorRasterizer::MergePlaneBuffersToCurrentLine()
|
|||||||
|
|
||||||
// iterate over the three plane buffers
|
// iterate over the three plane buffers
|
||||||
for (int i = 0; i < fPlaneBufferSize; i ++) {
|
for (int i = 0; i < fPlaneBufferSize; i ++) {
|
||||||
const uchar values[3] = {
|
|
||||||
fPlaneBuffers[0][i],
|
|
||||||
fPlaneBuffers[1][i],
|
|
||||||
fPlaneBuffers[2][i]
|
|
||||||
};
|
|
||||||
|
|
||||||
int pixels = 8;
|
int pixels = 8;
|
||||||
if (remainingPixels < 8) {
|
if (remainingPixels < 8) {
|
||||||
pixels = remainingPixels;
|
pixels = remainingPixels;
|
||||||
}
|
}
|
||||||
remainingPixels -= pixels;
|
remainingPixels -= pixels;
|
||||||
|
|
||||||
|
if (remainingPixels >= 8) {
|
||||||
|
register const uchar
|
||||||
|
red = fPlaneBuffers[0][i],
|
||||||
|
green = fPlaneBuffers[1][i],
|
||||||
|
blue = fPlaneBuffers[2][i];
|
||||||
|
|
||||||
|
register uchar value = 0;
|
||||||
|
if (red & 0x80) value = 0x80;
|
||||||
|
if (red & 0x40) value |= 0x10;
|
||||||
|
if (red & 0x20) value |= 0x02;
|
||||||
|
|
||||||
|
if (green & 0x80) value |= 0x40;
|
||||||
|
if (green & 0x40) value |= 0x08;
|
||||||
|
if (green & 0x20) value |= 0x01;
|
||||||
|
|
||||||
|
if (blue & 0x80) value |= 0x20;
|
||||||
|
if (blue & 0x40) value |= 0x04;
|
||||||
|
|
||||||
|
*out++ = value;
|
||||||
|
|
||||||
|
value = 0;
|
||||||
|
if (blue & 0x20) value = 0x80;
|
||||||
|
if (blue & 0x10) value |= 0x10;
|
||||||
|
if (blue & 0x08) value |= 0x02;
|
||||||
|
|
||||||
|
if (red & 0x10) value |= 0x40;
|
||||||
|
if (red & 0x08) value |= 0x08;
|
||||||
|
if (red & 0x04) value |= 0x01;
|
||||||
|
|
||||||
|
if (green & 0x10) value |= 0x20;
|
||||||
|
if (green & 0x08) value |= 0x04;
|
||||||
|
*out++ = value;
|
||||||
|
|
||||||
|
value = 0;
|
||||||
|
if (green & 0x04) value = 0x80;
|
||||||
|
if (green & 0x02) value |= 0x10;
|
||||||
|
if (green & 0x01) value |= 0x02;
|
||||||
|
|
||||||
|
if (blue & 0x04) value |= 0x40;
|
||||||
|
if (blue & 0x02) value |= 0x08;
|
||||||
|
if (blue & 0x01) value |= 0x01;
|
||||||
|
|
||||||
|
if (red & 0x02) value |= 0x20;
|
||||||
|
if (red & 0x01) value |= 0x04;
|
||||||
|
*out++ = value;
|
||||||
|
|
||||||
|
} else {
|
||||||
|
register const uchar
|
||||||
|
red = fPlaneBuffers[0][i],
|
||||||
|
green = fPlaneBuffers[1][i],
|
||||||
|
blue = fPlaneBuffers[2][i];
|
||||||
// for each bit in the current byte of each plane
|
// for each bit in the current byte of each plane
|
||||||
uchar mask = 0x80;
|
uchar mask = 0x80;
|
||||||
for (; pixels > 0; pixels --) {
|
for (; pixels > 0; pixels --) {
|
||||||
int rgb = 0;
|
int rgb = 0;
|
||||||
|
|
||||||
if (values[0] & mask) {
|
if (red & mask) {
|
||||||
rgb |= kRed;
|
rgb |= kRed;
|
||||||
}
|
}
|
||||||
if (values[1] & mask) {
|
if (green & mask) {
|
||||||
rgb |= kGreen;
|
rgb |= kGreen;
|
||||||
}
|
}
|
||||||
if (values[2] & mask) {
|
if (blue & mask) {
|
||||||
rgb |= kBlue;
|
rgb |= kBlue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -229,6 +274,7 @@ ColorRasterizer::MergePlaneBuffersToCurrentLine()
|
|||||||
mask >>= 1;
|
mask >>= 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// write last output value
|
// write last output value
|
||||||
if (outMask != 0x80) {
|
if (outMask != 0x80) {
|
||||||
@@ -358,7 +404,6 @@ static void initializeBitmap(BBitmap *bitmap, int width, int height)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#if 1
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
const int width = 10;
|
const int width = 10;
|
||||||
@@ -379,10 +424,8 @@ int main()
|
|||||||
rasterizer.SetBitmap(0, 0, &bitmap, height);
|
rasterizer.SetBitmap(0, 0, &bitmap, height);
|
||||||
rasterizer.InitializeBuffer();
|
rasterizer.InitializeBuffer();
|
||||||
while (rasterizer.HasNextLine()) {
|
while (rasterizer.HasNextLine()) {
|
||||||
// const uchar *rowBuffer = (uchar*)
|
|
||||||
rasterizer.RasterizeNextLine();
|
rasterizer.RasterizeNextLine();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Reference in New Issue
Block a user