1
0
Fork 0
mirror of https://github.com/alacritty/alacritty.git synced 2024-11-11 13:51:01 -05:00

remove code that has been upstreamed

This commit is contained in:
Martin Algesten 2017-05-31 11:10:05 +02:00 committed by Joe Wilm
parent dafa4ccde9
commit d5ab4183c6
2 changed files with 5 additions and 193 deletions

View file

@ -1,92 +0,0 @@
// Copyright 2016 Joe Wilm, The Alacritty Project Contributors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
use core_foundation::base::{CFRelease, CFRetain, CFTypeID, CFTypeRef, TCFType};
use core_graphics::color_space::{CGColorSpace, CGColorSpaceRef};
use core_graphics::base::CGFloat;
use std::mem;
#[repr(C)]
pub struct __CGColor;
pub type CGColorRef = *const __CGColor;
pub struct CGColor {
obj: CGColorRef,
}
impl Drop for CGColor {
fn drop(&mut self) {
unsafe {
CFRelease(self.as_CFTypeRef())
}
}
}
impl Clone for CGColor {
fn clone(&self) -> CGColor {
unsafe {
TCFType::wrap_under_get_rule(self.as_concrete_TypeRef())
}
}
}
impl TCFType<CGColorRef> for CGColor {
#[inline]
fn as_concrete_TypeRef(&self) -> CGColorRef {
self.obj
}
#[inline]
unsafe fn wrap_under_get_rule(reference: CGColorRef) -> CGColor {
let reference: CGColorRef = mem::transmute(CFRetain(mem::transmute(reference)));
TCFType::wrap_under_create_rule(reference)
}
#[inline]
fn as_CFTypeRef(&self) -> CFTypeRef {
unsafe {
mem::transmute(self.as_concrete_TypeRef())
}
}
#[inline]
unsafe fn wrap_under_create_rule(obj: CGColorRef) -> CGColor {
CGColor {
obj: obj,
}
}
#[inline]
fn type_id() -> CFTypeID {
unsafe {
CGColorGetTypeID()
}
}
}
impl CGColor {
pub fn new(color_space: CGColorSpace, values: [CGFloat; 4]) -> CGColor {
unsafe {
let result = CGColorCreate(color_space.as_concrete_TypeRef(), values.as_ptr());
TCFType::wrap_under_create_rule(result)
}
}
}
#[link(name = "ApplicationServices", kind = "framework")]
extern {
fn CGColorCreate(space: CGColorSpaceRef, vals: *const CGFloat) -> CGColorRef;
fn CGColorGetTypeID() -> CFTypeID;
}

View file

@ -26,10 +26,9 @@ use core_foundation::string::{CFString, CFStringRef};
use core_foundation::array::CFIndex; use core_foundation::array::CFIndex;
use core_foundation_sys::string::UniChar; use core_foundation_sys::string::UniChar;
use core_graphics::base::kCGImageAlphaPremultipliedFirst; use core_graphics::base::kCGImageAlphaPremultipliedFirst;
use core_graphics::base::CGFloat;
use core_graphics::color_space::CGColorSpace; use core_graphics::color_space::CGColorSpace;
use core_graphics::context::{CGContext, CGContextRef}; use core_graphics::context::{CGContext, CGContextRef};
use core_graphics::font::{CGFont, CGFontRef, CGGlyph}; use core_graphics::font::{CGFont, CGGlyph};
use core_graphics::geometry::{CGPoint, CGRect, CGSize}; use core_graphics::geometry::{CGPoint, CGRect, CGSize};
use core_text::font::{CTFont, new_from_descriptor as ct_new_from_descriptor}; use core_text::font::{CTFont, new_from_descriptor as ct_new_from_descriptor};
use core_text::font_collection::create_for_family; use core_text::font_collection::create_for_family;
@ -40,7 +39,7 @@ use core_text::font_descriptor::kCTFontVerticalOrientation;
use core_text::font_descriptor::{CTFontDescriptor, CTFontDescriptorRef, CTFontOrientation}; use core_text::font_descriptor::{CTFontDescriptor, CTFontDescriptorRef, CTFontOrientation};
use core_text::font_descriptor::SymbolicTraitAccessors; use core_text::font_descriptor::SymbolicTraitAccessors;
use libc::{size_t, c_int}; use libc::{c_int};
use euclid::point::Point2D; use euclid::point::Point2D;
use euclid::rect::Rect; use euclid::rect::Rect;
@ -48,9 +47,6 @@ use euclid::size::Size2D;
use super::{FontDesc, RasterizedGlyph, Metrics, FontKey, GlyphKey}; use super::{FontDesc, RasterizedGlyph, Metrics, FontKey, GlyphKey};
pub mod cg_color;
use self::cg_color::{CGColorRef, CGColor};
pub mod byte_order; pub mod byte_order;
use self::byte_order::kCGBitmapByteOrder32Host; use self::byte_order::kCGBitmapByteOrder32Host;
use self::byte_order::extract_rgb; use self::byte_order::extract_rgb;
@ -462,94 +458,14 @@ impl Font {
/// Additional methods needed to render fonts for Alacritty /// Additional methods needed to render fonts for Alacritty
/// ///
/// TODO upstream these into core_graphics crate /// TODO CGContextSetFontSmoothingStyle has been upstreamed in
/// core-graphics 0.8.0, but core-text must be bumped before we
/// can use it.
pub trait CGContextExt { pub trait CGContextExt {
fn set_allows_font_subpixel_quantization(&self, bool);
fn set_should_subpixel_quantize_fonts(&self, bool);
fn set_allows_font_subpixel_positioning(&self, bool);
fn set_should_subpixel_position_fonts(&self, bool);
fn set_allows_antialiasing(&self, bool);
fn set_should_antialias(&self, bool);
fn fill_rect(&self, rect: CGRect);
fn set_font_smoothing_background_color(&self, color: CGColor);
fn show_glyphs_at_positions(&self, &[CGGlyph], &[CGPoint]);
fn set_font(&self, &CGFont);
fn set_font_size(&self, size: f64);
fn set_font_smoothing_style(&self, style: i32); fn set_font_smoothing_style(&self, style: i32);
} }
impl CGContextExt for CGContext { impl CGContextExt for CGContext {
fn set_allows_font_subpixel_quantization(&self, allows: bool) {
unsafe {
CGContextSetAllowsFontSubpixelQuantization(self.as_concrete_TypeRef(), allows);
}
}
fn set_should_subpixel_quantize_fonts(&self, should: bool) {
unsafe {
CGContextSetShouldSubpixelQuantizeFonts(self.as_concrete_TypeRef(), should);
}
}
fn set_should_subpixel_position_fonts(&self, should: bool) {
unsafe {
CGContextSetShouldSubpixelPositionFonts(self.as_concrete_TypeRef(), should);
}
}
fn set_allows_font_subpixel_positioning(&self, allows: bool) {
unsafe {
CGContextSetAllowsFontSubpixelPositioning(self.as_concrete_TypeRef(), allows);
}
}
fn set_should_antialias(&self, should: bool) {
unsafe {
CGContextSetShouldAntialias(self.as_concrete_TypeRef(), should);
}
}
fn set_allows_antialiasing(&self, allows: bool) {
unsafe {
CGContextSetAllowsAntialiasing(self.as_concrete_TypeRef(), allows);
}
}
fn fill_rect(&self, rect: CGRect) {
unsafe {
CGContextFillRect(self.as_concrete_TypeRef(), rect);
}
}
fn set_font_smoothing_background_color(&self, color: CGColor) {
unsafe {
CGContextSetFontSmoothingBackgroundColor(self.as_concrete_TypeRef(),
color.as_concrete_TypeRef());
}
}
fn show_glyphs_at_positions(&self, glyphs: &[CGGlyph], positions: &[CGPoint]) {
assert_eq!(glyphs.len(), positions.len());
unsafe {
CGContextShowGlyphsAtPositions(self.as_concrete_TypeRef(),
glyphs.as_ptr(),
positions.as_ptr(),
glyphs.len());
}
}
fn set_font(&self, font: &CGFont) {
unsafe {
CGContextSetFont(self.as_concrete_TypeRef(), font.as_concrete_TypeRef());
}
}
fn set_font_size(&self, size: f64) {
unsafe {
CGContextSetFontSize(self.as_concrete_TypeRef(), size as CGFloat);
}
}
fn set_font_smoothing_style(&self, style: i32) { fn set_font_smoothing_style(&self, style: i32) {
unsafe { unsafe {
CGContextSetFontSmoothingStyle(self.as_concrete_TypeRef(), style as _); CGContextSetFontSmoothingStyle(self.as_concrete_TypeRef(), style as _);
@ -559,18 +475,6 @@ impl CGContextExt for CGContext {
#[link(name = "ApplicationServices", kind = "framework")] #[link(name = "ApplicationServices", kind = "framework")]
extern { extern {
fn CGContextSetAllowsFontSubpixelQuantization(c: CGContextRef, allows: bool);
fn CGContextSetShouldSubpixelQuantizeFonts(c: CGContextRef, should: bool);
fn CGContextSetAllowsFontSubpixelPositioning(c: CGContextRef, allows: bool);
fn CGContextSetShouldSubpixelPositionFonts(c: CGContextRef, should: bool);
fn CGContextSetAllowsAntialiasing(c: CGContextRef, allows: bool);
fn CGContextSetShouldAntialias(c: CGContextRef, should: bool);
fn CGContextFillRect(c: CGContextRef, r: CGRect);
fn CGContextSetFontSmoothingBackgroundColor(c: CGContextRef, color: CGColorRef);
fn CGContextShowGlyphsAtPositions(c: CGContextRef, glyphs: *const CGGlyph,
positions: *const CGPoint, count: size_t);
fn CGContextSetFont(c: CGContextRef, font: CGFontRef);
fn CGContextSetFontSize(c: CGContextRef, size: CGFloat);
fn CGContextSetFontSmoothingStyle(c: CGContextRef, style: c_int); fn CGContextSetFontSmoothingStyle(c: CGContextRef, style: c_int);
} }