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

OpenCanopy: Replace linked lists with arrays for GUI object children

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