Added a copy constructor to ServerPicture. ServerPicture's constructors are private now, and can be called only from ServerApp (friend). Changed BList to a stl::stack which is better suited as a stack... Changed ServerApp::CreatePicture() to accept a picture to clone, instead of passing back a token which was never used anyway.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@15840 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
ebc8a403e5
commit
9c0c899e7d
@ -747,12 +747,9 @@ ServerApp::_DispatchMessage(int32 code, BPrivate::LinkReceiver& link)
|
||||
|
||||
ServerPicture *cloned = NULL;
|
||||
if (original != NULL)
|
||||
cloned = CreatePicture();
|
||||
cloned = CreatePicture(original);
|
||||
|
||||
if (cloned != NULL) {
|
||||
// TODO: I'm not sure that this does a plain copy.
|
||||
// Check, and, in case, put the stuff in Data() directly
|
||||
cloned->AddData(original->Data(), original->DataLength());
|
||||
fLink.StartMessage(B_OK);
|
||||
fLink.Attach<int32>(cloned->Token());
|
||||
} else
|
||||
@ -2567,14 +2564,16 @@ ServerApp::CountPictures() const
|
||||
|
||||
|
||||
ServerPicture *
|
||||
ServerApp::CreatePicture(int32 *token)
|
||||
ServerApp::CreatePicture(const ServerPicture *original)
|
||||
{
|
||||
ServerPicture *picture = new (nothrow) ServerPicture();
|
||||
if (picture != NULL) {
|
||||
ServerPicture *picture;
|
||||
if (original != NULL)
|
||||
picture = new (nothrow) ServerPicture(*original);
|
||||
else
|
||||
picture = new (nothrow) ServerPicture();
|
||||
|
||||
if (picture != NULL)
|
||||
fPictureList.AddItem(picture);
|
||||
if (token != NULL)
|
||||
*token = picture->Token();
|
||||
}
|
||||
|
||||
return picture;
|
||||
}
|
||||
|
@ -72,7 +72,7 @@ class ServerApp : public MessageLooper {
|
||||
ServerBitmap *FindBitmap(int32 token) const;
|
||||
|
||||
int32 CountPictures() const;
|
||||
ServerPicture *CreatePicture(int32 *token = NULL);
|
||||
ServerPicture *CreatePicture(const ServerPicture *original = NULL);
|
||||
ServerPicture *FindPicture(const int32 &token) const;
|
||||
bool DeletePicture(const int32 &token);
|
||||
|
||||
|
@ -461,6 +461,16 @@ ServerPicture::ServerPicture()
|
||||
}
|
||||
|
||||
|
||||
ServerPicture::ServerPicture(const ServerPicture &picture)
|
||||
:
|
||||
fStack(picture.fStack)
|
||||
{
|
||||
fToken = gTokenSpace.NewToken(kPictureToken, this);
|
||||
|
||||
AddData(picture.Data(), picture.DataLength());
|
||||
}
|
||||
|
||||
|
||||
ServerPicture::~ServerPicture()
|
||||
{
|
||||
}
|
||||
@ -470,7 +480,7 @@ void
|
||||
ServerPicture::BeginOp(int16 op)
|
||||
{
|
||||
int32 size = 0;
|
||||
fStack.AddItem((void *)fData.Position());
|
||||
fStack.push(fData.Position());
|
||||
fData.Write(&op, sizeof(op));
|
||||
fData.Write(&size, sizeof(size));
|
||||
}
|
||||
@ -480,7 +490,9 @@ void
|
||||
ServerPicture::EndOp()
|
||||
{
|
||||
off_t curPos = fData.Position();
|
||||
off_t stackPos = (off_t)fStack.RemoveItem(fStack.CountItems() - 1);
|
||||
off_t stackPos = fStack.top();
|
||||
fStack.pop();
|
||||
|
||||
size_t size = curPos - stackPos - 6;
|
||||
|
||||
fData.Seek(stackPos + 2, SEEK_SET);
|
||||
|
@ -6,14 +6,15 @@
|
||||
#include <Region.h>
|
||||
#include <DataIO.h>
|
||||
#include <InterfaceDefs.h>
|
||||
#include <List.h>
|
||||
|
||||
#include <stack>
|
||||
|
||||
using std::stack;
|
||||
|
||||
class ServerApp;
|
||||
class ViewLayer;
|
||||
class ServerPicture {
|
||||
public:
|
||||
ServerPicture();
|
||||
virtual ~ServerPicture();
|
||||
|
||||
public:
|
||||
int32 Token() { return fToken; }
|
||||
|
||||
void BeginOp(int16 op);
|
||||
@ -40,13 +41,19 @@ virtual ~ServerPicture();
|
||||
|
||||
void Play(ViewLayer *view);
|
||||
|
||||
const void *Data() { return fData.Buffer(); }
|
||||
int32 DataLength() { return fData.BufferLength(); }
|
||||
const void *Data() const { return fData.Buffer(); }
|
||||
int32 DataLength() const { return fData.BufferLength(); }
|
||||
|
||||
private:
|
||||
friend class ServerApp;
|
||||
|
||||
ServerPicture();
|
||||
ServerPicture(const ServerPicture &);
|
||||
~ServerPicture();
|
||||
|
||||
int32 fToken;
|
||||
BMallocIO fData;
|
||||
BList fStack;
|
||||
stack<off_t> fStack;
|
||||
// DrawState *fState;
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user