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 {
BeginOp(B_PIC_SET_FONT_FAMILY);
WriteData(family, strlen(family));
Write<int8>(0);
Write<uint8>(0);
EndOp();
} catch (status_t &status) {
return status;
@@ -407,7 +407,7 @@ PictureDataWriter::WriteSetFontStyle(const font_style style)
try {
BeginOp(B_PIC_SET_FONT_STYLE);
WriteData(style, strlen(style));
Write<int8>(0);
Write<uint8>(0);
EndOp();
} catch (status_t &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);
size_t pos = 0;
int32 fontStateBlockSize = -1;
int32 stateBlockSize = -1;
while ((pos + 6) <= fSize) {
int16 op = *reinterpret_cast<const int16 *>(data);
int32 size = *reinterpret_cast<const int32 *>(data + 2);
@@ -284,6 +287,7 @@ PicturePlayer::Play(void **callBackTable, int32 tableEntries, void *userData)
{
if (tableEntries <= 20)
break;
// TODO: Implement
break;
}
@@ -299,6 +303,7 @@ PicturePlayer::Play(void **callBackTable, int32 tableEntries, void *userData)
{
if (tableEntries <= 21)
break;
// TODO: Implement
break;
}
@@ -320,17 +325,17 @@ PicturePlayer::Play(void **callBackTable, int32 tableEntries, void *userData)
case B_PIC_ENTER_STATE_CHANGE:
{
if (tableEntries <= 24)
break;
((fnc)callBackTable[24])(userData);
if (tableEntries > 24)
((fnc)callBackTable[24])(userData);
stateBlockSize = size;
break;
}
case B_PIC_ENTER_FONT_STATE:
{
if (tableEntries <= 26)
break;
((fnc)callBackTable[26])(userData);
if (tableEntries > 26)
((fnc)callBackTable[26])(userData);
fontStateBlockSize = size;
break;
}
@@ -512,15 +517,31 @@ PicturePlayer::Play(void **callBackTable, int32 tableEntries, void *userData)
break;
}
// TODO: This is not correct. B_PIC_ENTER_STATE_CHANGE and
// B_PIC_ENTER_FONT_STATE ops include other ops. We should just advance
// the buffer by the size of these ops, not the size of the whole block,
// otherwise the nested ops won't be executed. I disabled them in
// ServerPicture::SyncState() and ServerPicture::SetFontFromLink()
// until we handle them correctly here.
pos += size;
data += size;
// Skip the already handled block unless it's one of these two,
// since they can contain other nested ops.
if (op != B_PIC_ENTER_STATE_CHANGE && op != B_PIC_ENTER_FONT_STATE) {
pos += size;
data += size;
if (stateBlockSize > 0)
stateBlockSize -= size + 6;
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?
}
+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
enter_state_change(ViewLayer *view)
{
printf("EnterStateChange\n");
}
static void
exit_state_change(ViewLayer *view)
{
printf("ExitStateChange\n");
}
static void
enter_font_state(ViewLayer *view)
{
printf("EnterFontState\n");
}
static void
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;
font.SetSpacing(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;
font.SetSize(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;
font.SetRotation(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;
font.SetEncoding(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;
font.SetFlags(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;
font.SetShear(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;
font.SetFace(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
ServerPicture::SyncState(ViewLayer *view)
{
// TODO: Finish this
//BeginOp(B_PIC_ENTER_STATE_CHANGE);
EnterStateChange();
WriteSetOrigin(view->CurrentState()->Origin());
WriteSetPenLocation(view->CurrentState()->PenLocation());
@@ -819,14 +825,13 @@ ServerPicture::SyncState(ViewLayer *view)
WriteSetHighColor(view->CurrentState()->HighColor().GetColor32());
WriteSetLowColor(view->CurrentState()->LowColor().GetColor32());
//EndOp();
ExitStateChange();
}
void
ServerPicture::SetFontFromLink(BPrivate::LinkReceiver& link)
{
//BeginOp(B_PIC_ENTER_STATE_CHANGE);
BeginOp(B_PIC_ENTER_FONT_STATE);
uint16 mask;
link.Read<uint16>(&mask);
@@ -890,7 +895,7 @@ ServerPicture::SetFontFromLink(BPrivate::LinkReceiver& link)
WriteSetFontFlags(flags);
}
//EndOp();
EndOp();
}
-3
View File
@@ -19,9 +19,6 @@ public:
void EnterStateChange();
void ExitStateChange();
void EnterFontChange();
void ExitFontChange();
void SyncState(ViewLayer *view);
void SetFontFromLink(BPrivate::LinkReceiver& link);