From a90d12eaeecebed54dd928edf9a4a5cd5d93700f Mon Sep 17 00:00:00 2001 From: "aydin.kim" Date: Tue, 19 Nov 2013 16:46:24 +0900 Subject: [PATCH 01/11] fix build error on android(libuv 3.0) --- Makefile.in | 15 ++++++++++----- configure | 3 ++- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/Makefile.in b/Makefile.in index 4d20b026dff..0bf9b7e7707 100644 --- a/Makefile.in +++ b/Makefile.in @@ -55,10 +55,6 @@ export CFG_ENABLE_DEBUG export CFG_ENABLE_DEBUG_SKIA export RUSTC=$(CFG_RUSTC) export RUSTFLAGS=$(CFG_RUSTC_FLAGS) -export CC=$(CFG_CC) -export CXX=$(CFG_CXX) -export LD=$(CFG_LD) -export AR=$(CFG_AR) export RANLIB=$(CFG_RANLIB) export PYTHON=$(CFG_PYTHON2) export PATH=$(CFG_PATH) @@ -95,7 +91,7 @@ $(S)config.stamp : $(S)configure $(S)Makefile.in ifneq ($(CFG_LOCAL_RUSTC),1) $(CFG_RUSTC): $(B)src/compiler/rust/rust-auto-clean-stamp @$(call E, building rustc) - $(Q)CFG_RUSTC_FLAGS= CFG_ENABLE_DEBUG= RUSTFLAGS= $(MAKE) -C "$(CFG_BUILD_DIR)src/compiler/rust" CC=gcc CXX=g++ LD=ld AR=ar + $(Q)CFG_RUSTC_FLAGS= CFG_ENABLE_DEBUG= RUSTFLAGS= $(MAKE) -C "$(CFG_BUILD_DIR)src/compiler/rust" clean-rust: @$(call E, cleaning rustc) @@ -180,6 +176,11 @@ endif $(eval $(call DEF_SUBMODULE_DEPS,$(1))) +CROSS_COMPILER_CC = CC=$(CFG_CC) +CROSS_COMPILER_CXX = CXX=$(CFG_CXX) +CROSS_COMPILER_LD = LD=$(CFG_LD) +CROSS_COMPILER_AR = AR=$(CFG_AR) + $$(DONE_$(1)) : $$(DONE_DEPS_$(1)) $$(ROUGH_DEPS_$(1)) $$(RUSTC_DEP_$(1)) # @$$(call E, make: $(1)) # @$$(call E, $(1) deps= $$(DEPS_$(1))) @@ -191,6 +192,10 @@ $$(DONE_$(1)) : $$(DONE_DEPS_$(1)) $$(ROUGH_DEPS_$(1)) $$(RUSTC_DEP_$(1)) $$(ENV_CFLAGS_$(1)) \ $$(ENV_CXXFLAGS_$(1)) \ $$(ENV_RFLAGS_$(1)) \ + $$(CROSS_COMPILER_CC) \ + $$(CROSS_COMPILER_CXX) \ + $$(CROSS_COMPILER_LD) \ + $$(CROSS_COMPILER_AR) \ $$(MAKE) -C $$(B)src/$$(PATH_$(1)) && touch $$(DONE_$(1)) # main submodule target diff --git a/configure b/configure index b6fc8368288..c0f2187f364 100755 --- a/configure +++ b/configure @@ -374,7 +374,7 @@ probe_need CFG_AUTOCONF213 autoconf213 \ step_msg "looking for build programs" case ${TARGET_OSTYPE} in android) - CFG_PATH="${CFG_ANDROID_CROSS_PATH}/bin":$PATH + CFG_PATH=$PATH:"${CFG_ANDROID_CROSS_PATH}/bin" OLD_PATH=$PATH export PATH=${CFG_PATH} @@ -536,6 +536,7 @@ if [ $CFG_OSTYPE = "linux-androideabi" ] then CFG_SUBMODULES="\ support/glut/rust-glut \ + support/egl/rust-egl \ platform/android/libexpat \ platform/android/libfreetype2 \ platform/android/fontconfig \ From 8d85f71573e0092a7e41c3c33abe176ab94243fc Mon Sep 17 00:00:00 2001 From: "aydin.kim" Date: Wed, 20 Nov 2013 16:14:14 +0900 Subject: [PATCH 02/11] add android graphic surface layer using EGL extensions --- mk/sub.mk | 2 ++ .../main/compositing/compositor_layer.rs | 17 ++++++++++++++-- src/components/msg/msg.rc | 7 +++++++ .../msg/platform/android/surface.rs | 20 +++++++++++++++++++ 4 files changed, 44 insertions(+), 2 deletions(-) create mode 100644 src/components/msg/platform/android/surface.rs diff --git a/mk/sub.mk b/mk/sub.mk index da506cb2b1a..f2fc995a970 100644 --- a/mk/sub.mk +++ b/mk/sub.mk @@ -171,6 +171,7 @@ endif ifeq ($(CFG_OSTYPE),linux-androideabi) DEPS_rust-azure += \ + rust-egl \ rust-freetype \ rust-fontconfig \ fontconfig \ @@ -181,6 +182,7 @@ DEPS_rust-azure += \ # See note at top of file DEPS_rust-layers += \ + rust-egl \ rust-freetype \ rust-fontconfig \ rust-xlib \ diff --git a/src/components/main/compositing/compositor_layer.rs b/src/components/main/compositing/compositor_layer.rs index b1599d5460c..9e1784bba8d 100644 --- a/src/components/main/compositing/compositor_layer.rs +++ b/src/components/main/compositing/compositor_layer.rs @@ -11,7 +11,9 @@ use geom::size::Size2D; use gfx::render_task::{ReRenderMsg, UnusedBufferMsg}; use layers::layers::{ContainerLayerKind, ContainerLayer, Flip, NoFlip, TextureLayer}; use layers::layers::TextureLayerKind; -#[cfg(target_os="macos")] use layers::layers::VerticalFlip; +#[cfg(target_os="macos")] +#[cfg(target_os="android")] +use layers::layers::VerticalFlip; use layers::platform::surface::{NativeCompositingGraphicsContext, NativeSurfaceMethods}; use layers::texturegl::{Texture, TextureTarget}; #[cfg(target_os="macos")] use layers::texturegl::TextureTargetRectangle; @@ -424,7 +426,18 @@ impl CompositorLayer { (flip, TextureTargetRectangle(size)) } - #[cfg(not(target_os="macos"))] + #[cfg(target_os="android")] + fn texture_flip_and_target(cpu_painting: bool, size: Size2D) -> (Flip, TextureTarget) { + let flip = if cpu_painting { + NoFlip + } else { + VerticalFlip + }; + + (flip, TextureTarget2D) + } + + #[cfg(target_os="linux")] fn texture_flip_and_target(_: bool, _: Size2D) -> (Flip, TextureTarget) { (NoFlip, TextureTarget2D) } diff --git a/src/components/msg/msg.rc b/src/components/msg/msg.rc index 3811f5bffa7..35c364f6331 100644 --- a/src/components/msg/msg.rc +++ b/src/components/msg/msg.rc @@ -35,6 +35,13 @@ pub mod platform { pub mod surface; } + #[cfg(target_os="android")] + pub mod android { + #[cfg(target_os="android")] + pub mod surface; + } + + pub mod surface; } diff --git a/src/components/msg/platform/android/surface.rs b/src/components/msg/platform/android/surface.rs new file mode 100644 index 00000000000..04719ffdc39 --- /dev/null +++ b/src/components/msg/platform/android/surface.rs @@ -0,0 +1,20 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +//! EGL-specific implementation of cross-process surfaces. This uses EGL surfaces. + +use platform::surface::NativeSurfaceAzureMethods; + +use azure::AzSkiaGrGLSharedSurfaceRef; +use layers::platform::surface::NativeSurface; +use std::cast; + +impl NativeSurfaceAzureMethods for NativeSurface { + fn from_azure_surface(surface: AzSkiaGrGLSharedSurfaceRef) -> NativeSurface { + unsafe { + NativeSurface::from_image_khr(cast::transmute(surface)) + } + } +} + From 230bfeb0cd481dee11864231c59beec2ed1eb4ec Mon Sep 17 00:00:00 2001 From: "aydin.kim" Date: Tue, 26 Nov 2013 15:10:15 +0900 Subject: [PATCH 03/11] teporarily rollback of rust(because of uv error, we can not enter into amain. io errors are happened) --- src/compiler/rust | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/compiler/rust b/src/compiler/rust index 67d7be0ff19..f6b236b9d27 160000 --- a/src/compiler/rust +++ b/src/compiler/rust @@ -1 +1 @@ -Subproject commit 67d7be0ff197fe0d0c420abc8ac9c4b94a3ed025 +Subproject commit f6b236b9d2780edc1336ea5f62c2ba0fed6e34c5 From 318d06f38bb90db33cebc815b2a2bf2e56be29bc Mon Sep 17 00:00:00 2001 From: "aydin.kim" Date: Fri, 6 Dec 2013 15:47:36 +0900 Subject: [PATCH 04/11] modify way to call main on android --- src/components/main/servo.rc | 37 ++++++++++++++++++------------------ 1 file changed, 19 insertions(+), 18 deletions(-) diff --git a/src/components/main/servo.rc b/src/components/main/servo.rc index 43bd737bdd7..13e87ca213e 100755 --- a/src/components/main/servo.rc +++ b/src/components/main/servo.rc @@ -56,6 +56,8 @@ pub use servo_util::url::make_url; use std::comm; #[cfg(not(test))] use std::os; +#[cfg(not(test))] +use std::str; use std::task::spawn_with; #[path="compositing/compositor_task.rs"] @@ -100,27 +102,26 @@ pub mod platform; #[path = "util/mod.rs"] pub mod util; -#[cfg(not(test))] +#[cfg(not(test), target_os="linux")] +#[cfg(not(test), target_os="macos")] #[start] fn start(argc: int, argv: **u8) -> int { - #[cfg(target_os="linux")] - #[cfg(target_os="macos")] - fn getopts() -> Opts { - opts::from_cmdline_args(os::args()) - } - #[cfg(target_os="android")] - fn getopts() -> Opts { - let mut args:~[~str] = ~[]; - args.push(~"servo"); - let servo_url = os::getenv(~"SERVO_URL"); - match servo_url { - Some(s) => { args.push(s); }, - None => { fail!("No url input"); } - } - opts::from_cmdline_args(args) - } do std::rt::start_on_main_thread(argc, argv) { - run(getopts()) + run(opts::from_cmdline_args(os::args())) + } +} + +#[cfg(not(test), target_os="android")] +#[no_mangle] +pub extern "C" fn android_start(argc: int, argv: **u8) -> int { + do std::rt::start_on_main_thread(argc, argv) { + let mut args:~[~str] = ~[]; + for i in range(0u, argc as uint) { + unsafe { + args.push(str::raw::from_c_str(*argv.offset(i as int) as *i8)); + } + } + run(opts::from_cmdline_args(args)) } } From 3fe12748e070d21860bb2f3e88442763b32ef046 Mon Sep 17 00:00:00 2001 From: "aydin.kim" Date: Mon, 9 Dec 2013 15:22:26 +0900 Subject: [PATCH 05/11] add rust-egl to submodule --- .gitmodules | 3 +++ src/support/egl/rust-egl | 1 + 2 files changed, 4 insertions(+) create mode 160000 src/support/egl/rust-egl diff --git a/.gitmodules b/.gitmodules index e9d92f3f743..41d83443470 100644 --- a/.gitmodules +++ b/.gitmodules @@ -110,3 +110,6 @@ path = src/support/encoding/rust-encoding url = https://github.com/mozilla-servo/rust-encoding.git branch = rust-servo +[submodule "src/support/egl/rust-egl"] + path = src/support/egl/rust-egl + url = http://github.com/webconvforge/rust-egl.git diff --git a/src/support/egl/rust-egl b/src/support/egl/rust-egl new file mode 160000 index 00000000000..2eae43848b0 --- /dev/null +++ b/src/support/egl/rust-egl @@ -0,0 +1 @@ +Subproject commit 2eae43848b0a00d84f43e76b6d310bd69ffc7a3f From 16b56df45dc6bb090e296513e25907a7b9a6e165 Mon Sep 17 00:00:00 2001 From: "aydin.kim" Date: Wed, 21 Aug 2013 15:48:04 +0900 Subject: [PATCH 06/11] Servo-Android App packaging works --- .gitmodules | 3 +++ Makefile.in | 10 ++++++++++ src/platform/android/servo-android-glue | 1 + 3 files changed, 14 insertions(+) create mode 160000 src/platform/android/servo-android-glue diff --git a/.gitmodules b/.gitmodules index 41d83443470..d5856d448de 100644 --- a/.gitmodules +++ b/.gitmodules @@ -113,3 +113,6 @@ [submodule "src/support/egl/rust-egl"] path = src/support/egl/rust-egl url = http://github.com/webconvforge/rust-egl.git +[submodule "src/platform/android/servo-android-glue"] + path = src/platform/android/servo-android-glue + url = http://github.com/webconvforge/servo-android-glue.git diff --git a/Makefile.in b/Makefile.in index 0bf9b7e7707..19a192f8d25 100644 --- a/Makefile.in +++ b/Makefile.in @@ -343,6 +343,16 @@ package: servo cp $(B)src/platform/macos/rust-cocoa/lib*.dylib Servo.app/Contents/MacOS/src/platform/macos/rust-cocoa/ cp $(B)src/support/azure/rust-azure/lib*.dylib Servo.app/Contents/MacOS/src/support/azure/rust-azure/ +else ifeq ($(CFG_OSTYPE),linux-androideabi) +package: servo + mkdir -p sofile + -exec cp -f {} $(CFG_BUILD_HOME)sofile \; + find . ! \( \( -type d -path './sofile' -o -path './$(CFG_TARGET_TRIPLES)/src/compiler/rust' \) -prune \) -name '*.so' -type f | xargs cp -f -t $(CFG_BUILD_HOME)sofile + find $(CFG_RUST_HOME)/lib/rustc/$(CFG_TARGET_TRIPLES)/lib/ -name '*.so' -type f -size +1c | xargs cp -f -t $(CFG_BUILD_HOME)sofile + cd $(S)src/platform/android/servo-android-glue && make with-libs + cd $(CFG_BUILD_HOME) + cp $(S)src/platform/android/servo-android-glue/bin/ServoAndroid-debug.apk -t $(CFG_BUILD_HOME) + else bindings: $(AUTOGEN_SRC_script) diff --git a/src/platform/android/servo-android-glue b/src/platform/android/servo-android-glue new file mode 160000 index 00000000000..caf03d371cb --- /dev/null +++ b/src/platform/android/servo-android-glue @@ -0,0 +1 @@ +Subproject commit caf03d371cb99c9c72a7127114d8f5365a02eb06 From 32afea371774f7f3815950925ea96879977cc7e4 Mon Sep 17 00:00:00 2001 From: "aydin.kim" Date: Fri, 27 Dec 2013 10:54:08 +0900 Subject: [PATCH 07/11] update glut_windowing for language change --- .../main/platform/common/glut_windowing.rs | 37 ++++++++++++++----- 1 file changed, 28 insertions(+), 9 deletions(-) diff --git a/src/components/main/platform/common/glut_windowing.rs b/src/components/main/platform/common/glut_windowing.rs index 3fb0f055813..b1e6562758f 100644 --- a/src/components/main/platform/common/glut_windowing.rs +++ b/src/components/main/platform/common/glut_windowing.rs @@ -12,6 +12,7 @@ use windowing::{Forward, Back}; use alert::{Alert, AlertMethods}; use std::libc::c_int; +use std::local_data; use geom::point::Point2D; use geom::size::Size2D; use servo_msg::compositor_msg::{IdleRenderState, RenderState, RenderingRenderState}; @@ -35,7 +36,7 @@ impl ApplicationMethods for Application { } impl Drop for Application { - fn drop(&self) { + fn drop(&mut self) { } } @@ -78,26 +79,31 @@ impl WindowMethods for Window { throbber_frame: 0, }; - let event_queue = window.event_queue; + install_local_window(window); // Register event handlers. + + //Added dummy display callback to freeglut. According to freeglut ref, we should register some kind of display callback after freeglut 3.0. + do glut::display_func || { + debug!("GLUT display func registered"); + } do glut::reshape_func(window.glut_window) |width, height| { - event_queue.push(ResizeWindowEvent(width as uint, height as uint)) + local_window().event_queue.push(ResizeWindowEvent(width as uint, height as uint)) } do glut::keyboard_func |key, _, _| { - window.handle_key(key) + local_window().handle_key(key) } do glut::mouse_func |button, state, x, y| { if button < 3 { - window.handle_mouse(button, state, x, y); + local_window().handle_mouse(button, state, x, y); } else { match button { 3 => { - event_queue.push(ScrollWindowEvent(Point2D(0.0, 5.0 as f32), Point2D(0.0 as i32, 5.0 as i32))); + local_window().event_queue.push(ScrollWindowEvent(Point2D(0.0, 5.0 as f32), Point2D(0.0 as i32, 5.0 as i32))); }, 4 => { - event_queue.push(ScrollWindowEvent(Point2D(0.0, -5.0 as f32), Point2D(0.0 as i32, -5.0 as i32))); + local_window().event_queue.push(ScrollWindowEvent(Point2D(0.0, -5.0 as f32), Point2D(0.0 as i32, -5.0 as i32))); }, _ => {} } @@ -206,7 +212,7 @@ impl Window { /// Helper function to handle a click fn handle_mouse(&self, button: c_int, state: c_int, x: c_int, y: c_int) { // FIXME(tkuehn): max pixel dist should be based on pixel density - let max_pixel_dist = 10f64; + let max_pixel_dist = 10f32; let event = match state { glut::MOUSE_DOWN => { *self.mouse_down_point = Point2D(x, y); @@ -217,7 +223,7 @@ impl Window { if *self.mouse_down_button == button { let pixel_dist = *self.mouse_down_point - Point2D(x, y); let pixel_dist = ((pixel_dist.x * pixel_dist.x + - pixel_dist.y * pixel_dist.y) as float).sqrt(); + pixel_dist.y * pixel_dist.y) as f32).sqrt(); if pixel_dist < max_pixel_dist { let click_event = MouseWindowClickEvent(button as uint, Point2D(x as f32, y as f32)); @@ -245,3 +251,16 @@ impl Window { } } +static TLS_KEY: local_data::Key<@mut Window> = &local_data::Key; + +fn install_local_window(window: @mut Window) { + local_data::set(TLS_KEY, window); +} + +fn drop_local_window() { + local_data::pop(TLS_KEY); +} + +fn local_window() -> @mut Window { + local_data::get(TLS_KEY, |v| *v.unwrap()) +} From b4943c00b587a1558ea2078d9f9668b7e9fd9b57 Mon Sep 17 00:00:00 2001 From: "aydin.kim" Date: Mon, 30 Dec 2013 10:18:11 +0900 Subject: [PATCH 08/11] update submodules --- src/support/glut/rust-glut | 2 +- src/support/layers/rust-layers | 2 +- src/support/skia/skia | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/support/glut/rust-glut b/src/support/glut/rust-glut index 3626d203319..633324e13f6 160000 --- a/src/support/glut/rust-glut +++ b/src/support/glut/rust-glut @@ -1 +1 @@ -Subproject commit 3626d203319a4d12ac68fecee11e18850e180e78 +Subproject commit 633324e13f6b565615ef59f4463a4c528c90ba54 diff --git a/src/support/layers/rust-layers b/src/support/layers/rust-layers index 985790fe16d..e8123cee243 160000 --- a/src/support/layers/rust-layers +++ b/src/support/layers/rust-layers @@ -1 +1 @@ -Subproject commit 985790fe16d10d50391675d00df832fc2b8e1048 +Subproject commit e8123cee2432c1b430c3df781489493f8ecdb6c0 diff --git a/src/support/skia/skia b/src/support/skia/skia index 73b73c23696..a30fd879f21 160000 --- a/src/support/skia/skia +++ b/src/support/skia/skia @@ -1 +1 @@ -Subproject commit 73b73c23696a373b84289711b537eaa00065e4f9 +Subproject commit a30fd879f21f78672c41a519a60e590003e2caf1 From 28757e225724ad2eedc707273349215947dfe15d Mon Sep 17 00:00:00 2001 From: "aydin.kim" Date: Mon, 30 Dec 2013 10:22:43 +0900 Subject: [PATCH 09/11] update gfx font stuffs for android --- src/components/gfx/platform/android/font.rs | 58 +++++++++---------- .../gfx/platform/android/font_context.rs | 38 ++++++------ .../gfx/platform/android/font_list.rs | 11 ++-- 3 files changed, 50 insertions(+), 57 deletions(-) diff --git a/src/components/gfx/platform/android/font.rs b/src/components/gfx/platform/android/font.rs index 745157f5354..900bf5b00bd 100644 --- a/src/components/gfx/platform/android/font.rs +++ b/src/components/gfx/platform/android/font.rs @@ -29,11 +29,11 @@ use std::cast; use std::ptr; use std::str; -fn float_to_fixed_ft(f: float) -> i32 { +fn float_to_fixed_ft(f: f64) -> i32 { float_to_fixed(6, f) } -fn fixed_to_float_ft(f: i32) -> float { +fn fixed_to_float_ft(f: i32) -> f64 { fixed_to_float(6, f) } @@ -63,7 +63,7 @@ pub struct FontHandle { #[unsafe_destructor] impl Drop for FontHandle { #[fixed_stack_segment] - fn drop(&self) { + fn drop(&mut self) { assert!(self.face.is_not_null()); unsafe { if !FT_Done_Face(self.face).succeeded() { @@ -78,7 +78,7 @@ impl FontHandleMethods for FontHandle { buf: ~[u8], style: &SpecifiedFontStyle) -> Result { - let ft_ctx: FT_Library = fctx.ctx.ctx; + let ft_ctx: FT_Library = fctx.ctx.borrow().ctx; if ft_ctx.is_null() { return Err(()); } let face_result = do buf.as_imm_buf |bytes: *u8, len: uint| { @@ -93,7 +93,7 @@ impl FontHandleMethods for FontHandle { let handle = FontHandle { face: face, source: FontSourceMem(buf), - handle: *fctx + handle: fctx.clone() }; Ok(handle) } @@ -101,10 +101,8 @@ impl FontHandleMethods for FontHandle { }; #[fixed_stack_segment] - fn create_face_from_buffer(lib: FT_Library, - cbuf: *u8, cbuflen: uint, pt_size: float) - -> Result { - + fn create_face_from_buffer(lib: FT_Library, cbuf: *u8, cbuflen: uint, pt_size: f64) + -> Result { unsafe { let mut face: FT_Face = ptr::null(); let face_index = 0 as FT_Long; @@ -207,7 +205,7 @@ impl FontHandleMethods for FontHandle { let void_glyph = (*self.face).glyph; let slot: FT_GlyphSlot = cast::transmute(void_glyph); assert!(slot.is_not_null()); - debug!("metrics: {}", (*slot).metrics); + debug!("metrics: {:?}", (*slot).metrics); let advance = (*slot).metrics.horiAdvance; debug!("h_advance for {} is {}", glyph, advance); let advance = advance as i32; @@ -224,12 +222,12 @@ impl FontHandleMethods for FontHandle { /* TODO(Issue #76): complete me */ let face = self.get_face_rec(); - let underline_size = self.font_units_to_au(face.underline_thickness as float); - let underline_offset = self.font_units_to_au(face.underline_position as float); - let em_size = self.font_units_to_au(face.units_per_EM as float); - let ascent = self.font_units_to_au(face.ascender as float); - let descent = self.font_units_to_au(face.descender as float); - let max_advance = self.font_units_to_au(face.max_advance_width as float); + let underline_size = self.font_units_to_au(face.underline_thickness as f64); + let underline_offset = self.font_units_to_au(face.underline_position as f64); + let em_size = self.font_units_to_au(face.units_per_EM as f64); + let ascent = self.font_units_to_au(face.ascender as f64); + let descent = self.font_units_to_au(face.descender as f64); + let max_advance = self.font_units_to_au(face.max_advance_width as f64); // 'leading' is supposed to be the vertical distance between two baselines, // reflected by the height attibute in freetype. On OS X (w/ CTFont), @@ -237,7 +235,7 @@ impl FontHandleMethods for FontHandle { // the top of the next line's ascent or: (line_height - ascent - descent), // see http://stackoverflow.com/a/5635981 for CTFont implementation. // Convert using a formular similar to what CTFont returns for consistency. - let height = self.font_units_to_au(face.height as float); + let height = self.font_units_to_au(face.height as f64); let leading = height - (ascent + descent); let mut strikeout_size = geometry::from_pt(0.0); @@ -247,9 +245,9 @@ impl FontHandleMethods for FontHandle { let os2 = FT_Get_Sfnt_Table(face, ft_sfnt_os2) as *TT_OS2; let valid = os2.is_not_null() && (*os2).version != 0xffff; if valid { - strikeout_size = self.font_units_to_au((*os2).yStrikeoutSize as float); - strikeout_offset = self.font_units_to_au((*os2).yStrikeoutPosition as float); - x_height = self.font_units_to_au((*os2).sxHeight as float); + strikeout_size = self.font_units_to_au((*os2).yStrikeoutSize as f64); + strikeout_offset = self.font_units_to_au((*os2).yStrikeoutPosition as f64); + x_height = self.font_units_to_au((*os2).sxHeight as f64); } } @@ -277,7 +275,7 @@ impl FontHandleMethods for FontHandle { impl<'self> FontHandle { #[fixed_stack_segment] - fn set_char_size(face: FT_Face, pt_size: float) -> Result<(), ()>{ + fn set_char_size(face: FT_Face, pt_size: f64) -> Result<(), ()>{ let char_width = float_to_fixed_ft(pt_size) as FT_F26Dot6; let char_height = float_to_fixed_ft(pt_size) as FT_F26Dot6; let h_dpi = 72; @@ -290,10 +288,10 @@ impl<'self> FontHandle { } #[fixed_stack_segment] - pub fn new_from_file(fctx: &FontContextHandle, file: ~str, + pub fn new_from_file(fctx: &FontContextHandle, file: &str, style: &SpecifiedFontStyle) -> Result { unsafe { - let ft_ctx: FT_Library = fctx.ctx.ctx; + let ft_ctx: FT_Library = fctx.ctx.borrow().ctx; if ft_ctx.is_null() { return Err(()); } let mut face: FT_Face = ptr::null(); @@ -307,9 +305,9 @@ impl<'self> FontHandle { } if FontHandle::set_char_size(face, style.pt_size).is_ok() { Ok(FontHandle { - source: FontSourceFile(file), + source: FontSourceFile(file.to_str()), face: face, - handle: *fctx + handle: fctx.clone() }) } else { Err(()) @@ -321,7 +319,7 @@ impl<'self> FontHandle { pub fn new_from_file_unstyled(fctx: &FontContextHandle, file: ~str) -> Result { unsafe { - let ft_ctx: FT_Library = fctx.ctx.ctx; + let ft_ctx: FT_Library = fctx.ctx.borrow().ctx; if ft_ctx.is_null() { return Err(()); } let mut face: FT_Face = ptr::null(); @@ -337,7 +335,7 @@ impl<'self> FontHandle { Ok(FontHandle { source: FontSourceFile(file), face: face, - handle: *fctx + handle: fctx.clone() }) } } @@ -348,7 +346,7 @@ impl<'self> FontHandle { } } - fn font_units_to_au(&self, value: float) -> Au { + fn font_units_to_au(&self, value: f64) -> Au { let face = self.get_face_rec(); // face.size is a *c_void in the bindings, presumably to avoid @@ -356,8 +354,8 @@ impl<'self> FontHandle { let size: &FT_SizeRec = unsafe { cast::transmute(&(*face.size)) }; let metrics: &FT_Size_Metrics = &(*size).metrics; - let em_size = face.units_per_EM as float; - let x_scale = (metrics.x_ppem as float) / em_size as float; + let em_size = face.units_per_EM as f64; + let x_scale = (metrics.x_ppem as f64) / em_size as f64; // If this isn't true then we're scaling one of the axes wrong assert!(metrics.x_ppem == metrics.y_ppem); diff --git a/src/components/gfx/platform/android/font_context.rs b/src/components/gfx/platform/android/font_context.rs index c30f040040d..4b6c74d95c2 100644 --- a/src/components/gfx/platform/android/font_context.rs +++ b/src/components/gfx/platform/android/font_context.rs @@ -11,23 +11,24 @@ use freetype::freetype::{FTErrorMethods, FT_Library}; use freetype::freetype::{FT_Done_FreeType, FT_Init_FreeType}; use std::ptr; +use std::rc::Rc; +#[deriving(Clone)] struct FreeTypeLibraryHandle { ctx: FT_Library, } -impl Drop for FreeTypeLibraryHandle { - #[fixed_stack_segment] - fn drop(&self) { - assert!(self.ctx.is_not_null()); - unsafe { - FT_Done_FreeType(self.ctx); - } - } +#[deriving(Clone)] +pub struct FontContextHandle { + ctx: Rc, } -pub struct FontContextHandle { - ctx: @FreeTypeLibraryHandle, +impl Drop for FreeTypeLibraryHandle { + #[fixed_stack_segment] + fn drop(&mut self) { + assert!(self.ctx.is_not_null()); + unsafe { FT_Done_FreeType(self.ctx) }; + } } impl FontContextHandle { @@ -35,27 +36,22 @@ impl FontContextHandle { pub fn new() -> FontContextHandle { unsafe { let ctx: FT_Library = ptr::null(); - let result = FT_Init_FreeType(ptr::to_unsafe_ptr(&ctx)); - if !result.succeeded() { fail!(); } - - FontContextHandle { - ctx: @FreeTypeLibraryHandle { ctx: ctx }, + let result = FT_Init_FreeType(&ctx); + if !result.succeeded() { fail!("Unable to initialize FreeType library"); } + FontContextHandle { + ctx: Rc::new(FreeTypeLibraryHandle { ctx: ctx }), } } } } impl FontContextHandleMethods for FontContextHandle { - fn clone(&self) -> FontContextHandle { - FontContextHandle { ctx: self.ctx } - } - fn create_font_from_identifier(&self, name: ~str, style: UsedFontStyle) -> Result { debug!("Creating font handle for {:s}", name); - do path_from_identifier(name, &style).chain |file_name| { + do path_from_identifier(name, &style).and_then |file_name| { debug!("Opening font face {:s}", file_name); - FontHandle::new_from_file(self, file_name, &style) + FontHandle::new_from_file(self, file_name.to_owned(), &style) } } } diff --git a/src/components/gfx/platform/android/font_list.rs b/src/components/gfx/platform/android/font_list.rs index 6f6b26064ee..50cd2017a80 100644 --- a/src/components/gfx/platform/android/font_list.rs +++ b/src/components/gfx/platform/android/font_list.rs @@ -19,7 +19,6 @@ use fontconfig::fontconfig::{ use font::{FontHandleMethods, UsedFontStyle}; -use font_context::FontContextHandleMethods; use font_list::{FontEntry, FontFamily, FontFamilyMap}; use platform::font::FontHandle; use platform::font_context::FontContextHandle; @@ -53,7 +52,7 @@ impl FontListHandle { while FcPatternGetString(*font, FC_FAMILY, v, &family) == FcResultMatch { let family_name = str::raw::from_c_str(family as *c_char); debug!("Creating new FontFamily for family: {:s}", family_name); - let new_family = @mut FontFamily::new(family_name); + let new_family = FontFamily::new(family_name); family_map.insert(family_name, new_family); v += 1; } @@ -64,8 +63,8 @@ impl FontListHandle { } #[fixed_stack_segment] - pub fn load_variations_for_family(&self, family: @mut FontFamily) { - debug!("getting variations for {}", family); + pub fn load_variations_for_family(&self, family: &mut FontFamily) { + debug!("getting variations for {:?}", family); unsafe { let config = FcConfigGetCurrent(); let font_set = FcConfigGetFonts(config, FcSetSystem); @@ -120,7 +119,7 @@ impl FontListHandle { let font_handle = font_handle.unwrap(); debug!("Creating new FontEntry for face: {:s}", font_handle.face_name()); - let entry = @FontEntry::new(font_handle); + let entry = FontEntry::new(font_handle); family.entries.push(entry); } @@ -141,7 +140,7 @@ struct AutoPattern { impl Drop for AutoPattern { #[fixed_stack_segment] - fn drop(&self) { + fn drop(&mut self) { unsafe { FcPatternDestroy(self.pattern); } From 269d30092132f96890b226f9943d7b6d206ee411 Mon Sep 17 00:00:00 2001 From: "aydin.kim" Date: Fri, 3 Jan 2014 08:43:18 +0900 Subject: [PATCH 10/11] add a minor changes & trigger rust rebuild --- src/compiler/rust-auto-clean-trigger | 2 +- src/components/main/platform/common/glut_windowing.rs | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/compiler/rust-auto-clean-trigger b/src/compiler/rust-auto-clean-trigger index f15fda47fc8..6474e73f600 100644 --- a/src/compiler/rust-auto-clean-trigger +++ b/src/compiler/rust-auto-clean-trigger @@ -1,4 +1,4 @@ # If this file is modified, then rust will be forcibly cleaned and then rebuilt. # The actual contents of this file do not matter, but to trigger a change on the # build bots then the contents should be changed so git updates the mtime. -2013-10-31 +2014-01-02 diff --git a/src/components/main/platform/common/glut_windowing.rs b/src/components/main/platform/common/glut_windowing.rs index b1e6562758f..b781d562a5c 100644 --- a/src/components/main/platform/common/glut_windowing.rs +++ b/src/components/main/platform/common/glut_windowing.rs @@ -37,6 +37,7 @@ impl ApplicationMethods for Application { impl Drop for Application { fn drop(&mut self) { + drop_local_window(); } } From f2f90842a3e7d7f660d3769dd9b1f0d7b8311689 Mon Sep 17 00:00:00 2001 From: "aydin.kim" Date: Fri, 3 Jan 2014 09:51:33 +0900 Subject: [PATCH 11/11] fix .gitmodules to use https --- .gitmodules | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.gitmodules b/.gitmodules index d5856d448de..b36736b0923 100644 --- a/.gitmodules +++ b/.gitmodules @@ -112,7 +112,7 @@ branch = rust-servo [submodule "src/support/egl/rust-egl"] path = src/support/egl/rust-egl - url = http://github.com/webconvforge/rust-egl.git + url = https://github.com/webconvforge/rust-egl.git [submodule "src/platform/android/servo-android-glue"] path = src/platform/android/servo-android-glue - url = http://github.com/webconvforge/servo-android-glue.git + url = https://github.com/webconvforge/servo-android-glue.git