Making some headway on the cursor redraw problems when moving windows. Not quite fixed yet, though

git-svn-id: file:///srv/svn/repos/haiku/trunk/current@9027 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
DarkWyrm
2004-09-21 23:10:23 +00:00
parent 130b146f78
commit e841a5da12
3 changed files with 123 additions and 99 deletions
+1 -1
View File
@@ -199,7 +199,7 @@ void CursorHandler::DriverHide(void)
{ {
if(fDriverHidden) if(fDriverHidden)
return; return;
fDriverHidden=true; fDriverHidden=true;
if(!fCursor) if(!fCursor)
+121 -98
View File
@@ -138,7 +138,7 @@ void DisplayDriver::CopyRegion(BRegion *src, const BPoint &lefttop)
void DisplayDriver::DrawBitmap(BRegion *region, ServerBitmap *bitmap, const BRect &source, const BRect &dest, const DrawData *d) void DisplayDriver::DrawBitmap(BRegion *region, ServerBitmap *bitmap, const BRect &source, const BRect &dest, const DrawData *d)
{ {
Lock(); Lock();
FBBitmap frameBuffer; FBBitmap frameBuffer;
FBBitmap *bmp = &frameBuffer; FBBitmap *bmp = &frameBuffer;
@@ -300,7 +300,7 @@ void DisplayDriver::DrawBitmap(ServerBitmap *bmp, const BRect &src, const BRect
void DisplayDriver::CopyRegionList(BList* list, BList* pList, int32 rCount, BRegion* clipReg) void DisplayDriver::CopyRegionList(BList* list, BList* pList, int32 rCount, BRegion* clipReg)
{ {
Lock(); Lock();
FBBitmap frameBuffer; FBBitmap frameBuffer;
FBBitmap *bmp = &frameBuffer; FBBitmap *bmp = &frameBuffer;
@@ -310,7 +310,9 @@ void DisplayDriver::CopyRegionList(BList* list, BList* pList, int32 rCount, BReg
return; return;
} }
fCursorHandler->DriverHide();
uint32 bytesPerPixel = bmp->BytesPerRow() / bmp->Bounds().IntegerWidth(); uint32 bytesPerPixel = bmp->BytesPerRow() / bmp->Bounds().IntegerWidth();
BList rectList; BList rectList;
int32 i, k; int32 i, k;
@@ -318,95 +320,98 @@ void DisplayDriver::CopyRegionList(BList* list, BList* pList, int32 rCount, BReg
int32 Bwidth = bmp->Bounds().IntegerWidth() + 1; int32 Bwidth = bmp->Bounds().IntegerWidth() + 1;
int32 Bheight = bmp->Bounds().IntegerHeight() + 1; int32 Bheight = bmp->Bounds().IntegerHeight() + 1;
for(k=0; k < rCount; k++) for(k=0; k < rCount; k++)
{ {
BRegion *reg = (BRegion*)list->ItemAt(k); BRegion *reg = (BRegion*)list->ItemAt(k);
int32 rectCount = reg->CountRects(); int32 rectCount = reg->CountRects();
for(i=0; i < rectCount; i++){ for(i=0; i < rectCount; i++)
BRect r = reg->RectAt(i); {
uint8 *rectCopy; BRect r = reg->RectAt(i);
uint8 *srcAddress; uint8 *rectCopy;
uint8 *destAddress; uint8 *srcAddress;
int32 firstRow, lastRow; uint8 *destAddress;
int32 firstCol, lastCol; int32 firstRow, lastRow;
int32 copyLength; int32 firstCol, lastCol;
int32 copyRows; int32 copyLength;
int32 copyRows;
firstRow = (int32)(r.top < 0? 0: r.top);
lastRow = (int32)(r.bottom > (Bheight-1)? (Bheight-1): r.bottom); firstRow = (int32)(r.top < 0? 0: r.top);
firstCol = (int32)(r.left < 0? 0: r.left); lastRow = (int32)(r.bottom > (Bheight-1)? (Bheight-1): r.bottom);
lastCol = (int32)(r.right > (Bwidth-1)? (Bwidth-1): r.right); firstCol = (int32)(r.left < 0? 0: r.left);
copyLength = (lastCol - firstCol + 1) < 0? 0: (lastCol - firstCol + 1); lastCol = (int32)(r.right > (Bwidth-1)? (Bwidth-1): r.right);
copyRows = (lastRow - firstRow + 1) < 0? 0: (lastRow - firstRow + 1); copyLength = (lastCol - firstCol + 1) < 0? 0: (lastCol - firstCol + 1);
copyRows = (lastRow - firstRow + 1) < 0? 0: (lastRow - firstRow + 1);
rectCopy = (uint8*)malloc(copyLength * copyRows * bytesPerPixel);
rectCopy = (uint8*)malloc(copyLength * copyRows * bytesPerPixel);
srcAddress = bitmapBits
+ (((firstRow) * Bwidth + firstCol) * bytesPerPixel); srcAddress = bitmapBits + (((firstRow) * Bwidth + firstCol) * bytesPerPixel);
destAddress = rectCopy; destAddress = rectCopy;
for (int32 j = 0; j < copyRows; j++){ for (int32 j = 0; j < copyRows; j++)
uint8 *destRowAddress = destAddress + (j * copyLength * bytesPerPixel); {
uint8 *srcRowAddress = srcAddress + (j * Bwidth * bytesPerPixel); uint8 *destRowAddress = destAddress + (j * copyLength * bytesPerPixel);
memcpy(destRowAddress, srcRowAddress, copyLength * bytesPerPixel ); uint8 *srcRowAddress = srcAddress + (j * Bwidth * bytesPerPixel);
memcpy(destRowAddress, srcRowAddress, copyLength * bytesPerPixel );
}
rectList.AddItem(rectCopy);
} }
rectList.AddItem(rectCopy);
} }
}
int32 item = 0; int32 item = 0;
for(k=0; k < rCount; k++) for(k=0; k < rCount; k++)
{ {
BRegion *reg = (BRegion*)list->ItemAt(k); BRegion *reg = (BRegion*)list->ItemAt(k);
int32 rectCount = reg->CountRects(); int32 rectCount = reg->CountRects();
for(i=0; i < rectCount; i++){ for(i=0; i < rectCount; i++)
BRect r = reg->RectAt(i); {
uint8 *rectCopy; BRect r = reg->RectAt(i);
uint8 *srcAddress; uint8 *rectCopy;
uint8 *destAddress; uint8 *srcAddress;
int32 firstRow, lastRow; uint8 *destAddress;
int32 firstCol, lastCol; int32 firstRow, lastRow;
int32 copyLength, copyLength2; int32 firstCol, lastCol;
int32 copyRows, copyRows2; int32 copyLength, copyLength2;
int32 copyRows, copyRows2;
firstRow = (int32)(r.top < 0? 0: r.top);
lastRow = (int32)(r.bottom > (Bheight-1)? (Bheight-1): r.bottom); firstRow = (int32)(r.top < 0? 0: r.top);
firstCol = (int32)(r.left < 0? 0: r.left); lastRow = (int32)(r.bottom > (Bheight-1)? (Bheight-1): r.bottom);
lastCol = (int32)(r.right > (Bwidth-1)? (Bwidth-1): r.right); firstCol = (int32)(r.left < 0? 0: r.left);
copyLength = (lastCol - firstCol + 1) < 0? 0: (lastCol - firstCol + 1); lastCol = (int32)(r.right > (Bwidth-1)? (Bwidth-1): r.right);
copyRows = (lastRow - firstRow + 1) < 0? 0: (lastRow - firstRow + 1); copyLength = (lastCol - firstCol + 1) < 0? 0: (lastCol - firstCol + 1);
copyRows = (lastRow - firstRow + 1) < 0? 0: (lastRow - firstRow + 1);
rectCopy = (uint8*)rectList.ItemAt(item++);
rectCopy = (uint8*)rectList.ItemAt(item++);
srcAddress = rectCopy;
srcAddress = rectCopy;
r.Set(firstCol, firstRow, lastCol, lastRow);
r.OffsetBy( *((BPoint*)pList->ItemAt(k%rCount)) ); r.Set(firstCol, firstRow, lastCol, lastRow);
firstRow = (int32)(r.top < 0? 0: r.top); r.OffsetBy( *((BPoint*)pList->ItemAt(k%rCount)) );
lastRow = (int32)(r.bottom > (Bheight-1)? (Bheight-1): r.bottom); firstRow = (int32)(r.top < 0? 0: r.top);
firstCol = (int32)(r.left < 0? 0: r.left); lastRow = (int32)(r.bottom > (Bheight-1)? (Bheight-1): r.bottom);
lastCol = (int32)(r.right > (Bwidth-1)? (Bwidth-1): r.right); firstCol = (int32)(r.left < 0? 0: r.left);
copyLength2 = (lastCol - firstCol + 1) < 0? 0: (lastCol - firstCol + 1); lastCol = (int32)(r.right > (Bwidth-1)? (Bwidth-1): r.right);
copyRows2 = (lastRow - firstRow + 1) < 0? 0: (lastRow - firstRow + 1); copyLength2 = (lastCol - firstCol + 1) < 0? 0: (lastCol - firstCol + 1);
copyRows2 = (lastRow - firstRow + 1) < 0? 0: (lastRow - firstRow + 1);
destAddress = bitmapBits
+ (((firstRow) * Bwidth + firstCol) * bytesPerPixel); destAddress = bitmapBits + (((firstRow) * Bwidth + firstCol) * bytesPerPixel);
int32 minLength = copyLength < copyLength2? copyLength: copyLength2; int32 minLength = copyLength < copyLength2? copyLength: copyLength2;
int32 minRows = copyRows < copyRows2? copyRows: copyRows2; int32 minRows = copyRows < copyRows2? copyRows: copyRows2;
for (int32 j = 0; j < minRows; j++){ for (int32 j = 0; j < minRows; j++)
uint8 *destRowAddress = destAddress + (j * Bwidth * bytesPerPixel); {
uint8 *srcRowAddress = srcAddress + (j * copyLength * bytesPerPixel); uint8 *destRowAddress = destAddress + (j * Bwidth * bytesPerPixel);
memcpy(destRowAddress, srcRowAddress, minLength * bytesPerPixel ); uint8 *srcRowAddress = srcAddress + (j * copyLength * bytesPerPixel);
memcpy(destRowAddress, srcRowAddress, minLength * bytesPerPixel );
}
} }
} }
}
for(i=0; i < rectList.CountItems(); i++){ for(i=0; i < rectList.CountItems(); i++)
{
void *rectCopy; void *rectCopy;
rectCopy = rectList.ItemAt(i); rectCopy = rectList.ItemAt(i);
if (rectCopy) if (rectCopy)
@@ -414,6 +419,8 @@ void DisplayDriver::CopyRegionList(BList* list, BList* pList, int32 rCount, BReg
} }
rectList.MakeEmpty(); rectList.MakeEmpty();
fCursorHandler->DriverShow();
BRect inval(bmp->Bounds()); BRect inval(bmp->Bounds());
ReleaseBuffer(); ReleaseBuffer();
Unlock(); Unlock();
@@ -451,8 +458,14 @@ void DisplayDriver::DrawString(const char *string, const int32 &length, const BP
Lock(); Lock();
// TODO: Test for cursor intersection in DisplayDriver::DrawString // TODO: properly calculate intersecting rectangle with cursor in DisplayDriver::DrawString
fCursorHandler->DriverHide();
// Rough guesstimate for size
BRect intersection(pt.x,pt.x,pt.y,pt.y);
intersection.top-=d->font.Size()*1.5;
intersection.right+=d->font.Size()*1.5*length;
if(fCursorHandler->IntersectsCursor(intersection))
fCursorHandler->DriverHide();
BPoint point(pt); BPoint point(pt);
@@ -864,8 +877,9 @@ void DisplayDriver::FillArc(const BRect &r, const float &angle, const float &spa
// Watch out for bozos giving us whacko spans // Watch out for bozos giving us whacko spans
if ( (span >= 360) || (span <= -360) ) if ( (span >= 360) || (span <= -360) )
{ {
FillEllipse(r,color); FillEllipse(r,color);
return; fCursorHandler->DriverShow();
return;
} }
Lock(); Lock();
@@ -1229,8 +1243,9 @@ void DisplayDriver::FillArc(const BRect &r, const float &angle, const float &spa
// Watch out for bozos giving us whacko spans // Watch out for bozos giving us whacko spans
if ( (span >= 360) || (span <= -360) ) if ( (span >= 360) || (span <= -360) )
{ {
FillEllipse(r,d); FillEllipse(r,d);
return; fCursorHandler->DriverShow();
return;
} }
Lock(); Lock();
@@ -1932,6 +1947,7 @@ void DisplayDriver::FillPolygon(BPoint *ptlist, int32 numpts, const BRect &bound
{ {
printf("ERROR: Insufficient memory allocated to segment array\n"); printf("ERROR: Insufficient memory allocated to segment array\n");
delete[] segmentArray; delete[] segmentArray;
fCursorHandler->DriverShow();
Unlock(); Unlock();
return; return;
} }
@@ -2110,10 +2126,8 @@ void DisplayDriver::FillRect(const BRect &r, const RGBColor &color)
{ {
Lock(); Lock();
if(fCursorHandler->IntersectsCursor(r)) if(fCursorHandler->IntersectsCursor(r))
{
debugger("");
fCursorHandler->DriverHide(); fCursorHandler->DriverHide();
}
FillSolidRect(r,color); FillSolidRect(r,color);
fCursorHandler->DriverShow(); fCursorHandler->DriverShow();
Unlock(); Unlock();
@@ -2364,6 +2378,7 @@ void DisplayDriver::FillTriangle(BPoint *pts, const BRect &bounds, const RGBColo
start.x=MIN(first.x,MIN(second.x,third.x)); start.x=MIN(first.x,MIN(second.x,third.x));
end.x=MAX(first.x,MAX(second.x,third.x)); end.x=MAX(first.x,MAX(second.x,third.x));
StrokeSolidLine(ROUND(start.x), ROUND(start.y), ROUND(end.x), ROUND(start.y), color); StrokeSolidLine(ROUND(start.x), ROUND(start.y), ROUND(end.x), ROUND(start.y), color);
fCursorHandler->DriverShow();
return; return;
} }
@@ -2378,6 +2393,7 @@ void DisplayDriver::FillTriangle(BPoint *pts, const BRect &bounds, const RGBColo
StrokeSolidLine(ROUND(first.x), ROUND(first.y), ROUND(second.x), ROUND(first.y), color); StrokeSolidLine(ROUND(first.x), ROUND(first.y), ROUND(second.x), ROUND(first.y), color);
for(i=(int32)first.y+1; i<=third.y; i++) for(i=(int32)first.y+1; i<=third.y; i++)
StrokeSolidLine(ROUND(lineA.GetX(i)), i, ROUND(lineB.GetX(i)), i, color); StrokeSolidLine(ROUND(lineA.GetX(i)), i, ROUND(lineB.GetX(i)), i, color);
fCursorHandler->DriverShow();
return; return;
} }
@@ -2390,6 +2406,7 @@ void DisplayDriver::FillTriangle(BPoint *pts, const BRect &bounds, const RGBColo
StrokeSolidLine(ROUND(second.x), ROUND(second.y), ROUND(third.x), ROUND(second.y), color); StrokeSolidLine(ROUND(second.x), ROUND(second.y), ROUND(third.x), ROUND(second.y), color);
for(i=(int32)first.y; i<third.y; i++) for(i=(int32)first.y; i<third.y; i++)
StrokeSolidLine(ROUND(lineA.GetX(i)), i, ROUND(lineB.GetX(i)), i, color); StrokeSolidLine(ROUND(lineA.GetX(i)), i, ROUND(lineB.GetX(i)), i, color);
fCursorHandler->DriverShow();
return; return;
} }
@@ -2430,6 +2447,7 @@ void DisplayDriver::FillTriangle(BPoint *pts, const BRect &bounds, const DrawDat
// For now, cop out and use FillPolygon // For now, cop out and use FillPolygon
// Need to investigate if Triangle specific code would save processing time // Need to investigate if Triangle specific code would save processing time
FillPolygon(pts,3,bounds,d); FillPolygon(pts,3,bounds,d);
fCursorHandler->DriverShow();
} }
else else
{ {
@@ -2478,6 +2496,7 @@ void DisplayDriver::FillTriangle(BPoint *pts, const BRect &bounds, const DrawDat
start.x=MIN(first.x,MIN(second.x,third.x)); start.x=MIN(first.x,MIN(second.x,third.x));
end.x=MAX(first.x,MAX(second.x,third.x)); end.x=MAX(first.x,MAX(second.x,third.x));
StrokePatternLine(ROUND(start.x), ROUND(start.y), ROUND(end.x), ROUND(start.y), d); StrokePatternLine(ROUND(start.x), ROUND(start.y), ROUND(end.x), ROUND(start.y), d);
fCursorHandler->DriverShow();
return; return;
} }
@@ -2492,6 +2511,7 @@ void DisplayDriver::FillTriangle(BPoint *pts, const BRect &bounds, const DrawDat
StrokePatternLine(ROUND(first.x), ROUND(first.y), ROUND(second.x), ROUND(first.y), d); StrokePatternLine(ROUND(first.x), ROUND(first.y), ROUND(second.x), ROUND(first.y), d);
for(i=(int32)first.y+1; i<=third.y; i++) for(i=(int32)first.y+1; i<=third.y; i++)
StrokePatternLine(ROUND(lineA.GetX(i)), i, ROUND(lineB.GetX(i)), i, d); StrokePatternLine(ROUND(lineA.GetX(i)), i, ROUND(lineB.GetX(i)), i, d);
fCursorHandler->DriverShow();
return; return;
} }
@@ -2504,6 +2524,7 @@ void DisplayDriver::FillTriangle(BPoint *pts, const BRect &bounds, const DrawDat
StrokePatternLine(ROUND(second.x), ROUND(second.y), ROUND(third.x), ROUND(second.y), d); StrokePatternLine(ROUND(second.x), ROUND(second.y), ROUND(third.x), ROUND(second.y), d);
for(i=(int32)first.y; i<third.y; i++) for(i=(int32)first.y; i<third.y; i++)
StrokePatternLine(ROUND(lineA.GetX(i)), i, ROUND(lineB.GetX(i)), i, d); StrokePatternLine(ROUND(lineA.GetX(i)), i, ROUND(lineB.GetX(i)), i, d);
fCursorHandler->DriverShow();
return; return;
} }
@@ -2660,8 +2681,9 @@ void DisplayDriver::StrokeArc(const BRect &r, const float &angle, const float &s
// Watch out for bozos giving us whacko spans // Watch out for bozos giving us whacko spans
if ( (span >= 360) || (span <= -360) ) if ( (span >= 360) || (span <= -360) )
{ {
StrokeEllipse(r,color); StrokeEllipse(r,color);
return; fCursorHandler->DriverShow();
return;
} }
if ( span > 0 ) if ( span > 0 )
@@ -2827,8 +2849,9 @@ void DisplayDriver::StrokeArc(const BRect &r, const float &angle, const float &s
// Watch out for bozos giving us whacko spans // Watch out for bozos giving us whacko spans
if ( (span >= 360) || (span <= -360) ) if ( (span >= 360) || (span <= -360) )
{ {
StrokeEllipse(r,d); StrokeEllipse(r,d);
return; fCursorHandler->DriverShow();
return;
} }
if ( span > 0 ) if ( span > 0 )
+1
View File
@@ -13,6 +13,7 @@ SharedLibrary appserver :
BGet++.cpp BGet++.cpp
BitmapManager.cpp BitmapManager.cpp
ColorSet.cpp ColorSet.cpp
CursorHandler.cpp
Decorator.cpp Decorator.cpp
DisplayDriver.cpp DisplayDriver.cpp
DisplaySupport.cpp DisplaySupport.cpp