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);
|
fData.Read(data, size);
|
||||||
}
|
}
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
status_t TPicture::Play(void **callBackTable, int32 tableEntries,
|
status_t TPicture::Play(void **callBackTable, int32 tableEntries, void *userData)
|
||||||
void *userData)
|
|
||||||
{
|
{
|
||||||
// TODO: we should probably check if the functions in the table are not 0
|
// TODO: we should probably check if the functions in the table are not 0
|
||||||
// before calling them.
|
// before calling them.
|
||||||
|
|
||||||
int16 op=0;
|
// lenght of the stream
|
||||||
int32 size=0;
|
size_t length = fData.Seek(0, SEEK_END);
|
||||||
off_t pos=0;
|
fData.Seek(0, SEEK_SET);
|
||||||
|
|
||||||
while (fData.Position() < size)
|
while (fData.Position() < length) {
|
||||||
{
|
int16 op = GetOp();
|
||||||
op = GetOp();
|
int32 size = GetInt32();
|
||||||
size = GetInt32();
|
off_t pos = fData.Position();
|
||||||
pos = fData.Position();
|
|
||||||
|
|
||||||
switch (op)
|
switch (op) {
|
||||||
{
|
|
||||||
case B_PIC_MOVE_PEN_BY:
|
case B_PIC_MOVE_PEN_BY:
|
||||||
{
|
{
|
||||||
BPoint where = GetCoord();
|
BPoint where = GetCoord();
|
||||||
|
@ -457,8 +457,6 @@ ServerPicture::ServerPicture()
|
|||||||
|
|
||||||
|
|
||||||
ServerPicture::ServerPicture(const ServerPicture &picture)
|
ServerPicture::ServerPicture(const ServerPicture &picture)
|
||||||
:
|
|
||||||
fStack(picture.fStack)
|
|
||||||
{
|
{
|
||||||
fToken = gTokenSpace.NewToken(kPictureToken, this);
|
fToken = gTokenSpace.NewToken(kPictureToken, this);
|
||||||
|
|
||||||
@ -474,9 +472,11 @@ ServerPicture::~ServerPicture()
|
|||||||
void
|
void
|
||||||
ServerPicture::BeginOp(int16 op)
|
ServerPicture::BeginOp(int16 op)
|
||||||
{
|
{
|
||||||
int32 size = 0;
|
|
||||||
fStack.push(fData.Position());
|
fStack.push(fData.Position());
|
||||||
fData.Write(&op, sizeof(op));
|
fData.Write(&op, sizeof(op));
|
||||||
|
|
||||||
|
// Init the size of the opcode block to 0
|
||||||
|
size_t size = 0;
|
||||||
fData.Write(&size, sizeof(size));
|
fData.Write(&size, sizeof(size));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -487,10 +487,15 @@ ServerPicture::EndOp()
|
|||||||
off_t curPos = fData.Position();
|
off_t curPos = fData.Position();
|
||||||
off_t stackPos = fStack.top();
|
off_t stackPos = fStack.top();
|
||||||
fStack.pop();
|
fStack.pop();
|
||||||
|
|
||||||
|
// 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);
|
||||||
|
|
||||||
size_t size = curPos - stackPos - 6;
|
// Size was set to 0 in BeginOp(). Now we overwrite it with the correct value
|
||||||
|
fData.Seek(stackPos + sizeof(int16), SEEK_SET);
|
||||||
fData.Seek(stackPos + 2, SEEK_SET);
|
|
||||||
fData.Write(&size, sizeof(size));
|
fData.Write(&size, sizeof(size));
|
||||||
fData.Seek(curPos, SEEK_SET);
|
fData.Seek(curPos, SEEK_SET);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user