* ReadBitmap() could mess up the software cursor locking, since it

used the BRect version of HideSoftwareCursor() but then called
  ShowSoftwareCursor() unconditionally.
* Renamed Hide/ShowSoftwareCursor() to Hide/ShowFloatingOverlays().
* Removed no longer needed FontLocker.
* Implemented AutoFloatingOverlaysHider and got rid of a lot of
  code duplication this way.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@24095 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Stephan Aßmus
2008-02-24 15:31:12 +00:00
parent 60e1cfbfbb
commit b1ab9b5f07
3 changed files with 86 additions and 117 deletions
+49 -87
View File
@@ -55,29 +55,35 @@ extend_by_stroke_width(BRect& rect, float penSize)
} }
class FontLocker { class AutoFloatingOverlaysHider {
public: public:
FontLocker(const DrawState* context) AutoFloatingOverlaysHider(HWInterface* interface, const BRect& area)
: : fInterface(interface)
fFont(&context->Font()) , fHidden(interface->HideFloatingOverlays(area))
{ {
fFont->Lock();
} }
FontLocker(const ServerFont* font) AutoFloatingOverlaysHider(HWInterface* interface)
: : fInterface(interface)
fFont(font) , fHidden(fInterface->HideFloatingOverlays())
{ {
fFont->Lock();
} }
~FontLocker() ~AutoFloatingOverlaysHider()
{ {
fFont->Unlock(); if (fHidden)
fInterface->ShowFloatingOverlays();
}
bool WasHidden() const
{
return fHidden;
} }
private: private:
const ServerFont* fFont; HWInterface* fInterface;
bool fHidden;
}; };
@@ -395,7 +401,8 @@ DrawingEngine::CopyRegion(/*const*/ BRegion* region,
BRect frame = region->Frame(); BRect frame = region->Frame();
frame = frame | frame.OffsetByCopy(xOffset, yOffset); frame = frame | frame.OffsetByCopy(xOffset, yOffset);
bool cursorTouched = fGraphicsCard->HideSoftwareCursor(frame);
AutoFloatingOverlaysHider _(fGraphicsCard, frame);
int32 count = region->CountRects(); int32 count = region->CountRects();
@@ -498,9 +505,6 @@ DrawingEngine::CopyRegion(/*const*/ BRegion* region,
fGraphicsCard->CopyRegion(sortedRectList, count, xOffset, yOffset); fGraphicsCard->CopyRegion(sortedRectList, count, xOffset, yOffset);
delete[] sortedRectList; delete[] sortedRectList;
if (cursorTouched)
fGraphicsCard->ShowSoftwareCursor();
} }
// InvertRect // InvertRect
@@ -512,7 +516,7 @@ DrawingEngine::InvertRect(BRect r)
make_rect_valid(r); make_rect_valid(r);
r = fPainter->ClipRect(r); r = fPainter->ClipRect(r);
if (r.IsValid()) { if (r.IsValid()) {
bool cursorTouched = fGraphicsCard->HideSoftwareCursor(r); AutoFloatingOverlaysHider _(fGraphicsCard, r);
// try hardware optimized version first // try hardware optimized version first
if (fAvailableHWAccleration & HW_ACC_INVERT_REGION) { if (fAvailableHWAccleration & HW_ACC_INVERT_REGION) {
@@ -524,9 +528,6 @@ DrawingEngine::InvertRect(BRect r)
fGraphicsCard->Invalidate(r); fGraphicsCard->Invalidate(r);
} }
if (cursorTouched)
fGraphicsCard->ShowSoftwareCursor();
} }
} }
@@ -539,13 +540,11 @@ DrawingEngine::DrawBitmap(ServerBitmap *bitmap,
BRect clipped = fPainter->ClipRect(dest); BRect clipped = fPainter->ClipRect(dest);
if (clipped.IsValid()) { if (clipped.IsValid()) {
bool cursorTouched = fGraphicsCard->HideSoftwareCursor(clipped); AutoFloatingOverlaysHider _(fGraphicsCard, clipped);
fPainter->DrawBitmap(bitmap, source, dest); fPainter->DrawBitmap(bitmap, source, dest);
fGraphicsCard->Invalidate(clipped); fGraphicsCard->Invalidate(clipped);
if (cursorTouched)
fGraphicsCard->ShowSoftwareCursor();
} }
} }
@@ -562,7 +561,7 @@ DrawingEngine::DrawArc(BRect r, const float &angle,
extend_by_stroke_width(clipped, fPainter->PenSize()); extend_by_stroke_width(clipped, fPainter->PenSize());
clipped = fPainter->ClipRect(r); clipped = fPainter->ClipRect(r);
if (clipped.IsValid()) { if (clipped.IsValid()) {
bool cursorTouched = fGraphicsCard->HideSoftwareCursor(clipped); AutoFloatingOverlaysHider _(fGraphicsCard, clipped);
float xRadius = r.Width() / 2.0; float xRadius = r.Width() / 2.0;
float yRadius = r.Height() / 2.0; float yRadius = r.Height() / 2.0;
@@ -575,8 +574,6 @@ DrawingEngine::DrawArc(BRect r, const float &angle,
fPainter->StrokeArc(center, xRadius, yRadius, angle, span); fPainter->StrokeArc(center, xRadius, yRadius, angle, span);
fGraphicsCard->Invalidate(clipped); fGraphicsCard->Invalidate(clipped);
if (cursorTouched)
fGraphicsCard->ShowSoftwareCursor();
} }
} }
@@ -587,12 +584,12 @@ DrawingEngine::DrawBezier(BPoint *pts, bool filled)
CRASH_IF_NOT_LOCKED CRASH_IF_NOT_LOCKED
// TODO: figure out bounds and hide cursor depending on that // TODO: figure out bounds and hide cursor depending on that
fGraphicsCard->HideSoftwareCursor(); fGraphicsCard->HideFloatingOverlays();
BRect touched = fPainter->DrawBezier(pts, filled); BRect touched = fPainter->DrawBezier(pts, filled);
fGraphicsCard->Invalidate(touched); fGraphicsCard->Invalidate(touched);
fGraphicsCard->ShowSoftwareCursor(); fGraphicsCard->ShowFloatingOverlays();
} }
// DrawEllipse // DrawEllipse
@@ -616,13 +613,11 @@ DrawingEngine::DrawEllipse(BRect r, bool filled)
clipped = fPainter->ClipRect(clipped); clipped = fPainter->ClipRect(clipped);
if (clipped.IsValid()) { if (clipped.IsValid()) {
bool cursorTouched = fGraphicsCard->HideSoftwareCursor(clipped); AutoFloatingOverlaysHider _(fGraphicsCard, clipped);
fPainter->DrawEllipse(r, filled); fPainter->DrawEllipse(r, filled);
fGraphicsCard->Invalidate(clipped); fGraphicsCard->Invalidate(clipped);
if (cursorTouched)
fGraphicsCard->ShowSoftwareCursor();
} }
} }
@@ -638,13 +633,11 @@ DrawingEngine::DrawPolygon(BPoint* ptlist, int32 numpts,
extend_by_stroke_width(bounds, fPainter->PenSize()); extend_by_stroke_width(bounds, fPainter->PenSize());
bounds = fPainter->ClipRect(bounds); bounds = fPainter->ClipRect(bounds);
if (bounds.IsValid()) { if (bounds.IsValid()) {
bool cursorTouched = fGraphicsCard->HideSoftwareCursor(bounds); AutoFloatingOverlaysHider _(fGraphicsCard, bounds);
fPainter->DrawPolygon(ptlist, numpts, filled, closed); fPainter->DrawPolygon(ptlist, numpts, filled, closed);
fGraphicsCard->Invalidate(bounds); fGraphicsCard->Invalidate(bounds);
if (cursorTouched)
fGraphicsCard->ShowSoftwareCursor();
} }
} }
@@ -669,7 +662,7 @@ DrawingEngine::StrokeLine(const BPoint &start, const BPoint &end,
BRect touched(start, end); BRect touched(start, end);
make_rect_valid(touched); make_rect_valid(touched);
touched = fPainter->ClipRect(touched); touched = fPainter->ClipRect(touched);
bool cursorTouched = fGraphicsCard->HideSoftwareCursor(touched); AutoFloatingOverlaysHider _(fGraphicsCard, touched);
if (!fPainter->StraightLine(start, end, color)) { if (!fPainter->StraightLine(start, end, color)) {
fPainter->SetHighColor(color); fPainter->SetHighColor(color);
@@ -678,8 +671,6 @@ DrawingEngine::StrokeLine(const BPoint &start, const BPoint &end,
} }
fGraphicsCard->Invalidate(touched); fGraphicsCard->Invalidate(touched);
if (cursorTouched)
fGraphicsCard->ShowSoftwareCursor();
} }
// this function is used to draw a one pixel wide rect // this function is used to draw a one pixel wide rect
@@ -691,13 +682,11 @@ DrawingEngine::StrokeRect(BRect r, const rgb_color &color)
make_rect_valid(r); make_rect_valid(r);
BRect clipped = fPainter->ClipRect(r); BRect clipped = fPainter->ClipRect(r);
if (clipped.IsValid()) { if (clipped.IsValid()) {
bool cursorTouched = fGraphicsCard->HideSoftwareCursor(clipped); AutoFloatingOverlaysHider _(fGraphicsCard, clipped);
fPainter->StrokeRect(r, color); fPainter->StrokeRect(r, color);
fGraphicsCard->Invalidate(clipped); fGraphicsCard->Invalidate(clipped);
if (cursorTouched)
fGraphicsCard->ShowSoftwareCursor();
} }
} }
@@ -713,7 +702,7 @@ DrawingEngine::FillRect(BRect r, const rgb_color& color)
make_rect_valid(r); make_rect_valid(r);
r = fPainter->ClipRect(r); r = fPainter->ClipRect(r);
if (r.IsValid()) { if (r.IsValid()) {
bool cursorTouched = fGraphicsCard->HideSoftwareCursor(r); AutoFloatingOverlaysHider overlaysHider(fGraphicsCard, r);
// try hardware optimized version first // try hardware optimized version first
if (fAvailableHWAccleration & HW_ACC_FILL_REGION) { if (fAvailableHWAccleration & HW_ACC_FILL_REGION) {
@@ -721,15 +710,12 @@ DrawingEngine::FillRect(BRect r, const rgb_color& color)
region.IntersectWith(fPainter->ClippingRegion()); region.IntersectWith(fPainter->ClippingRegion());
fGraphicsCard->FillRegion(region, color, fGraphicsCard->FillRegion(region, color,
fSuspendSyncLevel == 0 fSuspendSyncLevel == 0
|| cursorTouched); || overlaysHider.WasHidden());
} else { } else {
fPainter->FillRect(r, color); fPainter->FillRect(r, color);
fGraphicsCard->Invalidate(r); fGraphicsCard->Invalidate(r);
} }
if (cursorTouched)
fGraphicsCard->ShowSoftwareCursor();
} }
} }
@@ -755,13 +741,13 @@ DrawingEngine::FillRegion(BRegion& r, const rgb_color& color)
return; return;
} }
bool cursorTouched = fGraphicsCard->HideSoftwareCursor(frame); AutoFloatingOverlaysHider overlaysHider(fGraphicsCard, frame);
// try hardware optimized version first // try hardware optimized version first
if ((fAvailableHWAccleration & HW_ACC_FILL_REGION) != 0 if ((fAvailableHWAccleration & HW_ACC_FILL_REGION) != 0
&& frame.Width() * frame.Height() > 100) { && frame.Width() * frame.Height() > 100) {
fGraphicsCard->FillRegion(r, color, fSuspendSyncLevel == 0 fGraphicsCard->FillRegion(r, color, fSuspendSyncLevel == 0
|| cursorTouched); || overlaysHider.WasHidden());
} else { } else {
int32 count = r.CountRects(); int32 count = r.CountRects();
for (int32 i = 0; i < count; i++) { for (int32 i = 0; i < count; i++) {
@@ -770,9 +756,6 @@ DrawingEngine::FillRegion(BRegion& r, const rgb_color& color)
fGraphicsCard->Invalidate(frame); fGraphicsCard->Invalidate(frame);
} }
if (cursorTouched)
fGraphicsCard->ShowSoftwareCursor();
} }
// #pragma mark - DrawState // #pragma mark - DrawState
@@ -788,14 +771,11 @@ DrawingEngine::StrokeRect(BRect r)
extend_by_stroke_width(clipped, fPainter->PenSize()); extend_by_stroke_width(clipped, fPainter->PenSize());
clipped = fPainter->ClipRect(clipped); clipped = fPainter->ClipRect(clipped);
if (clipped.IsValid()) { if (clipped.IsValid()) {
AutoFloatingOverlaysHider _(fGraphicsCard, clipped);
bool cursorTouched = fGraphicsCard->HideSoftwareCursor(clipped);
fPainter->StrokeRect(r); fPainter->StrokeRect(r);
fGraphicsCard->Invalidate(clipped); fGraphicsCard->Invalidate(clipped);
if (cursorTouched)
fGraphicsCard->ShowSoftwareCursor();
} }
} }
@@ -808,7 +788,7 @@ DrawingEngine::FillRect(BRect r)
make_rect_valid(r); make_rect_valid(r);
r = fPainter->AlignAndClipRect(r); r = fPainter->AlignAndClipRect(r);
if (r.IsValid()) { if (r.IsValid()) {
bool cursorTouched = fGraphicsCard->HideSoftwareCursor(r); AutoFloatingOverlaysHider overlaysHider(fGraphicsCard, r);
bool doInSoftware = true; bool doInSoftware = true;
if ((r.Width() + 1) * (r.Height() + 1) > 100.0) { if ((r.Width() + 1) * (r.Height() + 1) > 100.0) {
@@ -822,7 +802,7 @@ DrawingEngine::FillRect(BRect r)
region.IntersectWith(fPainter->ClippingRegion()); region.IntersectWith(fPainter->ClippingRegion());
fGraphicsCard->FillRegion(region, fPainter->HighColor(), fGraphicsCard->FillRegion(region, fPainter->HighColor(),
fSuspendSyncLevel == 0 fSuspendSyncLevel == 0
|| cursorTouched); || overlaysHider.WasHidden());
doInSoftware = false; doInSoftware = false;
} else if (fPainter->Pattern() == B_SOLID_LOW } else if (fPainter->Pattern() == B_SOLID_LOW
&& fPainter->DrawingMode() == B_OP_COPY) { && fPainter->DrawingMode() == B_OP_COPY) {
@@ -830,7 +810,7 @@ DrawingEngine::FillRect(BRect r)
region.IntersectWith(fPainter->ClippingRegion()); region.IntersectWith(fPainter->ClippingRegion());
fGraphicsCard->FillRegion(region, fPainter->LowColor(), fGraphicsCard->FillRegion(region, fPainter->LowColor(),
fSuspendSyncLevel == 0 fSuspendSyncLevel == 0
|| cursorTouched); || overlaysHider.WasHidden());
doInSoftware = false; doInSoftware = false;
} }
} }
@@ -850,9 +830,6 @@ DrawingEngine::FillRect(BRect r)
fGraphicsCard->Invalidate(r); fGraphicsCard->Invalidate(r);
} }
if (cursorTouched)
fGraphicsCard->ShowSoftwareCursor();
} }
} }
@@ -864,7 +841,7 @@ DrawingEngine::FillRegion(BRegion& r)
BRect clipped = fPainter->ClipRect(r.Frame()); BRect clipped = fPainter->ClipRect(r.Frame());
if (clipped.IsValid()) { if (clipped.IsValid()) {
bool cursorTouched = fGraphicsCard->HideSoftwareCursor(clipped); AutoFloatingOverlaysHider overlaysHider(fGraphicsCard, clipped);
bool doInSoftware = true; bool doInSoftware = true;
// try hardware optimized version first // try hardware optimized version first
@@ -875,14 +852,14 @@ DrawingEngine::FillRegion(BRegion& r)
r.IntersectWith(fPainter->ClippingRegion()); r.IntersectWith(fPainter->ClippingRegion());
fGraphicsCard->FillRegion(r, fPainter->HighColor(), fGraphicsCard->FillRegion(r, fPainter->HighColor(),
fSuspendSyncLevel == 0 fSuspendSyncLevel == 0
|| cursorTouched); || overlaysHider.WasHidden());
doInSoftware = false; doInSoftware = false;
} else if (fPainter->Pattern() == B_SOLID_LOW } else if (fPainter->Pattern() == B_SOLID_LOW
&& fPainter->DrawingMode() == B_OP_COPY) { && fPainter->DrawingMode() == B_OP_COPY) {
r.IntersectWith(fPainter->ClippingRegion()); r.IntersectWith(fPainter->ClippingRegion());
fGraphicsCard->FillRegion(r, fPainter->LowColor(), fGraphicsCard->FillRegion(r, fPainter->LowColor(),
fSuspendSyncLevel == 0 fSuspendSyncLevel == 0
|| cursorTouched); || overlaysHider.WasHidden());
doInSoftware = false; doInSoftware = false;
} }
} }
@@ -906,9 +883,6 @@ DrawingEngine::FillRegion(BRegion& r)
fGraphicsCard->Invalidate(touched); fGraphicsCard->Invalidate(touched);
} }
if (cursorTouched)
fGraphicsCard->ShowSoftwareCursor();
} }
} }
@@ -929,14 +903,12 @@ DrawingEngine::DrawRoundRect(BRect r, float xrad, float yrad, bool filled)
clipped.bottom = ceilf(clipped.bottom); clipped.bottom = ceilf(clipped.bottom);
if (clipped.IsValid()) { if (clipped.IsValid()) {
bool cursorTouched = fGraphicsCard->HideSoftwareCursor(clipped); AutoFloatingOverlaysHider _(fGraphicsCard, clipped);
BRect touched = filled ? fPainter->FillRoundRect(r, xrad, yrad) BRect touched = filled ? fPainter->FillRoundRect(r, xrad, yrad)
: fPainter->StrokeRoundRect(r, xrad, yrad); : fPainter->StrokeRoundRect(r, xrad, yrad);
fGraphicsCard->Invalidate(touched); fGraphicsCard->Invalidate(touched);
if (cursorTouched)
fGraphicsCard->ShowSoftwareCursor();
} }
} }
@@ -949,14 +921,14 @@ DrawingEngine::DrawShape(const BRect& bounds, int32 opCount,
// NOTE: hides cursor regardless of if and where // NOTE: hides cursor regardless of if and where
// shape is drawn on screen, TODO: optimize // shape is drawn on screen, TODO: optimize
fGraphicsCard->HideSoftwareCursor(); fGraphicsCard->HideFloatingOverlays();
BRect touched = fPainter->DrawShape(opCount, opList, BRect touched = fPainter->DrawShape(opCount, opList,
ptCount, ptList, ptCount, ptList,
filled); filled);
fGraphicsCard->Invalidate(touched); fGraphicsCard->Invalidate(touched);
fGraphicsCard->ShowSoftwareCursor(); fGraphicsCard->ShowFloatingOverlays();
} }
@@ -970,7 +942,7 @@ DrawingEngine::DrawTriangle(BPoint* pts, const BRect& bounds, bool filled)
extend_by_stroke_width(clipped, fPainter->PenSize()); extend_by_stroke_width(clipped, fPainter->PenSize());
clipped = fPainter->ClipRect(clipped); clipped = fPainter->ClipRect(clipped);
if (clipped.IsValid()) { if (clipped.IsValid()) {
bool cursorTouched = fGraphicsCard->HideSoftwareCursor(clipped); AutoFloatingOverlaysHider _(fGraphicsCard, clipped);
if (filled) if (filled)
fPainter->FillTriangle(pts[0], pts[1], pts[2]); fPainter->FillTriangle(pts[0], pts[1], pts[2]);
@@ -978,8 +950,6 @@ DrawingEngine::DrawTriangle(BPoint* pts, const BRect& bounds, bool filled)
fPainter->StrokeTriangle(pts[0], pts[1], pts[2]); fPainter->StrokeTriangle(pts[0], pts[1], pts[2]);
fGraphicsCard->Invalidate(clipped); fGraphicsCard->Invalidate(clipped);
if (cursorTouched)
fGraphicsCard->ShowSoftwareCursor();
} }
} }
@@ -994,13 +964,11 @@ DrawingEngine::StrokeLine(const BPoint &start, const BPoint &end)
extend_by_stroke_width(touched, fPainter->PenSize()); extend_by_stroke_width(touched, fPainter->PenSize());
touched = fPainter->ClipRect(touched); touched = fPainter->ClipRect(touched);
if (touched.IsValid()) { if (touched.IsValid()) {
bool cursorTouched = fGraphicsCard->HideSoftwareCursor(touched); AutoFloatingOverlaysHider _(fGraphicsCard, touched);
fPainter->StrokeLine(start, end); fPainter->StrokeLine(start, end);
fGraphicsCard->Invalidate(touched); fGraphicsCard->Invalidate(touched);
if (cursorTouched)
fGraphicsCard->ShowSoftwareCursor();
} }
} }
@@ -1032,7 +1000,7 @@ DrawingEngine::StrokeLineArray(int32 numLines,
extend_by_stroke_width(touched, fPainter->PenSize()); extend_by_stroke_width(touched, fPainter->PenSize());
touched = fPainter->ClipRect(touched); touched = fPainter->ClipRect(touched);
if (touched.IsValid()) { if (touched.IsValid()) {
bool cursorTouched = fGraphicsCard->HideSoftwareCursor(touched); AutoFloatingOverlaysHider _(fGraphicsCard, touched);
data = (const LineArrayData *)&(linedata[0]); data = (const LineArrayData *)&(linedata[0]);
@@ -1056,8 +1024,6 @@ DrawingEngine::StrokeLineArray(int32 numLines,
fPainter->SetPattern(pattern); fPainter->SetPattern(pattern);
fGraphicsCard->Invalidate(touched); fGraphicsCard->Invalidate(touched);
if (cursorTouched)
fGraphicsCard->ShowSoftwareCursor();
} }
} }
@@ -1088,7 +1054,7 @@ DrawingEngine::DrawString(const char* string, int32 length,
// TODO: BoundingBox is quite slow!! Optimizing it will be beneficial. // TODO: BoundingBox is quite slow!! Optimizing it will be beneficial.
// Cursiously, the DrawString after it is actually faster!?! // Cursiously, the DrawString after it is actually faster!?!
// TODO: make the availability of the hardware cursor part of the // TODO: make the availability of the hardware cursor part of the
// HW acceleration flags and skip all calculations for HideSoftwareCursor // HW acceleration flags and skip all calculations for HideFloatingOverlays
// in case we don't have one. // in case we don't have one.
// TODO: Watch out about penLocation and use Painter::PenLocation() when // TODO: Watch out about penLocation and use Painter::PenLocation() when
// not using BoundindBox anymore. // not using BoundindBox anymore.
@@ -1098,7 +1064,7 @@ DrawingEngine::DrawString(const char* string, int32 length,
b = fPainter->ClipRect(b); b = fPainter->ClipRect(b);
if (b.IsValid()) { if (b.IsValid()) {
//printf("bounding box '%s': %lld µs\n", string, system_time() - now); //printf("bounding box '%s': %lld µs\n", string, system_time() - now);
bool cursorTouched = fGraphicsCard->HideSoftwareCursor(b); AutoFloatingOverlaysHider _(fGraphicsCard, b);
//now = system_time(); //now = system_time();
BRect touched = fPainter->DrawString(string, length, pt, delta, BRect touched = fPainter->DrawString(string, length, pt, delta,
@@ -1106,8 +1072,6 @@ DrawingEngine::DrawString(const char* string, int32 length,
//printf("drawing string: %lld µs\n", system_time() - now); //printf("drawing string: %lld µs\n", system_time() - now);
fGraphicsCard->Invalidate(touched); fGraphicsCard->Invalidate(touched);
if (cursorTouched)
fGraphicsCard->ShowSoftwareCursor();
} }
return penLocation; return penLocation;
@@ -1167,7 +1131,7 @@ DrawingEngine::ReadBitmap(ServerBitmap *bitmap, bool drawCursor, BRect bounds)
BRect clip(0, 0, buffer->Width() - 1, buffer->Height() - 1); BRect clip(0, 0, buffer->Width() - 1, buffer->Height() - 1);
bounds = bounds & clip; bounds = bounds & clip;
fGraphicsCard->HideSoftwareCursor(bounds); AutoFloatingOverlaysHider _(fGraphicsCard, bounds);
status_t result = bitmap->ImportBits(buffer->Bits(), buffer->BitsLength(), status_t result = bitmap->ImportBits(buffer->Bits(), buffer->BitsLength(),
buffer->BytesPerRow(), buffer->ColorSpace(), buffer->BytesPerRow(), buffer->ColorSpace(),
@@ -1209,8 +1173,6 @@ DrawingEngine::ReadBitmap(ServerBitmap *bitmap, bool drawCursor, BRect bounds)
cursorWidth, cursorHeight); cursorWidth, cursorHeight);
} }
fGraphicsCard->ShowSoftwareCursor();
return result; return result;
} }
+30 -26
View File
@@ -39,7 +39,7 @@ HWInterfaceListener::~HWInterfaceListener()
HWInterface::HWInterface(bool doubleBuffered) HWInterface::HWInterface(bool doubleBuffered)
: MultiLocker("hw interface lock"), : MultiLocker("hw interface lock"),
fCursorAreaBackup(NULL), fCursorAreaBackup(NULL),
fSoftwareCursorLock("software cursor lock"), fFloatingOverlaysLock("floating overlays lock"),
fCursor(NULL), fCursor(NULL),
fDragBitmap(NULL), fDragBitmap(NULL),
fDragBitmapOffset(0, 0), fDragBitmapOffset(0, 0),
@@ -109,7 +109,7 @@ HWInterface::GetMonitorInfo(monitor_info* info)
void void
HWInterface::SetCursor(ServerCursor* cursor) HWInterface::SetCursor(ServerCursor* cursor)
{ {
if (!fSoftwareCursorLock.Lock()) if (!fFloatingOverlaysLock.Lock())
return; return;
// TODO: if a bitmap is being dragged, it could // TODO: if a bitmap is being dragged, it could
@@ -145,14 +145,14 @@ HWInterface::SetCursor(ServerCursor* cursor)
_AdoptDragBitmap(fDragBitmap, fDragBitmapOffset); _AdoptDragBitmap(fDragBitmap, fDragBitmapOffset);
Invalidate(_CursorFrame()); Invalidate(_CursorFrame());
} }
fSoftwareCursorLock.Unlock(); fFloatingOverlaysLock.Unlock();
} }
// SetCursorVisible // SetCursorVisible
void void
HWInterface::SetCursorVisible(bool visible) HWInterface::SetCursorVisible(bool visible)
{ {
if (!fSoftwareCursorLock.Lock()) if (!fFloatingOverlaysLock.Lock())
return; return;
if (fCursorVisible != visible) { if (fCursorVisible != visible) {
@@ -174,7 +174,7 @@ HWInterface::SetCursorVisible(bool visible)
Invalidate(r); Invalidate(r);
} }
} }
fSoftwareCursorLock.Unlock(); fFloatingOverlaysLock.Unlock();
} }
// IsCursorVisible // IsCursorVisible
@@ -182,9 +182,9 @@ bool
HWInterface::IsCursorVisible() HWInterface::IsCursorVisible()
{ {
bool visible = true; bool visible = true;
if (fSoftwareCursorLock.Lock()) { if (fFloatingOverlaysLock.Lock()) {
visible = fCursorVisible; visible = fCursorVisible;
fSoftwareCursorLock.Unlock(); fFloatingOverlaysLock.Unlock();
} }
return visible; return visible;
} }
@@ -193,21 +193,21 @@ HWInterface::IsCursorVisible()
void void
HWInterface::ObscureCursor() HWInterface::ObscureCursor()
{ {
if (!fSoftwareCursorLock.Lock()) if (!fFloatingOverlaysLock.Lock())
return; return;
if (!fCursorObscured) { if (!fCursorObscured) {
SetCursorVisible(false); SetCursorVisible(false);
fCursorObscured = true; fCursorObscured = true;
} }
fSoftwareCursorLock.Unlock(); fFloatingOverlaysLock.Unlock();
} }
// MoveCursorTo // MoveCursorTo
void void
HWInterface::MoveCursorTo(const float& x, const float& y) HWInterface::MoveCursorTo(const float& x, const float& y)
{ {
if (!fSoftwareCursorLock.Lock()) if (!fFloatingOverlaysLock.Lock())
return; return;
BPoint p(x, y); BPoint p(x, y);
@@ -232,7 +232,7 @@ HWInterface::MoveCursorTo(const float& x, const float& y)
Invalidate(_CursorFrame()); Invalidate(_CursorFrame());
} }
} }
fSoftwareCursorLock.Unlock(); fFloatingOverlaysLock.Unlock();
} }
@@ -240,9 +240,9 @@ BPoint
HWInterface::CursorPosition() HWInterface::CursorPosition()
{ {
BPoint location; BPoint location;
if (fSoftwareCursorLock.Lock()) { if (fFloatingOverlaysLock.Lock()) {
location = fCursorLocation; location = fCursorLocation;
fSoftwareCursorLock.Unlock(); fFloatingOverlaysLock.Unlock();
} }
return location; return location;
} }
@@ -252,9 +252,9 @@ void
HWInterface::SetDragBitmap(const ServerBitmap* bitmap, HWInterface::SetDragBitmap(const ServerBitmap* bitmap,
const BPoint& offsetFromCursor) const BPoint& offsetFromCursor)
{ {
if (fSoftwareCursorLock.Lock()) { if (fFloatingOverlaysLock.Lock()) {
_AdoptDragBitmap(bitmap, offsetFromCursor); _AdoptDragBitmap(bitmap, offsetFromCursor);
fSoftwareCursorLock.Unlock(); fFloatingOverlaysLock.Unlock();
} }
} }
@@ -403,9 +403,9 @@ HWInterface::HideOverlay(Overlay* overlay)
bool bool
HWInterface::HideSoftwareCursor(const BRect& area) HWInterface::HideFloatingOverlays(const BRect& area)
{ {
if (!fSoftwareCursorLock.Lock()) if (!fFloatingOverlaysLock.Lock())
return false; return false;
if (fCursorAreaBackup && !fCursorAreaBackup->cursor_hidden) { if (fCursorAreaBackup && !fCursorAreaBackup->cursor_hidden) {
BRect backupArea(fCursorAreaBackup->left, BRect backupArea(fCursorAreaBackup->left,
@@ -418,26 +418,29 @@ HWInterface::HideSoftwareCursor(const BRect& area)
return true; return true;
} }
} }
fSoftwareCursorLock.Unlock(); fFloatingOverlaysLock.Unlock();
return false; return false;
} }
void bool
HWInterface::HideSoftwareCursor() HWInterface::HideFloatingOverlays()
{ {
fSoftwareCursorLock.Lock(); if (!fFloatingOverlaysLock.Lock())
return false;
_RestoreCursorArea(); _RestoreCursorArea();
return true;
} }
void void
HWInterface::ShowSoftwareCursor() HWInterface::ShowFloatingOverlays()
{ {
if (fCursorAreaBackup && fCursorAreaBackup->cursor_hidden) { if (fCursorAreaBackup && fCursorAreaBackup->cursor_hidden) {
_DrawCursor(_CursorFrame()); _DrawCursor(_CursorFrame());
} }
fSoftwareCursorLock.Unlock(); fFloatingOverlaysLock.Unlock();
} }
@@ -514,7 +517,7 @@ HWInterface::_DrawCursor(BRect area) const
uint8* dst = buffer; uint8* dst = buffer;
if (fCursorAreaBackup && fCursorAreaBackup->buffer if (fCursorAreaBackup && fCursorAreaBackup->buffer
&& fSoftwareCursorLock.Lock()) { && fFloatingOverlaysLock.Lock()) {
fCursorAreaBackup->cursor_hidden = false; fCursorAreaBackup->cursor_hidden = false;
// remember which area the backup contains // remember which area the backup contains
fCursorAreaBackup->left = left; fCursorAreaBackup->left = left;
@@ -550,7 +553,7 @@ HWInterface::_DrawCursor(BRect area) const
dst += width * 4; dst += width * 4;
bup += bupBPR; bup += bupBPR;
} }
fSoftwareCursorLock.Unlock(); fFloatingOverlaysLock.Unlock();
} else { } else {
// blending // blending
for (int32 y = top; y <= bottom; y++) { for (int32 y = top; y <= bottom; y++) {
@@ -775,7 +778,8 @@ HWInterface::_CopyToFront(uint8* src, uint32 srcBPR,
break; break;
default: default:
fprintf(stderr, "HWInterface::CopyBackToFront() - unsupported front buffer format! (0x%lx)\n", frontBuffer->ColorSpace()); fprintf(stderr, "HWInterface::CopyBackToFront() - unsupported front "
"buffer format! (0x%x)\n", frontBuffer->ColorSpace());
break; break;
} }
} }
+7 -4
View File
@@ -159,9 +159,9 @@ class HWInterface : protected MultiLocker {
// --- // ---
// NOTE: Investigate locking for these! The client code should already hold a // NOTE: Investigate locking for these! The client code should already hold a
// ReadLock, but maybe these functions should acquire a WriteLock! // ReadLock, but maybe these functions should acquire a WriteLock!
bool HideSoftwareCursor(const BRect& area); bool HideFloatingOverlays(const BRect& area);
void HideSoftwareCursor(); bool HideFloatingOverlays();
void ShowSoftwareCursor(); void ShowFloatingOverlays();
// Listener support // Listener support
bool AddListener(HWInterfaceListener* listener); bool AddListener(HWInterfaceListener* listener);
@@ -217,7 +217,7 @@ class HWInterface : protected MultiLocker {
}; };
buffer_clip* fCursorAreaBackup; buffer_clip* fCursorAreaBackup;
mutable BLocker fSoftwareCursorLock; mutable BLocker fFloatingOverlaysLock;
ServerCursor* fCursor; ServerCursor* fCursor;
const ServerBitmap* fDragBitmap; const ServerBitmap* fDragBitmap;
@@ -226,6 +226,9 @@ class HWInterface : protected MultiLocker {
bool fCursorVisible; bool fCursorVisible;
bool fCursorObscured; bool fCursorObscured;
BPoint fCursorLocation; BPoint fCursorLocation;
BRect fTrackingRect;
bool fDoubleBuffered; bool fDoubleBuffered;
int fVGADevice; int fVGADevice;