From 6f3329a2f1e78ea882b74a39b18620837c3a42c0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marvin=20H=C3=A4user?= <8659494+mhaeuser@users.noreply.github.com> Date: Sat, 6 Mar 2021 11:22:21 +0100 Subject: [PATCH] OpenCanopy: Merge the intro animations --- Platform/OpenCanopy/Views/BootPicker.c | 93 ++++++-------------------- 1 file changed, 21 insertions(+), 72 deletions(-) diff --git a/Platform/OpenCanopy/Views/BootPicker.c b/Platform/OpenCanopy/Views/BootPicker.c index c866be67..6defeef2 100644 --- a/Platform/OpenCanopy/Views/BootPicker.c +++ b/Platform/OpenCanopy/Views/BootPicker.c @@ -1466,56 +1466,6 @@ InternalBootPickerExitLoop ( STATIC GUI_INTERPOLATION mBpAnimInfoOpacity; -VOID -InitBpAnimOpacity ( - IN GUI_INTERPOL_TYPE Type, - IN UINT64 StartTime, - IN UINT64 Duration - ) -{ - mBpAnimInfoOpacity.Type = Type; - mBpAnimInfoOpacity.StartTime = StartTime; - mBpAnimInfoOpacity.Duration = Duration; - mBpAnimInfoOpacity.StartValue = 0; - mBpAnimInfoOpacity.EndValue = 0xFF; - - mBootPickerOpacity = 0; -} - -BOOLEAN -InternalBootPickerAnimateOpacity ( - IN BOOT_PICKER_GUI_CONTEXT *Context, - IN OUT GUI_DRAWING_CONTEXT *DrawContext, - IN UINT64 CurrentTime - ) -{ - ASSERT (DrawContext != NULL); - - mBootPickerOpacity = (UINT8)GuiGetInterpolatedValue (&mBpAnimInfoOpacity, CurrentTime); - // - // The screen is drawn by the offset animation, which is always called after - // this one. Do not draw here to not cause pointless overhead. - // - // FIXME: Investigate and opt for one of the two. - // 1. Merge the offset and opacity animations into one. - // 2. Add a layer of literal 'draw requests' to merge and process drawing - // requests after all animations and events have been processed. - // - /*GuiDrawScreen ( - DrawContext, - mBootPickerContainer.Obj.OffsetX, - mBootPickerContainer.Obj.OffsetY, - DrawContext->Screen->Width, - mBootPickerContainer.Obj.Height - );*/ - - if (mBootPickerOpacity == mBpAnimInfoOpacity.EndValue) { - return TRUE; - } - - return FALSE; -} - STATIC GUI_INTERPOLATION mBpAnimInfoImageList; VOID @@ -1569,15 +1519,21 @@ InternalBootPickerAnimateImageList ( STATIC GUI_INTERPOLATION mBpAnimInfoSinMove; VOID -InitBpAnimSinMov ( - IN GUI_INTERPOL_TYPE Type, - IN UINT64 StartTime, - IN UINT64 Duration +InitBpAnimIntro ( + VOID ) { - mBpAnimInfoSinMove.Type = Type; - mBpAnimInfoSinMove.StartTime = StartTime; - mBpAnimInfoSinMove.Duration = Duration; + mBpAnimInfoOpacity.Type = GuiInterpolTypeSmooth; + mBpAnimInfoOpacity.StartTime = 0; + mBpAnimInfoOpacity.Duration = 25; + mBpAnimInfoOpacity.StartValue = 0; + mBpAnimInfoOpacity.EndValue = 0xFF; + + mBootPickerOpacity = 0; + + mBpAnimInfoSinMove.Type = GuiInterpolTypeSmooth; + mBpAnimInfoSinMove.StartTime = 0; + mBpAnimInfoSinMove.Duration = 25; mBpAnimInfoSinMove.StartValue = 0; mBpAnimInfoSinMove.EndValue = 35; // @@ -1588,7 +1544,7 @@ InitBpAnimSinMov ( } BOOLEAN -InternalBootPickerAnimateSinMov ( +InternalBootPickerAnimateIntro ( IN BOOT_PICKER_GUI_CONTEXT *Context, IN OUT GUI_DRAWING_CONTEXT *DrawContext, IN UINT64 CurrentTime @@ -1601,6 +1557,8 @@ InternalBootPickerAnimateSinMov ( ASSERT (DrawContext != NULL); + mBootPickerOpacity = (UINT8)GuiGetInterpolatedValue (&mBpAnimInfoOpacity, CurrentTime); + InterpolVal = GuiGetInterpolatedValue (&mBpAnimInfoSinMove, CurrentTime); DeltaSine = InterpolVal - PrevSine; mBootPicker.Hdr.Obj.OffsetX -= DeltaSine; @@ -1613,12 +1571,9 @@ InternalBootPickerAnimateSinMov ( (UINT32)(mBootPicker.Hdr.Obj.Width + DeltaSine), mBootPicker.Hdr.Obj.Height ); - - if (InterpolVal == mBpAnimInfoSinMove.EndValue) { - return TRUE; - } - - return FALSE; + + ASSERT (mBpAnimInfoSinMove.Duration == mBpAnimInfoOpacity.Duration); + return CurrentTime - mBpAnimInfoSinMove.StartTime >= mBpAnimInfoSinMove.Duration; } EFI_STATUS @@ -1709,16 +1664,10 @@ BootPickerViewInitialize ( // if (!GuiContext->DoneIntroAnimation) { - InitBpAnimOpacity (GuiInterpolTypeSmooth, 0, 25); - STATIC GUI_ANIMATION PickerAnim2; - PickerAnim2.Context = NULL; - PickerAnim2.Animate = InternalBootPickerAnimateOpacity; - InsertHeadList (&DrawContext->Animations, &PickerAnim2.Link); - - InitBpAnimSinMov (GuiInterpolTypeSmooth, 0, 25); + InitBpAnimIntro (); STATIC GUI_ANIMATION PickerAnim; PickerAnim.Context = NULL; - PickerAnim.Animate = InternalBootPickerAnimateSinMov; + PickerAnim.Animate = InternalBootPickerAnimateIntro; InsertHeadList (&DrawContext->Animations, &PickerAnim.Link); GuiContext->DoneIntroAnimation = TRUE; -- GitLab