3
0

ProfilerImGuiSystemComponent.h 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. /*
  2. * Copyright (c) Contributors to the Open 3D Engine Project.
  3. * For complete copyright and license terms please see the LICENSE at the root of this distribution.
  4. *
  5. * SPDX-License-Identifier: Apache-2.0 OR MIT
  6. *
  7. */
  8. #pragma once
  9. #include <Profiler/ProfilerImGuiBus.h>
  10. #include <ImGuiCpuProfiler.h>
  11. #include "ImGuiTreemapImpl.h"
  12. #include <AzCore/Component/Component.h>
  13. #if defined(IMGUI_ENABLED)
  14. #include <ImGuiBus.h>
  15. #include <imgui/imgui.h>
  16. #endif // defined(IMGUI_ENABLED)
  17. namespace Profiler
  18. {
  19. class ProfilerImGuiSystemComponent
  20. : public AZ::Component
  21. #if defined(IMGUI_ENABLED)
  22. , public ProfilerImGuiRequests
  23. , public ImGui::ImGuiUpdateListenerBus::Handler
  24. #endif // defined(IMGUI_ENABLED)
  25. {
  26. public:
  27. AZ_COMPONENT(ProfilerImGuiSystemComponent, "{E59A8A53-6784-4CCB-A8B5-9F91DA9BF1C5}");
  28. static void Reflect(AZ::ReflectContext* context);
  29. static void GetProvidedServices(AZ::ComponentDescriptor::DependencyArrayType& provided);
  30. static void GetIncompatibleServices(AZ::ComponentDescriptor::DependencyArrayType& incompatible);
  31. static void GetRequiredServices(AZ::ComponentDescriptor::DependencyArrayType& required);
  32. static void GetDependentServices(AZ::ComponentDescriptor::DependencyArrayType& dependent);
  33. ProfilerImGuiSystemComponent();
  34. ~ProfilerImGuiSystemComponent();
  35. protected:
  36. // AZ::Component interface implementation
  37. void Activate() override;
  38. void Deactivate() override;
  39. #if defined(IMGUI_ENABLED)
  40. // ProfilerImGuiRequests interface implementation
  41. void ShowCpuProfilerWindow(bool& keepDrawing) override;
  42. // ImGuiUpdateListenerBus overrides
  43. void OnImGuiUpdate() override;
  44. void OnImGuiMainMenuUpdate() override;
  45. #endif // defined(IMGUI_ENABLED)
  46. private:
  47. #if defined(IMGUI_ENABLED)
  48. ImGuiTreemapFactoryImpl m_imguiTreemapFactory;
  49. ImGuiCpuProfiler m_imguiCpuProfiler;
  50. bool m_showCpuProfiler{ false };
  51. #endif // defined(IMGUI_ENABLED)
  52. };
  53. } // namespace Profiler