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

  • From: looncraz-github.compositing <community@xxxxxxxxxxxx>
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Mon, 30 Apr 2012 09:48:52 +0200 (CEST)

added 1 changeset to branch 'refs/remotes/looncraz-github/compositing'
old head: 16c5fb8ef775487e3f4688c551b3317fe4a0155f
new head: 9fed48555405b8c692d2d63837b9aaa027fcc21c

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

9fed485: Remove some test code, orient towards multi-screen support.
  
  Screens 'register' themselves with the CompositeEngine so they can have their 
own rendering control threads.
  
  CompositeEngine will continue to developed as if multiple screens will be the 
norm.
  
  There are some other minor changes to address compatilibty with recent 
upstream changes as well.

                                         [ looncraz <looncraz@xxxxxxxxxxx> ]

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

Commit:      9fed48555405b8c692d2d63837b9aaa027fcc21c

Author:      looncraz <looncraz@xxxxxxxxxxx>
Date:        Mon Apr 30 01:50:41 2012 UTC

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

10 files changed, 83 insertions(+), 77 deletions(-)
src/servers/app/Screen.cpp                         |    9 +-
src/servers/app/ScreenManager.cpp                  |    3 +-
src/servers/app/ServerWindow.cpp                   |    4 +-
src/servers/app/Window.cpp                         |    7 +-
src/servers/app/drawing/DrawingEngine.cpp          |   11 --
src/servers/app/drawing/HWInterface.h              |    1 +
.../app/drawing/compositing/CompositeEngine.cpp    |   86 +++++++++++-----
.../app/drawing/compositing/CompositeEngine.h      |   12 ++-
.../drawing/compositing/CompositeHWInterface.cpp   |   20 +---
.../app/drawing/compositing/CompositeHWInterface.h |    7 +-

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

diff --git a/src/servers/app/Screen.cpp b/src/servers/app/Screen.cpp
index 4fb1845..0152b91 100644
--- a/src/servers/app/Screen.cpp
+++ b/src/servers/app/Screen.cpp
@@ -12,6 +12,7 @@
 #include "Screen.h"
 
 #include "BitmapManager.h"
+#include "CompositeEngine.h"
 #include "DrawingEngine.h"
 #include "HWInterface.h"
 
@@ -47,7 +48,10 @@ Screen::Screen(::HWInterface *interface, int32 id)
        fDriver(interface ? interface->CreateDrawingEngine() : NULL),
        fHWInterface(interface)
 {
-       _LOGF("Screen %li created\n", id);
+       // The CompositeEngine can render to 'n' screens simultaneously.
+       // ONLY Screens with valid DrawingEngines are to be registered.
+       if (fDriver != NULL)
+               gCompositeEngine->Register(this);
 }
 
 
@@ -86,6 +90,9 @@ Screen::Initialize()
 void
 Screen::Shutdown()
 {
+       // this will stop drawing from the CompositeEngine:
+       gCompositeEngine->Unregister(this);
+
        if (fHWInterface)
                fHWInterface->Shutdown();
 }
diff --git a/src/servers/app/ScreenManager.cpp 
b/src/servers/app/ScreenManager.cpp
index 544e6e4..fdc97ad 100644
--- a/src/servers/app/ScreenManager.cpp
+++ b/src/servers/app/ScreenManager.cpp
@@ -28,6 +28,7 @@ using std::nothrow;
 
 #ifndef HAIKU_TARGET_PLATFORM_LIBBE_TEST
 #      include "CompositeEngine.h"
+#      include "CompositeHWInterface.h"
 #else
 #      include "ViewHWInterface.h"
 #      include "DWindowHWInterface.h"
@@ -167,7 +168,7 @@ ScreenManager::_ScanDrivers()
        while (initDrivers) {
 
 #ifndef HAIKU_TARGET_PLATFORM_LIBBE_TEST
-                       interface = gCompositeEngine->GetHWInterface();
+                       interface = new CompositeHWInterface();
 #elif defined(USE_DIRECT_WINDOW_TEST_MODE)
                  interface = new DWindowHWInterface();
 #else
diff --git a/src/servers/app/ServerWindow.cpp b/src/servers/app/ServerWindow.cpp
index 9b93cdb..aae83ff 100644
--- a/src/servers/app/ServerWindow.cpp
+++ b/src/servers/app/ServerWindow.cpp
@@ -3592,10 +3592,8 @@ Window*
 ServerWindow::MakeWindow(BRect frame, const char* name,
        window_look look, window_feel feel, uint32 flags, uint32 workspace)
 {
-       // The non-offscreen ServerWindow uses the DrawingEngine instance from
-       // the desktop.
        return new(std::nothrow) ::CompositeWindow(frame, name, look, feel, 
flags,
-               workspace, this, NULL);
+               workspace, this, 
fDesktop->HWInterface()->CreateDrawingEngine());
 }
 
 
diff --git a/src/servers/app/Window.cpp b/src/servers/app/Window.cpp
index f0b3bed..f89cf23 100644
--- a/src/servers/app/Window.cpp
+++ b/src/servers/app/Window.cpp
@@ -129,10 +129,6 @@ Window::Window(const BRect& frame, const char *name,
 
        fWorkspacesViewCount(0)
 {
-       if (fDrawingEngine == NULL && fDesktop != NULL
-               && fDesktop->HWInterface() != NULL)
-               fDrawingEngine = fDesktop->HWInterface()->CreateDrawingEngine();
-
        _InitWindowStack();
 
        // make sure our arguments are valid
@@ -2330,8 +2326,7 @@ Window::DetachFromWindowStack(bool ownStackNeeded)
        Window* remainingTop = fCurrentStack->TopLayerWindow();
        if (remainingTop != NULL) {
                if (decorator != NULL)
-                       decorator->SetDrawingEngine(fDrawingEngine);
-                       
//decorator->SetDrawingEngine(remainingTop->fDrawingEngine);
+                       
decorator->SetDrawingEngine(remainingTop->fDrawingEngine);
                // propagate focus to the decorator
                remainingTop->SetFocus(remainingTop->IsFocus());
                remainingTop->SetLook(remainingTop->Look(), NULL);
diff --git a/src/servers/app/drawing/DrawingEngine.cpp 
b/src/servers/app/drawing/DrawingEngine.cpp
index 07398c3..89d8f78 100644
--- a/src/servers/app/drawing/DrawingEngine.cpp
+++ b/src/servers/app/drawing/DrawingEngine.cpp
@@ -24,8 +24,6 @@
 #include "Window.h"
 #include "WindowBuffer.h"
 
-#include "RapidDebug.h"
-
 #include "drawing_support.h"
 
 
@@ -189,7 +187,6 @@ DrawingEngine::FrameBufferChanged()
                if (fDrawingBuffer != NULL){
                        fPainter->AttachToBuffer(fDrawingBuffer);
                        fDrawingBuffer->AttachedToDrawingEngine(this);
-                       _LOG("Yes, we attached to fDrawingBuffer!\n");
                }
                else{
                        
fPainter->AttachToBuffer(fGraphicsCard->DrawingBuffer());
@@ -910,8 +907,6 @@ DrawingEngine::FillRect(BRect r, const rgb_color& color)
 {
        ASSERT_PARALLEL_LOCKED();
 
-       _LOGFDRAW("FillRect (%f, %f, %f, %f)\n", r.left, r.top, r.right, 
r.bottom);
-
        // NOTE: Write locking because we might use HW acceleration.
        // This needs to be investigated, I'm doing this because of
        // gut feeling.
@@ -940,7 +935,6 @@ void
 DrawingEngine::FillRegion(BRegion& r, const rgb_color& color)
 {
        ASSERT_PARALLEL_LOCKED();
-       _LOGDRAW("FillRegion (...)\n");
 
 
        // NOTE: region expected to be already clipped correctly!!
@@ -984,7 +978,6 @@ void
 DrawingEngine::StrokeRect(BRect r)
 {
        ASSERT_PARALLEL_LOCKED();
-       _LOGFDRAW("StrokeRect (%f, %f, %f, %f)\n", r.left, r.top, r.right, 
r.bottom);
 
        // support invalid rects
        make_rect_valid(r);
@@ -1011,8 +1004,6 @@ DrawingEngine::FillRect(BRect r)
        if (!r.IsValid())
                return;
 
-       _LOGFDRAW("FillRect (%f, %f, %f, %f)\n", r.left, r.top, r.right, 
r.bottom);
-
        AutoFloatingOverlaysHider overlaysHider(fGraphicsCard, r);
 
        bool doInSoftware = true;
@@ -1062,8 +1053,6 @@ DrawingEngine::FillRect(BRect r, const BGradient& 
gradient)
 
        make_rect_valid(r);
 
-       _LOGFDRAW("FillRect (%f, %f, %f, %f) w/ Gradient\n", r.left, r.top, 
r.right, r.bottom);
-
        r = fPainter->AlignAndClipRect(r);
        if (!r.IsValid())
                return;
diff --git a/src/servers/app/drawing/HWInterface.h 
b/src/servers/app/drawing/HWInterface.h
index d396525..a783707 100644
--- a/src/servers/app/drawing/HWInterface.h
+++ b/src/servers/app/drawing/HWInterface.h
@@ -28,6 +28,7 @@ class DrawingEngine;
 class EventStream;
 class Overlay;
 class RenderingBuffer;
+class Screen;
 class ServerBitmap;
 class UpdateQueue;
 class Window;
diff --git a/src/servers/app/drawing/compositing/CompositeEngine.cpp 
b/src/servers/app/drawing/compositing/CompositeEngine.cpp
index 4dd4d6c..35c8a44 100644
--- a/src/servers/app/drawing/compositing/CompositeEngine.cpp
+++ b/src/servers/app/drawing/compositing/CompositeEngine.cpp
@@ -17,6 +17,7 @@
 #include "CompositingPerfmon.h"
 #include "DrawingEngine.h"
 #include "ProfileMessageSupport.h"
+#include "Screen.h"
 #include "ServerApp.h"
 
 #include "Desktop.h"
@@ -54,7 +55,6 @@ CompositeEngine::CompositeEngine()
        fFullMode(true),
        fMouseVisible(true),
        fIsDrawing(false),
-       fHardware(NULL),
        fPerfmon(new CompositingPerfmon()),
        fThreadMultiplier(2),
        fMinThreads(2),
@@ -64,7 +64,8 @@ CompositeEngine::CompositeEngine()
        fActiveScreenStates(new CScreenStates()),
        fMouseOverlay(NULL),
        fFPSOverlay(NULL),
-       fDesktop(NULL)
+       fDesktop(NULL),
+       fActiveScreen(NULL)
        {
                // when we come to be very little is alive,
                // don't expect any other part of app_server to
@@ -130,10 +131,6 @@ CompositeEngine::Init()
                }
        }       // end getSettings
 
-
-       if (fHardware == NULL)
-               fHardware = new (std::nothrow) CompositeHWInterface();
-
        return true;
 }
 
@@ -641,31 +638,52 @@ CompositeEngine::SetDesktop(Desktop* desktop)
 }
 
 
+void
+CompositeEngine::Register(Screen* screen)
+{
+       if (screen == NULL){
+               _LOG("Attempt to register NULL screen\n");
+               return;
+       }
+       BAutolock _(fHardwareLock);
 
-HWInterface*
-CompositeEngine::GetHWInterface() const
-{      BAutolock _(fHardwareLock);
-       return fHardware;
+       _LOGF("Screen %li being registered...\n", screen->ID());
+       if (fActiveScreen == NULL)
+               SetActiveScreen(screen);
+
+       return;
+       // start drawing if we are not...
+       // For now this is simply assuming ONE screen total...
+       // Later drawing will be dynamically either for all screens
+       // or separate for each...
+       // It just depends on resolution mismatches and other options.
+       if (fActiveScreen != NULL
+               && !fIsDrawing
+               && fActiveScreen->GetDrawingEngine() != NULL)
+               BeginDrawing();
 }
 
 
-DrawingEngine*
-CompositeEngine::CreateDrawingEngine(CompositeWindow * window)
+void
+CompositeEngine::SetActiveScreen(Screen* screen)
 {
        BAutolock _(fHardwareLock);
-       return fHardware->CreateDrawingEngine();
+
+       fActiveScreen = screen;
 }
 
 
-DrawingEngine*
-CompositeEngine::GetDrawingEngine() const
+void
+CompositeEngine::Unregister(Screen* screen)
 {
-       BAutolock _(fHardwareLock);
-       _LOG("CompositeEngine::GetDrawingEngine()\n");
-       fHardware->LockParallelAccess();
-               DrawingEngine * engine = fHardware->GetDrawingEngine();
-       fHardware->UnlockParallelAccess();
-       return engine;
+       if (fActiveScreen == screen){
+               // we are in trouble, need to switch to the next screen,
+               // if there is one.. if not, we need to suspend drawing.
+               // when a new screen is registered, we would begin again
+               _LOGF("Active Screen (%li) destroyed!\n", screen->ID());
+       }else{
+               _LOGF("Screen %li destroyed\n", screen->ID());
+       }
 }
 
 
@@ -1101,10 +1119,23 @@ uint32
 CompositeEngine::NativeColor(const rgb_color& color) const
 {      BAutolock _(fHardwareLock);
 
-       if (fHardware)
-               return fHardware->NativeColor(color);
+       // Get the bit pattern for a specific color.  This is important in the
+       // event the driver requires a different pattern natively - so we can
+       // avoid unneccessary conversions...
 
-       return 0;
+       // The CompositeEngine exposes this functionality
+       if (fActiveScreen){
+               CompositeHWInterface * iface = 
dynamic_cast<CompositeHWInterface*>
+                       (fActiveScreen->HWInterface());
+
+               if (iface)
+                       return iface->NativeColor(color);
+       }
+
+       // return default battern of BBitmap B_RGBA32 (BRGA)
+       // TODO: is endianess going to an issue??
+       return (uint32)(color.alpha << 24) | (color.red << 16) | (color.green 
<< 8)
+               |(color.blue);
 }
 
 
@@ -1121,9 +1152,10 @@ CompositeEngine::Draw()
 
        BRegion region;
 
-       fHardware->LockParallelAccess();
-               DrawingEngine* draw = fHardware->GetDrawingEngine();
-       fHardware->UnlockParallelAccess();
+ *     each screen will have its own control thread, but all screens
+ *     share the same RenderThreadGroup.  The ActiveScreen has priority
+ *     for the rendering threads
+
 */
 }
 
diff --git a/src/servers/app/drawing/compositing/CompositeEngine.h 
b/src/servers/app/drawing/compositing/CompositeEngine.h
index f77d28c..b2bb041 100644
--- a/src/servers/app/drawing/compositing/CompositeEngine.h
+++ b/src/servers/app/drawing/compositing/CompositeEngine.h
@@ -103,10 +103,11 @@ public:
 
                        void                            SetDesktop(Desktop*);
 
-                       HWInterface*            GetHWInterface()        const;
-                       DrawingEngine*          
CreateDrawingEngine(CompositeWindow*);
-                       DrawingEngine*          GetDrawingEngine()      const;
-                               // drawing engine for the back-buffer
+                       void                            Register(Screen* 
screen);
+                       void                            Unregister(Screen* 
screen);
+                       void                            
SetActiveScreen(Screen*);
+
+                       int32                           GetActiveScreenID()     
const;
 
                        void                            CopyBackToFront(BRect&);
                        void                            
CopyBackToFront(BRegion&);
@@ -208,7 +209,6 @@ private:
 
                        BPoint                          fCursorLoc;
 
-                       CompositeHWInterface*fHardware;
                        CompositingPerfmon*     fPerfmon;
 
                        size_t                          fMemoryLimit,
@@ -235,6 +235,8 @@ private:
                        // overlays owned by the client
                        BObjectList<BPrivate::CompositeOverlay>
                                                                fOverlays;
+
+                       Screen*                         fActiveScreen;
 };
 
 
diff --git a/src/servers/app/drawing/compositing/CompositeHWInterface.cpp 
b/src/servers/app/drawing/compositing/CompositeHWInterface.cpp
index c3b7f49..5e56bfa 100644
--- a/src/servers/app/drawing/compositing/CompositeHWInterface.cpp
+++ b/src/servers/app/drawing/compositing/CompositeHWInterface.cpp
@@ -11,8 +11,7 @@
 
 CompositeHWInterface::CompositeHWInterface()
        :
-       AccelerantHWInterface(),
-       fDrawingEngine(NULL)
+       AccelerantHWInterface()
        {
 
        }
@@ -28,22 +27,7 @@ CompositeHWInterface::~CompositeHWInterface()
 DrawingEngine*
 CompositeHWInterface::CreateDrawingEngine()
 {
-       // TODO: would using Screen be better to get the FB DrawingEngine?
-       if(fDrawingEngine == NULL){
-               // create frame buffer's DrawingEngine
-               fDrawingEngine = AccelerantHWInterface::CreateDrawingEngine();
-               gCompositeEngine->BeginDrawing();
-               return fDrawingEngine;
-       }
-
-       return new (std::nothrow) DrawingEngine();
-}
-
-
-DrawingEngine*
-CompositeHWInterface::GetDrawingEngine()
-{
-       return fDrawingEngine;
+       return new (std::nothrow) DrawingEngine(this);
 }
 
 
diff --git a/src/servers/app/drawing/compositing/CompositeHWInterface.h 
b/src/servers/app/drawing/compositing/CompositeHWInterface.h
index 9cb2d0c..0a5b4a6 100644
--- a/src/servers/app/drawing/compositing/CompositeHWInterface.h
+++ b/src/servers/app/drawing/compositing/CompositeHWInterface.h
@@ -12,9 +12,7 @@ public:
        virtual                                 ~CompositeHWInterface();
 
 
-       DrawingEngine*                  CreateDrawingEngine();
-
-       DrawingEngine*                  GetDrawingEngine();
+               DrawingEngine*          CreateDrawingEngine();
 
        virtual status_t                Initialize();
        virtual status_t                Shutdown();
@@ -34,9 +32,8 @@ public:
 protected:
        virtual void                    _DrawCursor(IntRect area) const;
 
-
 private:
-       DrawingEngine*                  fDrawingEngine;
+
 
 };
 


Other related posts:

  • » [haiku-commits] BRANCH looncraz-github.compositing - in src/servers/app/drawing/compositing: . src/servers/app src/servers/app/drawing - looncraz-github . compositing