Memory allocation fixes.
This commit is contained in:
@@ -3768,47 +3768,56 @@ 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
|
||||||
* doesn't seem to be a way to create a View without a BView on
|
* doesn't seem to be a way to create a View without a BView on
|
||||||
* application side (the constructor wants a token).
|
* application side (the constructor wants a token).
|
||||||
* This would be better, as it would avoid the DrawingContext mess.
|
* This would be better, as it would avoid the DrawingContext mess.
|
||||||
*/
|
*/
|
||||||
OffscreenWindow window(bitmap, "ClipToPicture", fCurrentView->Window());
|
OffscreenWindow window(bitmap, "ClipToPicture", fCurrentView->Window());
|
||||||
View view(bounds, IntPoint(0, 0), "ClipToPicture");
|
View view(bounds, IntPoint(0, 0), "ClipToPicture");
|
||||||
window->SetTopView(view);
|
window->SetTopView(view);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Clear the bitmap with the transparent color
|
// Clear the bitmap with the transparent color
|
||||||
memset(bitmap->Bits(), 0, bitmap->BitsLength());
|
memset(bitmap->Bits(), 0, bitmap->BitsLength());
|
||||||
|
|
||||||
// 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();
|
||||||
// Copy the current state of the client view, so we draw with the right
|
if (engine == NULL) {
|
||||||
// font, color and everything
|
delete bitmap;
|
||||||
engine->SetDrawState(fCurrentView->CurrentState());
|
return B_NO_MEMORY;
|
||||||
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();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 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
|
// 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) {
|
||||||
|
|||||||
Reference in New Issue
Block a user