RenderPluginDelegate.mm 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. #include "RenderPluginDelegate.h"
  2. @implementation RenderPluginDelegate
  3. - (void)mainDisplayInited:(struct UnityDisplaySurfaceBase*)surface
  4. {
  5. mainDisplaySurface = surface;
  6. // TODO: move lifecycle to init?
  7. UnityRegisterLifeCycleListener(self);
  8. }
  9. @end
  10. #define CALL_METHOD_ON_ARRAY(method) \
  11. do{ \
  12. for(id<RenderPluginDelegate> del in delegateArray) \
  13. { \
  14. if([del respondsToSelector:@selector(method)]) \
  15. [del method]; \
  16. } \
  17. } while(0)
  18. #define CALL_METHOD_ON_ARRAY_ARG(method, arg) \
  19. do{ \
  20. for(id<RenderPluginDelegate> del in delegateArray) \
  21. { \
  22. if([del respondsToSelector:@selector(method:)]) \
  23. [del method:arg]; \
  24. } \
  25. } while(0)
  26. @implementation RenderPluginArrayDelegate
  27. @synthesize delegateArray;
  28. - (void)mainDisplayInited:(struct UnityDisplaySurfaceBase*)surface
  29. {
  30. [super mainDisplayInited: surface];
  31. CALL_METHOD_ON_ARRAY_ARG(mainDisplayInited, surface);
  32. }
  33. - (void)onBeforeMainDisplaySurfaceRecreate:(struct RenderingSurfaceParams*)params
  34. {
  35. CALL_METHOD_ON_ARRAY_ARG(onBeforeMainDisplaySurfaceRecreate, params);
  36. }
  37. - (void)onAfterMainDisplaySurfaceRecreate;
  38. {
  39. CALL_METHOD_ON_ARRAY(onAfterMainDisplaySurfaceRecreate);
  40. }
  41. - (void)onFrameResolved;
  42. {
  43. CALL_METHOD_ON_ARRAY(onFrameResolved);
  44. }
  45. - (void)didBecomeActive:(NSNotification*)notification
  46. {
  47. CALL_METHOD_ON_ARRAY_ARG(didBecomeActive, notification);
  48. }
  49. - (void)willResignActive:(NSNotification*)notification
  50. {
  51. CALL_METHOD_ON_ARRAY_ARG(willResignActive, notification);
  52. }
  53. - (void)didEnterBackground:(NSNotification*)notification
  54. {
  55. CALL_METHOD_ON_ARRAY_ARG(didEnterBackground, notification);
  56. }
  57. - (void)willEnterForeground:(NSNotification*)notification
  58. {
  59. CALL_METHOD_ON_ARRAY_ARG(willEnterForeground, notification);
  60. }
  61. - (void)willTerminate:(NSNotification*)notification
  62. {
  63. CALL_METHOD_ON_ARRAY_ARG(willTerminate, notification);
  64. }
  65. @end
  66. #undef CALL_METHOD_ON_ARRAY
  67. #undef CALL_METHOD_ON_ARRAY_ARG