提交 7b7d36a8 编写于 作者: M Marvin Häuser

OpenCanopy: Replace linked lists with arrays for GUI object children

上级 06991a81
......@@ -107,7 +107,8 @@ EFI_STATUS
BootPickerViewInitialize (
OUT GUI_DRAWING_CONTEXT *DrawContext,
IN BOOT_PICKER_GUI_CONTEXT *GuiContext,
IN GUI_CURSOR_GET_IMAGE GetCursorImage
IN GUI_CURSOR_GET_IMAGE GetCursorImage,
IN UINT8 NumBootEntries
);
VOID
......@@ -116,10 +117,11 @@ BootPickerViewLateInitialize (
);
EFI_STATUS
BootPickerEntriesAdd (
BootPickerEntriesSet (
IN OC_PICKER_CONTEXT *Context,
IN BOOT_PICKER_GUI_CONTEXT *GuiContext,
IN OC_BOOT_ENTRY *Entry,
IN UINT8 EntryIndex,
IN BOOLEAN Default
);
......
......@@ -109,7 +109,8 @@ OcShowMenuByOc (
Status = BootPickerViewInitialize (
&mDrawContext,
&mGuiContext,
InternalGetCursorImage
InternalGetCursorImage,
(UINT8) BootContext->BootEntryCount
);
if (EFI_ERROR (Status)) {
OcShowMenuByOcLeave ();
......@@ -117,10 +118,11 @@ OcShowMenuByOc (
}
for (Index = 0; Index < BootContext->BootEntryCount; ++Index) {
Status = BootPickerEntriesAdd (
Status = BootPickerEntriesSet (
BootContext->PickerContext,
&mGuiContext,
BootEntries[Index],
(UINT8) Index + 1,
Index == BootContext->DefaultEntry->EntryIndex - 1
);
if (EFI_ERROR (Status)) {
......
......@@ -141,7 +141,7 @@ GuiObjDrawDelegate (
{
BOOLEAN Result;
LIST_ENTRY *ChildEntry;
UINTN Index;
GUI_OBJ_CHILD *Child;
UINT32 ChildDrawOffsetX;
......@@ -158,12 +158,8 @@ GuiObjDrawDelegate (
ASSERT (Height <= This->Height);
ASSERT (DrawContext != NULL);
for (
ChildEntry = GetPreviousNode (&This->Children, &This->Children);
!IsNull (&This->Children, ChildEntry);
ChildEntry = GetPreviousNode (&This->Children, ChildEntry)
) {
Child = BASE_CR (ChildEntry, GUI_OBJ_CHILD, Link);
for (Index = 0; Index < This->NumChildren; ++Index) {
Child = This->Children[Index];
ChildDrawOffsetX = OffsetX;
ChildDrawWidth = Width;
......@@ -220,8 +216,8 @@ GuiObjDelegatePtrEvent (
IN INT64 OffsetY
)
{
UINTN Index;
GUI_OBJ *Obj;
LIST_ENTRY *ChildEntry;
GUI_OBJ_CHILD *Child;
ASSERT (This != NULL);
......@@ -229,12 +225,8 @@ GuiObjDelegatePtrEvent (
ASSERT (This->Height > OffsetY);
ASSERT (DrawContext != NULL);
for (
ChildEntry = GetFirstNode (&This->Children);
!IsNull (&This->Children, ChildEntry);
ChildEntry = GetNextNode (&This->Children, ChildEntry)
) {
Child = BASE_CR (ChildEntry, GUI_OBJ_CHILD, Link);
for (Index = 0; Index < This->NumChildren; ++Index) {
Child = This->Children[Index];
if (OffsetX < Child->Obj.OffsetX
|| OffsetX >= Child->Obj.OffsetX + Child->Obj.Width
|| OffsetY < Child->Obj.OffsetY
......@@ -937,6 +929,7 @@ GuiGetBaseCoords (
GUI_OBJ_CHILD *ChildObj;
INT64 X;
INT64 Y;
UINT32 Index;
ASSERT (This != NULL);
ASSERT (DrawContext != NULL);
......@@ -955,7 +948,15 @@ GuiGetBaseCoords (
ChildObj = BASE_CR (Obj, GUI_OBJ_CHILD, Obj);
Obj = ChildObj->Parent;
ASSERT (Obj != NULL);
ASSERT (IsNodeInList (&Obj->Children, &ChildObj->Link));
DEBUG_CODE_BEGIN ();
for (Index = 0; Index < Obj->NumChildren; ++Index) {
if (Obj->Children[Index] == ChildObj) {
break;
}
}
ASSERT (Index != Obj->NumChildren);
DEBUG_CODE_END ();
}
*BaseX = X;
......
......@@ -79,6 +79,8 @@ typedef struct {
GUI_ANIMATE Animate;
} GUI_ANIMATION;
typedef struct GUI_OBJ_CHILD_ GUI_OBJ_CHILD;
struct GUI_OBJ_ {
INT64 OffsetX;
INT64 OffsetY;
......@@ -87,14 +89,14 @@ struct GUI_OBJ_ {
GUI_OBJ_DRAW Draw;
GUI_OBJ_PTR_EVENT PtrEvent;
GUI_OBJ_KEY_EVENT KeyEvent;
LIST_ENTRY Children;
UINT32 NumChildren;
GUI_OBJ_CHILD **Children;
};
typedef struct {
LIST_ENTRY Link;
struct GUI_OBJ_CHILD_ {
GUI_OBJ *Parent;
GUI_OBJ Obj;
} GUI_OBJ_CHILD;
};
typedef struct {
UINT32 Width;
......
......@@ -21,11 +21,12 @@ typedef struct {
GUI_IMAGE Label;
OC_BOOT_ENTRY *Context;
BOOLEAN CustomIcon;
UINT8 Index;
} GUI_VOLUME_ENTRY;
typedef struct {
GUI_OBJ_CHILD Hdr;
GUI_VOLUME_ENTRY *SelectedEntry;
GUI_OBJ_CHILD Hdr;
UINT32 SelectedIndex;
} GUI_VOLUME_PICKER;
#endif // BOOT_PICKER_H
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册