Memory allocation fixes.

This commit is contained in:
Adrien Destugues
2014-01-22 17:47:01 +01:00
parent 48810d1b3a
commit fd9ceef841
+13 -4
View File
@@ -3768,9 +3768,14 @@ ServerWindow::PictureToRegion(ServerPicture* picture, BRegion& region,
* 32 - 1; * 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); UtilityBitmap* bitmap = new UtilityBitmap(bounds, B_RGBA32, 0);
if (bitmap != NULL) { if (bitmap == NULL)
return B_NO_MEMORY;
#if 0 #if 0
/* /*
* TODO stippi says we could use OffscreenWindow to do this, but there * TODO stippi says we could use OffscreenWindow to do this, but there
@@ -3789,6 +3794,11 @@ ServerWindow::PictureToRegion(ServerPicture* picture, BRegion& region,
// Render the picture to the bitmap // Render the picture to the bitmap
BitmapHWInterface interface(bitmap); BitmapHWInterface interface(bitmap);
DrawingEngine* engine = interface.CreateDrawingEngine(); 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 // Copy the current state of the client view, so we draw with the right
// font, color and everything // font, color and everything
engine->SetDrawState(fCurrentView->CurrentState()); engine->SetDrawState(fCurrentView->CurrentState());
@@ -3803,12 +3813,11 @@ ServerWindow::PictureToRegion(ServerPicture* picture, BRegion& region,
picture->Play(&context); picture->Play(&context);
engine->UnlockParallelAccess(); engine->UnlockParallelAccess();
} }
} delete engine;
// TODO stop here: we want agg to clip using the bitmap (with alpha), not // TODO stop here: we want agg to clip using the bitmap (with alpha), not
// the region. // the region.
region.MakeEmpty();
int32 width = bounds.IntegerWidth() + 1; int32 width = bounds.IntegerWidth() + 1;
int32 height = bounds.IntegerHeight() + 1; int32 height = bounds.IntegerHeight() + 1;
if (bitmap != NULL) { if (bitmap != NULL) {