Skip to content

Commit

Permalink
chore: prep v1
Browse files Browse the repository at this point in the history
  • Loading branch information
triniwiz committed Mar 8, 2022
1 parent d54d746 commit 1e69f68
Show file tree
Hide file tree
Showing 91 changed files with 78 additions and 10,717 deletions.
8 changes: 2 additions & 6 deletions packages/canvas/src-native/canvas-native/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
cargo-features=["strip"]

[workspace]

members = [
Expand All @@ -8,12 +6,10 @@ members = [
]

[profile.release]
#panic = "abort"
panic = "abort"
codegen-units = 1
lto = true
#opt-level = 3
opt-level = "z"
debug = false
incremental = false

strip = "symbols"
strip = true
Original file line number Diff line number Diff line change
Expand Up @@ -20,22 +20,21 @@ cc = "1.0.56"

[dependencies]
regex = "1.5.4"
roxmltree = "0.14.0"
base64 = "0.13.0"
image = "0.23.7"
encoding_rs = "0.8.24"
gl-bindings = { version = "0.1.0", path = "../gl-bindings" }
lazy_static = "1.4.0"
css-color-parser = "0.1.2"
reqwest = { version = "0.11.9", features = ["blocking"] }
phf = { version = "0.8.0", features = ["macros"] }
phf = { version = "0.10.1", features = ["macros"] }
rgb = "0.8.25"
log = "0.4.8"
stringreader = "0.1.1"
rand = "0.8.4"

[target.'cfg(target_os="android")'.dependencies]
openssl = { version = "0.10", features = ["vendored"] }
openssl = { version = "0.10.38", features = ["vendored"] }
jni = { version = "0.19.0", default-features = false }
android_logger = "0.9.0"
#skia-safe = { git = "https://github.com/triniwiz/rust-skia", branch="feat/svg" , features = ["gl"] }
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use std::str::FromStr;

use jni::errors::Error;

use jni::JNIEnv;
use jni::objects::{JClass, JObject, JString, JValue, ReleaseMode};
use jni::sys::{
Expand All @@ -15,17 +15,17 @@ use crate::common::context::fill_and_stroke_styles::paint::PaintStyle;
use crate::common::context::fill_and_stroke_styles::pattern::Repetition;
use crate::common::context::image_asset::ImageAsset;
use crate::common::context::image_smoothing::ImageSmoothingQuality;
use crate::common::context::line_styles::line_cap::LineCap;

use crate::common::context::line_styles::line_join::LineJoin;
use crate::common::context::matrix::Matrix;
use crate::common::context::paths::path::Path;
use crate::common::context::pixel_manipulation::image_data::ImageData;
use crate::common::context::text_styles::text_align::TextAlign;
use crate::common::context::text_styles::text_baseline::TextBaseLine;
use crate::common::context::text_styles::text_direction::TextDirection;
use crate::common::ffi::paint_style_value::{PaintStyleValue, PaintStyleValueType};
use crate::common::ffi::paint_style_value::{PaintStyleValueType};
use crate::common::utils::color::to_parsed_color;
use crate::common::utils::image::{from_image_slice, from_image_slice_encoded, to_image};
use crate::common::utils::image::{from_image_slice, from_image_slice_encoded};

const JSON_CLASS: &str = "org/json/JSONObject";
const SIG_OBJECT_CTOR: &str = "()V";
Expand Down Expand Up @@ -921,7 +921,7 @@ pub extern "C" fn Java_org_nativescript_canvas_TNSCanvasRenderingContext2D_nativ
image_data: jbyteArray,
repetition: jint,
) -> jlong {
use log::{debug, info};

unsafe {
if context == 0 {
return 0;
Expand Down Expand Up @@ -954,7 +954,7 @@ pub extern "C" fn Java_org_nativescript_canvas_TNSCanvasRenderingContext2D_nativ
height: jint,
repetition: jint,
) -> jlong {
use log::{debug, info};

unsafe {
if context == 0 {
return 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@ use std::os::raw::c_void;

use jni::JNIEnv;
use jni::objects::{JClass, JObject, ReleaseMode};
use jni::sys::{jboolean, jfloatArray, jint};

const SURFACE_TEXTURE_CLASS: &'static str = "android/graphics/SurfaceTexture";
use jni::sys::{jfloatArray, jint};

#[no_mangle]
pub unsafe extern "C" fn Java_org_nativescript_canvas_TextureRender_nativeDrawFrame(
Expand Down Expand Up @@ -184,7 +182,7 @@ pub unsafe extern "C" fn Java_org_nativescript_canvas_TextureRender_nativeDrawFr
// env.call_static_method(clazz, "setIdentityM", "([F;I)V", &[])

let size = matrix.size().unwrap_or(0) as usize;
let mut matrix = std::slice::from_raw_parts_mut(matrix.as_ptr() as *mut f32, size);
let matrix = std::slice::from_raw_parts_mut(matrix.as_ptr() as *mut f32, size);

if flip_y_web_gl {
identity(matrix);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use std::os::raw::c_void;
use jni::JNIEnv;
use jni::objects::{JByteBuffer, JClass, JObject, ReleaseMode};
use jni::sys::{
jboolean, jbyteArray, jdouble, jdoubleArray, jfloatArray, jint, jintArray, jlong, jlongArray,
jboolean, jbyteArray, jdoubleArray, jfloatArray, jint, jintArray, jlong, jlongArray,
JNI_TRUE, jshortArray,
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@

use std::os::raw::c_void;

use jni::errors::Error;

use jni::JNIEnv;
use jni::objects::{AutoPrimitiveArray, JByteBuffer, JClass, JObject, ReleaseMode};
use jni::objects::{JByteBuffer, JClass, JObject, ReleaseMode};
use jni::sys::{
jboolean, jbyteArray, jfloatArray, jint, jintArray, jlong, JNI_TRUE, jobject, jshortArray,
jboolean, jbyteArray, jfloatArray, jint, jintArray, jlong, JNI_TRUE, jshortArray,
};
use skia_safe::RCHandle;


use crate::common::context::image_asset::ImageAsset;

Expand All @@ -21,15 +21,15 @@ const RGBA_INTEGER: u32 = 0x8D99;
pub unsafe extern "C" fn Java_org_nativescript_canvas_TNSWebGLRenderingContext_nativeTexImage2DTexture(
_env: JNIEnv,
_: JClass,
width: jint,
height: jint,
src_texture: jint,
_width: jint,
_height: jint,
_src_texture: jint,
) {
let mut previous_view_port = [-1_i32; 4];
let mut previous_active_texture = [-1_i32; 1];
let mut previous_texture = [-1_i32; 1];
let mut previous_program = [-1_i32; 1];
let mut previous_frame_buffer = [-1_i32; 1];
let _previous_view_port = [-1_i32; 4];
let _previous_active_texture = [-1_i32; 1];
let _previous_texture = [-1_i32; 1];
let _previous_program = [-1_i32; 1];
let _previous_frame_buffer = [-1_i32; 1];
}

#[no_mangle]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use std::ffi::CStr;
use std::os::raw::{c_char, c_float, c_longlong};

use std::os::raw::{c_float, c_longlong};

use jni::JNIEnv;
use jni::objects::{JClass, JString};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

use jni::JNIEnv;
use jni::objects::{JClass, JString};
use jni::sys::{jboolean, jbyteArray, jint, jlong, JNI_FALSE, JNI_TRUE, jobject, jstring};
use jni::sys::{jboolean, jbyteArray, jint, jlong, JNI_FALSE, JNI_TRUE, jstring};

use crate::common::context::image_asset::{ImageAsset, OutputFormat};

Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
use jni::errors::Error;

use jni::JNIEnv;
use jni::objects::{AutoPrimitiveArray, JByteBuffer, JClass, JObject, ReleaseMode};
use jni::objects::{JByteBuffer, JClass, JObject, ReleaseMode};
use jni::sys::{jboolean, jbyteArray, jfloat, jint, jlong, JNI_TRUE};
use skia_safe::{RCHandle, Rect};


use crate::common::context::image_asset::ImageAsset;
use crate::common::image_bitmap;
use crate::common::image_bitmap::{
create_from_image_asset_src_rect, create_from_image_data, create_image_asset,
create_image_bitmap,
};
use crate::common::utils::image::{from_image_slice, from_image_slice_encoded};


/*
ImageBitmap backed by ImageAsset
Expand Down Expand Up @@ -392,7 +391,7 @@ pub extern "C" fn Java_org_nativescript_canvas_TNSImageBitmap_nativeCreateFromBi
resize_width: jfloat,
resize_height: jfloat,
) -> jlong {
let mut result = super::utils::image::get_bytes_from_bitmap(env, bitmap);
let result = super::utils::image::get_bytes_from_bitmap(env, bitmap);
create_image_asset(
result.0.as_slice(),
result.1.width as f32,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,10 @@ use jni::sys::{jboolean, jbyteArray, jfloat, jint, jlong, JNI_FALSE, JNI_TRUE, j

use log::Level;
use skia_safe::{
AlphaType, Color, ColorType, EncodedImageFormat, ImageInfo, IPoint, ISize, PixelGeometry,
RCHandle, Rect, Size, Surface,
AlphaType, Color, ColorType, EncodedImageFormat, ImageInfo, ISize, PixelGeometry, Rect, Surface,
};
use skia_safe::gpu::gl::Interface;
use skia_safe::image::CachingHint;


use crate::common::context::{Context, Device, State};
use crate::common::context::paths::path::Path;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
use std::str::FromStr;

use css_color_parser::{Color, ColorParseError};

use jni::JNIEnv;
use jni::objects::{JClass, JString};
use jni::sys::{jlong, jstring};
use log::{debug, info};


use crate::common::context::Context;
use crate::common::context::fill_and_stroke_styles::paint::PaintStyle;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
#![allow(non_camel_case_types)]
#![allow(non_snake_case)]

use std::borrow::Borrow;
use std::str::Utf8Error;



use jni::JNIEnv;
use jni::objects::{JByteBuffer, JClass, JString, JValue, ReleaseMode};
use jni::objects::{JByteBuffer, JClass, JString, ReleaseMode};
use jni::sys::{jbyteArray, jlong, jstring};

use crate::common::context::text_decoder::TextDecoder;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

use jni::JNIEnv;
use jni::objects::{JClass, JString};
use jni::sys::{jbyteArray, jlong, jobject, jstring};
use jni::sys::{jbyteArray, jlong, jstring};

use crate::common::context::text_encoder::TextEncoder;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
use std::borrow::Cow;

use std::os::raw::c_void;

use jni::JNIEnv;
use jni::objects::{JByteBuffer, JClass, JObject};
use jni::sys::{jbyteArray, jobject};
use log::{debug, info};
use jni::objects::{JClass, JObject};
use jni::sys::{jbyteArray};
use log::{debug};

use crate::android::utils::bitmap::AndroidBitmapInfo;

use super::bitmap::*;


pub fn get_bytes_from_bitmap(env: JNIEnv, bitmap: JObject) -> (Vec<u8>, AndroidBitmapInfo) {
let native_interface = env.get_native_interface();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ impl Context {
src_rect: impl Into<Rect>,
dst_rect: impl Into<Rect>,
) {
let mut src_rect = src_rect.into();
let mut dst_rect = dst_rect.into();
let src_rect = src_rect.into();
let dst_rect = dst_rect.into();
self.state
.paint
.image_smoothing_quality_set(self.state.image_filter_quality());
let mut paint = self.state.paint.image_paint().clone();
let paint = self.state.paint.image_paint().clone();
self.surface.canvas().draw_image_rect_with_sampling_options(
image,
Some((&src_rect, SrcRectConstraint::Strict)),
Expand All @@ -26,7 +26,7 @@ impl Context {
}

pub fn draw_image_with_rect(&mut self, image: &Image, dst_rect: impl Into<Rect>) {
let mut dst_rect = dst_rect.into();
let dst_rect = dst_rect.into();
self.state
.paint
.image_smoothing_quality_set(self.state.image_filter_quality());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ impl Context {
}

if let Some(rule) = fill_rule {
let mut path = path.unwrap_or(self.path.borrow_mut());
let path = path.unwrap_or(self.path.borrow_mut());
path.path.set_fill_type(rule.to_fill_type());

if let Some(paint) = self.state.paint.fill_shadow_paint(
Expand Down Expand Up @@ -85,7 +85,7 @@ impl Context {
y: f32,
rule: FillRule,
) -> bool {
let mut path = path.unwrap_or(&self.path).clone();
let path = path.unwrap_or(&self.path).clone();
let total_matrix = self.surface.canvas().local_to_device_as_3x3();
let invertible = is_invertible(&total_matrix);
if !invertible {
Expand All @@ -96,7 +96,7 @@ impl Context {
}
let matrix = total_matrix.clone();
let inverse = matrix.invert().unwrap();
let mut point: Point = (x, y).into();
let point: Point = (x, y).into();
let transformed_point = inverse.map_point(point);
let mut path_to_compare = path.path.clone();
path_to_compare.set_fill_type(rule.to_fill_type());
Expand All @@ -114,7 +114,7 @@ impl Context {
return false;
}
let inverse = matrix.invert().unwrap();
let mut point: Point = (x, y).into();
let point: Point = (x, y).into();
let transformed_point = inverse.map_point(point);
let path_to_compare = path.path.clone();
path_to_compare.contains(transformed_point)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
use std::borrow::Cow;

use std::collections::VecDeque;
use std::convert::TryFrom;


use skia_safe::{
font_style::{Slant, Weight, Width},
typeface::Typeface,
FontMetrics, FontMgr, FontStyle,
};

use crate::common::context::drawing_text::typography::ParsedFontStyle::{Italic, Normal, Oblique};

use crate::{
common::context::text_styles::text_align::TextAlign,
common::context::text_styles::text_baseline::TextBaseLine,
Expand Down Expand Up @@ -104,7 +104,7 @@ impl Font {

fn to_font(&self) -> skia_safe::Font {
let style = to_font_style(self.font.font_weight(), self.font.font_style());
let mut families: Vec<String> = parse_font_family(self.font.font_family());
let families: Vec<String> = parse_font_family(self.font.font_family());
let mut default_typeface =
Typeface::from_name("sans-serif", style).unwrap_or(Typeface::default());
let mgr = FontMgr::default();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ pub enum Gradient {
}

impl Gradient {
pub fn set_shader(&mut self, shader: Option<Shader>) {
pub fn set_shader(&mut self, _shader: Option<Shader>) {
match &self {
Gradient::Linear { .. } => {}
Gradient::Radial { .. } => {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ impl Context {
if value.eq("none") {
return;
}
let mut filters: Vec<&str> = value.split(")").collect();
let filters: Vec<&str> = value.split(")").collect();
let filters: Vec<FilterType> = filters
.into_iter()
.filter(|x| {
Expand Down
Loading

0 comments on commit 1e69f68

Please sign in to comment.