refactoring, speedup by decoupling back to front transferes from drawing and usage of special memcpy routine, minor speedups in Painter
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@12437 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -523,68 +523,8 @@ AccelerantHWInterface::BackBuffer() const
|
||||
void
|
||||
AccelerantHWInterface::_DrawCursor(BRect area) const
|
||||
{
|
||||
|
||||
BRect cf = _CursorFrame();
|
||||
if (cf.IsValid() && area.Intersects(cf)) {
|
||||
// clip to common area
|
||||
area = area & cf;
|
||||
|
||||
int32 left = (int32)floorf(area.left);
|
||||
int32 top = (int32)floorf(area.top);
|
||||
int32 right = (int32)ceilf(area.right);
|
||||
int32 bottom = (int32)ceilf(area.bottom);
|
||||
int32 width = right - left + 1;
|
||||
int32 height = bottom - top + 1;
|
||||
|
||||
// make a bitmap from the backbuffer
|
||||
// that has the cursor blended on top of it
|
||||
|
||||
// blending buffer
|
||||
uint8* buffer = new uint8[width * height * 4];
|
||||
|
||||
// offset into back buffer
|
||||
uint8* src = (uint8*)fBackBuffer->Bits();
|
||||
uint32 srcBPR = fBackBuffer->BytesPerRow();
|
||||
src += top * srcBPR + left * 4;
|
||||
|
||||
// offset into cursor bitmap
|
||||
uint8* crs = (uint8*)fCursor->Bits();
|
||||
uint32 crsBPR = fCursor->BytesPerRow();
|
||||
// since area is clipped to cf,
|
||||
// the diff between top and cf.top is always positive,
|
||||
// same for diff between left and cf.left
|
||||
crs += (top - (int32)floorf(cf.top)) * crsBPR
|
||||
+ (left - (int32)floorf(cf.left)) * 4;
|
||||
|
||||
uint8* dst = buffer;
|
||||
|
||||
// blending
|
||||
for (int32 y = top; y <= bottom; y++) {
|
||||
uint8* s = src;
|
||||
uint8* c = crs;
|
||||
uint8* d = dst;
|
||||
for (int32 x = left; x <= right; x++) {
|
||||
// assume backbuffer alpha = 255
|
||||
// TODO: it appears alpha in cursor us upside down
|
||||
uint8 a = 255 - c[3];
|
||||
d[0] = (((s[0] - c[0]) * a) + (c[0] << 8)) >> 8;
|
||||
d[1] = (((s[1] - c[1]) * a) + (c[1] << 8)) >> 8;
|
||||
d[2] = (((s[2] - c[2]) * a) + (c[2] << 8)) >> 8;
|
||||
d[3] = 255;
|
||||
s += 4;
|
||||
c += 4;
|
||||
d += 4;
|
||||
}
|
||||
crs += crsBPR;
|
||||
src += srcBPR;
|
||||
dst += width * 4;
|
||||
}
|
||||
|
||||
// copy result to front buffer
|
||||
_CopyToFront(buffer, width * 4, left, top, right, bottom);
|
||||
|
||||
delete[] buffer;
|
||||
}
|
||||
|
||||
// use the default implementation for now,
|
||||
// until we have a hardware cursor
|
||||
HWInterface::_DrawCursor(area);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user