2005-12-29 18:36:18 +03:00
|
|
|
/*
|
2006-02-05 21:14:14 +03:00
|
|
|
* Copyright 2001-2006, Haiku.
|
2005-12-29 18:36:18 +03:00
|
|
|
* Distributed under the terms of the MIT License.
|
|
|
|
*
|
|
|
|
* Authors:
|
|
|
|
* DarkWyrm <bpmagic@columbus.rr.com>
|
|
|
|
*/
|
2003-01-13 01:51:01 +03:00
|
|
|
#ifndef _SERVER_BITMAP_H_
|
|
|
|
#define _SERVER_BITMAP_H_
|
|
|
|
|
2005-12-29 18:36:18 +03:00
|
|
|
|
2003-01-13 01:51:01 +03:00
|
|
|
#include <GraphicsDefs.h>
|
|
|
|
#include <Rect.h>
|
|
|
|
#include <OS.h>
|
|
|
|
|
2005-12-29 18:36:18 +03:00
|
|
|
|
2003-02-13 03:03:31 +03:00
|
|
|
class BitmapManager;
|
|
|
|
|
2003-01-13 01:51:01 +03:00
|
|
|
/*!
|
|
|
|
\class ServerBitmap ServerBitmap.h
|
|
|
|
\brief Bitmap class used inside the server.
|
|
|
|
|
|
|
|
This class is not directly allocated or freed. Instead, it is
|
|
|
|
managed by the BitmapManager class. It is also the base class for
|
|
|
|
all cursors. Every BBitmap has a shadow ServerBitmap object.
|
|
|
|
*/
|
2005-04-13 23:31:24 +04:00
|
|
|
class ServerBitmap {
|
|
|
|
public:
|
2006-02-05 21:14:14 +03:00
|
|
|
inline bool IsValid() const
|
|
|
|
{ return fInitialized; }
|
|
|
|
|
2005-12-29 18:36:18 +03:00
|
|
|
void Acquire();
|
2003-01-13 01:51:01 +03:00
|
|
|
|
2005-04-13 23:31:24 +04:00
|
|
|
inline area_id Area() const
|
|
|
|
{ return fArea; }
|
|
|
|
inline int32 AreaOffset() const
|
|
|
|
{ return fOffset; }
|
2005-12-29 18:36:18 +03:00
|
|
|
|
2005-04-13 23:31:24 +04:00
|
|
|
inline uint8* Bits() const
|
|
|
|
{ return fBuffer; }
|
2005-04-15 19:32:21 +04:00
|
|
|
inline uint32 BitsLength() const
|
2005-04-15 19:31:57 +04:00
|
|
|
{ return (uint32)(fBytesPerRow * fHeight); }
|
2005-04-13 23:31:24 +04:00
|
|
|
|
|
|
|
inline BRect Bounds() const
|
|
|
|
{ return BRect(0, 0, fWidth - 1, fHeight - 1); }
|
2006-02-05 21:14:14 +03:00
|
|
|
inline int32 Width() const
|
|
|
|
{ return fWidth; }
|
|
|
|
inline int32 Height() const
|
|
|
|
{ return fHeight; }
|
2005-12-29 18:36:18 +03:00
|
|
|
|
2005-04-13 23:31:24 +04:00
|
|
|
inline int32 BytesPerRow() const
|
|
|
|
{ return fBytesPerRow; }
|
|
|
|
inline uint8 BitsPerPixel() const
|
2005-04-13 23:38:25 +04:00
|
|
|
{ return fBitsPerPixel; }
|
2005-04-13 23:31:24 +04:00
|
|
|
inline color_space ColorSpace() const
|
|
|
|
{ return fSpace; }
|
2005-12-29 18:36:18 +03:00
|
|
|
|
2003-03-12 17:29:59 +03:00
|
|
|
//! Returns the identifier token for the bitmap
|
2005-04-13 23:31:24 +04:00
|
|
|
inline int32 Token() const
|
|
|
|
{ return fToken; }
|
2005-12-29 18:36:18 +03:00
|
|
|
|
2004-02-15 23:26:01 +03:00
|
|
|
//! Does a shallow copy of the bitmap passed to it
|
2005-04-13 23:31:24 +04:00
|
|
|
inline void ShallowCopy(const ServerBitmap *from);
|
2005-12-29 18:36:18 +03:00
|
|
|
|
2006-03-05 15:59:39 +03:00
|
|
|
status_t ImportBits(const void *bits, int32 bitsLength,
|
|
|
|
int32 bytesPerRow, color_space colorSpace);
|
|
|
|
|
2006-02-05 21:14:14 +03:00
|
|
|
void PrintToStream();
|
|
|
|
|
2003-01-13 01:51:01 +03:00
|
|
|
protected:
|
2003-06-23 06:54:52 +04:00
|
|
|
friend class BitmapManager;
|
2003-10-19 02:45:16 +04:00
|
|
|
friend class PicturePlayer;
|
|
|
|
|
2005-12-29 18:36:18 +03:00
|
|
|
ServerBitmap(BRect rect,
|
|
|
|
color_space space,
|
|
|
|
int32 flags,
|
2006-02-05 21:14:14 +03:00
|
|
|
int32 bytesPerRow = -1,
|
2005-12-29 18:36:18 +03:00
|
|
|
screen_id screen = B_MAIN_SCREEN_ID);
|
|
|
|
ServerBitmap(const ServerBitmap* bmp);
|
|
|
|
virtual ~ServerBitmap();
|
|
|
|
|
2005-04-13 23:31:24 +04:00
|
|
|
//! used by the BitmapManager
|
|
|
|
inline void _SetArea(area_id ID)
|
2005-12-29 18:36:18 +03:00
|
|
|
{ fArea = ID; }
|
|
|
|
|
2005-04-13 23:31:24 +04:00
|
|
|
//! used by the BitmapManager
|
|
|
|
inline void _SetBuffer(void *ptr)
|
2005-12-29 18:36:18 +03:00
|
|
|
{ fBuffer = (uint8*)ptr; }
|
|
|
|
|
|
|
|
bool _Release();
|
2005-04-13 23:31:24 +04:00
|
|
|
|
|
|
|
void _AllocateBuffer();
|
|
|
|
void _FreeBuffer();
|
2005-12-29 18:36:18 +03:00
|
|
|
|
2005-04-13 23:31:24 +04:00
|
|
|
void _HandleSpace(color_space space,
|
|
|
|
int32 bytesperline = -1);
|
|
|
|
|
|
|
|
bool fInitialized;
|
|
|
|
area_id fArea;
|
|
|
|
uint8* fBuffer;
|
2005-12-29 18:36:18 +03:00
|
|
|
int32 fReferenceCount;
|
|
|
|
|
2005-04-13 23:31:24 +04:00
|
|
|
int32 fWidth;
|
|
|
|
int32 fHeight;
|
|
|
|
int32 fBytesPerRow;
|
|
|
|
color_space fSpace;
|
|
|
|
int32 fFlags;
|
|
|
|
int fBitsPerPixel;
|
|
|
|
int32 fToken;
|
|
|
|
int32 fOffset;
|
2003-01-13 01:51:01 +03:00
|
|
|
};
|
|
|
|
|
2005-04-13 23:31:24 +04:00
|
|
|
class UtilityBitmap : public ServerBitmap {
|
|
|
|
public:
|
|
|
|
UtilityBitmap(BRect rect,
|
|
|
|
color_space space,
|
|
|
|
int32 flags,
|
|
|
|
int32 bytesperline = -1,
|
|
|
|
screen_id screen = B_MAIN_SCREEN_ID);
|
|
|
|
UtilityBitmap(const ServerBitmap* bmp);
|
|
|
|
|
2005-04-14 04:06:01 +04:00
|
|
|
UtilityBitmap(const uint8* alreadyPaddedData,
|
|
|
|
uint32 width,
|
|
|
|
uint32 height,
|
|
|
|
color_space format);
|
|
|
|
|
|
|
|
|
2005-04-13 23:31:24 +04:00
|
|
|
virtual ~UtilityBitmap();
|
2004-02-07 16:47:52 +03:00
|
|
|
};
|
|
|
|
|
2005-04-13 23:31:24 +04:00
|
|
|
// ShallowCopy
|
|
|
|
void
|
|
|
|
ServerBitmap::ShallowCopy(const ServerBitmap* from)
|
|
|
|
{
|
|
|
|
if (!from)
|
|
|
|
return;
|
2005-12-29 18:36:18 +03:00
|
|
|
|
2005-04-13 23:31:24 +04:00
|
|
|
fInitialized = from->fInitialized;
|
|
|
|
fArea = from->fArea;
|
|
|
|
fBuffer = from->fBuffer;
|
|
|
|
fWidth = from->fWidth;
|
|
|
|
fHeight = from->fHeight;
|
|
|
|
fBytesPerRow = from->fBytesPerRow;
|
|
|
|
fSpace = from->fSpace;
|
|
|
|
fFlags = from->fFlags;
|
|
|
|
fBitsPerPixel = from->fBitsPerPixel;
|
|
|
|
fToken = from->fToken;
|
|
|
|
fOffset = from->fOffset;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#endif // _SERVER_BITMAP_H_
|