* Implemented new BView drawing functions DrawBitmap[Async](
const BBitmap* bitmap, BRect bitmapRect, BRect viewRect, uint32 options). Only option so far is B_FILTER_BITMAP_BILINEAR. * BView::DrawBitmap[Async](const BBitmap* bitmap, BRect viewRect) was accessing the bitmap pointer without checking it. Would therefore crash when passing NULL, unlike the other methods. * The BPicture code already reserved room for the BBitmap flags, but did not store the actual flags and neiter use them for anything. Since the bitmap data is stored anyways, the bitmap creation flags do not matter. So I reused this for the new bitmap drawing options. * Rewrote Bitmap.h and removed the B_BITMAP_SCALE_BILINEAR flag again. * Tried to optimize Painter::_DrawBitmapBilinearCopy32() a little by giving the compiler better hints. There seems to be a marginal, possibly imagined speed increase < 0.05 ms. ;-) git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@26665 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -26,107 +26,124 @@ enum {
|
||||
B_BITMAP_IS_LOCKED = 0x00000008 | B_BITMAP_IS_AREA,
|
||||
B_BITMAP_IS_CONTIGUOUS = 0x00000010 | B_BITMAP_IS_LOCKED,
|
||||
B_BITMAP_IS_OFFSCREEN = 0x00000020,
|
||||
// Offscreen but non-overlay bitmaps are not supported on Haiku,
|
||||
// but appearantly never were on BeOS either! The accelerant API
|
||||
// would need to be extended to so that the app_server can ask
|
||||
// the graphics driver to reserve memory for a bitmap and for this
|
||||
// to make any sense, an accelerated blit from this memory into
|
||||
// the framebuffer needs to be added to the API as well.
|
||||
B_BITMAP_WILL_OVERLAY = 0x00000040 | B_BITMAP_IS_OFFSCREEN,
|
||||
B_BITMAP_RESERVE_OVERLAY_CHANNEL = 0x00000080,
|
||||
|
||||
// Haiku extensions:
|
||||
B_BITMAP_NO_SERVER_LINK = 0x00000100,
|
||||
B_BITMAP_SCALE_BILINEAR = 0x00000200
|
||||
// TODO: Make this simply "SMOOTH_SCALE" and use
|
||||
// better quality methods the faster the computer?
|
||||
// Cheap to create, object will manage memory itself,
|
||||
// no BApplication needs to run, but one can't draw such
|
||||
// a BBitmap.
|
||||
};
|
||||
|
||||
#define B_ANY_BYTES_PER_ROW -1
|
||||
|
||||
|
||||
class BBitmap : public BArchivable {
|
||||
public:
|
||||
BBitmap(BRect bounds, uint32 flags, color_space colorSpace,
|
||||
int32 bytesPerRow = B_ANY_BYTES_PER_ROW,
|
||||
screen_id screenID = B_MAIN_SCREEN_ID);
|
||||
BBitmap(BRect bounds, color_space colorSpace, bool acceptsViews = false,
|
||||
bool needsContiguous = false);
|
||||
BBitmap(const BBitmap& source, uint32 flags);
|
||||
BBitmap(const BBitmap& source);
|
||||
BBitmap(const BBitmap *source, bool acceptsViews = false,
|
||||
bool needsContiguous = false);
|
||||
virtual ~BBitmap();
|
||||
public:
|
||||
BBitmap(BRect bounds, uint32 flags,
|
||||
color_space colorSpace,
|
||||
int32 bytesPerRow = B_ANY_BYTES_PER_ROW,
|
||||
screen_id screenID = B_MAIN_SCREEN_ID);
|
||||
BBitmap(BRect bounds, color_space colorSpace,
|
||||
bool acceptsViews = false,
|
||||
bool needsContiguous = false);
|
||||
BBitmap(const BBitmap& source, uint32 flags);
|
||||
BBitmap(const BBitmap& source);
|
||||
BBitmap(const BBitmap* source,
|
||||
bool acceptsViews = false,
|
||||
bool needsContiguous = false);
|
||||
virtual ~BBitmap();
|
||||
|
||||
// Archiving
|
||||
BBitmap(BMessage *data);
|
||||
static BArchivable *Instantiate(BMessage *data);
|
||||
virtual status_t Archive(BMessage *data, bool deep = true) const;
|
||||
// Archiving
|
||||
BBitmap(BMessage* data);
|
||||
static BArchivable* Instantiate(BMessage* data);
|
||||
virtual status_t Archive(BMessage* data, bool deep = true) const;
|
||||
|
||||
status_t InitCheck() const;
|
||||
bool IsValid() const;
|
||||
status_t InitCheck() const;
|
||||
bool IsValid() const;
|
||||
|
||||
status_t LockBits(uint32 *state = NULL);
|
||||
void UnlockBits();
|
||||
status_t LockBits(uint32* state = NULL);
|
||||
void UnlockBits();
|
||||
|
||||
area_id Area() const;
|
||||
void *Bits() const;
|
||||
int32 BitsLength() const;
|
||||
int32 BytesPerRow() const;
|
||||
color_space ColorSpace() const;
|
||||
BRect Bounds() const;
|
||||
uint32 Flags() const;
|
||||
area_id Area() const;
|
||||
void* Bits() const;
|
||||
int32 BitsLength() const;
|
||||
int32 BytesPerRow() const;
|
||||
color_space ColorSpace() const;
|
||||
BRect Bounds() const;
|
||||
|
||||
void SetBits(const void *data, int32 length, int32 offset,
|
||||
color_space colorSpace);
|
||||
status_t SetDrawingFlags(uint32 flags);
|
||||
uint32 Flags() const;
|
||||
|
||||
// not part of the R5 API
|
||||
status_t ImportBits(const void *data, int32 length, int32 bpr,
|
||||
int32 offset, color_space colorSpace);
|
||||
status_t ImportBits(const void *data, int32 length, int32 bpr,
|
||||
color_space colorSpace, BPoint from, BPoint to,
|
||||
int32 width, int32 height);
|
||||
status_t ImportBits(const BBitmap *bitmap);
|
||||
status_t ImportBits(const BBitmap *bitmap, BPoint from, BPoint to,
|
||||
int32 width, int32 height);
|
||||
void SetBits(const void* data, int32 length,
|
||||
int32 offset, color_space colorSpace);
|
||||
|
||||
status_t GetOverlayRestrictions(overlay_restrictions *restrictions) const;
|
||||
// not part of the R5 API
|
||||
status_t ImportBits(const void* data, int32 length,
|
||||
int32 bpr, int32 offset,
|
||||
color_space colorSpace);
|
||||
status_t ImportBits(const void* data, int32 length,
|
||||
int32 bpr, color_space colorSpace,
|
||||
BPoint from, BPoint to, int32 width,
|
||||
int32 height);
|
||||
status_t ImportBits(const BBitmap* bitmap);
|
||||
status_t ImportBits(const BBitmap* bitmap, BPoint from,
|
||||
BPoint to, int32 width, int32 height);
|
||||
|
||||
// to mimic a BWindow
|
||||
virtual void AddChild(BView *view);
|
||||
virtual bool RemoveChild(BView *view);
|
||||
int32 CountChildren() const;
|
||||
BView *ChildAt(int32 index) const;
|
||||
BView *FindView(const char *viewName) const;
|
||||
BView *FindView(BPoint point) const;
|
||||
bool Lock();
|
||||
void Unlock();
|
||||
bool IsLocked() const;
|
||||
status_t GetOverlayRestrictions(
|
||||
overlay_restrictions* restrictions) const;
|
||||
|
||||
BBitmap& operator=(const BBitmap& source);
|
||||
// to mimic a BWindow
|
||||
virtual void AddChild(BView* view);
|
||||
virtual bool RemoveChild(BView* view);
|
||||
int32 CountChildren() const;
|
||||
BView* ChildAt(int32 index) const;
|
||||
BView* FindView(const char* viewName) const;
|
||||
BView* FindView(BPoint point) const;
|
||||
bool Lock();
|
||||
void Unlock();
|
||||
bool IsLocked() const;
|
||||
|
||||
private:
|
||||
friend class BView;
|
||||
friend class BApplication;
|
||||
friend class BPrivate::BPrivateScreen;
|
||||
BBitmap& operator=(const BBitmap& source);
|
||||
|
||||
virtual status_t Perform(perform_code d, void *arg);
|
||||
virtual void _ReservedBitmap1();
|
||||
virtual void _ReservedBitmap2();
|
||||
virtual void _ReservedBitmap3();
|
||||
private:
|
||||
friend class BView;
|
||||
friend class BApplication;
|
||||
friend class BPrivate::BPrivateScreen;
|
||||
|
||||
int32 _ServerToken() const;
|
||||
void _InitObject(BRect bounds, color_space colorSpace, uint32 flags,
|
||||
int32 bytesPerRow, screen_id screenID);
|
||||
void _CleanUp();
|
||||
void _AssertPointer();
|
||||
virtual status_t Perform(perform_code d, void* arg);
|
||||
virtual void _ReservedBitmap1();
|
||||
virtual void _ReservedBitmap2();
|
||||
virtual void _ReservedBitmap3();
|
||||
|
||||
uint8 *fBasePointer;
|
||||
int32 fSize;
|
||||
color_space fColorSpace;
|
||||
BRect fBounds;
|
||||
int32 fBytesPerRow;
|
||||
BWindow *fWindow;
|
||||
int32 fServerToken;
|
||||
int32 fAreaOffset;
|
||||
uint8 unused;
|
||||
area_id fArea;
|
||||
area_id fServerArea;
|
||||
uint32 fFlags;
|
||||
status_t fInitError;
|
||||
int32 _ServerToken() const;
|
||||
void _InitObject(BRect bounds,
|
||||
color_space colorSpace, uint32 flags,
|
||||
int32 bytesPerRow, screen_id screenID);
|
||||
void _CleanUp();
|
||||
void _AssertPointer();
|
||||
|
||||
private:
|
||||
uint8* fBasePointer;
|
||||
int32 fSize;
|
||||
color_space fColorSpace;
|
||||
BRect fBounds;
|
||||
int32 fBytesPerRow;
|
||||
BWindow* fWindow;
|
||||
int32 fServerToken;
|
||||
int32 fAreaOffset;
|
||||
uint8 unused;
|
||||
area_id fArea;
|
||||
area_id fServerArea;
|
||||
uint32 fFlags;
|
||||
status_t fInitError;
|
||||
};
|
||||
|
||||
#endif // _BITMAP_H
|
||||
|
||||
Reference in New Issue
Block a user