I have no idea anymore what I was messing with here, but it looks interesting.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@25147 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Stephan Aßmus
2008-04-25 10:47:55 +00:00
parent e7187dd0f0
commit 0a6ef8179c
+62 -18
View File
@@ -80,6 +80,7 @@ Window::Window(const char* title)
// destructor
Window::~Window()
{
fInterface.Shutdown();
fDesktop->Lock();
fDesktop->Quit();
}
@@ -224,27 +225,70 @@ union pixel2 {
uint8 data8[8];
};
// gfxcpy32
// * numBytes is expected to be a multiple of 4
inline
void
gfxcpy32(uint8* dst, uint8* src, int32 numBytes)
{
uint64* d64 = (uint64*)dst;
uint64* s64 = (uint64*)src;
int32 numBytesStart = numBytes;
while (numBytes >= 32) {
*d64++ = *s64++;
*d64++ = *s64++;
*d64++ = *s64++;
*d64++ = *s64++;
numBytes -= 32;
}
if (numBytes >= 16) {
*d64++ = *s64++;
*d64++ = *s64++;
numBytes -= 16;
}
if (numBytes >= 8) {
*d64++ = *s64++;
numBytes -= 8;
}
if (numBytes == 4) {
uint32* d32 = (uint32*)(dst + numBytesStart - numBytes);
uint32* s32 = (uint32*)(src + numBytesStart - numBytes);
*d32 = *s32;
}
}
void
blend_line_64(uint8* buffer, int32 pixels, uint8 r, uint8 g, uint8 b, uint8 a)
{
pixel2 p;
pixels /= 2;
r = (r * a) >> 8;
g = (g * a) >> 8;
b = (b * a) >> 8;
a = 255 - a;
uint8 tempBuffer[pixels * 8];
uint8* t = tempBuffer;
uint8* s = buffer;
for (int32 i = 0; i < pixels; i++) {
p.data64 = *(uint64*)buffer;
p.data64 = *(uint64*)s;
p.data8[0] = ((b - p.data8[0]) * a + (p.data8[0] << 8)) >> 8;
p.data8[1] = ((g - p.data8[1]) * a + (p.data8[1] << 8)) >> 8;
p.data8[2] = ((r - p.data8[2]) * a + (p.data8[2] << 8)) >> 8;
p.data8[3] = a;
t[0] = ((p.data8[0] * a) >> 8) + b;
t[1] = ((p.data8[1] * a) >> 8) + g;
t[2] = ((p.data8[2] * a) >> 8) + r;
p.data8[4] = ((b - p.data8[4]) * a + (p.data8[4] << 8)) >> 8;
p.data8[5] = ((g - p.data8[5]) * a + (p.data8[5] << 8)) >> 8;
p.data8[6] = ((r - p.data8[6]) * a + (p.data8[6] << 8)) >> 8;
p.data8[7] = a;
t[4] = ((p.data8[4] * a) >> 8) + b;
t[5] = ((p.data8[5] * a) >> 8) + g;
t[6] = ((p.data8[6] * a) >> 8) + r;
*((uint64*)buffer) = p.data64;
buffer += 8;
t += 8;
s += 8;
}
gfxcpy32(buffer, tempBuffer, pixels * 8);
}
void
test2(uint8* buffer, uint32 bpr)
@@ -267,9 +311,9 @@ test2(uint8* buffer, uint32 bpr)
blend_line_32(handle, 512, 255, 0, 0, 20);
handle += bpr;
}
// }
// }*/
bigtime_t start64 = system_time();*/
bigtime_t start64 = system_time();
// for (int32 x = 0; x < 10; x++) {
handle = buffer;
for (int32 i = 0; i < 640; i++) {
@@ -278,10 +322,10 @@ test2(uint8* buffer, uint32 bpr)
}
// }
/* bigtime_t finish = system_time();
printf("8: %lld\n", start32 - start8);
printf("32: %lld\n", start64 - start32);
printf("64: %lld\n", finish - start64);*/
bigtime_t finish = system_time();
// printf("8: %lld\n", start32 - start8);
// printf("32: %lld\n", start64 - start32);
printf("blend 64: %lld\n", finish - start64);
}
// #pragma mark -
@@ -301,7 +345,7 @@ Window::DirectConnected(direct_buffer_info* info)
case B_DIRECT_MODIFY:
fBuffer.SetTo(info);
fDesktop->SetOffset(info->window_bounds.left, info->window_bounds.top);
test1((uint8*)info->bits, info->bytes_per_row);
test2((uint8*)info->bits, info->bytes_per_row);
break;
case B_DIRECT_STOP:
fBuffer.SetTo(NULL);