Fixed a bug which prevented BPictures to be drawn. Small cleanup
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@16341 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
d14dde17c4
commit
2c2773c4c3
@ -149,24 +149,21 @@ void TPicture::GetData(void *data, int32 size)
|
||||
fData.Read(data, size);
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
||||
status_t TPicture::Play(void **callBackTable, int32 tableEntries,
|
||||
void *userData)
|
||||
status_t TPicture::Play(void **callBackTable, int32 tableEntries, void *userData)
|
||||
{
|
||||
// TODO: we should probably check if the functions in the table are not 0
|
||||
// before calling them.
|
||||
|
||||
int16 op=0;
|
||||
int32 size=0;
|
||||
off_t pos=0;
|
||||
// lenght of the stream
|
||||
size_t length = fData.Seek(0, SEEK_END);
|
||||
fData.Seek(0, SEEK_SET);
|
||||
|
||||
while (fData.Position() < size)
|
||||
{
|
||||
op = GetOp();
|
||||
size = GetInt32();
|
||||
pos = fData.Position();
|
||||
while (fData.Position() < length) {
|
||||
int16 op = GetOp();
|
||||
int32 size = GetInt32();
|
||||
off_t pos = fData.Position();
|
||||
|
||||
switch (op)
|
||||
{
|
||||
switch (op) {
|
||||
case B_PIC_MOVE_PEN_BY:
|
||||
{
|
||||
BPoint where = GetCoord();
|
||||
|
@ -457,8 +457,6 @@ ServerPicture::ServerPicture()
|
||||
|
||||
|
||||
ServerPicture::ServerPicture(const ServerPicture &picture)
|
||||
:
|
||||
fStack(picture.fStack)
|
||||
{
|
||||
fToken = gTokenSpace.NewToken(kPictureToken, this);
|
||||
|
||||
@ -474,9 +472,11 @@ ServerPicture::~ServerPicture()
|
||||
void
|
||||
ServerPicture::BeginOp(int16 op)
|
||||
{
|
||||
int32 size = 0;
|
||||
fStack.push(fData.Position());
|
||||
fData.Write(&op, sizeof(op));
|
||||
|
||||
// Init the size of the opcode block to 0
|
||||
size_t size = 0;
|
||||
fData.Write(&size, sizeof(size));
|
||||
}
|
||||
|
||||
@ -488,9 +488,14 @@ ServerPicture::EndOp()
|
||||
off_t stackPos = fStack.top();
|
||||
fStack.pop();
|
||||
|
||||
size_t size = curPos - stackPos - 6;
|
||||
// The size of the op is calculated like this:
|
||||
// current position on the stream minus the position on the stack,
|
||||
// minus the space occupied by the op code itself (int16)
|
||||
// and the space occupied by the size field (size_t)
|
||||
size_t size = curPos - stackPos - sizeof(size_t) - sizeof(int16);
|
||||
|
||||
fData.Seek(stackPos + 2, SEEK_SET);
|
||||
// Size was set to 0 in BeginOp(). Now we overwrite it with the correct value
|
||||
fData.Seek(stackPos + sizeof(int16), SEEK_SET);
|
||||
fData.Write(&size, sizeof(size));
|
||||
fData.Seek(curPos, SEEK_SET);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user