context: // MonoGame - Copyright (C) The MonoGame Team
  // This file is subject to the terms and conditions defined in
  // file 'LICENSE.txt', which is part of this source code package.
  
  using System;
  using System.Collections.Generic;
  using System.Collections.ObjectModel;
  
  #if MONOMAC
  #if PLATFORM_MACOS_LEGACY
  using MonoMac.AppKit;
  using MonoMac.Foundation;
  #else
  using AppKit;
  using Foundation;
  #endif
  #elif IOS
  using UIKit;
  #elif ANDROID
  using Android.Views;
  using Android.Runtime;
  #endif
  
  // NOTE: This is the legacy graphics adapter implementation
  // which should no longer be updated.  All new development
  // should go into the new one.
  
  namespace Microsoft.Xna.Framework.Graphics
  {
      public sealed class GraphicsAdapter : IDisposable
      {
          /// <summary>
          /// Defines the driver type for graphics adapter. Usable only on DirectX platforms for now.
          /// </summary>
          public enum DriverType
          {
              /// <summary>
              /// Hardware device been used for rendering. Maximum speed and performance.
              /// </summary>
              Hardware,
              /// <summary>
              /// Emulates the hardware device on CPU. Slowly, only for testing.
              /// </summary>
              Reference,
              /// <summary>
              /// Useful when <see cref="DriverType.Hardware"/> acceleration does not work.
              /// </summary>
              FastSoftware
          }
  
          private static ReadOnlyCollection<GraphicsAdapter> _adapters;
  
          private DisplayModeCollection _supportedDisplayModes;
  
  
  #if MONOMAC
  		private NSScreen _screen;
          internal GraphicsAdapter(NSScreen screen)
          {
              _screen = screen;
          }
  #elif IOS
  		private UIScreen _screen;
          internal GraphicsAdapter(UIScreen screen)
          {
              _screen = screen;
          }
  #elif DESKTOPGL
          int _displayIndex;
  #else
          internal GraphicsAdapter()
          {
          }
  #endif
  
          public void Dispose()
          {
          }
  
          public DisplayMode CurrentDisplayMode
          {
              get
              {
  #if MONOMAC
                  //Dummy values until MonoMac implements Quartz Display Services
                  SurfaceFormat format = SurfaceFormat.Color;
                  
                  return new DisplayMode((int)_screen.Frame.Width,
                                         (int)_screen.Frame.Height,
                                         format);
  #elif IOS
                  return new DisplayMode((int)(_screen.Bounds.Width * _screen.Scale),
                         (int)(_screen.Bounds.Height * _screen.Scale),
                         SurfaceFormat.Color);
  #elif ANDROID
                  View view = ((AndroidGameWindow)Game.Instance.Window).GameView;
                  return new DisplayMode(view.Width, view.Height, SurfaceFormat.Color);
  #elif DESKTOPGL
                  var displayIndex = Sdl.Display.GetWindowDisplayIndex(SdlGameWindow.Instance.Handle);
  
                  Sdl.Display.Mode mode;
                  Sdl.Display.GetCurrentDisplayMode(displayIndex, out mode);
  
                  return new DisplayMode(mode.Width, mode.Height, SurfaceFormat.Color);
  #elif WINDOWS
                  using (var graphics = System.Drawing.Graphics.FromHwnd(IntPtr.Zero))
                  {
                      var dc = graphics.GetHdc();
                      int width = GetDeviceCaps(dc, HORZRES);
                      int height = GetDeviceCaps(dc, VERTRES);
                      graphics.ReleaseHdc(dc);
                      return new DisplayMode(width, height, SurfaceFormat.Color);
                  }
  #else
                  return new DisplayMode(800, 600, SurfaceFormat.Color);
  #endif
              }
          }
  
          public static GraphicsAdapter DefaultAdapter
          {
              get { return Adapters[0]; }
          }
  
          public static ReadOnlyCollection<GraphicsAdapter> Adapters
          {
              get
              {
                  if (_adapters == null)
                  {
  #if MONOMAC
                      GraphicsAdapter[] tmpAdapters = new GraphicsAdapter[NSScreen.Screens.Length];
                      for (int i=0; i<NSScreen.Screens.Length; i++) {
                          tmpAdapters[i] = new GraphicsAdapter(NSScreen.Screens[i]);
                      }
                      
                      _adapters = new ReadOnlyCollection<GraphicsAdapter>(tmpAdapters);
  #elif IOS
  					_adapters = new ReadOnlyCollection<GraphicsAdapter>(
  						new [] {new GraphicsAdapter(UIScreen.MainScreen)});
  #else
                      _adapters = new ReadOnlyCollection<GraphicsAdapter>(new[] { new GraphicsAdapter() });
  #endif
                  }
  
                  return _adapters;
              }
          }
  
          /// <summary>
          /// Used to request creation of the reference graphics device, 
          /// or the default hardware accelerated device (when set to false).
          /// </summary>
          /// <remarks>
          /// This only works on DirectX platforms where a reference graphics
          /// device is available and must be defined before the graphics device
          /// is created. It defaults to false.
          /// </remarks>
          public static bool UseReferenceDevice
          {
              get { return UseDriverType == DriverType.Reference; }
              set { UseDriverType = value ? DriverType.Reference : DriverType.Hardware; }
          }
  
          /// <summary>
          /// Used to request creation of a specific kind of driver.
          /// </summary>
          /// <remarks>
          /// These values only work on DirectX platforms and must be defined before the graphics device
          /// is created. <see cref="DriverType.Hardware"/> by default.
          /// </remarks>
          public static DriverType UseDriverType { get; set; }
  
          /*
  		public bool QueryRenderTargetFormat(
  			GraphicsProfile graphicsProfile,
  			SurfaceFormat format,
  			DepthFormat depthFormat,
  			int multiSampleCount,
  			out SurfaceFormat selectedFormat,
  			out DepthFormat selectedDepthFormat,
  			out int selectedMultiSampleCount)
  		{
  			throw new NotImplementedException();
  		}
  
          public string Description
          {
              get
              {
                  throw new NotImplementedException();
              }
          }
  
          public int DeviceId
          {
              get
              {
                  throw new NotImplementedException();
              }
          }
  
          public Guid DeviceIdentifier
          {
              get
              {
                  throw new NotImplementedException();
              }
          }
  
          public string DeviceName
          {
              get
              {
                  throw new NotImplementedException();
              }
          }
  
          public string DriverDll
          {
              get
              {
                  throw new NotImplementedException();
              }
          }
  
          public Version DriverVersion
          {
              get
              {
                  throw new NotImplementedException();
              }
          }
  
          public bool IsDefaultAdapter
          {
              get
              {
                  throw new NotImplementedException();
              }
          }
  
          public bool IsWideScreen
          {
              get
              {
                  throw new NotImplementedException();
              }
          }
  
          public IntPtr MonitorHandle
          {
              get
              {
                  throw new NotImplementedException();
              }
          }
  
          public int Revision
          {
              get
              {
                  throw new NotImplementedException();
              }
          }
  
          public int SubSystemId
          {
              get
              {
  
gt:                 throw new NotImplementedException();