2006-03-18 19:42:14 +03:00
|
|
|
/*
|
|
|
|
* Copyright 2001-2006, Haiku.
|
|
|
|
* Distributed under the terms of the MIT License.
|
|
|
|
*
|
|
|
|
* Authors:
|
|
|
|
* DarkWyrm <bpmagic@columbus.rr.com>
|
2006-04-22 20:41:12 +04:00
|
|
|
* Axel Dörfler, axeld@pinc-software.de
|
2006-03-18 19:42:14 +03:00
|
|
|
*/
|
|
|
|
#ifndef SERVER_BITMAP_H
|
|
|
|
#define SERVER_BITMAP_H
|
|
|
|
|
|
|
|
|
2006-04-22 20:41:12 +04:00
|
|
|
#include "RGBColor.h"
|
|
|
|
|
2006-03-18 19:42:14 +03:00
|
|
|
#include <GraphicsDefs.h>
|
|
|
|
#include <Rect.h>
|
|
|
|
#include <OS.h>
|
|
|
|
|
2006-04-22 00:14:41 +04:00
|
|
|
#include <video_overlay.h>
|
|
|
|
|
2006-03-18 19:42:14 +03:00
|
|
|
|
|
|
|
class BitmapManager;
|
|
|
|
class ClientMemoryAllocator;
|
2006-04-22 00:14:41 +04:00
|
|
|
class HWInterface;
|
2006-04-22 20:41:12 +04:00
|
|
|
class OverlayCookie;
|
|
|
|
struct overlay_client_data;
|
2006-03-18 19:42:14 +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.
|
|
|
|
*/
|
|
|
|
class ServerBitmap {
|
|
|
|
public:
|
|
|
|
inline bool IsValid() const
|
2006-04-22 20:41:12 +04:00
|
|
|
{ return fBuffer != NULL; }
|
2006-03-18 19:42:14 +03:00
|
|
|
|
|
|
|
void Acquire();
|
|
|
|
|
|
|
|
inline uint8* Bits() const
|
|
|
|
{ return fBuffer; }
|
|
|
|
inline uint32 BitsLength() const
|
|
|
|
{ return (uint32)(fBytesPerRow * fHeight); }
|
|
|
|
|
|
|
|
inline BRect Bounds() const
|
|
|
|
{ return BRect(0, 0, fWidth - 1, fHeight - 1); }
|
|
|
|
inline int32 Width() const
|
|
|
|
{ return fWidth; }
|
|
|
|
inline int32 Height() const
|
|
|
|
{ return fHeight; }
|
|
|
|
|
|
|
|
inline int32 BytesPerRow() const
|
|
|
|
{ return fBytesPerRow; }
|
|
|
|
inline uint8 BitsPerPixel() const
|
|
|
|
{ return fBitsPerPixel; }
|
|
|
|
inline color_space ColorSpace() const
|
|
|
|
{ return fSpace; }
|
|
|
|
|
|
|
|
//! Returns the identifier token for the bitmap
|
|
|
|
inline int32 Token() const
|
|
|
|
{ return fToken; }
|
|
|
|
|
|
|
|
inline void* AllocationCookie() const
|
|
|
|
{ return fAllocationCookie; }
|
|
|
|
|
|
|
|
area_id Area() const;
|
|
|
|
uint32 AreaOffset() const;
|
|
|
|
|
2006-04-22 20:41:12 +04:00
|
|
|
void SetOverlayCookie(::OverlayCookie* cookie);
|
|
|
|
::OverlayCookie* OverlayCookie() const;
|
2006-04-22 00:14:41 +04:00
|
|
|
|
2006-03-18 19:42:14 +03:00
|
|
|
//! Does a shallow copy of the bitmap passed to it
|
|
|
|
inline void ShallowCopy(const ServerBitmap *from);
|
|
|
|
|
|
|
|
status_t ImportBits(const void *bits, int32 bitsLength,
|
|
|
|
int32 bytesPerRow, color_space colorSpace);
|
|
|
|
status_t ImportBits(const void *bits, int32 bitsLength,
|
|
|
|
int32 bytesPerRow, color_space colorSpace,
|
|
|
|
BPoint from, BPoint to, int32 width,
|
|
|
|
int32 height);
|
|
|
|
|
|
|
|
void PrintToStream();
|
|
|
|
|
|
|
|
protected:
|
|
|
|
friend class BitmapManager;
|
|
|
|
friend class PicturePlayer;
|
|
|
|
|
|
|
|
ServerBitmap(BRect rect,
|
|
|
|
color_space space,
|
|
|
|
int32 flags,
|
|
|
|
int32 bytesPerRow = -1,
|
|
|
|
screen_id screen = B_MAIN_SCREEN_ID);
|
|
|
|
ServerBitmap(const ServerBitmap* bmp);
|
|
|
|
virtual ~ServerBitmap();
|
|
|
|
|
|
|
|
//! used by the BitmapManager
|
|
|
|
// inline void _SetBuffer(void *ptr)
|
|
|
|
// { fBuffer = (uint8*)ptr; }
|
|
|
|
|
|
|
|
bool _Release();
|
|
|
|
|
|
|
|
void _AllocateBuffer();
|
|
|
|
|
|
|
|
void _HandleSpace(color_space space,
|
|
|
|
int32 bytesperline = -1);
|
|
|
|
|
|
|
|
ClientMemoryAllocator* fAllocator;
|
|
|
|
void* fAllocationCookie;
|
2006-04-22 20:41:12 +04:00
|
|
|
::OverlayCookie* fOverlayCookie;
|
2006-03-18 19:42:14 +03:00
|
|
|
uint8* fBuffer;
|
|
|
|
int32 fReferenceCount;
|
|
|
|
|
|
|
|
int32 fWidth;
|
|
|
|
int32 fHeight;
|
|
|
|
int32 fBytesPerRow;
|
|
|
|
color_space fSpace;
|
|
|
|
int32 fFlags;
|
|
|
|
int fBitsPerPixel;
|
|
|
|
int32 fToken;
|
|
|
|
};
|
|
|
|
|
|
|
|
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);
|
|
|
|
|
|
|
|
UtilityBitmap(const uint8* alreadyPaddedData,
|
|
|
|
uint32 width,
|
|
|
|
uint32 height,
|
|
|
|
color_space format);
|
|
|
|
|
|
|
|
|
|
|
|
virtual ~UtilityBitmap();
|
|
|
|
};
|
|
|
|
|
2006-04-22 00:14:41 +04:00
|
|
|
//! An allocation cookie for overlays
|
|
|
|
class OverlayCookie {
|
|
|
|
public:
|
|
|
|
OverlayCookie(HWInterface& interface);
|
|
|
|
~OverlayCookie();
|
|
|
|
|
2006-04-22 20:41:12 +04:00
|
|
|
status_t InitCheck() const;
|
|
|
|
|
|
|
|
void SetOverlayData(const overlay_buffer* overlayBuffer,
|
|
|
|
overlay_token token, overlay_client_data* clientData);
|
2006-04-23 18:28:48 +04:00
|
|
|
void TakeOverToken(OverlayCookie* other);
|
2006-04-22 01:13:11 +04:00
|
|
|
|
2006-04-22 20:41:12 +04:00
|
|
|
const overlay_buffer* OverlayBuffer() const;
|
|
|
|
overlay_client_data* ClientData() const;
|
2006-04-22 01:13:11 +04:00
|
|
|
overlay_token OverlayToken() const;
|
2006-04-22 00:14:41 +04:00
|
|
|
|
2006-04-22 20:41:12 +04:00
|
|
|
sem_id Semaphore() const
|
|
|
|
{ return fSemaphore; }
|
|
|
|
|
|
|
|
const RGBColor& Color() const
|
|
|
|
{ return fColor; }
|
|
|
|
|
2006-04-23 18:28:48 +04:00
|
|
|
void SetVisible(bool visible)
|
|
|
|
{ fVisible = visible; }
|
|
|
|
bool IsVisible() const
|
|
|
|
{ return fVisible; }
|
|
|
|
|
|
|
|
void SetView(const BRect& source, const BRect& destination);
|
|
|
|
const BRect& Source() const
|
|
|
|
{ return fSource; }
|
|
|
|
const BRect& Destination() const
|
|
|
|
{ return fDestination; }
|
|
|
|
|
|
|
|
void Show();
|
|
|
|
void Hide();
|
|
|
|
|
2006-04-22 00:14:41 +04:00
|
|
|
private:
|
2006-04-22 01:13:11 +04:00
|
|
|
HWInterface& fHWInterface;
|
|
|
|
const overlay_buffer* fOverlayBuffer;
|
2006-04-22 20:41:12 +04:00
|
|
|
overlay_client_data* fClientData;
|
2006-04-22 01:13:11 +04:00
|
|
|
overlay_token fOverlayToken;
|
2006-04-22 20:41:12 +04:00
|
|
|
sem_id fSemaphore;
|
|
|
|
RGBColor fColor;
|
2006-04-23 18:28:48 +04:00
|
|
|
BRect fSource;
|
|
|
|
BRect fDestination;
|
|
|
|
bool fVisible;
|
2006-04-22 00:14:41 +04:00
|
|
|
};
|
|
|
|
|
2006-04-22 20:41:12 +04:00
|
|
|
// ShallowCopy (only for server bitmaps)
|
2006-03-18 19:42:14 +03:00
|
|
|
void
|
|
|
|
ServerBitmap::ShallowCopy(const ServerBitmap* from)
|
|
|
|
{
|
|
|
|
if (!from)
|
|
|
|
return;
|
|
|
|
|
|
|
|
fBuffer = from->fBuffer;
|
|
|
|
fWidth = from->fWidth;
|
|
|
|
fHeight = from->fHeight;
|
|
|
|
fBytesPerRow = from->fBytesPerRow;
|
|
|
|
fSpace = from->fSpace;
|
|
|
|
fFlags = from->fFlags;
|
|
|
|
fBitsPerPixel = from->fBitsPerPixel;
|
|
|
|
fToken = from->fToken;
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif // SERVER_BITMAP_H
|