2003-01-13 01:51:01 +03:00
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
// Copyright (c) 2001-2002, OpenBeOS
|
|
|
|
//
|
|
|
|
// Permission is hereby granted, free of charge, to any person obtaining a
|
|
|
|
// copy of this software and associated documentation files (the "Software"),
|
|
|
|
// to deal in the Software without restriction, including without limitation
|
|
|
|
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
|
|
|
// and/or sell copies of the Software, and to permit persons to whom the
|
|
|
|
// Software is furnished to do so, subject to the following conditions:
|
|
|
|
//
|
|
|
|
// The above copyright notice and this permission notice shall be included in
|
|
|
|
// all copies or substantial portions of the Software.
|
|
|
|
//
|
|
|
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
|
|
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
|
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
|
|
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
|
|
|
// DEALINGS IN THE SOFTWARE.
|
|
|
|
//
|
|
|
|
// File Name: ServerBitmap.h
|
|
|
|
// Author: DarkWyrm <bpmagic@columbus.rr.com>
|
|
|
|
// Description: Bitmap class used inside the server
|
|
|
|
//
|
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
#ifndef _SERVER_BITMAP_H_
|
|
|
|
#define _SERVER_BITMAP_H_
|
|
|
|
|
|
|
|
#include <GraphicsDefs.h>
|
|
|
|
#include <Rect.h>
|
|
|
|
#include <OS.h>
|
|
|
|
|
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.
|
|
|
|
*/
|
|
|
|
class ServerBitmap
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
ServerBitmap(BRect rect,color_space space, int32 flags,
|
|
|
|
int32 bytesperline=-1, screen_id screen=B_MAIN_SCREEN_ID);
|
|
|
|
ServerBitmap(const ServerBitmap *bmp);
|
|
|
|
~ServerBitmap(void);
|
|
|
|
|
|
|
|
/*!
|
|
|
|
\brief Returns the area in which the buffer resides
|
|
|
|
\return
|
|
|
|
- \c B_ERROR if the buffer is not allocated in an area
|
|
|
|
- area_id for the buffer
|
|
|
|
*/
|
2004-02-07 16:47:52 +03:00
|
|
|
area_id Area(void) const { return _area; }
|
2003-01-13 01:51:01 +03:00
|
|
|
|
2003-03-12 17:29:59 +03:00
|
|
|
// Returns the offset of the bitmap in its area
|
|
|
|
int32 AreaOffset(void) { return _offset; }
|
|
|
|
|
2003-01-13 01:51:01 +03:00
|
|
|
//! Returns the bitmap's buffer
|
2004-02-07 16:47:52 +03:00
|
|
|
uint8 *Bits(void) const { return _buffer; }
|
|
|
|
uint32 BitsLength(void) const;
|
2003-01-13 01:51:01 +03:00
|
|
|
|
|
|
|
//! Returns the size of the bitmap
|
2004-02-07 16:47:52 +03:00
|
|
|
BRect Bounds() const { return BRect(0,0,_width-1,_height-1); };
|
2003-01-13 01:51:01 +03:00
|
|
|
|
|
|
|
//! Returns the number of bytes in each row, including padding
|
2004-02-07 16:47:52 +03:00
|
|
|
int32 BytesPerRow(void) const { return _bytesperrow; };
|
2003-01-13 01:51:01 +03:00
|
|
|
|
|
|
|
//! Returns the pixel color depth
|
2004-02-07 16:47:52 +03:00
|
|
|
uint8 BitsPerPixel(void) const { return _bpp; }
|
2003-01-13 01:51:01 +03:00
|
|
|
|
|
|
|
//! Returns the color space of the bitmap
|
2004-02-07 16:47:52 +03:00
|
|
|
color_space ColorSpace(void) const { return _space; }
|
2003-01-13 01:51:01 +03:00
|
|
|
|
|
|
|
//! Returns the width of the bitmap
|
|
|
|
int32 Width(void) const { return _width; }
|
|
|
|
|
|
|
|
//! Returns the height of the bitmap
|
|
|
|
int32 Height(void) const { return _height; }
|
|
|
|
|
|
|
|
//! Returns whether the bitmap is valid
|
2004-02-07 16:47:52 +03:00
|
|
|
bool InitCheck(void) const { return _initialized; }
|
2003-01-13 01:51:01 +03:00
|
|
|
|
2003-03-12 17:29:59 +03:00
|
|
|
//! Returns the identifier token for the bitmap
|
2004-02-07 16:47:52 +03:00
|
|
|
int32 Token(void) const { return _token; }
|
2003-03-12 17:29:59 +03:00
|
|
|
|
2004-02-15 23:26:01 +03:00
|
|
|
//! Does a shallow copy of the bitmap passed to it
|
|
|
|
void ShallowCopy(const ServerBitmap *from)
|
|
|
|
{
|
|
|
|
if(!from)
|
|
|
|
return;
|
|
|
|
|
|
|
|
_initialized=from->_initialized;
|
|
|
|
_area=from->_area;
|
|
|
|
_buffer=from->_buffer;
|
|
|
|
_width=from->_width;
|
|
|
|
_height=from->_height;
|
|
|
|
_bytesperrow=from->_bytesperrow;
|
|
|
|
_space=from->_space;
|
|
|
|
_flags=from->_flags;
|
|
|
|
_bpp=from->_bpp;
|
|
|
|
_token=from->_token;
|
|
|
|
_offset=from->_offset;
|
|
|
|
}
|
|
|
|
|
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;
|
|
|
|
|
2003-01-13 01:51:01 +03:00
|
|
|
//! Internal function used by the BitmapManager.
|
|
|
|
void _SetArea(area_id ID) { _area=ID; }
|
|
|
|
|
|
|
|
//! Internal function used by the BitmapManager.
|
|
|
|
void _SetBuffer(void *ptr) { _buffer=(uint8*)ptr; }
|
2003-02-22 23:23:22 +03:00
|
|
|
void _AllocateBuffer(void);
|
|
|
|
void _FreeBuffer(void);
|
2003-01-13 01:51:01 +03:00
|
|
|
|
|
|
|
void _HandleSpace(color_space space, int32 bytesperline=-1);
|
|
|
|
|
|
|
|
bool _initialized;
|
|
|
|
area_id _area;
|
|
|
|
uint8 *_buffer;
|
|
|
|
|
|
|
|
int32 _width,_height;
|
|
|
|
int32 _bytesperrow;
|
|
|
|
color_space _space;
|
|
|
|
int32 _flags;
|
|
|
|
int _bpp;
|
2003-03-12 17:29:59 +03:00
|
|
|
int32 _token;
|
|
|
|
int32 _offset;
|
2003-01-13 01:51:01 +03:00
|
|
|
};
|
|
|
|
|
2004-02-07 16:47:52 +03: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);
|
|
|
|
~UtilityBitmap(void);
|
|
|
|
};
|
|
|
|
|
2003-02-07 20:30:17 +03:00
|
|
|
#endif
|