Repository: xbmc/xbmc
File: xbmc/windowing/osx/OpenGL/WindowControllerMacOS.mm (Objective-C++)

Code before:
  auto window = [[NSWindow alloc] initWithContentRect:frame
                                            styleMask:style
                                              backing:NSBackingStoreBuffered
                                                defer:YES];
  window.backgroundColor = NSColor.blackColor;
  window.title = title;
  window.titlebarAppearsTransparent = YES;
  window.titleVisibility = NSWindowTitleHidden;

  window.collectionBehavior = NSWindowCollectionBehaviorFullScreenPrimary |
                              NSWindowCollectionBehaviorFullScreenDisallowsTiling;
  window.tabbingMode = NSWindowTabbingModeDisallowed;

  if ((self = [super initWithWindow:window]))
  {
    self.windowFrameAutosaveName = @"OSXGLWindowPositionHeightWidth";
    self.shouldCascadeWindows = NO;
    window.delegate = self;
    window.contentView = [[OSXGLView alloc] initWithFrame:NSZeroRect];
    window.acceptsMouseMovedEvents = YES;
  }
  g_application.m_AppFocused = true;
  return self;
}

- (void)setGUIRenderingForPerformance:(BOOL)enabled
{
  const std::shared_ptr<CAppInboundProtocol> appPort = CServiceBroker::GetAppPort();
  if (appPort)
    appPort->SetRenderGUI(enabled);
}

- (void)windowDidResize:(NSNotification*)aNotification
{
  if ((self.window.styleMask & NSWindowStyleMaskFullScreen) != NSWindowStyleMaskFullScreen)
  {
    NSRect rect = [self.window.contentView
        convertRectToBacking:[self.window contentRectForFrameRect:self.window.frame]];

    XBMC_Event newEvent = {};
    newEvent.type = XBMC_VIDEORESIZE;
    newEvent.resize.width = static_cast<int>(rect.size.width);
    newEvent.resize.height = static_cast<int>(rect.size.height);
    newEvent.resize.scale = 1.0;

    // check for valid sizes cause in some cases
    // we are hit during fullscreen transition from macos
    // and might be technically "zero" sized
    if (newEvent.resize.width != 0 && newEvent.resize.height != 0)
    {
      std::shared_ptr<CAppInboundProtocol> appPort = CServiceBroker::GetAppPort();

Review comment (performance):
Nitpick: i would remove “ForPerformance” from the function name. A method name should reflect what the method does, not why it is called. 

Code after:
} // unnamed namespace

@implementation XBMCWindowControllerMacOS

- (nullable instancetype)initWithTitle:(NSString*)title defaultSize:(NSSize)size
{
  auto frame = NSMakeRect(0, 0, size.width, size.height);
  const NSWindowStyleMask style = NSWindowStyleMaskTitled | NSWindowStyleMaskClosable |
                                  NSWindowStyleMaskMiniaturizable | NSWindowStyleMaskResizable;

  auto window = [[NSWindow alloc] initWithContentRect:frame
                                            styleMask:style
                                              backing:NSBackingStoreBuffered
                                                defer:YES];
  window.backgroundColor = NSColor.blackColor;
  window.title = title;
  window.titlebarAppearsTransparent = YES;
  window.titleVisibility = NSWindowTitleHidden;

  window.collectionBehavior = NSWindowCollectionBehaviorFullScreenPrimary |
                              NSWindowCollectionBehaviorFullScreenDisallowsTiling;
  window.tabbingMode = NSWindowTabbingModeDisallowed;

  if ((self = [super initWithWindow:window]))
  {
    self.windowFrameAutosaveName = @"OSXGLWindowPositionHeightWidth";
    self.shouldCascadeWindows = NO;
    window.delegate = self;
    window.contentView = [[OSXGLView alloc] initWithFrame:NSZeroRect];
    window.acceptsMouseMovedEvents = YES;
  }
  g_application.m_AppFocused = true;
  return self;
}
- (void)windowDidResize:(NSNotification*)aNotification
{
  if ((self.window.styleMask & NSWindowStyleMaskFullScreen) != NSWindowStyleMaskFullScreen)
  {
    NSRect rect = [self.window.contentView
        convertRectToBacking:[self.window contentRectForFrameRect:self.window.frame]];

    XBMC_Event newEvent = {};
    newEvent.type = XBMC_VIDEORESIZE;
    newEvent.resize.width = static_cast<int>(rect.size.width);
    newEvent.resize.height = static_cast<int>(rect.size.height);
    newEvent.resize.scale = 1.0;

    // check for valid sizes cause in some cases
    // we are hit during fullscreen transition from macos
    // and might be technically "zero" sized
    if (newEvent.resize.width != 0 && newEvent.resize.height != 0)