skia2/tools/sk_app/mac/WindowContextFactory_mac.h
Jim Van Verth 7bb0ff05ce [graphite] Add support to Mac Viewer.
Adds a type enum to WindowContext to determine which kind of
GPU context (GrDirectContext or skgpu::Context) we're using.

Bug: skia:12466
Change-Id: I288878740392a43cd9e82c925fbe2c372d140dc5
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/454699
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: Jim Van Verth <jvanverth@google.com>
2021-09-30 21:38:25 +00:00

66 lines
1.5 KiB
C++

/*
* 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
#include "tools/sk_app/WindowContext.h"
#include <Cocoa/Cocoa.h>
#include <memory>
namespace sk_app {
struct DisplayParams;
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
}
namespace window_context_factory {
struct MacWindowInfo {
NSView* fMainView;
};
#ifdef SK_VULKAN
inline std::unique_ptr<WindowContext> MakeVulkanForMac(const MacWindowInfo&, const DisplayParams&) {
// No Vulkan support on Mac.
return nullptr;
}
#endif
#ifdef SK_GL
std::unique_ptr<WindowContext> MakeRasterForMac(const MacWindowInfo&, const DisplayParams&);
std::unique_ptr<WindowContext> MakeGLForMac(const MacWindowInfo&, const DisplayParams&);
#endif
#ifdef SK_DAWN
std::unique_ptr<WindowContext> MakeDawnMTLForMac(const MacWindowInfo&, const DisplayParams&);
#endif
#ifdef SK_METAL
std::unique_ptr<WindowContext> MakeMetalForMac(const MacWindowInfo&, const DisplayParams&);
#ifdef SK_GRAPHITE_ENABLED
std::unique_ptr<WindowContext> MakeGraphiteMetalForMac(const MacWindowInfo&, const DisplayParams&);
#endif
#endif
} // namespace window_context_factory
} // namespace sk_app
#endif