usb_ecm: Use the current configuration instead of a fixed one.
[haiku.git] / src / servers / app / ServerBitmap.h
blobe3b4b36757d5bea7b312caa999a1c7a1ac567be3
1 /*
2 * Copyright 2001-2010, Haiku.
3 * Distributed under the terms of the MIT License.
5 * Authors:
6 * DarkWyrm <bpmagic@columbus.rr.com>
7 * Axel Dörfler, axeld@pinc-software.de
8 */
9 #ifndef SERVER_BITMAP_H
10 #define SERVER_BITMAP_H
13 #include <GraphicsDefs.h>
14 #include <Rect.h>
15 #include <OS.h>
17 #include <Referenceable.h>
19 #include "ClientMemoryAllocator.h"
22 class BitmapManager;
23 class HWInterface;
24 class Overlay;
25 class ServerApp;
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 {
36 public:
37 inline bool IsValid() const
38 { return fBuffer != NULL; }
40 inline uint8* Bits() const
41 { return fBuffer; }
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
48 { return fWidth; }
49 inline int32 Height() const
50 { return fHeight; }
52 inline int32 BytesPerRow() const
53 { return fBytesPerRow; }
55 inline color_space ColorSpace() const
56 { return fSpace; }
57 inline uint32 Flags() const
58 { return fFlags; }
60 //! Returns the identifier token for the bitmap
61 inline int32 Token() const
62 { return fToken; }
64 area_id Area() 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,
81 int32 height);
83 void PrintToStream();
85 protected:
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();
96 protected:
97 ClientMemory fClientMemory;
98 AreaMemory* fMemory;
99 ::Overlay* fOverlay;
100 uint8* fBuffer;
102 int32 fWidth;
103 int32 fHeight;
104 int32 fBytesPerRow;
105 color_space fSpace;
106 uint32 fFlags;
108 ServerApp* fOwner;
109 int32 fToken;
112 class UtilityBitmap : public ServerBitmap {
113 public:
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,
121 color_space format);
123 virtual ~UtilityBitmap();
127 //! (only for server bitmaps)
128 void
129 ServerBitmap::ShallowCopy(const ServerBitmap* from)
131 if (!from)
132 return;
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