Implement calling the exit_xxx hooks. Thanks to Marc Flerackers for the

help.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@21943 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Stefano Ceccherini
2007-08-14 12:45:42 +00:00
parent 9cc1cb3cae
commit 796e4e4552
4 changed files with 59 additions and 36 deletions
+2 -2
View File
@@ -392,7 +392,7 @@ PictureDataWriter::WriteSetFontFamily(const font_family family)
try { try {
BeginOp(B_PIC_SET_FONT_FAMILY); BeginOp(B_PIC_SET_FONT_FAMILY);
WriteData(family, strlen(family)); WriteData(family, strlen(family));
Write<int8>(0); Write<uint8>(0);
EndOp(); EndOp();
} catch (status_t &status) { } catch (status_t &status) {
return status; return status;
@@ -407,7 +407,7 @@ PictureDataWriter::WriteSetFontStyle(const font_style style)
try { try {
BeginOp(B_PIC_SET_FONT_STYLE); BeginOp(B_PIC_SET_FONT_STYLE);
WriteData(style, strlen(style)); WriteData(style, strlen(style));
Write<int8>(0); Write<uint8>(0);
EndOp(); EndOp();
} catch (status_t &status) { } catch (status_t &status) {
return status; return status;
+36 -15
View File
@@ -69,6 +69,9 @@ PicturePlayer::Play(void **callBackTable, int32 tableEntries, void *userData)
const char *data = reinterpret_cast<const char *>(fData); const char *data = reinterpret_cast<const char *>(fData);
size_t pos = 0; size_t pos = 0;
int32 fontStateBlockSize = -1;
int32 stateBlockSize = -1;
while ((pos + 6) <= fSize) { while ((pos + 6) <= fSize) {
int16 op = *reinterpret_cast<const int16 *>(data); int16 op = *reinterpret_cast<const int16 *>(data);
int32 size = *reinterpret_cast<const int32 *>(data + 2); int32 size = *reinterpret_cast<const int32 *>(data + 2);
@@ -284,6 +287,7 @@ PicturePlayer::Play(void **callBackTable, int32 tableEntries, void *userData)
{ {
if (tableEntries <= 20) if (tableEntries <= 20)
break; break;
// TODO: Implement
break; break;
} }
@@ -299,6 +303,7 @@ PicturePlayer::Play(void **callBackTable, int32 tableEntries, void *userData)
{ {
if (tableEntries <= 21) if (tableEntries <= 21)
break; break;
// TODO: Implement
break; break;
} }
@@ -320,17 +325,17 @@ PicturePlayer::Play(void **callBackTable, int32 tableEntries, void *userData)
case B_PIC_ENTER_STATE_CHANGE: case B_PIC_ENTER_STATE_CHANGE:
{ {
if (tableEntries <= 24) if (tableEntries > 24)
break; ((fnc)callBackTable[24])(userData);
((fnc)callBackTable[24])(userData); stateBlockSize = size;
break; break;
} }
case B_PIC_ENTER_FONT_STATE: case B_PIC_ENTER_FONT_STATE:
{ {
if (tableEntries <= 26) if (tableEntries > 26)
break; ((fnc)callBackTable[26])(userData);
((fnc)callBackTable[26])(userData); fontStateBlockSize = size;
break; break;
} }
@@ -512,15 +517,31 @@ PicturePlayer::Play(void **callBackTable, int32 tableEntries, void *userData)
break; break;
} }
// TODO: This is not correct. B_PIC_ENTER_STATE_CHANGE and // Skip the already handled block unless it's one of these two,
// B_PIC_ENTER_FONT_STATE ops include other ops. We should just advance // since they can contain other nested ops.
// the buffer by the size of these ops, not the size of the whole block, if (op != B_PIC_ENTER_STATE_CHANGE && op != B_PIC_ENTER_FONT_STATE) {
// otherwise the nested ops won't be executed. I disabled them in pos += size;
// ServerPicture::SyncState() and ServerPicture::SetFontFromLink() data += size;
// until we handle them correctly here. if (stateBlockSize > 0)
pos += size; stateBlockSize -= size + 6;
data += size; if (fontStateBlockSize > 0)
fontStateBlockSize -= size + 6;
}
// call the exit_state_change hook if needed
if (stateBlockSize == 0) {
if (tableEntries > 25)
((fnc)callBackTable[25])(userData);
stateBlockSize = -1;
}
// call the exit_font_state hook if needed
if (fontStateBlockSize == 0) {
if (tableEntries > 27)
((fnc)callBackTable[27])(userData);
fontStateBlockSize = -1;
}
// TODO: what if too much was read, should we return B_ERROR? // TODO: what if too much was read, should we return B_ERROR?
} }
+21 -16
View File
@@ -473,31 +473,30 @@ pop_state(ViewLayer *view)
} }
// TODO: Be smart and actually take advantage of these methods:
// only apply state changes when they are called
static void static void
enter_state_change(ViewLayer *view) enter_state_change(ViewLayer *view)
{ {
printf("EnterStateChange\n");
} }
static void static void
exit_state_change(ViewLayer *view) exit_state_change(ViewLayer *view)
{ {
printf("ExitStateChange\n");
} }
static void static void
enter_font_state(ViewLayer *view) enter_font_state(ViewLayer *view)
{ {
printf("EnterFontState\n");
} }
static void static void
exit_font_state(ViewLayer *view) exit_font_state(ViewLayer *view)
{ {
printf("ExitFontState\n"); view->Window()->GetDrawingEngine()->SetFont(view->CurrentState()->Font());
} }
@@ -601,7 +600,6 @@ set_font_spacing(ViewLayer *view, int32 spacing)
ServerFont font; ServerFont font;
font.SetSpacing(spacing); font.SetSpacing(spacing);
view->CurrentState()->SetFont(font, B_FONT_SPACING); view->CurrentState()->SetFont(font, B_FONT_SPACING);
view->Window()->GetDrawingEngine()->SetFont(view->CurrentState()->Font());
} }
@@ -611,7 +609,6 @@ set_font_size(ViewLayer *view, float size)
ServerFont font; ServerFont font;
font.SetSize(size); font.SetSize(size);
view->CurrentState()->SetFont(font, B_FONT_SIZE); view->CurrentState()->SetFont(font, B_FONT_SIZE);
view->Window()->GetDrawingEngine()->SetFont(view->CurrentState()->Font());
} }
@@ -621,7 +618,6 @@ set_font_rotate(ViewLayer *view, float rotation)
ServerFont font; ServerFont font;
font.SetRotation(rotation); font.SetRotation(rotation);
view->CurrentState()->SetFont(font, B_FONT_ROTATION); view->CurrentState()->SetFont(font, B_FONT_ROTATION);
view->Window()->GetDrawingEngine()->SetFont(view->CurrentState()->Font());
} }
@@ -631,7 +627,6 @@ set_font_encoding(ViewLayer *view, int32 encoding)
ServerFont font; ServerFont font;
font.SetEncoding(encoding); font.SetEncoding(encoding);
view->CurrentState()->SetFont(font, B_FONT_ENCODING); view->CurrentState()->SetFont(font, B_FONT_ENCODING);
view->Window()->GetDrawingEngine()->SetFont(view->CurrentState()->Font());
} }
@@ -641,7 +636,6 @@ set_font_flags(ViewLayer *view, int32 flags)
ServerFont font; ServerFont font;
font.SetFlags(flags); font.SetFlags(flags);
view->CurrentState()->SetFont(font, B_FONT_FLAGS); view->CurrentState()->SetFont(font, B_FONT_FLAGS);
view->Window()->GetDrawingEngine()->SetFont(view->CurrentState()->Font());
} }
@@ -651,7 +645,6 @@ set_font_shear(ViewLayer *view, float shear)
ServerFont font; ServerFont font;
font.SetShear(shear); font.SetShear(shear);
view->CurrentState()->SetFont(font, B_FONT_SHEAR); view->CurrentState()->SetFont(font, B_FONT_SHEAR);
view->Window()->GetDrawingEngine()->SetFont(view->CurrentState()->Font());
} }
@@ -661,7 +654,6 @@ set_font_face(ViewLayer *view, int32 face)
ServerFont font; ServerFont font;
font.SetFace(face); font.SetFace(face);
view->CurrentState()->SetFont(font, B_FONT_FACE); view->CurrentState()->SetFont(font, B_FONT_FACE);
view->Window()->GetDrawingEngine()->SetFont(view->CurrentState()->Font());
} }
@@ -801,11 +793,25 @@ ServerPicture::~ServerPicture()
} }
void
ServerPicture::EnterStateChange()
{
BeginOp(B_PIC_ENTER_STATE_CHANGE);
}
void
ServerPicture::ExitStateChange()
{
EndOp();
}
void void
ServerPicture::SyncState(ViewLayer *view) ServerPicture::SyncState(ViewLayer *view)
{ {
// TODO: Finish this // TODO: Finish this
//BeginOp(B_PIC_ENTER_STATE_CHANGE); EnterStateChange();
WriteSetOrigin(view->CurrentState()->Origin()); WriteSetOrigin(view->CurrentState()->Origin());
WriteSetPenLocation(view->CurrentState()->PenLocation()); WriteSetPenLocation(view->CurrentState()->PenLocation());
@@ -819,14 +825,13 @@ ServerPicture::SyncState(ViewLayer *view)
WriteSetHighColor(view->CurrentState()->HighColor().GetColor32()); WriteSetHighColor(view->CurrentState()->HighColor().GetColor32());
WriteSetLowColor(view->CurrentState()->LowColor().GetColor32()); WriteSetLowColor(view->CurrentState()->LowColor().GetColor32());
//EndOp(); ExitStateChange();
} }
void void
ServerPicture::SetFontFromLink(BPrivate::LinkReceiver& link) ServerPicture::SetFontFromLink(BPrivate::LinkReceiver& link)
{ {
//BeginOp(B_PIC_ENTER_STATE_CHANGE); BeginOp(B_PIC_ENTER_FONT_STATE);
uint16 mask; uint16 mask;
link.Read<uint16>(&mask); link.Read<uint16>(&mask);
@@ -890,7 +895,7 @@ ServerPicture::SetFontFromLink(BPrivate::LinkReceiver& link)
WriteSetFontFlags(flags); WriteSetFontFlags(flags);
} }
//EndOp(); EndOp();
} }
-3
View File
@@ -19,9 +19,6 @@ public:
void EnterStateChange(); void EnterStateChange();
void ExitStateChange(); void ExitStateChange();
void EnterFontChange();
void ExitFontChange();
void SyncState(ViewLayer *view); void SyncState(ViewLayer *view);
void SetFontFromLink(BPrivate::LinkReceiver& link); void SetFontFromLink(BPrivate::LinkReceiver& link);