9#ifndef WindowContextFactory_mac_DEFINED
10#define WindowContextFactory_mac_DEFINED
14#include <Cocoa/Cocoa.h>
23 #ifdef SK_BUILD_FOR_IOS
24 UIScreen* screen = view.window.screen ?: [UIScreen mainScreen];
25 return screen.nativeScale;
27 NSScreen* screen = view.window.screen ?: [NSScreen mainScreen];
28 return screen.backingScaleFactor;
36#if defined(SK_GL) || defined(SK_ANGLE)
37static inline NSOpenGLPixelFormat* GetGLPixelFormat(
int sampleCount) {
38 constexpr int kMaxAttributes = 19;
39 NSOpenGLPixelFormatAttribute attributes[kMaxAttributes];
40 int numAttributes = 0;
41 attributes[numAttributes++] = NSOpenGLPFAAccelerated;
42 attributes[numAttributes++] = NSOpenGLPFAClosestPolicy;
43 attributes[numAttributes++] = NSOpenGLPFADoubleBuffer;
44 attributes[numAttributes++] = NSOpenGLPFAOpenGLProfile;
45 attributes[numAttributes++] = NSOpenGLProfileVersion3_2Core;
46 attributes[numAttributes++] = NSOpenGLPFAColorSize;
47 attributes[numAttributes++] = 24;
48 attributes[numAttributes++] = NSOpenGLPFAAlphaSize;
49 attributes[numAttributes++] = 8;
50 attributes[numAttributes++] = NSOpenGLPFADepthSize;
51 attributes[numAttributes++] = 0;
52 attributes[numAttributes++] = NSOpenGLPFAStencilSize;
53 attributes[numAttributes++] = 8;
54 if (sampleCount > 1) {
55 attributes[numAttributes++] = NSOpenGLPFAMultisample;
56 attributes[numAttributes++] = NSOpenGLPFASampleBuffers;
57 attributes[numAttributes++] = 1;
58 attributes[numAttributes++] = NSOpenGLPFASamples;
59 attributes[numAttributes++] = sampleCount;
61 attributes[numAttributes++] = NSOpenGLPFASampleBuffers;
62 attributes[numAttributes++] = 0;
64 attributes[numAttributes++] = 0;
65 SkASSERT(numAttributes <= kMaxAttributes);
66 return [[NSOpenGLPixelFormat alloc] initWithAttributes:attributes];
71inline std::unique_ptr<WindowContext> MakeVulkanForMac(
const MacWindowInfo&,
const DisplayParams&) {
78std::unique_ptr<WindowContext>
MakeRasterForMac(
const MacWindowInfo&,
const DisplayParams&);
79std::unique_ptr<WindowContext>
MakeGLForMac(
const MacWindowInfo&,
const DisplayParams&);
83std::unique_ptr<WindowContext>
MakeANGLEForMac(
const MacWindowInfo&,
const DisplayParams&);
87#if defined(SK_GRAPHITE)
93std::unique_ptr<WindowContext>
MakeMetalForMac(
const MacWindowInfo&,
const DisplayParams&);
94#if defined(SK_GRAPHITE)
std::unique_ptr< WindowContext > MakeGraphiteDawnMetalForMac(const MacWindowInfo &info, const DisplayParams ¶ms)
std::unique_ptr< WindowContext > MakeGLForMac(const MacWindowInfo &info, const DisplayParams ¶ms)
std::unique_ptr< WindowContext > MakeRasterForMac(const MacWindowInfo &info, const DisplayParams ¶ms)
std::unique_ptr< WindowContext > MakeMetalForMac(const MacWindowInfo &info, const DisplayParams ¶ms)
std::unique_ptr< WindowContext > MakeANGLEForMac(const MacWindowInfo &info, const DisplayParams ¶ms)
static CGFloat GetBackingScaleFactor(NSView *view)
std::unique_ptr< WindowContext > MakeGraphiteMetalForMac(const MacWindowInfo &info, const DisplayParams ¶ms)