* Implemented a new client allocation method: instead of having all bitmaps of
all teams in serveral server areas, and instead of having to eventually clone them all several times in BBitmap, we now have one or more areas per team, and BBitmap will only clone areas once if needed. As a side effect, this method should be magnitudes faster than the previous version. * This method is also much more secure: instead of putting the allocation maintenance structures into those everyone-read-write areas, they are now separated, so that faulty applications cannot crash the app_server this way anymore. This should fix bug #172. * Freeing memory is not yet implemented though! (although all memory will be freed upon app exit) * There are now 3 different bitmap allocation strategies: per ClientMemoryAllocator (ie. via ServerApp), per area (for overlays, not yet implemented), and using malloc()/free() for server-only bitmaps. * ServerBitmap now deletes its buffers itself. * Cleaned up BBitmap and BApplication a bit. * The test environment currently doesn't build anymore, will fix it next. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@16826 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2001-2005, Haiku.
|
||||
* Copyright 2001-2006, Haiku.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*
|
||||
* Authors:
|
||||
@@ -8,12 +8,17 @@
|
||||
#ifndef _APPLICATION_PRIVATE_H
|
||||
#define _APPLICATION_PRIVATE_H
|
||||
|
||||
|
||||
#include <Application.h>
|
||||
|
||||
|
||||
class BApplication::Private {
|
||||
public:
|
||||
static inline BPrivate::PortLink *ServerLink()
|
||||
{ return be_app->fServerLink; }
|
||||
public:
|
||||
static inline BPrivate::PortLink *ServerLink()
|
||||
{ return be_app->fServerLink; }
|
||||
|
||||
static inline BPrivate::ServerMemoryAllocator* ServerAllocator()
|
||||
{ return be_app->fServerAllocator; }
|
||||
};
|
||||
|
||||
#endif // _APPLICATION_PRIVATE_H
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
/*
|
||||
* Copyright 2006, Haiku, Inc. All Rights Reserved.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*
|
||||
* Authors:
|
||||
* Axel Dörfler, [email protected]
|
||||
*/
|
||||
#ifndef SERVER_MEMORY_ALLOCATOR_H
|
||||
#define SERVER_MEMORY_ALLOCATOR_H
|
||||
|
||||
|
||||
#include <OS.h>
|
||||
#include <List.h>
|
||||
|
||||
namespace BPrivate {
|
||||
|
||||
class ServerMemoryAllocator {
|
||||
public:
|
||||
ServerMemoryAllocator();
|
||||
~ServerMemoryAllocator();
|
||||
|
||||
status_t InitCheck();
|
||||
|
||||
status_t AddArea(area_id serverArea, area_id& _localArea, uint8*& _base);
|
||||
void RemoveArea(area_id serverArea);
|
||||
|
||||
status_t AreaAndBaseFor(area_id serverArea, area_id& area, uint8*& base);
|
||||
|
||||
private:
|
||||
BList fAreas;
|
||||
};
|
||||
|
||||
} // namespace BPrivate
|
||||
|
||||
#endif /* SERVER_MEMORY_ALLOCATOR_H */
|
||||
@@ -318,4 +318,12 @@ enum {
|
||||
AS_LAST_CODE
|
||||
};
|
||||
|
||||
// bitmap allocation types
|
||||
enum {
|
||||
kAllocator,
|
||||
kNewAllocatorArea,
|
||||
kArea,
|
||||
kHeap
|
||||
};
|
||||
|
||||
#endif // APP_SERVER_PROTOCOL_H
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
/*
|
||||
* Copyright 2001-2005, Haiku.
|
||||
* Copyright 2001-2006, Haiku.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*
|
||||
* Authors:
|
||||
* DarkWyrm <[email protected]>
|
||||
*/
|
||||
#ifndef BITMAP_MANAGER_H_
|
||||
#define BITMAP_MANAGER_H_
|
||||
#ifndef BITMAP_MANAGER_H
|
||||
#define BITMAP_MANAGER_H
|
||||
|
||||
|
||||
#include <GraphicsDefs.h>
|
||||
@@ -15,28 +15,25 @@
|
||||
#include <OS.h>
|
||||
#include <Rect.h>
|
||||
|
||||
#include "BGet++.h"
|
||||
|
||||
class ClientMemoryAllocator;
|
||||
class ServerBitmap;
|
||||
|
||||
|
||||
class BitmapManager {
|
||||
public:
|
||||
BitmapManager();
|
||||
virtual ~BitmapManager();
|
||||
|
||||
ServerBitmap* CreateBitmap(BRect bounds, color_space space,
|
||||
int32 flags, int32 bytesPerRow = -1,
|
||||
screen_id screen = B_MAIN_SCREEN_ID);
|
||||
ServerBitmap* CreateBitmap(ClientMemoryAllocator* allocator, BRect bounds,
|
||||
color_space space, int32 flags, int32 bytesPerRow = -1,
|
||||
screen_id screen = B_MAIN_SCREEN_ID,
|
||||
int8* _allocationType = NULL);
|
||||
void DeleteBitmap(ServerBitmap* bitmap);
|
||||
|
||||
protected:
|
||||
BList fBitmapList;
|
||||
int8* fBuffer;
|
||||
BLocker fLock;
|
||||
AreaPool fMemPool;
|
||||
};
|
||||
|
||||
extern BitmapManager *gBitmapManager;
|
||||
|
||||
#endif /* BITMAP_MANAGER_H_ */
|
||||
#endif /* BITMAP_MANAGER_H */
|
||||
|
||||
@@ -5,8 +5,8 @@
|
||||
* Authors:
|
||||
* DarkWyrm <[email protected]>
|
||||
*/
|
||||
#ifndef _SERVER_BITMAP_H_
|
||||
#define _SERVER_BITMAP_H_
|
||||
#ifndef SERVER_BITMAP_H
|
||||
#define SERVER_BITMAP_H
|
||||
|
||||
|
||||
#include <GraphicsDefs.h>
|
||||
@@ -15,6 +15,7 @@
|
||||
|
||||
|
||||
class BitmapManager;
|
||||
class ClientMemoryAllocator;
|
||||
|
||||
/*!
|
||||
\class ServerBitmap ServerBitmap.h
|
||||
@@ -31,11 +32,6 @@ class ServerBitmap {
|
||||
|
||||
void Acquire();
|
||||
|
||||
inline area_id Area() const
|
||||
{ return fArea; }
|
||||
inline int32 AreaOffset() const
|
||||
{ return fOffset; }
|
||||
|
||||
inline uint8* Bits() const
|
||||
{ return fBuffer; }
|
||||
inline uint32 BitsLength() const
|
||||
@@ -59,6 +55,12 @@ class ServerBitmap {
|
||||
inline int32 Token() const
|
||||
{ return fToken; }
|
||||
|
||||
inline void* AllocationCookie() const
|
||||
{ return fAllocationCookie; }
|
||||
|
||||
area_id Area() const;
|
||||
uint32 AreaOffset() const;
|
||||
|
||||
//! Does a shallow copy of the bitmap passed to it
|
||||
inline void ShallowCopy(const ServerBitmap *from);
|
||||
|
||||
@@ -84,23 +86,19 @@ protected:
|
||||
virtual ~ServerBitmap();
|
||||
|
||||
//! used by the BitmapManager
|
||||
inline void _SetArea(area_id ID)
|
||||
{ fArea = ID; }
|
||||
|
||||
//! used by the BitmapManager
|
||||
inline void _SetBuffer(void *ptr)
|
||||
{ fBuffer = (uint8*)ptr; }
|
||||
// inline void _SetBuffer(void *ptr)
|
||||
// { fBuffer = (uint8*)ptr; }
|
||||
|
||||
bool _Release();
|
||||
|
||||
void _AllocateBuffer();
|
||||
void _FreeBuffer();
|
||||
|
||||
void _HandleSpace(color_space space,
|
||||
int32 bytesperline = -1);
|
||||
|
||||
bool fInitialized;
|
||||
area_id fArea;
|
||||
ClientMemoryAllocator* fAllocator;
|
||||
void* fAllocationCookie;
|
||||
uint8* fBuffer;
|
||||
int32 fReferenceCount;
|
||||
|
||||
@@ -111,7 +109,6 @@ protected:
|
||||
int32 fFlags;
|
||||
int fBitsPerPixel;
|
||||
int32 fToken;
|
||||
int32 fOffset;
|
||||
};
|
||||
|
||||
class UtilityBitmap : public ServerBitmap {
|
||||
@@ -140,7 +137,6 @@ ServerBitmap::ShallowCopy(const ServerBitmap* from)
|
||||
return;
|
||||
|
||||
fInitialized = from->fInitialized;
|
||||
fArea = from->fArea;
|
||||
fBuffer = from->fBuffer;
|
||||
fWidth = from->fWidth;
|
||||
fHeight = from->fHeight;
|
||||
@@ -149,8 +145,6 @@ ServerBitmap::ShallowCopy(const ServerBitmap* from)
|
||||
fFlags = from->fFlags;
|
||||
fBitsPerPixel = from->fBitsPerPixel;
|
||||
fToken = from->fToken;
|
||||
fOffset = from->fOffset;
|
||||
}
|
||||
|
||||
|
||||
#endif // _SERVER_BITMAP_H_
|
||||
#endif // SERVER_BITMAP_H
|
||||
|
||||
Reference in New Issue
Block a user