2 * Copyright 2001-2010, Haiku.
3 * Distributed under the terms of the MIT License.
6 * DarkWyrm <bpmagic@columbus.rr.com>
7 * Axel Dörfler, axeld@pinc-software.de
9 #ifndef SERVER_BITMAP_H
10 #define SERVER_BITMAP_H
13 #include <GraphicsDefs.h>
17 #include <Referenceable.h>
19 #include "ClientMemoryAllocator.h"
28 /*! \class ServerBitmap ServerBitmap.h
29 \brief Bitmap class used inside the server.
31 This class is not directly allocated or freed. Instead, it is
32 managed by the BitmapManager class. It is also the base class for
33 all cursors. Every BBitmap has a shadow ServerBitmap object.
35 class ServerBitmap
: public BReferenceable
{
37 inline bool IsValid() const
38 { return fBuffer
!= NULL
; }
40 inline uint8
* Bits() const
42 inline uint32
BitsLength() const
43 { return (uint32
)(fBytesPerRow
* fHeight
); }
45 inline BRect
Bounds() const
46 { return BRect(0, 0, fWidth
- 1, fHeight
- 1); }
47 inline int32
Width() const
49 inline int32
Height() const
52 inline int32
BytesPerRow() const
53 { return fBytesPerRow
; }
55 inline color_space
ColorSpace() const
57 inline uint32
Flags() const
60 //! Returns the identifier token for the bitmap
61 inline int32
Token() const
65 uint32
AreaOffset() const;
67 void SetOverlay(::Overlay
* overlay
);
68 ::Overlay
* Overlay() const;
70 void SetOwner(ServerApp
* owner
);
71 ServerApp
* Owner() const;
73 //! Does a shallow copy of the bitmap passed to it
74 inline void ShallowCopy(const ServerBitmap
*from
);
76 status_t
ImportBits(const void *bits
, int32 bitsLength
,
77 int32 bytesPerRow
, color_space colorSpace
);
78 status_t
ImportBits(const void *bits
, int32 bitsLength
,
79 int32 bytesPerRow
, color_space colorSpace
,
80 BPoint from
, BPoint to
, int32 width
,
86 friend class BitmapManager
;
88 ServerBitmap(BRect rect
, color_space space
,
89 uint32 flags
, int32 bytesPerRow
= -1,
90 screen_id screen
= B_MAIN_SCREEN_ID
);
91 ServerBitmap(const ServerBitmap
* bmp
);
92 virtual ~ServerBitmap();
94 void AllocateBuffer();
97 ClientMemory fClientMemory
;
112 class UtilityBitmap
: public ServerBitmap
{
114 UtilityBitmap(BRect rect
, color_space space
,
115 uint32 flags
, int32 bytesperline
= -1,
116 screen_id screen
= B_MAIN_SCREEN_ID
);
117 UtilityBitmap(const ServerBitmap
* bmp
);
119 UtilityBitmap(const uint8
* alreadyPaddedData
,
120 uint32 width
, uint32 height
,
123 virtual ~UtilityBitmap();
127 //! (only for server bitmaps)
129 ServerBitmap::ShallowCopy(const ServerBitmap
* from
)
134 fBuffer
= from
->fBuffer
;
135 fWidth
= from
->fWidth
;
136 fHeight
= from
->fHeight
;
137 fBytesPerRow
= from
->fBytesPerRow
;
138 fSpace
= from
->fSpace
;
139 fFlags
= from
->fFlags
;
140 fToken
= from
->fToken
;
143 #endif // SERVER_BITMAP_H