[haiku-commits] haiku: hrev46740 - src/servers/app

  • From: pulkomandy@xxxxxxxxxxxxx
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Wed, 22 Jan 2014 17:51:04 +0100 (CET)

hrev46740 adds 1 changeset to branch 'master'
old head: 48810d1b3a7e423246c778923aa2e127cc22be5d
new head: fd9ceef84149796f2b707d6e91401d2dcac8cb80
overview: http://cgit.haiku-os.org/haiku/log/?qt=range&q=fd9ceef+%5E48810d1

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

fd9ceef: Memory allocation fixes.

                             [ Adrien Destugues <pulkomandy@xxxxxxxxxxxxx> ]

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

Revision:    hrev46740
Commit:      fd9ceef84149796f2b707d6e91401d2dcac8cb80
URL:         http://cgit.haiku-os.org/haiku/commit/?id=fd9ceef
Author:      Adrien Destugues <pulkomandy@xxxxxxxxxxxxx>
Date:        Wed Jan 22 16:45:42 2014 UTC

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

1 file changed, 41 insertions(+), 32 deletions(-)
src/servers/app/ServerWindow.cpp | 73 ++++++++++++++++++++----------------

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

diff --git a/src/servers/app/ServerWindow.cpp b/src/servers/app/ServerWindow.cpp
index 0d894b4..75b603c 100644
--- a/src/servers/app/ServerWindow.cpp
+++ b/src/servers/app/ServerWindow.cpp
@@ -3768,47 +3768,56 @@ ServerWindow::PictureToRegion(ServerPicture* picture, 
BRegion& region,
                        * 32 - 1;
        }
 
-       // TODO: I used a RGBA32 bitmap because drawing on a GRAY8 doesn't work.
+       region.MakeEmpty();
+
+       // TODO: Only the alpha channel is relevant, but there is no B_ALPHA8
+       // color space, so we use 75% more memory.
        UtilityBitmap* bitmap = new UtilityBitmap(bounds, B_RGBA32, 0);
-       if (bitmap != NULL) {
+       if (bitmap == NULL)
+               return B_NO_MEMORY;
+
 #if 0
-               /*
-                * TODO stippi says we could use OffscreenWindow to do this, 
but there
-                * doesn't seem to be a way to create a View without a BView on
-                * application side (the constructor wants a token).
-                * This would be better, as it would avoid the DrawingContext 
mess.
-                */
-               OffscreenWindow window(bitmap, "ClipToPicture", 
fCurrentView->Window());
-               View view(bounds, IntPoint(0, 0), "ClipToPicture");
-               window->SetTopView(view);
+       /*
+        * TODO stippi says we could use OffscreenWindow to do this, but there
+        * doesn't seem to be a way to create a View without a BView on
+        * application side (the constructor wants a token).
+        * This would be better, as it would avoid the DrawingContext mess.
+        */
+       OffscreenWindow window(bitmap, "ClipToPicture", fCurrentView->Window());
+       View view(bounds, IntPoint(0, 0), "ClipToPicture");
+       window->SetTopView(view);
 #endif
 
-               // Clear the bitmap with the transparent color
-               memset(bitmap->Bits(), 0, bitmap->BitsLength());
-
-               // Render the picture to the bitmap
-               BitmapHWInterface interface(bitmap);
-               DrawingEngine* engine = interface.CreateDrawingEngine();
-               // Copy the current state of the client view, so we draw with 
the right
-               // font, color and everything
-               engine->SetDrawState(fCurrentView->CurrentState());
-               OffscreenContext context(engine);
-               if (engine->LockParallelAccess())
-               {
-                       // FIXME ConstrainClippingRegion docs says passing NULL 
disables
-                       // all clipping. This doesn't work and will crash in 
Painter.
-                       BRegion clipping;
-                       clipping.Include(bounds);
-                       engine->ConstrainClippingRegion(&clipping);
-                       picture->Play(&context);
-                       engine->UnlockParallelAccess();
-               }
+       // Clear the bitmap with the transparent color
+       memset(bitmap->Bits(), 0, bitmap->BitsLength());
+
+       // Render the picture to the bitmap
+       BitmapHWInterface interface(bitmap);
+       DrawingEngine* engine = interface.CreateDrawingEngine();
+       if (engine == NULL) {
+               delete bitmap;
+               return B_NO_MEMORY;
+       }
+
+       // Copy the current state of the client view, so we draw with the right
+       // font, color and everything
+       engine->SetDrawState(fCurrentView->CurrentState());
+       OffscreenContext context(engine);
+       if (engine->LockParallelAccess())
+       {
+               // FIXME ConstrainClippingRegion docs says passing NULL disables
+               // all clipping. This doesn't work and will crash in Painter.
+               BRegion clipping;
+               clipping.Include(bounds);
+               engine->ConstrainClippingRegion(&clipping);
+               picture->Play(&context);
+               engine->UnlockParallelAccess();
        }
+       delete engine;
 
        // TODO stop here: we want agg to clip using the bitmap (with alpha), 
not
        // the region.
 
-       region.MakeEmpty();
        int32 width = bounds.IntegerWidth() + 1;
        int32 height = bounds.IntegerHeight() + 1;
        if (bitmap != NULL) {


Other related posts:

  • » [haiku-commits] haiku: hrev46740 - src/servers/app - pulkomandy