2 * Copyright 2001-2007, Haiku, Inc. All rights reserved.
3 * Distributed under the terms of the MIT License.
9 #include <Archivable.h>
10 #include <InterfaceDefs.h>
20 B_BITMAP_CLEAR_TO_WHITE
= 0x00000001,
21 B_BITMAP_ACCEPTS_VIEWS
= 0x00000002,
22 B_BITMAP_IS_AREA
= 0x00000004,
23 B_BITMAP_IS_LOCKED
= 0x00000008 | B_BITMAP_IS_AREA
,
24 B_BITMAP_IS_CONTIGUOUS
= 0x00000010 | B_BITMAP_IS_LOCKED
,
25 B_BITMAP_IS_OFFSCREEN
= 0x00000020,
26 // Offscreen but non-overlay bitmaps are not supported on Haiku,
27 // but appearantly never were on BeOS either! The accelerant API
28 // would need to be extended to so that the app_server can ask
29 // the graphics driver to reserve memory for a bitmap and for this
30 // to make any sense, an accelerated blit from this memory into
31 // the framebuffer needs to be added to the API as well.
32 B_BITMAP_WILL_OVERLAY
= 0x00000040 | B_BITMAP_IS_OFFSCREEN
,
33 B_BITMAP_RESERVE_OVERLAY_CHANNEL
= 0x00000080,
36 B_BITMAP_NO_SERVER_LINK
= 0x00000100,
37 // Cheap to create, object will manage memory itself,
38 // no BApplication needs to run, but one can't draw such
42 #define B_ANY_BYTES_PER_ROW -1
45 class BBitmap
: public BArchivable
{
47 BBitmap(BRect bounds
, uint32 flags
,
48 color_space colorSpace
,
49 int32 bytesPerRow
= B_ANY_BYTES_PER_ROW
,
50 screen_id screenID
= B_MAIN_SCREEN_ID
);
51 BBitmap(BRect bounds
, color_space colorSpace
,
52 bool acceptsViews
= false,
53 bool needsContiguous
= false);
54 BBitmap(const BBitmap
& source
, uint32 flags
);
55 BBitmap(const BBitmap
& source
);
56 BBitmap(const BBitmap
* source
,
57 bool acceptsViews
= false,
58 bool needsContiguous
= false);
62 BBitmap(BMessage
* data
);
63 static BArchivable
* Instantiate(BMessage
* data
);
64 virtual status_t
Archive(BMessage
* data
, bool deep
= true) const;
66 status_t
InitCheck() const;
69 status_t
LockBits(uint32
* state
= NULL
);
74 int32
BitsLength() const;
75 int32
BytesPerRow() const;
76 color_space
ColorSpace() const;
79 status_t
SetDrawingFlags(uint32 flags
);
82 void SetBits(const void* data
, int32 length
,
83 int32 offset
, color_space colorSpace
);
85 // not part of the R5 API
86 status_t
ImportBits(const void* data
, int32 length
,
87 int32 bpr
, int32 offset
,
88 color_space colorSpace
);
89 status_t
ImportBits(const void* data
, int32 length
,
90 int32 bpr
, color_space colorSpace
,
91 BPoint from
, BPoint to
, int32 width
,
93 status_t
ImportBits(const BBitmap
* bitmap
);
94 status_t
ImportBits(const BBitmap
* bitmap
, BPoint from
,
95 BPoint to
, int32 width
, int32 height
);
97 status_t
GetOverlayRestrictions(
98 overlay_restrictions
* restrictions
) const;
100 // to mimic a BWindow
101 virtual void AddChild(BView
* view
);
102 virtual bool RemoveChild(BView
* view
);
103 int32
CountChildren() const;
104 BView
* ChildAt(int32 index
) const;
105 BView
* FindView(const char* viewName
) const;
106 BView
* FindView(BPoint point
) const;
109 bool IsLocked() const;
111 BBitmap
& operator=(const BBitmap
& source
);
116 friend class BApplication
;
117 friend class ::BPrivate::BPrivateScreen
;
118 friend class Private
;
120 virtual status_t
Perform(perform_code d
, void* arg
);
121 virtual void _ReservedBitmap1();
122 virtual void _ReservedBitmap2();
123 virtual void _ReservedBitmap3();
125 int32
_ServerToken() const;
126 void _InitObject(BRect bounds
,
127 color_space colorSpace
, uint32 flags
,
128 int32 bytesPerRow
, screen_id screenID
);
130 void _AssertPointer();
132 void _ReconnectToAppServer();
137 color_space fColorSpace
;