[haiku-commits] BRANCH looncraz-github.CAP-volatile - in src/servers/app: . drawing

  • From: looncraz-github.CAP-volatile <community@xxxxxxxxxxxx>
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Fri, 16 Nov 2012 20:48:51 +0100 (CET)

added 1 changeset to branch 'refs/remotes/looncraz-github/CAP-volatile'
old head: f073294b25dcd5e3217631527542de7a789a1cd0
new head: 6eee51727424bddac0e2d141299b8970dd0b034c

----------------------------------------------------------------------------

6eee517: Make drawing outside of BView::Draw(BRect) visible.
  
  This is a partial commit while I examine the need for entirely new
  clipping and drawing logic for all on-screen objects.  Basically,
  to strip out the logic from the middle of unrelated code to
  facilitate future modifications to said behavior(s).
  
  Current idea is to implement all of the following:
  
  OnScreenPolicy
  :ClippingPolicy
  :DrawingPolicy
  
  Desktop
  :OnScreenPolicy
  
  OnScreenObject
  :ClippingObject
  :DrawingObject
  
  Window
  :OnScreenObject
  
  WindowBuffer
  :OnScreenObject
  
  Decorator
  :OnScreenObject
  
  WindowList->OnScreenList
  window_anchor->onscreen_anchor
  
  etc...
  
  All current clipping and drawing code (relative to Window) will be
  relocated and refactored in this experiment to centralize logic.

                                         [ looncraz <looncraz@xxxxxxxxxxx> ]

----------------------------------------------------------------------------

Commit:      6eee51727424bddac0e2d141299b8970dd0b034c

Author:      looncraz <looncraz@xxxxxxxxxxx>
Date:        Fri Nov 16 19:28:40 2012 UTC

----------------------------------------------------------------------------

4 files changed, 53 insertions(+), 21 deletions(-)
src/servers/app/ServerWindow.cpp         |  3 +-
src/servers/app/Window.cpp               | 47 ++++++++++++++++++++++++++--
src/servers/app/Window.h                 |  3 ++
src/servers/app/drawing/WindowBuffer.cpp | 21 ++-----------

----------------------------------------------------------------------------

diff --git a/src/servers/app/ServerWindow.cpp b/src/servers/app/ServerWindow.cpp
index f2e650d..4e584d5 100644
--- a/src/servers/app/ServerWindow.cpp
+++ b/src/servers/app/ServerWindow.cpp
@@ -2186,7 +2186,7 @@ ServerWindow::_DispatchViewDrawingMessage(int32 code,
        BRegion* drawingRegion = fWindow->GetRegion(fCurrentDrawingRegion);
        fWindow->ConvertScreenToDrawing(drawingRegion);
        drawingEngine->ConstrainClippingRegion(drawingRegion);
-       
+
        switch (code) {
                case AS_STROKE_LINE:
                {
@@ -2851,6 +2851,7 @@ ServerWindow::_DispatchViewDrawingMessage(int32 code,
                        break;
        }
 
+       fWindow->DrawFromBuffer(drawingRegion);
        fWindow->RecycleRegion(drawingRegion);
        drawingEngine->UnlockParallelAccess();
 }
diff --git a/src/servers/app/Window.cpp b/src/servers/app/Window.cpp
index b071376..5b70d08 100644
--- a/src/servers/app/Window.cpp
+++ b/src/servers/app/Window.cpp
@@ -405,6 +405,10 @@ Window::ResizeBy(int32 x, int32 y, BRegion* dirtyRegion, 
bool resizeStack)
                }
        }
 
+       // Just in case our top view isn't anchored to origin...
+       if (fTopView != NULL)
+               fTopView->InvalidateOffsetFromWindow(true);
+
        // send a message to the client informing about the changed size
        BRect frame(Frame());
        BMessage msg(B_WINDOW_RESIZED);
@@ -828,6 +832,45 @@ Window::RedrawDirtyRegion()
 
 
 void
+Window::DrawFromBuffer(BRegion* drawingRegion)
+{
+       if (IsWindowBufferEnabled() == false)
+               return;
+
+       DrawingEngine* draw = fDesktop->GetDrawingEngine();
+
+       BRegion* screenRegion = GetRegion(*drawingRegion);
+       ConvertDrawingToScreen(screenRegion);
+       
+       fDrawingEngine->LockParallelAccess();
+       draw->LockParallelAccess();
+
+               draw->ConstrainClippingRegion(screenRegion);
+
+               BRect sourceRect;
+               BRect destinationRect;
+
+               for (int32 i = 0; i < drawingRegion->CountRects(); ++i) {
+                       sourceRect = drawingRegion->RectAt(i);
+                       destinationRect = sourceRect;
+                       
+                       ConvertDrawingToScreen(&destinationRect);
+                       
+//                     _LOGF("DFB: (%.0f, %.0f, %.0f, %.0f) : (%.0f, %.0f, 
%.0f, %.0f)\n",
+//                             sourceRect.left, sourceRect.top, 
sourceRect.right,
+//                             sourceRect.bottom, destinationRect.left, 
destinationRect.top,
+//                             destinationRect.right, destinationRect.bottom);
+                       
+                       draw->DrawBuffer(WindowBuffer(), sourceRect, 
destinationRect, 0);
+               }
+
+       RecycleRegion(screenRegion);
+       draw->UnlockParallelAccess();
+       fDrawingEngine->UnlockParallelAccess();
+}
+
+
+void
 Window::MarkDirty(BRegion& regionOnScreen)
 {
        // for marking any part of the desktop dirty
@@ -2614,7 +2657,7 @@ Window::ConvertDrawingToScreen(BRect* rect) const
                return;
        
        WindowBuffer()->ConvertFromBuffer(rect);
-       rect->OffsetBy(Frame().left, Frame().right);
+       rect->OffsetBy(Frame().left, Frame().top);
 }
 
 
@@ -2625,7 +2668,7 @@ Window::ConvertDrawingToScreen(BRegion* region) const
                return;
        
        WindowBuffer()->ConvertFromBuffer(region);
-       region->OffsetBy(Frame().left, Frame().right);
+       region->OffsetBy(Frame().left, Frame().top);
 }
 
 
diff --git a/src/servers/app/Window.h b/src/servers/app/Window.h
index a244670..6086a3d 100644
--- a/src/servers/app/Window.h
+++ b/src/servers/app/Window.h
@@ -153,6 +153,9 @@ public:
                        // generic version, used by the Desktop
                        void                            
ProcessDirtyRegion(BRegion& regionOnScreen);
                        void                            RedrawDirtyRegion();
+                       
+                       // Draw from WindowBuffer to the frame buffer
+                       void                            DrawFromBuffer(BRegion* 
drawingRegion);
 
                        // can be used from inside classes that don't
                        // need to know about Desktop (first version uses 
Desktop)
diff --git a/src/servers/app/drawing/WindowBuffer.cpp 
b/src/servers/app/drawing/WindowBuffer.cpp
index e650d3a..397c434 100644
--- a/src/servers/app/drawing/WindowBuffer.cpp
+++ b/src/servers/app/drawing/WindowBuffer.cpp
@@ -25,28 +25,16 @@ WindowBuffer::WindowBuffer(Window* window)
 {
        fBounds.OffsetBy(-fBounds.left, -fBounds.top);
 
-#      if ENABLE_LOGGING
-       BRect rect = window->Frame();
-
-       _LOGF("WindowBuffer(%s)( %i, %i, %i, %i )\n",
-               window->Title(),
-               (int)rect.left, (int)rect.top, (int)rect.right, (int)rect.bottom
-       );
-#      endif
-
        _NewWindowSize(&fWidth, &fHeight);
 
        if (fBuffer != NULL)
-               memset(fBuffer, 0, BytesPerRow() * Height());
-
-       _LOGF("\tBuffer created: %li x %li\n", fWidth, fHeight);
+               memset(fBuffer, 255, BytesPerRow() * Height());
 }
 
 
 WindowBuffer::~WindowBuffer()
 {
        fLock.Lock();
-
        free(fBuffer);
 }
 
@@ -243,8 +231,6 @@ bool
 WindowBuffer::CopyToFrontLock()
 {
        // TODO: do we really care about the return values??
-       // TODO: introduce timeout for compositing so threads
-       //              can work on other buffers... or skip us :'(
        if (fLock.Lock() && fClientDrawLock.Lock())
                return true;
        
_LOG("FAILURE!\nFAILURE!!\tWindowBuffer::CopyToFrontLock()\nFAILURE!\n");
@@ -282,8 +268,6 @@ WindowBuffer::_ResizeTo(int32 width, int32 height)
        if (width == fWidth && height == fHeight)
                return;
 
-       // TODO: should we LockExclusiveAccess() to the drawing engine?
-       // it may be superfluous.. but maybe not...
        if (fBuffer != NULL) {
                uint32 bytesPerPixel = 4;
                uint32 bytesPerRow = bytesPerPixel*width;
@@ -349,7 +333,8 @@ WindowBuffer::_ResizeTo(int32 width, int32 height)
        fWidth = width;
        fHeight = height;
 
-       // as our pointer data changed, the drawing engine needs to be updated:
+       // As our data pointer changed, the drawing engine needs to be updated 
so
+       // Painer paints into the new memory location.
        fWindow->GetDrawingEngine()->SetDrawingBuffer(this);
 }
 


Other related posts: