-
Notifications
You must be signed in to change notification settings - Fork 737
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
4,471 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
// Copyright (c) 2011 Google Inc. All rights reserved. | ||
// | ||
// Redistribution and use in source and binary forms, with or without | ||
// modification, are permitted provided that the following conditions are | ||
// met: | ||
// | ||
// * Redistributions of source code must retain the above copyright | ||
// notice, this list of conditions and the following disclaimer. | ||
// * Redistributions in binary form must reproduce the above | ||
// copyright notice, this list of conditions and the following disclaimer | ||
// in the documentation and/or other materials provided with the | ||
// distribution. | ||
// * Neither the name of Google Inc. nor the names of its | ||
// contributors may be used to endorse or promote products derived from | ||
// this software without specific prior written permission. | ||
// | ||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | ||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | ||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | ||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | ||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | ||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | ||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | ||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | ||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | ||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,128 @@ | ||
JavaCPP Presets for Skia | ||
======================== | ||
|
||
Introduction | ||
------------ | ||
This directory contains the JavaCPP Presets module for: | ||
|
||
* [mono/skia](https://github.com/mono/skia) branch `update-master` as of 2017-05-11 https://skia.org/ | ||
|
||
Please refer to the parent README.md file for more detailed information about the JavaCPP Presets. | ||
|
||
|
||
Documentation | ||
------------- | ||
Java API documentation is available here: | ||
|
||
* http://bytedeco.org/javacpp-presets/skia/apidocs/ | ||
|
||
∗ Bindings are currently available only for the C API of Skia. | ||
|
||
Sample Usage | ||
------------ | ||
Here is a simple example of Skia ported to Java from this C source file: | ||
|
||
* https://github.com/mono/skia/blob/update-master/experimental/c-api-example/skia-c-example.c | ||
|
||
We can use [Maven 3](http://maven.apache.org/) to download and install automatically all the class files as well as the native binaries. To run this sample code, after creating the `pom.xml` and `src/main/java/SkiaCExample.java` source files below, simply execute on the command line: | ||
```bash | ||
$ mvn compile exec:java | ||
``` | ||
|
||
### The `pom.xml` build file | ||
```xml | ||
<project> | ||
<modelVersion>4.0.0</modelVersion> | ||
<groupId>org.bytedeco.javacpp-presets.skia</groupId> | ||
<artifactId>skiaexample</artifactId> | ||
<version>1.3.3-SNAPSHOT</version> | ||
<properties> | ||
<exec.mainClass>SkiaCExample</exec.mainClass> | ||
</properties> | ||
<dependencies> | ||
<dependency> | ||
<groupId>org.bytedeco.javacpp-presets</groupId> | ||
<artifactId>skia-platform</artifactId> | ||
<version>20170511-53d6729-1.3.3-SNAPSHOT</version> | ||
</dependency> | ||
</dependencies> | ||
</project> | ||
``` | ||
|
||
### The `src/main/java/SkiaCExample.java` source file | ||
```java | ||
import java.io.FileOutputStream; | ||
import java.io.IOException; | ||
|
||
import org.bytedeco.javacpp.*; | ||
|
||
import static org.bytedeco.javacpp.Skia.*; | ||
|
||
public class SkiaCExample { | ||
private static sk_surface_t makeSurface(int w, int h) { | ||
sk_imageinfo_t info = new sk_imageinfo_t(); | ||
info.width(w); | ||
info.height(h); | ||
info.colorType(sk_colortype_get_default_8888()); | ||
info.alphaType(PREMUL_SK_ALPHATYPE); | ||
return sk_surface_new_raster(info, null); | ||
} | ||
|
||
private static void emitPng(String path, sk_surface_t surface) throws IOException { | ||
sk_image_t image = sk_surface_new_image_snapshot(surface); | ||
sk_data_t data = sk_image_encode(image); | ||
sk_image_unref(image); | ||
Pointer pointer = sk_data_get_data(data).limit(sk_data_get_size(data)); | ||
FileOutputStream out = new FileOutputStream(path); | ||
out.getChannel().write(pointer.asByteBuffer()); | ||
out.close(); | ||
} | ||
|
||
private static void draw(sk_canvas_t canvas) { | ||
sk_paint_t fill = sk_paint_new(); | ||
sk_paint_set_color(fill, 0xFF0000FF); | ||
sk_canvas_draw_paint(canvas, fill); | ||
|
||
sk_paint_set_color(fill, 0xFF00FFFF); | ||
sk_rect_t rect = new sk_rect_t(); | ||
rect.left(100.0f); | ||
rect.top(100.0f); | ||
rect.right(540.0f); | ||
rect.bottom(380.0f); | ||
sk_canvas_draw_rect(canvas, rect, fill); | ||
|
||
sk_paint_t stroke = sk_paint_new(); | ||
sk_paint_set_color(stroke, 0xFFFF0000); | ||
sk_paint_set_antialias(stroke, true); | ||
sk_paint_set_style(stroke, STROKE_SK_PAINT_STYLE); | ||
sk_paint_set_stroke_width(stroke, 5.0f); | ||
sk_path_t path = sk_path_new(); | ||
|
||
sk_path_move_to(path, 50.0f, 50.0f); | ||
sk_path_line_to(path, 590.0f, 50.0f); | ||
sk_path_cubic_to(path, -490.0f, 50.0f, 1130.0f, 430.0f, 50.0f, 430.0f); | ||
sk_path_line_to(path, 590.0f, 430.0f); | ||
sk_canvas_draw_path(canvas, path, stroke); | ||
|
||
sk_paint_set_color(fill, 0x8000FF00); | ||
sk_rect_t rect2 = new sk_rect_t(); | ||
rect2.left(120.0f); | ||
rect2.top(120.0f); | ||
rect2.right(520.0f); | ||
rect2.bottom(360.0f); | ||
sk_canvas_draw_oval(canvas, rect2, fill); | ||
|
||
sk_path_delete(path); | ||
sk_paint_delete(stroke); | ||
sk_paint_delete(fill); | ||
} | ||
|
||
public static void main (String[] args) throws IOException { | ||
sk_surface_t surface = makeSurface(640, 480); | ||
sk_canvas_t canvas = sk_surface_get_canvas(surface); | ||
draw(canvas); | ||
emitPng("skia-c-example.png", surface); | ||
sk_surface_unref(surface); | ||
} | ||
} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
#!/bin/bash | ||
# This file is meant to be included by the parent cppbuild.sh script | ||
if [[ -z "$PLATFORM" ]]; then | ||
pushd .. | ||
bash cppbuild.sh "$@" skia | ||
popd | ||
exit | ||
fi | ||
|
||
case $PLATFORM in | ||
linux-x86) | ||
export CC="gcc -m32" | ||
export CXX="g++ -m32" | ||
;; | ||
linux-x86_64) | ||
export CC="gcc -m64" | ||
export CXX="g++ -m64" | ||
;; | ||
macosx-*) | ||
;; | ||
*) | ||
echo "Error: Platform \"$PLATFORM\" is not supported" | ||
return 0 | ||
;; | ||
esac | ||
|
||
# Must be kept in sync with skia.version in pom.xml | ||
SKIA_VERSION=53d672981d2f4535d61da05befa793a73103c4fd | ||
download "https://github.com/mono/skia/archive/$SKIA_VERSION.zip" "skia-$SKIA_VERSION.zip" | ||
|
||
if [ ! -d depot_tools ]; then | ||
echo "Fetching depot_tools..." | ||
git clone 'https://chromium.googlesource.com/chromium/tools/depot_tools.git' depot_tools | ||
fi | ||
export PATH="$PWD/depot_tools:$PATH" | ||
|
||
mkdir -p "$PLATFORM" | ||
cd "$PLATFORM" | ||
if [ ! -d "skia-$SKIA_VERSION" ]; then | ||
echo "Decompressing archives..." | ||
unzip "../skia-$SKIA_VERSION.zip" | ||
fi | ||
cd "skia-$SKIA_VERSION" | ||
python tools/git-sync-deps | ||
|
||
bin/gn gen out/Shared --args='is_official_build=false is_debug=false is_component_build=true extra_cflags=["-DSKIA_C_DLL"]' | ||
ninja -C out/Shared | ||
|
||
cd ../.. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<parent> | ||
<groupId>org.bytedeco</groupId> | ||
<artifactId>javacpp-presets</artifactId> | ||
<version>1.3.3-SNAPSHOT</version> | ||
<relativePath>../../</relativePath> | ||
</parent> | ||
|
||
<groupId>org.bytedeco.javacpp-presets</groupId> | ||
<artifactId>skia-platform</artifactId> | ||
<version>20170511-53d6729-${project.parent.version}</version> | ||
<name>JavaCPP Presets Platform for Skia</name> | ||
|
||
<properties> | ||
<javacpp.moduleId>skia</javacpp.moduleId> | ||
</properties> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>${project.groupId}</groupId> | ||
<artifactId>${javacpp.moduleId}</artifactId> | ||
<version>${project.version}</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>${project.groupId}</groupId> | ||
<artifactId>${javacpp.moduleId}</artifactId> | ||
<version>${project.version}</version> | ||
<classifier>${javacpp.platform.linux-x86}</classifier> | ||
</dependency> | ||
<dependency> | ||
<groupId>${project.groupId}</groupId> | ||
<artifactId>${javacpp.moduleId}</artifactId> | ||
<version>${project.version}</version> | ||
<classifier>${javacpp.platform.linux-x86_64}</classifier> | ||
</dependency> | ||
<dependency> | ||
<groupId>${project.groupId}</groupId> | ||
<artifactId>${javacpp.moduleId}</artifactId> | ||
<version>${project.version}</version> | ||
<classifier>${javacpp.platform.macosx-x86_64}</classifier> | ||
</dependency> | ||
</dependencies> | ||
|
||
<build> | ||
<plugins> | ||
<plugin> | ||
<artifactId>maven-jar-plugin</artifactId> | ||
<executions> | ||
<execution> | ||
<id>default-jar</id> | ||
<configuration> | ||
<archive> | ||
<manifestEntries> | ||
<Class-Path>${javacpp.moduleId}.jar ${javacpp.moduleId}-linux-x86.jar ${javacpp.moduleId}-linux-x86_64.jar ${javacpp.moduleId}-macosx-x86_64.jar</Class-Path> | ||
</manifestEntries> | ||
</archive> | ||
</configuration> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
|
||
</project> |
Oops, something went wrong.