diff --git a/src/servers/app/BitmapDrawingEngine.cpp b/src/servers/app/BitmapDrawingEngine.cpp index ce7f1d24fa..6927842b50 100644 --- a/src/servers/app/BitmapDrawingEngine.cpp +++ b/src/servers/app/BitmapDrawingEngine.cpp @@ -18,6 +18,23 @@ BitmapDrawingEngine::~BitmapDrawingEngine() } +bool +BitmapDrawingEngine::IsParallelAccessLocked() const +{ + // We don't share the HWInterface instance that the Painter is + // attached to, so we never need to be locked. + return true; +} + + +bool +BitmapDrawingEngine::IsExclusiveAccessLocked() const +{ + // See IsParallelAccessLocked(). + return true; +} + + status_t BitmapDrawingEngine::SetSize(int32 newWidth, int32 newHeight) { @@ -63,7 +80,7 @@ BitmapDrawingEngine::SetSize(int32 newWidth, int32 newHeight) } -UtilityBitmap * +UtilityBitmap* BitmapDrawingEngine::ExportToBitmap(int32 width, int32 height, color_space space) { diff --git a/src/servers/app/BitmapDrawingEngine.h b/src/servers/app/BitmapDrawingEngine.h index b8d98f4ae6..f81fa3597b 100644 --- a/src/servers/app/BitmapDrawingEngine.h +++ b/src/servers/app/BitmapDrawingEngine.h @@ -12,13 +12,18 @@ public: BitmapDrawingEngine(); virtual ~BitmapDrawingEngine(); +#if DEBUG + virtual bool IsParallelAccessLocked() const; +#endif + virtual bool IsExclusiveAccessLocked() const; + status_t SetSize(int32 newWidth, int32 newHeight); - UtilityBitmap * ExportToBitmap(int32 width, int32 height, + UtilityBitmap* ExportToBitmap(int32 width, int32 height, color_space space); private: - BitmapHWInterface * fHWInterface; - UtilityBitmap * fBitmap; + BitmapHWInterface* fHWInterface; + UtilityBitmap* fBitmap; BRegion fClipping; }; diff --git a/src/servers/app/Desktop.cpp b/src/servers/app/Desktop.cpp index 5aeeec6f5c..85c83002c3 100644 --- a/src/servers/app/Desktop.cpp +++ b/src/servers/app/Desktop.cpp @@ -1197,7 +1197,12 @@ Desktop::MoveWindowBy(Window* window, float x, float y, int32 workspace) // moved into the dirty region (for now) newDirtyRegion.Include(&window->VisibleRegion()); - GetDrawingEngine()->CopyRegion(©Region, (int32)x, (int32)y); + // NOTE: Having all windows locked should prevent any + // problems with locking the drawing engine here. + if (GetDrawingEngine()->LockParallelAccess()) { + GetDrawingEngine()->CopyRegion(©Region, (int32)x, (int32)y); + GetDrawingEngine()->UnlockParallelAccess(); + } // in the dirty region, exclude the parts that we // could move by blitting diff --git a/src/servers/app/Window.cpp b/src/servers/app/Window.cpp index b3a87aa76d..16dbd31a03 100644 --- a/src/servers/app/Window.cpp +++ b/src/servers/app/Window.cpp @@ -468,22 +468,28 @@ Window::CopyContents(BRegion* region, int32 xOffset, int32 yOffset) if (allDirtyRegions != NULL) copyRegion->Exclude(allDirtyRegions); - fDrawingEngine->CopyRegion(copyRegion, xOffset, yOffset); + if (fDrawingEngine->LockParallelAccess()) { + fDrawingEngine->CopyRegion(copyRegion, xOffset, yOffset); + fDrawingEngine->UnlockParallelAccess(); - // Prevent those parts from being added to the dirty region... - newDirty->Exclude(copyRegion); + // Prevent those parts from being added to the dirty region... + newDirty->Exclude(copyRegion); - // The parts that could be copied are not dirty (at the - // target location!) - copyRegion->OffsetBy(xOffset, yOffset); - // ... and even exclude them from the pending dirty region! - if (fPendingUpdateSession->IsUsed()) - fPendingUpdateSession->DirtyRegion().Exclude(copyRegion); + // The parts that could be copied are not dirty (at the + // target location!) + copyRegion->OffsetBy(xOffset, yOffset); + // ... and even exclude them from the pending dirty region! + if (fPendingUpdateSession->IsUsed()) + fPendingUpdateSession->DirtyRegion().Exclude(copyRegion); + } fRegionPool.Recycle(copyRegion); } else { // Fallback, should never be here. - fDrawingEngine->CopyRegion(region, xOffset, yOffset); + if (fDrawingEngine->LockParallelAccess()) { + fDrawingEngine->CopyRegion(region, xOffset, yOffset); + fDrawingEngine->UnlockParallelAccess(); + } } if (allDirtyRegions != NULL) diff --git a/src/servers/app/drawing/DrawingEngine.cpp b/src/servers/app/drawing/DrawingEngine.cpp index 28974f2baa..3627b98ec5 100644 --- a/src/servers/app/drawing/DrawingEngine.cpp +++ b/src/servers/app/drawing/DrawingEngine.cpp @@ -458,7 +458,7 @@ void DrawingEngine::CopyRegion(/*const*/ BRegion* region, int32 xOffset, int32 yOffset) { - ASSERT_EXCLUSIVE_LOCKED(); + ASSERT_PARALLEL_LOCKED(); BRect frame = region->Frame(); frame = frame | frame.OffsetByCopy(xOffset, yOffset); diff --git a/src/servers/app/drawing/DrawingEngine.h b/src/servers/app/drawing/DrawingEngine.h index ef8a811507..4dd95cf2bb 100644 --- a/src/servers/app/drawing/DrawingEngine.h +++ b/src/servers/app/drawing/DrawingEngine.h @@ -51,12 +51,12 @@ public: // locking bool LockParallelAccess(); #if DEBUG - bool IsParallelAccessLocked() const; + virtual bool IsParallelAccessLocked() const; #endif void UnlockParallelAccess(); bool LockExclusiveAccess(); - bool IsExclusiveAccessLocked(); + virtual bool IsExclusiveAccessLocked(); void UnlockExclusiveAccess(); // for screen shots