* the app_server now uses a global token space - this should later be changed to

have different token spaces depending on the scope of its objects.
* removed TokenHandler - we're now using BTokenSpace instead.
* removed unused IPoint.cpp - if we ever need it again, it can still easily be
  resurrected from the dead.
* some cleanup.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@14925 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Axel Dörfler 2005-11-14 19:46:20 +00:00
parent 4a6c604ad4
commit be05d56c7e
18 changed files with 194 additions and 570 deletions

View File

@ -8,44 +8,31 @@
#ifndef BITMAP_MANAGER_H_
#define BITMAP_MANAGER_H_
#include <GraphicsDefs.h>
#include <List.h>
#include <Locker.h>
#include <OS.h>
#include <Rect.h>
#include <Locker.h>
#include "BGet++.h"
#include "TokenHandler.h"
class ServerBitmap;
/*!
\class BitmapManager BitmapManager.h
\brief Handler for BBitmap allocation
Whenever a ServerBitmap associated with a client-side BBitmap needs to be
created or destroyed, the BitmapManager needs to handle it. It takes care of
all memory management related to them.
NOTE: The allocator used is not thread-safe, it is currently protected
by the BitmapManager lock.
*/
class BitmapManager {
public:
public:
BitmapManager();
virtual ~BitmapManager();
virtual ~BitmapManager();
ServerBitmap *CreateBitmap( BRect bounds,
color_space space,
int32 flags,
int32 bytesPerRow = -1,
screen_id screen = B_MAIN_SCREEN_ID);
ServerBitmap* CreateBitmap(BRect bounds, color_space space,
int32 flags, int32 bytesPerRow = -1,
screen_id screen = B_MAIN_SCREEN_ID);
void DeleteBitmap(ServerBitmap* bitmap);
protected:
protected:
BList fBitmapList;
int8 *fBuffer;
TokenHandler fTokenizer;
int8* fBuffer;
BLocker fLock;
AreaPool fMemPool;
};

View File

@ -1,60 +0,0 @@
//------------------------------------------------------------------------------
// Copyright (c) 2001-2002, Haiku
//
// 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: TokenHandler.h
// Author: DarkWyrm <bpmagic@columbus.rr.com>
// Description: Class to provide tokens with excluded values possible.
//
//------------------------------------------------------------------------------
#ifndef TOKENHANDLER_H_
#define TOKENHANDLER_H_
#include <OS.h>
#include <List.h>
#include <Locker.h>
// Local Defines ---------------------------------------------------------------
#define B_PREFERRED_TOKEN -2 /* A little bird told me about this one */
#define B_NULL_TOKEN -1
#define B_ANY_TOKEN 0
#define B_HANDLER_TOKEN 1
/*!
\class TokenHandler TokenHandler.h
\brief Class to provide tokens with excluded values possible.
*/
class TokenHandler
{
public:
TokenHandler(void);
~TokenHandler(void);
int32 GetToken(void);
void ExcludeValue(int32 value);
void Reset(void);
void ResetExcludes(void);
bool IsExclude(int32 value);
private:
int32 _index;
BLocker _lock;
BList *_excludes;
};
#endif

View File

@ -8,19 +8,8 @@
* Stephan Aßmus <superstippi@gmx.de>
*/
#include <unistd.h>
#include <Accelerant.h>
#include <AppDefs.h>
#include <Directory.h>
#include <Entry.h>
#include <File.h>
#include <Message.h>
#include <Path.h>
#include <PortLink.h>
#include <StopWatch.h>
#include <RosterPrivate.h>
#include <Autolock.h>
#include "AppServer.h"
#include "BitmapManager.h"
#include "ColorSet.h"
@ -30,10 +19,9 @@
#include "Desktop.h"
#include "FontManager.h"
#include "HWInterface.h"
#include "RegistrarDefs.h"
#include "RGBColor.h"
#include "Layer.h"
#include "WinBorder.h"
#include "RGBColor.h"
#include "RegistrarDefs.h"
#include "RootLayer.h"
#include "ScreenManager.h"
#include "ServerApp.h"
@ -43,8 +31,21 @@
#include "ServerWindow.h"
#include "SystemPalette.h"
#include "Utils.h"
#include "WinBorder.h"
#include "AppServer.h"
#include <Accelerant.h>
#include <AppDefs.h>
#include <Autolock.h>
#include <Directory.h>
#include <Entry.h>
#include <File.h>
#include <Message.h>
#include <Path.h>
#include <PortLink.h>
#include <RosterPrivate.h>
#include <StopWatch.h>
#include <unistd.h>
//#define DEBUG_KEYHANDLING
//#define DEBUG_SERVER
@ -67,10 +68,12 @@
// Globals
port_id gAppServerPort;
static AppServer *sAppServer;
BTokenSpace gTokenSpace;
//! System-wide GUI color object
ColorSet gGUIColorSet;
/*!
\brief Constructor

View File

@ -4,9 +4,9 @@
*
* Author: DarkWyrm <bpmagic@columbus.rr.com>
*/
#ifndef APP_SERVER_H
#define APP_SERVER_H
#ifndef _HAIKU_APP_SERVER_H_
#define _HAIKU_APP_SERVER_H_
#include <OS.h>
#include <Locker.h>
@ -15,6 +15,7 @@
#include <Window.h>
#include <String.h>
#include <ObjectList.h>
#include <TokenSpace.h>
#include "ServerConfig.h"
#include "MessageLooper.h"
@ -24,18 +25,12 @@ class BitmapManager;
class ColorSet;
class Desktop;
using BPrivate::BTokenSpace;
namespace BPrivate {
class PortLink;
};
/*!
\class AppServer AppServer.h
\brief main manager object for the app_server
File for the main app_server thread. This particular thread monitors for
application start and quit messages. It also starts the housekeeping threads
and initializes most of the server's globals.
*/
class AppServer : public MessageLooper {
public:
@ -77,4 +72,4 @@ extern BitmapManager *gBitmapManager;
extern ColorSet gGUIColorSet;
extern port_id gAppServerPort;
#endif /* _HAIKU_APP_SERVER_H_ */
#endif /* APP_SERVER_H */

View File

@ -8,6 +8,10 @@
/** Handler for allocating and freeing area memory for BBitmaps
* on the server side. Utilizes the BGET pool allocator.
*
* Whenever a ServerBitmap associated with a client-side BBitmap needs to be
* created or destroyed, the BitmapManager needs to handle it. It takes care of
* all memory management related to them.
*/
@ -17,28 +21,31 @@
#include <Autolock.h>
#include "ServerBitmap.h"
#include "BitmapManager.h"
#include "ServerBitmap.h"
#include "ServerTokenSpace.h"
using std::nothrow;
//! The bitmap allocator for the server. Memory is allocated/freed by the AppServer class
BitmapManager *gBitmapManager = NULL;
//! Number of bytes to allocate to each area used for bitmap storage
#define BITMAP_AREA_SIZE B_PAGE_SIZE * 2
//! Sets up stuff to be ready to allocate space for bitmaps
BitmapManager::BitmapManager()
:
fBitmapList(1024),
fBuffer(NULL),
fTokenizer(),
fLock("BitmapManager Lock"),
fMemPool("bitmap pool", BITMAP_AREA_SIZE)
{
}
//! Deallocates everything associated with the manager
BitmapManager::~BitmapManager()
{
@ -51,6 +58,7 @@ BitmapManager::~BitmapManager()
}
}
/*!
\brief Allocates a new ServerBitmap.
\param bounds Size of the bitmap
@ -80,7 +88,7 @@ BitmapManager::CreateBitmap(BRect bounds, color_space space, int32 flags,
if (buffer && fBitmapList.AddItem(bitmap)) {
bitmap->fArea = area_for(buffer);
bitmap->fBuffer = buffer;
bitmap->fToken = fTokenizer.GetToken();
bitmap->fToken = gTokenSpace.NewToken(kBitmapToken, bitmap);
bitmap->fInitialized = true;
// calculate area offset
@ -97,6 +105,7 @@ BitmapManager::CreateBitmap(BRect bounds, color_space space, int32 flags,
return bitmap;
}
/*!
\brief Deletes a ServerBitmap.
\param bitmap The bitmap to delete

View File

@ -1,46 +1,32 @@
//------------------------------------------------------------------------------
// Copyright (c) 2001-2005, Haiku, Inc.
//
// 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: CursorManager.cpp
// Author: DarkWyrm <bpmagic@columbus.rr.com>
// Description: Handles the system's cursor infrastructure
//
//------------------------------------------------------------------------------
/*
* Copyright 2001-2005, Haiku.
* Distributed under the terms of the MIT License.
*
* Authors:
* DarkWyrm <bpmagic@columbus.rr.com>
*/
/** Handles the system's cursor infrastructure */
#include <Directory.h>
#include <String.h>
#include "CursorData.h"
#include "CursorManager.h"
#include "HaikuSystemCursor.h"
#include "ServerCursor.h"
#include "ServerConfig.h"
#include "HaikuSystemCursor.h"
#include "ServerTokenSpace.h"
//! Initializes the CursorManager
CursorManager::CursorManager()
: BLocker("CursorManager")
{
// Error code for AddCursor
fTokenizer.ExcludeValue(B_ERROR);
// Set system cursors to "unassigned"
// ToDo: decide about default cursor
#if 1
fDefaultCursor = new ServerCursor(kHaikuCursorBits, kHaikuCursorWidth,
kHaikuCursorHeight, kHaikuCursorFormat);
@ -100,7 +86,7 @@ CursorManager::~CursorManager()
\return The token assigned to the cursor or B_ERROR if sc is NULL
*/
int32
CursorManager::AddCursor(ServerCursor *cursor)
CursorManager::AddCursor(ServerCursor* cursor)
{
if (!cursor)
return B_ERROR;
@ -108,7 +94,7 @@ CursorManager::AddCursor(ServerCursor *cursor)
Lock();
fCursorList.AddItem(cursor);
int32 token = fTokenizer.GetToken();
int32 token = fTokenSpace.NewToken(B_SERVER_TOKEN, cursor);
cursor->fToken = token;
Unlock();
@ -347,77 +333,50 @@ CursorManager::ChangeCursor(cursor_which which, int32 token)
// Do the assignment
switch (which) {
case B_CURSOR_DEFAULT:
{
if (fDefaultCursor)
delete fDefaultCursor;
delete fDefaultCursor;
fDefaultCursor = cursor;
break;
}
case B_CURSOR_TEXT:
{
if(fTextCursor)
delete fTextCursor;
case B_CURSOR_TEXT:
delete fTextCursor;
fTextCursor = cursor;
break;
}
case B_CURSOR_MOVE:
{
if(fMoveCursor)
delete fMoveCursor;
case B_CURSOR_MOVE:
delete fMoveCursor;
fMoveCursor = cursor;
break;
}
case B_CURSOR_DRAG:
{
if(fDragCursor)
delete fDragCursor;
case B_CURSOR_DRAG:
delete fDragCursor;
fDragCursor = cursor;
break;
}
case B_CURSOR_RESIZE:
{
if(fResizeCursor)
delete fResizeCursor;
case B_CURSOR_RESIZE:
delete fResizeCursor;
fResizeCursor = cursor;
break;
}
case B_CURSOR_RESIZE_NWSE:
{
if(fNWSECursor)
delete fNWSECursor;
case B_CURSOR_RESIZE_NWSE:
delete fNWSECursor;
fNWSECursor = cursor;
break;
}
case B_CURSOR_RESIZE_NESW:
{
if(fNESWCursor)
delete fNESWCursor;
case B_CURSOR_RESIZE_NESW:
delete fNESWCursor;
fNESWCursor = cursor;
break;
}
case B_CURSOR_RESIZE_NS:
{
if(fNSCursor)
delete fNSCursor;
case B_CURSOR_RESIZE_NS:
delete fNSCursor;
fNSCursor = cursor;
break;
}
case B_CURSOR_RESIZE_EW:
{
if(fEWCursor)
delete fEWCursor;
case B_CURSOR_RESIZE_EW:
delete fEWCursor;
fEWCursor = cursor;
break;
}
default:
Unlock();
return;
@ -439,11 +398,9 @@ CursorManager::ChangeCursor(cursor_which which, int32 token)
ServerCursor *
CursorManager::FindCursor(int32 token)
{
for (int32 i = 0; i < fCursorList.CountItems(); i++) {
ServerCursor *cursor = (ServerCursor *)fCursorList.ItemAt(i);
if (cursor && cursor->fToken == token)
return cursor;
}
ServerCursor* cursor;
if (gTokenSpace.GetToken(token, kCursorToken, (void**)&cursor) == B_OK)
return cursor;
return NULL;
}

View File

@ -1,39 +1,25 @@
//------------------------------------------------------------------------------
// Copyright (c) 2001-2002, Haiku, Inc.
//
// 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: CursorManager.h
// Author: DarkWyrm <bpmagic@columbus.rr.com>
// Description: Handles the system's cursor infrastructure
//
//------------------------------------------------------------------------------
#ifndef CURSORMANAGER_H_
#define CURSORMANAGER_H_
/*
* Copyright 2001-2005, Haiku.
* Distributed under the terms of the MIT License.
*
* Authors:
* DarkWyrm <bpmagic@columbus.rr.com>
*/
#ifndef CURSOR_MANAGER_H
#define CURSOR_MANAGER_H
#include <List.h>
#include <Locker.h>
#include "CursorSet.h"
#include "TokenHandler.h"
#include <TokenSpace.h>
#include "CursorSet.h"
using BPrivate::BTokenSpace;
class ServerCursor;
/*!
\class CursorManager CursorManager.h
\brief Handles almost all cursor management functions for the system
@ -43,22 +29,24 @@ class ServerCursor;
of an application's cursors whenever an application closes.
*/
class CursorManager : public BLocker {
public:
public:
CursorManager();
~CursorManager();
int32 AddCursor(ServerCursor *sc);
virtual ~CursorManager();
int32 AddCursor(ServerCursor* cursor);
void DeleteCursor(int32 token);
void RemoveAppCursors(team_id team);
void SetCursorSet(const char *path);
ServerCursor *GetCursor(cursor_which which);
void SetCursorSet(const char* path);
ServerCursor* GetCursor(cursor_which which);
cursor_which GetCursorWhich();
void ChangeCursor(cursor_which which, int32 token);
void SetDefaults();
ServerCursor *FindCursor(int32 token);
ServerCursor* FindCursor(int32 token);
private:
private:
BList fCursorList;
TokenHandler fTokenizer;
BTokenSpace fTokenSpace;
// System cursor members
ServerCursor *fDefaultCursor,
@ -73,4 +61,4 @@ private:
cursor_which fCurrentWhich;
};
#endif
#endif /* CURSOR_MANAGER_H */

View File

@ -1,115 +0,0 @@
//------------------------------------------------------------------------------
// Copyright (c) 2001-2002, Haiku, Inc.
//
// 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: IPoint.h
// Author: DarkWyrm <bpmagic@columbus.rr.com>
// Based on BPoint code by Frans Van Nispen
// Description: Integer BPoint class
//------------------------------------------------------------------------------
#include "IPoint.h"
#include <math.h>
#include <stdio.h>
#include <Rect.h>
void IPoint::ConstrainTo(BRect r)
{
x = (int32)max_c(min_c(x, r.right), r.left);
y = (int32)max_c(min_c(y, r.bottom), r.top);
}
void IPoint::PrintToStream() const
{
printf("IPoint(x:%ld, y:%ld)\n", x, y);
}
IPoint IPoint::operator+(const IPoint &p) const
{
return IPoint(x + p.x, y + p.y);
}
IPoint IPoint::operator+(const BPoint &p) const
{
return IPoint(x + (int32)p.x, y + (int32)p.y);
}
IPoint IPoint::operator-(const IPoint &p) const
{
return IPoint(x - p.x, y - p.y);
}
IPoint IPoint::operator-(const BPoint &p) const
{
return IPoint(x - (int32)p.x, y - (int32)p.y);
}
IPoint &IPoint::operator+=(const IPoint &p)
{
x += p.x;
y += p.y;
return *this;
}
IPoint &IPoint::operator+=(const BPoint &p)
{
x += (int32)p.x;
y += (int32)p.y;
return *this;
}
IPoint &IPoint::operator-=(const IPoint &p)
{
x -= p.x;
y -= p.y;
return *this;
}
IPoint &IPoint::operator-=(const BPoint &p)
{
x -= (int32)p.x;
y -= (int32)p.y;
return *this;
}
bool IPoint::operator!=(const IPoint &p) const
{
return x != p.x || y != p.y;
}
bool IPoint::operator!=(const BPoint &p) const
{
return x != (int32)p.x || y != (int32)p.y;
}
bool IPoint::operator==(const IPoint &p) const
{
return x == p.x && y == p.y;
}
bool IPoint::operator==(const BPoint &p) const
{
return x == (int32)p.x && y == (int32)p.y;
}

View File

@ -48,7 +48,6 @@ Server app_server :
ServerWindow.cpp
SubWindowList.cpp
SystemPalette.cpp
TokenHandler.cpp
Utils.cpp
VirtualScreen.cpp
WinBorder.cpp

View File

@ -50,6 +50,7 @@
#include "ServerCursor.h"
#include "ServerPicture.h"
#include "ServerScreen.h"
#include "ServerTokenSpace.h"
#include "ServerWindow.h"
#include "SystemPalette.h"
#include "Utils.h"
@ -2404,13 +2405,11 @@ ServerApp::CountBitmaps() const
ServerBitmap*
ServerApp::FindBitmap(int32 token) const
{
int32 count = fBitmapList.CountItems();
for (int32 i = 0; i < count; i++) {
ServerBitmap* bitmap = (ServerBitmap*)fBitmapList.ItemAt(i);
if (bitmap && bitmap->Token() == token)
return bitmap;
}
// TODO: we need to make sure the bitmap is ours?!
ServerBitmap* bitmap;
if (gTokenSpace.GetToken(token, kBitmapToken, (void**)&bitmap) == B_OK)
return bitmap;
return NULL;
}
@ -2425,12 +2424,11 @@ ServerApp::CountPictures() const
ServerPicture *
ServerApp::FindPicture(int32 token) const
{
for (int32 i = 0; i < fPictureList.CountItems(); i++) {
ServerPicture *picture = static_cast<ServerPicture *>(fPictureList.ItemAt(i));
if (picture && picture->GetToken() == token)
return picture;
}
// TODO: we need to make sure the picture is ours?!
ServerPicture* picture;
if (gTokenSpace.GetToken(token, kPictureToken, (void**)&picture) == B_OK)
return picture;
return NULL;
}

View File

@ -1,48 +1,28 @@
//------------------------------------------------------------------------------
// Copyright (c) 2001-2002, Haiku, Inc.
//
// 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: ServerPicture.cpp
// Author: DarkWyrm <bpmagic@columbus.rr.com>
// Description: Server-side counterpart to BPicture
//
//------------------------------------------------------------------------------
#include "TokenHandler.h"
/*
* Copyright 2001-2005, Haiku, Inc.
* Distributed under the terms of the MIT License.
*
* Authors:
* DarkWyrm <bpmagic@columbus.rr.com>
*/
/** Server-side counterpart to BPicture */
#include "ServerPicture.h"
#include "ServerTokenSpace.h"
TokenHandler picture_token_handler;
ServerPicture::ServerPicture(void)
ServerPicture::ServerPicture()
{
_token=picture_token_handler.GetToken();
_initialized=false;
fToken = gTokenSpace.NewToken(B_SERVER_TOKEN, this);
int8 *ptr;
_area=create_area("ServerPicture",(void**)&ptr,B_ANY_ADDRESS,B_PAGE_SIZE,
B_NO_LOCK,B_READ_AREA | B_WRITE_AREA);
if(_area!=B_BAD_VALUE && _area!=B_NO_MEMORY && _area!=B_ERROR)
_initialized=true;
fArea = create_area("ServerPicture", (void**)&ptr, B_ANY_ADDRESS,
B_PAGE_SIZE, B_NO_LOCK,B_READ_AREA | B_WRITE_AREA);
}
ServerPicture::~ServerPicture(void)
ServerPicture::~ServerPicture()
{
}

View File

@ -1,51 +1,32 @@
//------------------------------------------------------------------------------
// Copyright (c) 2001-2002, Haiku, Inc.
//
// 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: ServerPicture.cpp
// Author: DarkWyrm <bpmagic@columbus.rr.com>
// Description: Server-side counterpart to BPicture
//
//------------------------------------------------------------------------------
/*
* Copyright 2001-2005, Haiku, Inc.
* Distributed under the terms of the MIT License.
*
* Authors:
* DarkWyrm <bpmagic@columbus.rr.com>
*/
#ifndef SERVER_PICTURE_H
#define SERVER_PICTURE_H
#include <OS.h>
class AreaLink;
class ServerPicture
{
public:
ServerPicture(void);
~ServerPicture(void);
bool InitCheck(void) { return _initialized; }
area_id Area(void) { return _area; }
int32 GetToken(void) { return _token; }
private:
AreaLink *arealink;
bool _initialized;
area_id _area;
int32 _token;
class ServerPicture {
public:
ServerPicture();
~ServerPicture();
status_t InitCheck() const { return fArea >= B_OK ? B_OK : fArea; }
area_id Area() const { return fArea; }
int32 Token() const { return fToken; }
private:
AreaLink* fAreaLink;
area_id fArea;
int32 fToken;
};
#endif
#endif /* SERVER_PICTURE_H */

View File

@ -0,0 +1,24 @@
/*
* Copyright 2005, Haiku, Inc.
* Distributed under the terms of the MIT License.
*
* Authors:
* Axel Dörfler, axeld@pinc-software.de
*/
#ifndef SERVER_TOKEN_SPACE_H
#define SERVER_TOKEN_SPACE_H
#include <TokenSpace.h>
using BPrivate::BTokenSpace;
const int32 kCursorToken = 3;
const int32 kBitmapToken = 4;
const int32 kPictureToken = 5;
extern BTokenSpace gTokenSpace;
#endif /* SERVER_TOKEN_SPACE_H */

View File

@ -50,7 +50,6 @@
#include "ServerBitmap.h"
#include "ServerPicture.h"
#include "ServerProtocol.h"
#include "TokenHandler.h"
#include "Utils.h"
#include "WinBorder.h"
#include "Workspace.h"

View File

@ -1,122 +0,0 @@
//------------------------------------------------------------------------------
// Copyright (c) 2001-2002, Haiku, Inc.
//
// 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: TokenHandler.cpp
// Author: DarkWyrm <bpmagic@columbus.rr.com>
// Description: Class to provide tokens with excluded values possible.
//
//------------------------------------------------------------------------------
#include "TokenHandler.h"
//! Does setup
TokenHandler::TokenHandler(void)
{
_index=-1;
_excludes=new BList(0);
}
//! Undoes the setup from the constructor
TokenHandler::~TokenHandler(void)
{
ResetExcludes();
delete _excludes;
}
/*!
\brief Returns a unique token
\return A unique token
If a value is excluded the next higher non-excluded value is returned.
*/
int32 TokenHandler::GetToken(void)
{
int32 value;
_lock.Lock();
_index++;
while(IsExclude(_index))
_index++;
value=_index;
_lock.Unlock();
return value;
}
/*!
\brief Excludes a value from being returned as a token.
This is quite useful for excluding values like B_ERROR and such.
*/
void TokenHandler::ExcludeValue(int32 value)
{
_lock.Lock();
if(!IsExclude(value))
_excludes->AddItem(new int32(value));
_lock.Unlock();
}
//! Resets the token index
void TokenHandler::Reset(void)
{
_lock.Lock();
_index=-1;
_lock.Unlock();
}
//! Empties object of all assigned excluded values
void TokenHandler::ResetExcludes(void)
{
_lock.Lock();
int32 *temp;
for(int32 i=0; i<_excludes->CountItems();i++)
{
temp=(int32*)_excludes->ItemAt(i);
if(temp)
delete temp;
}
_excludes->MakeEmpty();
_lock.Unlock();
}
/*!
\brief Determines whether a value is excluded
\param value The value to be checked
\return True if the value is excluded from being a token, false if not.
*/
bool TokenHandler::IsExclude(int32 value)
{
bool match=false;
int32 *temp;
_lock.Lock();
for(int32 i=0;i<_excludes->CountItems();i++)
{
temp=(int32*)_excludes->ItemAt(i);
if(temp && *temp==value)
{
match=true;
break;
}
}
_lock.Unlock();
return match;
}

View File

@ -26,7 +26,6 @@
#include "RootLayer.h"
#include "ServerApp.h"
#include "ServerWindow.h"
#include "TokenHandler.h"
#include "WinBorder.h"
#include "Workspace.h"

View File

@ -49,7 +49,6 @@ SharedLibrary libhwinterfaceimpl.so :
SharedLibrary libhaikuappserver.so :
Angle.cpp
BGet++.cpp
BitmapManager.cpp
ColorSet.cpp
CursorData.cpp
CursorSet.cpp
@ -57,14 +56,12 @@ SharedLibrary libhaikuappserver.so :
DrawState.cpp
FontFamily.cpp
HashTable.cpp
IPoint.cpp
RGBColor.cpp
ServerBitmap.cpp
ServerCursor.cpp
ServerFont.cpp
FontManager.cpp
SystemPalette.cpp
TokenHandler.cpp
Utils.cpp
# drawing
@ -82,12 +79,12 @@ Server haiku_app_server :
Decorator.cpp
DebugInfoManager.cpp
SubWindowList.cpp
#PicturePlayer.cpp
PNGDump.cpp
RAMLinkMsgReader.cpp
MessageLooper.cpp
# Manager Classes
BitmapManager.cpp
CursorManager.cpp
DecorManager.cpp
ScreenManager.cpp

View File

@ -11,3 +11,8 @@ Application BitmapDrawing :
: be
;
if ( $(TARGET_PLATFORM) = libbe_test ) {
HaikuInstall install-test-apps : $(HAIKU_APP_TEST_DIR) : BitmapDrawing
: tests!apps ;
}