虚幻4 Slate主线程

来源:互联网 发布:淘宝上的海外专营店 编辑:程序博客网 时间:2024/05/17 23:31

总控制:

Engine_Updating\Engine\Source\Runtime\Slate\Private\Framework\Application\SlateApplication.cpp

void FSlateApplication::PrivateDrawWindows( TSharedPtr<SWindow> DrawOnlyThisWindow ){<span style="color:#ff0000;">DrawWindowAndChildren(CurrentWindow, DrawWindowArgs);</span>
{<span style="color:#ff0000;"></span>SLATE_CYCLE_COUNTER_SCOPE(GSlateRendererDrawWindows);<span style="color:#ff0000;">Renderer->DrawWindows( DrawWindowArgs.OutDrawBuffer );</span>}}

第一个,主线程装配所有的这一帧的UI的数据,保存在DrawWindowArgs.OutDrawBuffer里面,

然后最后调用到第二个红色的地方,用来想渲染线程发送Task。在发送task之前,会调用batcher,先把可以batch的batch到一起。


下面是装配函数:


\Engine\Source\Runtime\Slate\Private\Framework\Application\SlateApplication.cpp

void FSlateApplication::DrawWindowAndChildren( const TSharedRef<SWindow>& WindowToDraw, FDrawWindowArgs& DrawWindowArgs ){// Only draw visible windowsif( WindowToDraw->IsVisible() && !WindowToDraw->IsWindowMinimized() ){SLATE_CYCLE_COUNTER_SCOPE_CUSTOM(GSlateDrawWindowAndChildren, WindowToDraw->GetCreatedInLocation());// Switch to the appropriate world for drawingFScopedSwitchWorldHack SwitchWorld( WindowToDraw );//FPlatformMisc::BeginNamedEvent(FColor::Magenta, "Slate::DrawPrep");<span style="color:#ff0000;">FSlateWindowElementList& WindowElementList = DrawWindowArgs.OutDrawBuffer.AddWindowElementList( WindowToDraw );</span>//FPlatformMisc::EndNamedEvent();// Drawing is done in window space, so null out the positions and keep the size.FGeometry WindowGeometry = WindowToDraw->GetWindowGeometryInWindow();int32 MaxLayerId = 0;{//FPlatformMisc::BeginNamedEvent(FColor::Magenta, "Slate::ClearHitTestGrid");WindowToDraw->GetHittestGrid()->ClearGridForNewFrame( VirtualDesktopRect );//FPlatformMisc::EndNamedEvent();FPlatformMisc::BeginNamedEvent(FColor::Magenta, "Slate::DrawWindow");<span style="color:#ff0000;">MaxLayerId = WindowToDraw->PaintWindow(FPaintArgs(WindowToDraw.Get(), *WindowToDraw->GetHittestGrid(), WindowToDraw->GetPositionInScreen(), GetCurrentTime(), GetDeltaTime()),WindowGeometry, WindowToDraw->GetClippingRectangleInWindow(),WindowElementList,0,FWidgetStyle(),WindowToDraw->IsEnabled() );</span>

第一个红色代码,清掉上一帧的历史数据,班会一个空的buffer,

第二个红色的代码,递归调用,遍历树形结构,向WindowElementList里面填数据。







0 0
原创粉丝点击