Reland "Fix sk_app macOS raster window build conditions."
The "raster" window on macOS and iOS is actually backed by GL. Fix the
build rules and code conditions to reflect this. This allows for some
sk_app applications to run on macOS and iOS with skia_use_gl=false.
> Revert:
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/397737
> Commit-Queue: Brian Osman <brianosman@google.com>
> Reviewed-by: Brian Osman <brianosman@google.com>
> Land:
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/397256
> Commit-Queue: Ben Wagner <bungeman@google.com>
> Reviewed-by: Brian Osman <brianosman@google.com>
Change-Id: Ia8a421f4818856dd90cb4847095eee0d1836d1e6
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/398056
Reviewed-by: Ben Wagner <bungeman@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: Ben Wagner <bungeman@google.com>
diff --git a/BUILD.gn b/BUILD.gn
index 7b03e0f..ebee8f7 100644
--- a/BUILD.gn
+++ b/BUILD.gn
@@ -2557,7 +2557,6 @@
]
} else if (is_mac) {
sources += [
- "tools/sk_app/mac/RasterWindowContext_mac.mm",
"tools/sk_app/mac/WindowContextFactory_mac.h",
"tools/sk_app/mac/Window_mac.h",
"tools/sk_app/mac/Window_mac.mm",
@@ -2570,7 +2569,6 @@
]
} else if (is_ios) {
sources += [
- "tools/sk_app/ios/RasterWindowContext_ios.mm",
"tools/sk_app/ios/WindowContextFactory_ios.h",
"tools/sk_app/ios/Window_ios.h",
"tools/sk_app/ios/Window_ios.mm",
@@ -2592,9 +2590,15 @@
sources += [ "tools/sk_app/win/ANGLEWindowContext_win.cpp" ]
}
} else if (is_mac) {
- sources += [ "tools/sk_app/mac/GLWindowContext_mac.mm" ]
+ sources += [
+ "tools/sk_app/mac/GLWindowContext_mac.mm",
+ "tools/sk_app/mac/RasterWindowContext_mac.mm",
+ ]
} else if (is_ios) {
- sources += [ "tools/sk_app/ios/GLWindowContext_ios.mm" ]
+ sources += [
+ "tools/sk_app/ios/GLWindowContext_ios.mm",
+ "tools/sk_app/ios/RasterWindowContext_ios.mm",
+ ]
}
}
@@ -2863,7 +2867,7 @@
]
}
- if (skia_use_gl && skia_use_icu && skia_use_harfbuzz) {
+ if (skia_use_icu && skia_use_harfbuzz) {
test_app("editor") {
is_shared_library = is_android
deps = [ "modules/skplaintexteditor:editor_app" ]
diff --git a/modules/skplaintexteditor/app/editor_application.cpp b/modules/skplaintexteditor/app/editor_application.cpp
index cf37eb6..7ee67e1 100644
--- a/modules/skplaintexteditor/app/editor_application.cpp
+++ b/modules/skplaintexteditor/app/editor_application.cpp
@@ -366,8 +366,17 @@
}
};
-//static constexpr sk_app::Window::BackendType kBackendType = sk_app::Window::kRaster_BackendType;
+#ifdef SK_VULKAN
+static constexpr sk_app::Window::BackendType kBackendType = sk_app::Window::kVulkan_BackendType;
+#elif SK_METAL
+static constexpr sk_app::Window::BackendType kBackendType = sk_app::Window::kMetal_BackendType;
+#elif SK_GL
static constexpr sk_app::Window::BackendType kBackendType = sk_app::Window::kNativeGL_BackendType;
+#elif SK_DAWN
+static constexpr sk_app::Window::BackendType kBackendType = sk_app::Window::kDawn_BackendType;
+#else
+static constexpr sk_app::Window::BackendType kBackendType = sk_app::Window::kRaster_BackendType;
+#endif
struct EditorApplication : public sk_app::Application {
std::unique_ptr<sk_app::Window> fWindow;
diff --git a/tools/sk_app/ios/WindowContextFactory_ios.h b/tools/sk_app/ios/WindowContextFactory_ios.h
index 513e23a..be8759f 100644
--- a/tools/sk_app/ios/WindowContextFactory_ios.h
+++ b/tools/sk_app/ios/WindowContextFactory_ios.h
@@ -28,16 +28,21 @@
UIViewController* fViewController;
};
+#ifdef SK_VULKAN
inline std::unique_ptr<WindowContext> MakeVulkanForIOS(const IOSWindowInfo&, const DisplayParams&) {
// No Vulkan support on iOS yet.
return nullptr;
}
+#endif
+#ifdef SK_METAL
std::unique_ptr<WindowContext> MakeMetalForIOS(const IOSWindowInfo&, const DisplayParams&);
+#endif
+#ifdef SK_GL
std::unique_ptr<WindowContext> MakeGLForIOS(const IOSWindowInfo&, const DisplayParams&);
-
std::unique_ptr<WindowContext> MakeRasterForIOS(const IOSWindowInfo&, const DisplayParams&);
+#endif
} // namespace window_context_factory
diff --git a/tools/sk_app/ios/Window_ios.mm b/tools/sk_app/ios/Window_ios.mm
index d3e34b3..1ff7d1a 100644
--- a/tools/sk_app/ios/Window_ios.mm
+++ b/tools/sk_app/ios/Window_ios.mm
@@ -91,15 +91,14 @@
#endif
#ifdef SK_GL
case kNativeGL_BackendType:
- default:
fWindowContext = MakeGLForIOS(info, fRequestedDisplayParams);
break;
-#else
- default:
-#endif
case kRaster_BackendType:
fWindowContext = MakeRasterForIOS(info, fRequestedDisplayParams);
break;
+#endif
+ default:
+ SkASSERT_RELEASE(false);
}
this->onBackendCreated();
diff --git a/tools/sk_app/mac/WindowContextFactory_mac.h b/tools/sk_app/mac/WindowContextFactory_mac.h
index acf860a..e772030 100644
--- a/tools/sk_app/mac/WindowContextFactory_mac.h
+++ b/tools/sk_app/mac/WindowContextFactory_mac.h
@@ -35,18 +35,22 @@
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
-std::unique_ptr<WindowContext> MakeRasterForMac(const MacWindowInfo&, const DisplayParams&);
#ifdef SK_METAL
std::unique_ptr<WindowContext> MakeMetalForMac(const MacWindowInfo&, const DisplayParams&);
#endif
diff --git a/tools/sk_app/mac/Window_mac.mm b/tools/sk_app/mac/Window_mac.mm
index 63ef3f8..4cdee9c 100644
--- a/tools/sk_app/mac/Window_mac.mm
+++ b/tools/sk_app/mac/Window_mac.mm
@@ -139,15 +139,14 @@
#endif
#ifdef SK_GL
case kNativeGL_BackendType:
- default:
fWindowContext = MakeGLForMac(info, fRequestedDisplayParams);
break;
-#else
- default:
-#endif
case kRaster_BackendType:
fWindowContext = MakeRasterForMac(info, fRequestedDisplayParams);
break;
+#endif
+ default:
+ SkASSERT_RELEASE(false);
}
this->onBackendCreated();