OLD | NEW |
1 Skia's Stable C API | 1 Skia's Stable C API |
2 =================== | 2 =================== |
3 | 3 |
4 <div style="text-align:center"> | 4 <div style="text-align:center"> |
5 <strong>EXPERIMENTAL EXPERIMENTAL EXPERIMENTAL EXPERIMENTAL<br> | 5 <strong>EXPERIMENTAL EXPERIMENTAL EXPERIMENTAL EXPERIMENTAL<br> |
6 DO NOT USE — FOR INTERNAL TESTING ONLY</strong> | 6 DO NOT USE — FOR INTERNAL TESTING ONLY</strong> |
7 </div> | 7 </div> |
8 | 8 |
9 Several issues hinder the development of a stable ABI (application | 9 Several issues hinder the development of a stable ABI (application |
10 binary interface) for Skia: | 10 binary interface) for Skia: |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
99 emit_png("skia-c-example.png", surface); | 99 emit_png("skia-c-example.png", surface); |
100 sk_surface_unref(surface); | 100 sk_surface_unref(surface); |
101 return 0; | 101 return 0; |
102 } | 102 } |
103 | 103 |
104 <a href="https://fiddle.skia.org/c/6c6c01438d9c3d80e9c22e606359432e"><img src="h
ttps://fiddle.skia.org/i/6c6c01438d9c3d80e9c22e606359432e_raster.png" alt=""></a
> | 104 <a href="https://fiddle.skia.org/c/6c6c01438d9c3d80e9c22e606359432e"><img src="h
ttps://fiddle.skia.org/i/6c6c01438d9c3d80e9c22e606359432e_raster.png" alt=""></a
> |
105 | 105 |
106 Cmake example | 106 Cmake example |
107 ------------- | 107 ------------- |
108 | 108 |
109 The following proof-of-concept workflow currently works on MacOS and Ubuntu | 109 The following proof-of-concept workflow currently works on MacOS and |
| 110 Ubuntu and depends on a C/C++ compiler, git, and cmake: |
110 | 111 |
111 1. Aquire Skia (you may have already done this): | 112 1. Aquire, compile, and install Skia as a shared library: |
112 | 113 |
113 <!--?prettify lang=sh?--> | 114 <!--?prettify lang=sh?--> |
114 | 115 |
115 cd [Wherever you want skia src code] | 116 prefix="$HOME" |
| 117 cd $(mktemp -d /tmp/skiaXXXX) |
116 git clone 'https://skia.googlesource.com/skia' | 118 git clone 'https://skia.googlesource.com/skia' |
117 SKIA_DIR="$PWD/skia" | 119 cmake -DCMAKE_INSTALL_PREFIX:PATH="$prefix" skia/cmake |
| 120 cmake --build . --target skia |
| 121 cmake --build . --target install |
118 | 122 |
119 2. Compile Skia (outside of source) as a shared library: | 123 2. Compile, link, and run the example program: |
120 | 124 |
121 <!--?prettify lang=sh?--> | 125 <!--?prettify lang=sh?--> |
122 | 126 |
123 cd [Wherever you want skia build files] | 127 cc -o skia-c-example -I "$prefix/include" \ |
124 mkdir build_skia | 128 skia/experimental/c-api-example/skia-c-example.c \ |
125 cd build_skia | 129 "$prefix"/lib/libskia.* -Wl,-rpath -Wl,"$prefix/lib" |
126 SKIA_BUILD="$PWD" | |
127 cmake "$SKIA_DIR/cmake" -G Ninja && ninja | |
128 | |
129 3. Compile, link, and run the example program: | |
130 | |
131 <!--?prettify lang=sh?--> | |
132 | |
133 cd [Wherever you want the example] | |
134 mkdir skia_c_example | |
135 cd skia_c_example | |
136 cp "$SKIA_DIR/experimental/c-api-example/skia-c-example.c" . | |
137 cc -c -I "$SKIA_DIR/include/c" skia-c-example.c -o skia-c-example.o | |
138 c++ skia-c-example.o \ | |
139 "$SKIA_BUILD"/libskia.* -Wl,-rpath -Wl,"$SKIA_BUILD" \ | |
140 -o skia-c-example | |
141 ./skia-c-example | 130 ./skia-c-example |
142 [ $(uname) = Darwin ] && open skia-c-example.png | 131 [ $(uname) = Darwin ] && open skia-c-example.png |
143 [ $(uname) = Linux ] && xdg-open skia-c-example.png | 132 [ $(uname) = Linux ] && xdg-open skia-c-example.png |
OLD | NEW |