2016-07-26 19:02:50 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Copyright 2016 Google Inc.
|
|
|
|
*
|
|
|
|
* Use of this source code is governed by a BSD-style license that can be
|
|
|
|
* found in the LICENSE file.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef WindowContextFactory_mac_DEFINED
|
|
|
|
#define WindowContextFactory_mac_DEFINED
|
|
|
|
|
2019-08-01 20:21:49 +00:00
|
|
|
#include "tools/sk_app/WindowContext.h"
|
|
|
|
|
2019-01-28 19:46:04 +00:00
|
|
|
#include <Cocoa/Cocoa.h>
|
2016-08-04 19:30:31 +00:00
|
|
|
|
2019-08-01 20:21:49 +00:00
|
|
|
#include <memory>
|
|
|
|
|
2016-07-26 19:02:50 +00:00
|
|
|
namespace sk_app {
|
|
|
|
|
|
|
|
struct DisplayParams;
|
|
|
|
|
2021-01-28 19:30:59 +00:00
|
|
|
static inline CGFloat GetBackingScaleFactor(NSView* view) {
|
|
|
|
#ifdef SK_BUILD_FOR_IOS
|
|
|
|
UIScreen* screen = view.window.screen ?: [UIScreen mainScreen];
|
|
|
|
return screen.nativeScale;
|
|
|
|
#else
|
|
|
|
NSScreen* screen = view.window.screen ?: [NSScreen mainScreen];
|
|
|
|
return screen.backingScaleFactor;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2016-07-26 19:02:50 +00:00
|
|
|
namespace window_context_factory {
|
|
|
|
|
|
|
|
struct MacWindowInfo {
|
2019-01-28 19:46:04 +00:00
|
|
|
NSView* fMainView;
|
2016-07-26 19:02:50 +00:00
|
|
|
};
|
|
|
|
|
2021-04-19 14:12:12 +00:00
|
|
|
#ifdef SK_VULKAN
|
2019-08-01 20:21:49 +00:00
|
|
|
inline std::unique_ptr<WindowContext> MakeVulkanForMac(const MacWindowInfo&, const DisplayParams&) {
|
2016-07-26 19:02:50 +00:00
|
|
|
// No Vulkan support on Mac.
|
|
|
|
return nullptr;
|
|
|
|
}
|
2021-04-19 14:12:12 +00:00
|
|
|
#endif
|
2016-07-26 19:02:50 +00:00
|
|
|
|
2021-04-19 14:12:12 +00:00
|
|
|
#ifdef SK_GL
|
|
|
|
std::unique_ptr<WindowContext> MakeRasterForMac(const MacWindowInfo&, const DisplayParams&);
|
2019-08-01 20:21:49 +00:00
|
|
|
std::unique_ptr<WindowContext> MakeGLForMac(const MacWindowInfo&, const DisplayParams&);
|
2021-04-19 14:12:12 +00:00
|
|
|
#endif
|
2016-07-26 19:02:50 +00:00
|
|
|
|
2019-08-02 19:04:52 +00:00
|
|
|
#ifdef SK_DAWN
|
|
|
|
std::unique_ptr<WindowContext> MakeDawnMTLForMac(const MacWindowInfo&, const DisplayParams&);
|
|
|
|
#endif
|
|
|
|
|
2019-02-08 20:36:14 +00:00
|
|
|
#ifdef SK_METAL
|
2019-08-01 20:21:49 +00:00
|
|
|
std::unique_ptr<WindowContext> MakeMetalForMac(const MacWindowInfo&, const DisplayParams&);
|
2019-02-08 20:36:14 +00:00
|
|
|
#endif
|
2016-08-09 17:53:11 +00:00
|
|
|
|
2016-07-26 19:02:50 +00:00
|
|
|
} // namespace window_context_factory
|
|
|
|
|
|
|
|
} // namespace sk_app
|
|
|
|
|
|
|
|
#endif
|