diff --git a/.travis.yml b/.travis.yml index 6eff7f6a4..cf34997ff 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,14 +2,18 @@ language: rust rust: - nightly - stable +cache: cargo addons: apt: packages: - libegl1-mesa-dev - libgtk-3-dev - libsdl2-dev + - libglfw3-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 @@ -18,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 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" 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] 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 +} diff --git a/examples/c_canvas_glfw_minimal/Makefile b/examples/c_canvas_glfw_minimal/Makefile index d0182c390..e70e3f0e7 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 @@ -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) 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..a3973975b 100644 --- a/examples/c_canvas_glfw_minimal/c_canvas_glfw_minimal.c +++ b/examples/c_canvas_glfw_minimal/c_canvas_glfw_minimal.c @@ -9,12 +9,16 @@ // except according to those terms. #include -#include +#include #include #include #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); 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 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); /// }