summaryrefslogtreecommitdiffstats
path: root/third_party/rust/core-graphics-types
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 00:47:55 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 00:47:55 +0000
commit26a029d407be480d791972afb5975cf62c9360a6 (patch)
treef435a8308119effd964b339f76abb83a57c29483 /third_party/rust/core-graphics-types
parentInitial commit. (diff)
downloadfirefox-26a029d407be480d791972afb5975cf62c9360a6.tar.xz
firefox-26a029d407be480d791972afb5975cf62c9360a6.zip
Adding upstream version 124.0.1.upstream/124.0.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'third_party/rust/core-graphics-types')
-rw-r--r--third_party/rust/core-graphics-types/.cargo-checksum.json1
-rw-r--r--third_party/rust/core-graphics-types/Cargo.toml31
-rw-r--r--third_party/rust/core-graphics-types/src/base.rs43
-rw-r--r--third_party/rust/core-graphics-types/src/geometry.rs202
-rw-r--r--third_party/rust/core-graphics-types/src/lib.rs14
5 files changed, 291 insertions, 0 deletions
diff --git a/third_party/rust/core-graphics-types/.cargo-checksum.json b/third_party/rust/core-graphics-types/.cargo-checksum.json
new file mode 100644
index 0000000000..cc00991ad2
--- /dev/null
+++ b/third_party/rust/core-graphics-types/.cargo-checksum.json
@@ -0,0 +1 @@
+{"files":{"Cargo.toml":"cac07dfd7a2fcbb169a0c471a8a139ade8da91f92b7fbc198f3f2185d9c94d16","src/base.rs":"561db031cc746eab35a10fe72e10c314615b11e13cd48366fcdb2223196308a7","src/geometry.rs":"4ed03b07a4c5ba0f090689d31ef6eab8ec5b8f6eb7fb4e04fdf65e5ad8cd70ea","src/lib.rs":"31700ac9508fd32005bafd1c12a86a6803d198e9b1a71166a7391e642c091cd1"},"package":"2bb142d41022986c1d8ff29103a1411c8a3dfad3552f87a4f8dc50d61d4f4e33"} \ No newline at end of file
diff --git a/third_party/rust/core-graphics-types/Cargo.toml b/third_party/rust/core-graphics-types/Cargo.toml
new file mode 100644
index 0000000000..365717dfb4
--- /dev/null
+++ b/third_party/rust/core-graphics-types/Cargo.toml
@@ -0,0 +1,31 @@
+# THIS FILE IS AUTOMATICALLY GENERATED BY CARGO
+#
+# When uploading crates to the registry Cargo will automatically
+# "normalize" Cargo.toml files for maximal compatibility
+# with all versions of Cargo and also rewrite `path` dependencies
+# to registry (e.g., crates.io) dependencies.
+#
+# If you are reading this file be aware that the original Cargo.toml
+# will likely look very different (and much more reasonable).
+# See Cargo.toml.orig for the original contents.
+
+[package]
+name = "core-graphics-types"
+version = "0.1.2"
+authors = ["The Servo Project Developers"]
+description = "Bindings for some fundamental Core Graphics types"
+homepage = "https://github.com/servo/core-foundation-rs"
+license = "MIT OR Apache-2.0"
+repository = "https://github.com/servo/core-foundation-rs"
+
+[package.metadata.docs.rs]
+default-target = "x86_64-apple-darwin"
+
+[dependencies.bitflags]
+version = "1.0"
+
+[dependencies.core-foundation]
+version = "0.9"
+
+[dependencies.libc]
+version = "0.2"
diff --git a/third_party/rust/core-graphics-types/src/base.rs b/third_party/rust/core-graphics-types/src/base.rs
new file mode 100644
index 0000000000..03a85f1559
--- /dev/null
+++ b/third_party/rust/core-graphics-types/src/base.rs
@@ -0,0 +1,43 @@
+// Copyright 2013 The Servo Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+// this file defines CGFloat, as well as stubbed data types.
+
+#![allow(non_camel_case_types)]
+#![allow(non_upper_case_globals)]
+
+use libc;
+
+#[cfg(any(target_arch = "x86",
+ target_arch = "arm",
+ target_arch = "aarch64"))]
+pub type boolean_t = libc::c_int;
+#[cfg(target_arch = "x86_64")]
+pub type boolean_t = libc::c_uint;
+
+#[cfg(target_pointer_width = "64")]
+pub type CGFloat = libc::c_double;
+#[cfg(not(target_pointer_width = "64"))]
+pub type CGFloat = libc::c_float;
+
+pub type CGError = i32;
+
+pub type CGGlyph = libc::c_ushort;
+
+pub const kCGErrorSuccess: CGError = 0;
+pub const kCGErrorFailure: CGError = 1000;
+pub const kCGErrorIllegalArgument: CGError = 1001;
+pub const kCGErrorInvalidConnection: CGError = 1002;
+pub const kCGErrorInvalidContext: CGError = 1003;
+pub const kCGErrorCannotComplete: CGError = 1004;
+pub const kCGErrorNotImplemented: CGError = 1006;
+pub const kCGErrorRangeCheck: CGError = 1007;
+pub const kCGErrorTypeCheck: CGError = 1008;
+pub const kCGErrorInvalidOperation: CGError = 1010;
+pub const kCGErrorNoneAvailable: CGError = 1011;
diff --git a/third_party/rust/core-graphics-types/src/geometry.rs b/third_party/rust/core-graphics-types/src/geometry.rs
new file mode 100644
index 0000000000..586075270c
--- /dev/null
+++ b/third_party/rust/core-graphics-types/src/geometry.rs
@@ -0,0 +1,202 @@
+// Copyright 2013 The Servo Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+use base::CGFloat;
+use core_foundation::base::TCFType;
+use core_foundation::dictionary::CFDictionary;
+
+pub const CG_ZERO_POINT: CGPoint = CGPoint {
+ x: 0.0,
+ y: 0.0,
+};
+
+pub const CG_ZERO_SIZE: CGSize = CGSize {
+ width: 0.0,
+ height: 0.0,
+};
+
+pub const CG_ZERO_RECT: CGRect = CGRect {
+ origin: CG_ZERO_POINT,
+ size: CG_ZERO_SIZE,
+};
+
+pub const CG_AFFINE_TRANSFORM_IDENTITY: CGAffineTransform = CGAffineTransform {
+ a: 1.0, b: 0.0,
+ c: 0.0, d: 1.0,
+ tx: 0.0, ty: 0.0,
+};
+
+#[repr(C)]
+#[derive(Clone, Copy, Debug, Default)]
+pub struct CGSize {
+ pub width: CGFloat,
+ pub height: CGFloat,
+}
+
+impl CGSize {
+ #[inline]
+ pub fn new(width: CGFloat, height: CGFloat) -> CGSize {
+ CGSize {
+ width: width,
+ height: height,
+ }
+ }
+
+ #[inline]
+ pub fn apply_transform(&self, t: &CGAffineTransform) -> CGSize {
+ unsafe {
+ ffi::CGSizeApplyAffineTransform(*self, *t)
+ }
+ }
+}
+
+#[repr(C)]
+#[derive(Clone, Copy, Debug, Default)]
+pub struct CGPoint {
+ pub x: CGFloat,
+ pub y: CGFloat,
+}
+
+impl CGPoint {
+ #[inline]
+ pub fn new(x: CGFloat, y: CGFloat) -> CGPoint {
+ CGPoint {
+ x: x,
+ y: y,
+ }
+ }
+
+ #[inline]
+ pub fn apply_transform(&self, t: &CGAffineTransform) -> CGPoint {
+ unsafe {
+ ffi::CGPointApplyAffineTransform(*self, *t)
+ }
+ }
+}
+
+#[repr(C)]
+#[derive(Clone, Copy, Debug, Default)]
+pub struct CGRect {
+ pub origin: CGPoint,
+ pub size: CGSize
+}
+
+impl CGRect {
+ #[inline]
+ pub fn new(origin: &CGPoint, size: &CGSize) -> CGRect {
+ CGRect {
+ origin: *origin,
+ size: *size,
+ }
+ }
+
+ #[inline]
+ pub fn inset(&self, size: &CGSize) -> CGRect {
+ unsafe {
+ ffi::CGRectInset(*self, size.width, size.height)
+ }
+ }
+
+ #[inline]
+ pub fn from_dict_representation(dict: &CFDictionary) -> Option<CGRect> {
+ let mut rect = CGRect::new(&CGPoint::new(0., 0.), &CGSize::new(0., 0.));
+ let result = unsafe {
+ ffi::CGRectMakeWithDictionaryRepresentation(dict.as_concrete_TypeRef(), &mut rect)
+ };
+ if result == 0 {
+ None
+ } else {
+ Some(rect)
+ }
+ }
+
+ #[inline]
+ pub fn is_empty(&self) -> bool {
+ unsafe {
+ // I use one, as it seems that `YES` is not available from this crate.
+ ffi::CGRectIsEmpty(*self) == 1
+ }
+ }
+
+ #[inline]
+ pub fn is_intersects(&self, other: &CGRect) -> bool {
+ unsafe {
+ // I use one, as it seems that `YES` is not available from this crate.
+ ffi::CGRectIntersectsRect(*self, *other) == 1
+ }
+ }
+
+ #[inline]
+ pub fn apply_transform(&self, t: &CGAffineTransform) -> CGRect {
+ unsafe {
+ ffi::CGRectApplyAffineTransform(*self, *t)
+ }
+ }
+
+ #[inline]
+ pub fn contains(&self, point: &CGPoint) -> bool {
+ unsafe { ffi::CGRectContainsPoint(*self,*point) == 1 }
+ }
+}
+
+#[repr(C)]
+#[derive(Clone, Copy, Debug, Default)]
+pub struct CGAffineTransform {
+ pub a: CGFloat,
+ pub b: CGFloat,
+ pub c: CGFloat,
+ pub d: CGFloat,
+ pub tx: CGFloat,
+ pub ty: CGFloat,
+}
+
+impl CGAffineTransform {
+ #[inline]
+ pub fn new(
+ a: CGFloat,
+ b: CGFloat,
+ c: CGFloat,
+ d: CGFloat,
+ tx: CGFloat,
+ ty: CGFloat,
+ ) -> CGAffineTransform {
+ CGAffineTransform { a, b, c, d, tx, ty }
+ }
+
+ #[inline]
+ pub fn invert(&self) -> CGAffineTransform {
+ unsafe {
+ ffi::CGAffineTransformInvert(*self)
+ }
+ }
+}
+
+mod ffi {
+ use base::{CGFloat, boolean_t};
+ use geometry::{CGAffineTransform, CGPoint, CGRect, CGSize};
+ use core_foundation::dictionary::CFDictionaryRef;
+
+ #[link(name = "CoreGraphics", kind = "framework")]
+ extern {
+ pub fn CGRectInset(rect: CGRect, dx: CGFloat, dy: CGFloat) -> CGRect;
+ pub fn CGRectMakeWithDictionaryRepresentation(dict: CFDictionaryRef,
+ rect: *mut CGRect) -> boolean_t;
+ pub fn CGRectIsEmpty(rect: CGRect) -> boolean_t;
+ pub fn CGRectIntersectsRect(rect1: CGRect, rect2: CGRect) -> boolean_t;
+
+ pub fn CGAffineTransformInvert(t: CGAffineTransform) -> CGAffineTransform;
+
+ pub fn CGPointApplyAffineTransform(point: CGPoint, t: CGAffineTransform) -> CGPoint;
+ pub fn CGRectApplyAffineTransform(rect: CGRect, t: CGAffineTransform) -> CGRect;
+ pub fn CGSizeApplyAffineTransform(size: CGSize, t: CGAffineTransform) -> CGSize;
+
+ pub fn CGRectContainsPoint(rect:CGRect, point: CGPoint) -> boolean_t;
+ }
+}
+
diff --git a/third_party/rust/core-graphics-types/src/lib.rs b/third_party/rust/core-graphics-types/src/lib.rs
new file mode 100644
index 0000000000..f34bf01207
--- /dev/null
+++ b/third_party/rust/core-graphics-types/src/lib.rs
@@ -0,0 +1,14 @@
+// Copyright 2013 The Servo Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+extern crate libc;
+extern crate core_foundation;
+
+pub mod base;
+pub mod geometry;