DisplayManager.h 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. #pragma once
  2. #include "GlesHelper.h"
  3. @class EAGLContext;
  4. @class UnityView;
  5. typedef struct
  6. RenderingSurfaceParams
  7. {
  8. // rendering setup
  9. int msaaSampleCount;
  10. int renderW;
  11. int renderH;
  12. int srgb;
  13. int wideColor;
  14. int metalFramebufferOnly;
  15. // unity setup
  16. int disableDepthAndStencil;
  17. int useCVTextureCache;
  18. }
  19. RenderingSurfaceParams;
  20. @interface DisplayConnection : NSObject
  21. - (id)init:(UIScreen*)targetScreen;
  22. - (void)dealloc;
  23. - (void)createView:(BOOL)useForRendering showRightAway:(BOOL)showRightAway;
  24. - (void)createView:(BOOL)useForRendering;
  25. - (void)createWithWindow:(UIWindow*)window andView:(UIView*)view;
  26. - (void)initRendering;
  27. - (void)recreateSurface:(RenderingSurfaceParams)params;
  28. - (void)shouldShowWindow:(BOOL)show;
  29. - (void)requestRenderingResolution:(CGSize)res;
  30. - (void)present;
  31. @property (readonly, copy, nonatomic) UIScreen* screen;
  32. @property (readonly, copy, nonatomic) UIWindow* window;
  33. @property (readonly, copy, nonatomic) UIView* view;
  34. @property (readonly, nonatomic) CGSize screenSize;
  35. @property (readonly, nonatomic) UnityDisplaySurfaceBase* surface;
  36. @end
  37. @interface DisplayManager : NSObject
  38. - (id)objectForKeyedSubscript:(id)key;
  39. - (BOOL)displayAvailable:(UIScreen*)targetScreen;
  40. - (void)updateDisplayListInUnity;
  41. - (void)startFrameRendering;
  42. - (void)present;
  43. - (void)endFrameRendering;
  44. - (void)enumerateDisplaysWithBlock:(void (^)(DisplayConnection* conn))block;
  45. + (void)Initialize;
  46. + (DisplayManager*)Instance;
  47. @property (readonly, nonatomic) DisplayConnection* mainDisplay;
  48. @property (readonly, nonatomic) NSUInteger displayCount;
  49. @end
  50. inline DisplayConnection* GetMainDisplay()
  51. {
  52. return [DisplayManager Instance].mainDisplay;
  53. }
  54. inline UnityDisplaySurfaceBase* GetMainDisplaySurface()
  55. {
  56. return GetMainDisplay().surface;
  57. }