/* This Source Code Form is subject to the terms of the Mozilla Public *License,v.2.0.IfacopyoftheMPLwasnotdistributedwiththis
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
use gleam::gl; use glutin::NotCurrent; use std::fs::File; use std::io::Read; use webrender::api::*; use webrender::api::units::*; use webrender::render_api::*; use webrender::DebugFlags; use winit::dpi::LogicalSize; use winit::platform::run_return::EventLoopExtRunReturn;
impl Window { fn new(name: &'static str, clear_color: ColorF) -> Self { let events_loop = winit::event_loop::EventLoop::new(); let window_builder = winit::window::WindowBuilder::new()
.with_title(name)
.with_inner_size(LogicalSize::new(800. as f64, 600. as f64)); let context = glutin::ContextBuilder::new()
.with_gl(glutin::GlRequest::GlThenGles {
opengl_version: (3, 2),
opengles_version: (3, 0),
})
.build_windowed(window_builder, &events_loop)
.unwrap();
let context = unsafe { context.make_current().unwrap() };
let gl = match context.get_api() {
glutin::Api::OpenGl => unsafe {
gl::GlFns::load_with(|symbol| context.get_proc_address(symbol) as *const _)
},
glutin::Api::OpenGlEs => unsafe {
gl::GlesFns::load_with(|symbol| context.get_proc_address(symbol) as *const _)
},
glutin::Api::WebGl => unimplemented!(),
};
let opts = webrender::WebRenderOptions {
clear_color,
..webrender::WebRenderOptions::default()
};
let device_size = { let size = context
.window()
.inner_size();
DeviceIntSize::new(size.width as i32, size.height as i32)
}; let notifier = Box::new(Notifier::new(events_loop.create_proxy())); let (renderer, sender) = webrender::create_webrender_instance(gl.clone(), notifier, opts, None).unwrap(); letmut api = sender.create_api(); let document_id = api.add_document(device_size);
let epoch = Epoch(0); let pipeline_id = PipelineId(0, 0); letmut txn = Transaction::new();
let font_key = api.generate_font_key(); let font_bytes = load_file("../wrench/reftests/text/FreeSans.ttf");
txn.add_raw_font(font_key, font_bytes, 0);
let font_instance_key = api.generate_font_instance_key();
txn.add_font_instance(font_instance_key, font_key, 32.0, None, None, Vec::new());
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.