From 96c03347fe17f3e77fc66c3989f35ee590238aca Mon Sep 17 00:00:00 2001 From: Emmanuel Gil Peyrot Date: Tue, 30 Jun 2020 17:18:41 +0200 Subject: [PATCH 1/9] Only import std::mem on macOS --- demo/native/src/main.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/demo/native/src/main.rs b/demo/native/src/main.rs index d869b78e7..b81bdc02a 100644 --- a/demo/native/src/main.rs +++ b/demo/native/src/main.rs @@ -26,7 +26,6 @@ use pathfinder_resources::ResourceLoader; use pathfinder_resources::fs::FilesystemResourceLoader; use std::cell::Cell; use std::collections::VecDeque; -use std::mem; use std::path::PathBuf; use std::sync::Mutex; use surfman::{SurfaceAccess, SurfaceType, declare_surfman}; @@ -34,6 +33,8 @@ use winit::{ControlFlow, ElementState, Event as WinitEvent, EventsLoop, EventsLo use winit::{MouseButton, VirtualKeyCode, Window as WinitWindow, WindowBuilder, WindowEvent}; use winit::dpi::LogicalSize; +#[cfg(all(target_os = "macos", not(feature = "pf-gl")))] +use std::mem; #[cfg(any(not(target_os = "macos"), feature = "pf-gl"))] use gl::types::GLuint; #[cfg(any(not(target_os = "macos"), feature = "pf-gl"))] @@ -494,4 +495,4 @@ fn convert_winit_event(winit_event: WinitEvent, } _ => None, } -} \ No newline at end of file +} From b73bcc7394332a82f2d0015bd7778c0c80c564bd Mon Sep 17 00:00:00 2001 From: Emmanuel Gil Peyrot Date: Tue, 30 Jun 2020 17:22:40 +0200 Subject: [PATCH 2/9] Remove unused import in canvas tests --- canvas/src/tests.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/canvas/src/tests.rs b/canvas/src/tests.rs index 6aad48183..cab1183d7 100644 --- a/canvas/src/tests.rs +++ b/canvas/src/tests.rs @@ -3,7 +3,7 @@ // For this file only, any copyright is dedicated to the Public Domain. // https://creativecommons.org/publicdomain/zero/1.0/ -use pathfinder_geometry::vector::{Vector2F, vec2f}; +use pathfinder_geometry::vector::vec2f; use super::Path2D; #[test] From d4e3c2b6cd6ba67d9d71de9d65aa597b67409cdb Mon Sep 17 00:00:00 2001 From: Emmanuel Gil Peyrot Date: Tue, 30 Jun 2020 18:07:19 +0200 Subject: [PATCH 3/9] Replace unknown attribute norun with no_run, as per the warning --- renderer/src/concurrent/executor.rs | 2 +- renderer/src/concurrent/scene_proxy.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/renderer/src/concurrent/executor.rs b/renderer/src/concurrent/executor.rs index 150f4d32d..57e6d86af 100644 --- a/renderer/src/concurrent/executor.rs +++ b/renderer/src/concurrent/executor.rs @@ -14,7 +14,7 @@ pub trait Executor { /// Like the Rayon snippet: /// - /// ```norun + /// ```no_run /// (0..length).into_par_iter().map(builder).collect() /// ``` fn build_vector(&self, length: usize, builder: F) -> Vec diff --git a/renderer/src/concurrent/scene_proxy.rs b/renderer/src/concurrent/scene_proxy.rs index e5a88db17..109644114 100644 --- a/renderer/src/concurrent/scene_proxy.rs +++ b/renderer/src/concurrent/scene_proxy.rs @@ -92,7 +92,7 @@ impl SceneProxy { /// /// Exactly equivalent to: /// - /// ```norun + /// ```no_run /// scene_proxy.build(build_options); /// scene_proxy.render(renderer); /// } From 8ba64cc5f478888f3160dd8170fc0f0baf27d802 Mon Sep 17 00:00:00 2001 From: Emmanuel Gil Peyrot Date: Tue, 30 Jun 2020 17:33:11 +0200 Subject: [PATCH 4/9] Cache all built dependencies, to avoid rebuilding them on each CI run --- .travis.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.travis.yml b/.travis.yml index 6eff7f6a4..f4eb4fb1c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,6 +2,7 @@ language: rust rust: - nightly - stable +cache: cargo addons: apt: packages: @@ -10,6 +11,8 @@ addons: - libsdl2-dev - cmake script: + - cargo install sccache + - export RUSTC_WRAPPER=sccache - rustup target add aarch64-unknown-linux-gnu - cd simd - cargo build --target aarch64-unknown-linux-gnu From c0c4d178e5f2da7509fc91e593a36d37001dca5d Mon Sep 17 00:00:00 2001 From: Emmanuel Gil Peyrot Date: Tue, 30 Jun 2020 17:36:04 +0200 Subject: [PATCH 5/9] Fix includes and use pkg-config to find libraries in C examples --- examples/c_canvas_glfw_minimal/Makefile | 4 ++-- examples/c_canvas_glfw_minimal/c_canvas_glfw_minimal.c | 2 +- examples/c_canvas_minimal/Makefile | 8 ++++---- examples/c_canvas_minimal/c_canvas_minimal.c | 2 +- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/examples/c_canvas_glfw_minimal/Makefile b/examples/c_canvas_glfw_minimal/Makefile index d0182c390..f1fa73c95 100644 --- a/examples/c_canvas_glfw_minimal/Makefile +++ b/examples/c_canvas_glfw_minimal/Makefile @@ -5,8 +5,8 @@ RUST_TARGET_DIR?=../../target RUST_SRC_DIR?=../../c RUSTFLAGS?= -CFLAGS?=-Wall -g -I../../c/build/include -LIBS?=-lpathfinder_c -lglfw +CFLAGS?=-Wall -g $(shell pkg-config --cflags pathfinder_c glfw3) +LIBS?=$(shell pkg-config --libs pathfinder_c glfw3) MKDIR?=mkdir -p RM?=rm CARGO?=cargo diff --git a/examples/c_canvas_glfw_minimal/c_canvas_glfw_minimal.c b/examples/c_canvas_glfw_minimal/c_canvas_glfw_minimal.c index 793453378..ed520d9fd 100644 --- a/examples/c_canvas_glfw_minimal/c_canvas_glfw_minimal.c +++ b/examples/c_canvas_glfw_minimal/c_canvas_glfw_minimal.c @@ -9,7 +9,7 @@ // except according to those terms. #include -#include +#include #include #include #include diff --git a/examples/c_canvas_minimal/Makefile b/examples/c_canvas_minimal/Makefile index d2c8a5dc3..d91745180 100644 --- a/examples/c_canvas_minimal/Makefile +++ b/examples/c_canvas_minimal/Makefile @@ -5,8 +5,8 @@ RUST_TARGET_DIR?=../../target RUST_SRC_DIR?=../../c RUSTFLAGS?=-C target-cpu=native -CFLAGS?=-Wall -g -I../../c/build/include -LIBS?=-lpathfinder_c +CFLAGS?=-Wall -g $(shell pkg-config --cflags pathfinder_c sdl2) +LIBS?=$(shell pkg-config --libs pathfinder_c sdl2) MKDIR?=mkdir -p RM?=rm CARGO?=cargo @@ -35,10 +35,10 @@ all: $(TARGET_DIR)/c_canvas_minimal .PHONY: clean rustlib $(TARGET_DIR)/c_canvas_minimal: $(OBJ_DIR)/c_canvas_minimal.o rustlib - $(MKDIR) $(TARGET_DIR) && $(CC) $(LDFLAGS) $(LIBS) `sdl2-config --libs` -o $@ $< + $(MKDIR) $(TARGET_DIR) && $(CC) $(LDFLAGS) $(LIBS) -o $@ $< $(OBJ_DIR)/%.o: $(SRC_DIR)/%.c - $(MKDIR) $(OBJ_DIR) && $(CC) -c $(CFLAGS) `sdl2-config --cflags` -o $@ $< + $(MKDIR) $(OBJ_DIR) && $(CC) -c $(CFLAGS) -o $@ $< rustlib: cd $(RUST_SRC_DIR) && RUSTFLAGS="$(RUSTFLAGS)" $(CARGO) build $(CARGOFLAGS) diff --git a/examples/c_canvas_minimal/c_canvas_minimal.c b/examples/c_canvas_minimal/c_canvas_minimal.c index 8cb54be41..eef2866f7 100644 --- a/examples/c_canvas_minimal/c_canvas_minimal.c +++ b/examples/c_canvas_minimal/c_canvas_minimal.c @@ -10,7 +10,7 @@ #include #include -#include +#include #include #include #include From 9534dc4f7ee098b54ea2633ae1a785677a630696 Mon Sep 17 00:00:00 2001 From: Emmanuel Gil Peyrot Date: Tue, 30 Jun 2020 17:04:49 +0200 Subject: [PATCH 6/9] Add a CI pass for pathfinder_c on Linux This crate has often been broken by macOS changes, this patch avoids it being broken again in the future. See 42289eec6ea9e8a50cb76babf4027ed4d318c48c or 9998fe49bd3ce864df83c60a5a7461a1a5174684 for examples of such breakage. --- .travis.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.travis.yml b/.travis.yml index f4eb4fb1c..cf34997ff 100644 --- a/.travis.yml +++ b/.travis.yml @@ -9,6 +9,7 @@ addons: - libegl1-mesa-dev - libgtk-3-dev - libsdl2-dev + - libglfw3-dev - cmake script: - cargo install sccache @@ -21,6 +22,10 @@ script: - cd .. - cargo build - cargo test + - cd c + - cargo cinstall --prefix=$TRAVIS_HOME/.fake-install + - cd ../examples/c_canvas_glfw_minimal + - PKG_CONFIG_PATH=$TRAVIS_HOME/.fake-install/lib/pkgconfig make env: global: - HARFBUZZ_SYS_NO_PKG_CONFIG=true From 11a06e9efad38ed6b14ce39d341f534bf16da772 Mon Sep 17 00:00:00 2001 From: Emmanuel Gil Peyrot Date: Thu, 2 Jul 2020 16:28:18 +0200 Subject: [PATCH 7/9] Tentatively fix Metal types on Linux --- c/cbindgen.toml | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/c/cbindgen.toml b/c/cbindgen.toml index 902ee9b50..bf00318be 100644 --- a/c/cbindgen.toml +++ b/c/cbindgen.toml @@ -7,8 +7,12 @@ header = """\ #if defined(__APPLE__) && defined(__OBJC__) #include +typedef NSObject NSObjectCAMetalDrawable; +typedef NSObject NSObjectMTLDevice; #else -typedef struct CAMetalLayerPrivate CAMetalLayer; +typedef void* NSObjectCAMetalDrawable; +typedef void* NSObjectMTLDevice; +typedef void* IOSurfaceRef; #endif #ifdef __cplusplus @@ -42,14 +46,14 @@ include = [ "BuildOptions" = "PFBuildOptionsPrivate" "CanvasFontContext" = "PFCanvasFontContextPrivate" "CanvasRenderingContext2D" = "PFCanvasRenderingContext2DPrivate" -"CoreAnimationDrawableRef" = "NSObject" +"CoreAnimationDrawableRef" = "NSObjectCAMetalDrawable" "DestFramebuffer_GLDevice" = "PFDestFramebufferGLDevicePrivate" "DestFramebuffer_MetalDevice" = "PFDestFramebufferMetalDevicePrivate" "FillStyle" = "PFFillStylePrivate" "GLDevice" = "PFGLDevicePrivate" "Handle" = "FKHandlePrivate" "MetalDevice" = "PFMetalDevicePrivate" -"NativeMetalDeviceRef" = "NSObject" +"NativeMetalDeviceRef" = "NSObjectMTLDevice" "Path2D" = "PFPath2DPrivate" "RenderTransform" = "PFRenderTransformPrivate" "Renderer_GLDevice" = "PFRendererGLDevicePrivate" From 113eae8424e726223a3b21c29bf3a01d2b7976e7 Mon Sep 17 00:00:00 2001 From: Emmanuel Gil Peyrot Date: Thu, 2 Jul 2020 19:43:19 +0200 Subject: [PATCH 8/9] Fix c_canvas_glfw_minimal example The latest D3D11 changes prevented it from building. --- .../c_canvas_glfw_minimal/c_canvas_glfw_minimal.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/examples/c_canvas_glfw_minimal/c_canvas_glfw_minimal.c b/examples/c_canvas_glfw_minimal/c_canvas_glfw_minimal.c index ed520d9fd..a3973975b 100644 --- a/examples/c_canvas_glfw_minimal/c_canvas_glfw_minimal.c +++ b/examples/c_canvas_glfw_minimal/c_canvas_glfw_minimal.c @@ -15,6 +15,10 @@ #include #include +#ifndef GLFW_TRUE +#define GLFW_TRUE 1 +#endif + static void HandleGLFWError(int errorCode, const char *description); static const void *LoadGLFunction(const char *name, void *userdata); static void HandleKeypress(GLFWwindow *window, int key, int scancode, int action, int mods); @@ -44,9 +48,11 @@ int main(int argc, const char **argv) { PFGLDestFramebufferCreateFullWindow(&(PFVector2I){640, 480}); PFGLRendererRef renderer = PFGLRendererCreate(PFGLDeviceCreate(PF_GL_VERSION_GL3, 0), PFFilesystemResourceLoaderLocate(), - dest_framebuffer, + &(PFRendererMode){PF_RENDERER_LEVEL_D3D9}, &(PFRendererOptions){ - (PFColorF){1.0, 1.0, 1.0, 1.0}, PF_RENDERER_OPTIONS_FLAGS_HAS_BACKGROUND_COLOR + dest_framebuffer, + (PFColorF){1.0, 1.0, 1.0, 1.0}, + PF_RENDERER_OPTIONS_FLAGS_HAS_BACKGROUND_COLOR }); // Make a canvas. We're going to draw a house. @@ -72,7 +78,8 @@ int main(int argc, const char **argv) { // Render the canvas to screen. PFSceneRef scene = PFCanvasCreateScene(canvas); - PFSceneProxyRef scene_proxy = PFSceneProxyCreateFromSceneAndRayonExecutor(scene); + PFSceneProxyRef scene_proxy = + PFSceneProxyCreateFromSceneAndRayonExecutor(scene, PF_RENDERER_LEVEL_D3D9); PFSceneProxyBuildAndRenderGL(scene_proxy, renderer, PFBuildOptionsCreate()); glfwSwapBuffers(window); From 2bd8421bfabcc135738ee8596114c683f592043c Mon Sep 17 00:00:00 2001 From: Emmanuel Gil Peyrot Date: Thu, 2 Jul 2020 20:17:08 +0200 Subject: [PATCH 9/9] XXX --- examples/c_canvas_glfw_minimal/Makefile | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/examples/c_canvas_glfw_minimal/Makefile b/examples/c_canvas_glfw_minimal/Makefile index f1fa73c95..e70e3f0e7 100644 --- a/examples/c_canvas_glfw_minimal/Makefile +++ b/examples/c_canvas_glfw_minimal/Makefile @@ -22,26 +22,19 @@ endif ifeq ($(DEBUG),) CFLAGS+=-O2 - LDFLAGS?=-L$(RUST_TARGET_DIR)/release - CARGOFLAGS?=--release else CFLAGS+=-O0 - LDFLAGS?=-L$(RUST_TARGET_DIR)/debug - CARGOFLAGS?= endif all: $(TARGET_DIR)/c_canvas_glfw_minimal -.PHONY: clean rustlib +.PHONY: clean -$(TARGET_DIR)/c_canvas_glfw_minimal: $(OBJ_DIR)/c_canvas_glfw_minimal.o rustlib +$(TARGET_DIR)/c_canvas_glfw_minimal: $(OBJ_DIR)/c_canvas_glfw_minimal.o $(MKDIR) $(TARGET_DIR) && $(CC) $(LDFLAGS) $(LIBS) -o $@ $< $(OBJ_DIR)/%.o: $(SRC_DIR)/%.c $(MKDIR) $(OBJ_DIR) && $(CC) -c $(CFLAGS) -o $@ $< -rustlib: - cd $(RUST_SRC_DIR) && RUSTFLAGS="$(RUSTFLAGS)" $(CARGO) build $(CARGOFLAGS) - clean: $(RM) -rf $(TARGET_DIR) && $(RM) -rf $(OBJ_DIR)