[haiku-commits] r35822 - in haiku/trunk/src/servers/app: . drawing

  • From: superstippi@xxxxxx
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Fri, 12 Mar 2010 13:46:24 +0100 (CET)

Author: stippi
Date: 2010-03-12 13:46:24 +0100 (Fri, 12 Mar 2010)
New Revision: 35822
Changeset: http://dev.haiku-os.org/changeset/35822/haiku

Modified:
   haiku/trunk/src/servers/app/BitmapDrawingEngine.cpp
   haiku/trunk/src/servers/app/BitmapDrawingEngine.h
   haiku/trunk/src/servers/app/Desktop.cpp
   haiku/trunk/src/servers/app/Window.cpp
   haiku/trunk/src/servers/app/drawing/DrawingEngine.cpp
   haiku/trunk/src/servers/app/drawing/DrawingEngine.h
Log:
Tried to fix all issues with running a DEBUG build of app_server.
 * CopyRegion should not need the HWInterface to be exclusive locked.
 * BitmapDrawingInterface does not need to be locked at all, since
   it doesn't use a shared HWInterface instance.
 * Window and Desktop should lock the HWInterface appropriately
   before invoking CopyRegion() on the DrawingEngine.


Modified: haiku/trunk/src/servers/app/BitmapDrawingEngine.cpp
===================================================================
--- haiku/trunk/src/servers/app/BitmapDrawingEngine.cpp 2010-03-12 11:25:30 UTC 
(rev 35821)
+++ haiku/trunk/src/servers/app/BitmapDrawingEngine.cpp 2010-03-12 12:46:24 UTC 
(rev 35822)
@@ -18,6 +18,23 @@
 }
 
 
+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 @@
 }
 
 
-UtilityBitmap *
+UtilityBitmap*
 BitmapDrawingEngine::ExportToBitmap(int32 width, int32 height,
        color_space space)
 {

Modified: haiku/trunk/src/servers/app/BitmapDrawingEngine.h
===================================================================
--- haiku/trunk/src/servers/app/BitmapDrawingEngine.h   2010-03-12 11:25:30 UTC 
(rev 35821)
+++ haiku/trunk/src/servers/app/BitmapDrawingEngine.h   2010-03-12 12:46:24 UTC 
(rev 35822)
@@ -12,13 +12,18 @@
                                                                
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;
 };
 

Modified: haiku/trunk/src/servers/app/Desktop.cpp
===================================================================
--- haiku/trunk/src/servers/app/Desktop.cpp     2010-03-12 11:25:30 UTC (rev 
35821)
+++ haiku/trunk/src/servers/app/Desktop.cpp     2010-03-12 12:46:24 UTC (rev 
35822)
@@ -1197,7 +1197,12 @@
        // moved into the dirty region (for now)
        newDirtyRegion.Include(&window->VisibleRegion());
 
-       GetDrawingEngine()->CopyRegion(&copyRegion, (int32)x, (int32)y);
+       // NOTE: Having all windows locked should prevent any
+       // problems with locking the drawing engine here.
+       if (GetDrawingEngine()->LockParallelAccess()) {
+               GetDrawingEngine()->CopyRegion(&copyRegion, (int32)x, (int32)y);
+               GetDrawingEngine()->UnlockParallelAccess();
+       }
 
        // in the dirty region, exclude the parts that we
        // could move by blitting

Modified: haiku/trunk/src/servers/app/Window.cpp
===================================================================
--- haiku/trunk/src/servers/app/Window.cpp      2010-03-12 11:25:30 UTC (rev 
35821)
+++ haiku/trunk/src/servers/app/Window.cpp      2010-03-12 12:46:24 UTC (rev 
35822)
@@ -468,22 +468,28 @@
                                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)

Modified: haiku/trunk/src/servers/app/drawing/DrawingEngine.cpp
===================================================================
--- haiku/trunk/src/servers/app/drawing/DrawingEngine.cpp       2010-03-12 
11:25:30 UTC (rev 35821)
+++ haiku/trunk/src/servers/app/drawing/DrawingEngine.cpp       2010-03-12 
12:46:24 UTC (rev 35822)
@@ -458,7 +458,7 @@
 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);

Modified: haiku/trunk/src/servers/app/drawing/DrawingEngine.h
===================================================================
--- haiku/trunk/src/servers/app/drawing/DrawingEngine.h 2010-03-12 11:25:30 UTC 
(rev 35821)
+++ haiku/trunk/src/servers/app/drawing/DrawingEngine.h 2010-03-12 12:46:24 UTC 
(rev 35822)
@@ -51,12 +51,12 @@
        // 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


Other related posts:

  • » [haiku-commits] r35822 - in haiku/trunk/src/servers/app: . drawing - superstippi