ProfilerMarkerFactory.cpp 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. #include "pch.h"
  2. #include "IUnityInterface.h"
  3. #include "ProfilerMarkerFactory.h"
  4. #include "ScopedProfiler.h"
  5. #include "UnityProfilerInterfaceFunctions.h"
  6. namespace unity
  7. {
  8. namespace webrtc
  9. {
  10. std::unique_ptr<ProfilerMarkerFactory> ProfilerMarkerFactory::Create(UnityProfiler* profiler)
  11. {
  12. RTC_DCHECK(profiler);
  13. return std::unique_ptr<ProfilerMarkerFactory>(new ProfilerMarkerFactory(profiler));
  14. }
  15. ProfilerMarkerFactory::ProfilerMarkerFactory(UnityProfiler* profiler)
  16. : profiler_(profiler)
  17. {
  18. }
  19. ProfilerMarkerFactory::~ProfilerMarkerFactory() { }
  20. const UnityProfilerMarkerDesc* ProfilerMarkerFactory::CreateMarker(
  21. const char* name, UnityProfilerCategoryId category, UnityProfilerMarkerFlags flags, int eventDataCount)
  22. {
  23. const UnityProfilerMarkerDesc* desc = nullptr;
  24. int result = profiler_->CreateMarker(&desc, name, category, flags, eventDataCount);
  25. if (result)
  26. {
  27. RTC_LOG(LS_ERROR) << "IUnityProfiler::CreateMarker error" << result;
  28. throw;
  29. }
  30. return desc;
  31. }
  32. UnityProfilerCategoryId ProfilerMarkerFactory::CreateCategory(const char* name)
  33. {
  34. // todo(kazuki):
  35. // return profiler_->CreateCategory(&desc, name, category, flags, eventDataCount);
  36. return kUnityProfilerCategoryRender;
  37. }
  38. std::unique_ptr<const ScopedProfiler>
  39. ProfilerMarkerFactory::CreateScopedProfiler(const UnityProfilerMarkerDesc& desc)
  40. {
  41. return std::make_unique<const ScopedProfiler>(profiler_, desc);
  42. }
  43. std::unique_ptr<const ScopedProfilerThread>
  44. ProfilerMarkerFactory::CreateScopedProfilerThread(const char* groupName, const char* name)
  45. {
  46. return std::make_unique<const ScopedProfilerThread>(profiler_, groupName, name);
  47. }
  48. }
  49. }