aboutsummaryrefslogtreecommitdiffstats
path: root/components
diff options
context:
space:
mode:
Diffstat (limited to 'components')
-rw-r--r--components/canvas/canvas_data.rs19
-rw-r--r--components/canvas/canvas_paint_thread.rs2
-rw-r--r--components/canvas/webgl_mode/inprocess.rs5
-rw-r--r--components/canvas/webgl_thread.rs78
-rw-r--r--components/canvas_traits/canvas.rs3
-rw-r--r--components/compositing/compositor.rs64
-rw-r--r--components/compositing/compositor_thread.rs16
-rw-r--r--components/compositing/windowing.rs3
-rw-r--r--components/constellation/constellation.rs9
-rw-r--r--components/constellation/pipeline.rs5
-rw-r--r--components/gfx/font.rs5
-rw-r--r--components/gfx/font_cache_thread.rs21
-rw-r--r--components/gfx/font_context.rs7
-rw-r--r--components/gfx/tests/font_context.rs11
-rw-r--r--components/gfx/text/text_run.rs3
-rw-r--r--components/gfx_traits/lib.rs17
-rw-r--r--components/layout/display_list/webrender_helpers.rs2
-rw-r--r--components/layout/fragment.rs6
-rw-r--r--components/layout/sequential.rs6
-rw-r--r--components/layout_2020/display_list/conversions.rs90
-rw-r--r--components/layout_2020/display_list/gradient.rs2
-rw-r--r--components/layout_2020/display_list/mod.rs2
-rw-r--r--components/layout_2020/fragment_tree/fragment_tree.rs5
-rw-r--r--components/layout_2020/query.rs4
-rw-r--r--components/layout_thread/lib.rs21
-rw-r--r--components/layout_thread_2020/lib.rs15
-rw-r--r--components/malloc_size_of/lib.rs48
-rw-r--r--components/media/media_thread.rs3
-rw-r--r--components/msg/constellation_msg.rs12
-rw-r--r--components/net/image_cache.rs11
-rw-r--r--components/net_traits/image/base.rs3
-rw-r--r--components/script/dom/gpucanvascontext.rs22
-rw-r--r--components/script/dom/gpuswapchain.rs3
-rw-r--r--components/script/dom/webglrenderingcontext.rs3
-rw-r--r--components/script_layout_interface/lib.rs7
-rw-r--r--components/script_traits/lib.rs27
-rw-r--r--components/servo/lib.rs17
-rw-r--r--components/webgpu/lib.rs40
-rw-r--r--components/webrender_traits/lib.rs40
39 files changed, 330 insertions, 327 deletions
diff --git a/components/canvas/canvas_data.rs b/components/canvas/canvas_data.rs
index ac00083d44e..0a86bcd1c3c 100644
--- a/components/canvas/canvas_data.rs
+++ b/components/canvas/canvas_data.rs
@@ -27,7 +27,8 @@ use std::sync::{Arc, Mutex};
use style::properties::style_structs::Font as FontStyleStruct;
use style::values::computed::font;
use style_traits::values::ToCss;
-use webrender_api::units::RectExt as RectExt_;
+use webrender_api::units::{DeviceIntSize, RectExt as RectExt_};
+use webrender_api::{ImageData, ImageDescriptor, ImageDescriptorFlags, ImageFormat, ImageKey};
/// The canvas data stores a state machine for the current status of
/// the path data and any relevant transformations that are
@@ -405,11 +406,11 @@ pub struct CanvasData<'a> {
state: CanvasPaintState<'a>,
saved_states: Vec<CanvasPaintState<'a>>,
webrender_api: Box<dyn WebrenderApi>,
- image_key: Option<webrender_api::ImageKey>,
+ image_key: Option<ImageKey>,
/// An old webrender image key that can be deleted when the next epoch ends.
- old_image_key: Option<webrender_api::ImageKey>,
+ old_image_key: Option<ImageKey>,
/// An old webrender image key that can be deleted when the current epoch ends.
- very_old_image_key: Option<webrender_api::ImageKey>,
+ very_old_image_key: Option<ImageKey>,
font_cache_thread: Mutex<FontCacheThread>,
}
@@ -1107,15 +1108,15 @@ impl<'a> CanvasData<'a> {
pub fn send_data(&mut self, chan: IpcSender<CanvasImageData>) {
let size = self.drawtarget.get_size();
- let descriptor = webrender_api::ImageDescriptor {
- size: webrender_api::units::DeviceIntSize::new(size.width, size.height),
+ let descriptor = ImageDescriptor {
+ size: DeviceIntSize::new(size.width, size.height),
stride: None,
- format: webrender_api::ImageFormat::BGRA8,
+ format: ImageFormat::BGRA8,
offset: 0,
- flags: webrender_api::ImageDescriptorFlags::empty(),
+ flags: ImageDescriptorFlags::empty(),
};
let data = self.drawtarget.snapshot_data_owned();
- let data = webrender_api::ImageData::Raw(Arc::new(data));
+ let data = ImageData::Raw(Arc::new(data));
let mut updates = vec![];
diff --git a/components/canvas/canvas_paint_thread.rs b/components/canvas/canvas_paint_thread.rs
index f7c1d38b76f..df2b62971ca 100644
--- a/components/canvas/canvas_paint_thread.rs
+++ b/components/canvas/canvas_paint_thread.rs
@@ -27,7 +27,7 @@ pub enum ImageUpdate {
}
pub trait WebrenderApi {
- fn generate_key(&self) -> Result<webrender_api::ImageKey, ()>;
+ fn generate_key(&self) -> Result<ImageKey, ()>;
fn update_images(&self, updates: Vec<ImageUpdate>);
fn clone(&self) -> Box<dyn WebrenderApi>;
}
diff --git a/components/canvas/webgl_mode/inprocess.rs b/components/canvas/webgl_mode/inprocess.rs
index 64180b47930..4b7fa73b79c 100644
--- a/components/canvas/webgl_mode/inprocess.rs
+++ b/components/canvas/webgl_mode/inprocess.rs
@@ -16,6 +16,7 @@ use surfman::SurfaceTexture;
use surfman_chains::SwapChains;
use surfman_chains_api::SwapChainAPI;
use surfman_chains_api::SwapChainsAPI;
+use webrender_api::{DocumentId, RenderApiSender};
use webrender_surfman::WebrenderSurfman;
use webrender_traits::{
WebrenderExternalImageApi, WebrenderExternalImageRegistry, WebrenderImageSource,
@@ -33,8 +34,8 @@ impl WebGLComm {
/// Creates a new `WebGLComm` object.
pub fn new(
surfman: WebrenderSurfman,
- webrender_api_sender: webrender_api::RenderApiSender,
- webrender_doc: webrender_api::DocumentId,
+ webrender_api_sender: RenderApiSender,
+ webrender_doc: DocumentId,
external_images: Arc<Mutex<WebrenderExternalImageRegistry>>,
api_type: GlType,
) -> WebGLComm {
diff --git a/components/canvas/webgl_thread.rs b/components/canvas/webgl_thread.rs
index 27809ae957e..d979ef3301b 100644
--- a/components/canvas/webgl_thread.rs
+++ b/components/canvas/webgl_thread.rs
@@ -69,6 +69,11 @@ use surfman::SurfaceInfo;
use surfman::SurfaceType;
use surfman_chains::SwapChains;
use surfman_chains_api::SwapChainsAPI;
+use webrender_api::{
+ units::DeviceIntSize, DirtyRect, DocumentId, ExternalImageData, ExternalImageId,
+ ExternalImageType, ImageData, ImageDescriptor, ImageDescriptorFlags, ImageFormat, ImageKey,
+ RenderApi, RenderApiSender, TextureTarget, Transaction,
+};
use webrender_traits::{WebrenderExternalImageRegistry, WebrenderImageHandlerType};
use webxr::SurfmanGL as WebXRSurfman;
use webxr_api::ContextId as WebXRContextId;
@@ -229,9 +234,9 @@ impl Default for GLState {
pub(crate) struct WebGLThread {
/// The GPU device.
device: Device,
- /// Channel used to generate/update or delete `webrender_api::ImageKey`s.
- webrender_api: webrender_api::RenderApi,
- webrender_doc: webrender_api::DocumentId,
+ /// Channel used to generate/update or delete `ImageKey`s.
+ webrender_api: RenderApi,
+ webrender_doc: DocumentId,
/// Map of live WebGLContexts.
contexts: FnvHashMap<WebGLContextId, GLContextData>,
/// Cached information for WebGLContexts.
@@ -255,8 +260,8 @@ pub(crate) struct WebGLThread {
/// The data required to initialize an instance of the WebGLThread type.
pub(crate) struct WebGLThreadInit {
- pub webrender_api_sender: webrender_api::RenderApiSender,
- pub webrender_doc: webrender_api::DocumentId,
+ pub webrender_api_sender: RenderApiSender,
+ pub webrender_doc: DocumentId,
pub external_images: Arc<Mutex<WebrenderExternalImageRegistry>>,
pub sender: WebGLSender<WebGLMsg>,
pub receiver: WebGLReceiver<WebGLMsg>,
@@ -744,7 +749,7 @@ impl WebGLThread {
fn remove_webgl_context(&mut self, context_id: WebGLContextId) {
// Release webrender image keys.
if let Some(info) = self.cached_context_info.remove(&context_id) {
- let mut txn = webrender_api::Transaction::new();
+ let mut txn = Transaction::new();
txn.delete_image(info.image_key);
self.webrender_api.send_transaction(self.webrender_doc, txn)
}
@@ -923,66 +928,63 @@ impl WebGLThread {
/// Creates a `webrender_api::ImageKey` that uses shared textures.
fn create_wr_external_image(
- webrender_api: &mut webrender_api::RenderApi,
- webrender_doc: webrender_api::DocumentId,
+ webrender_api: &mut RenderApi,
+ webrender_doc: DocumentId,
size: Size2D<i32>,
alpha: bool,
context_id: WebGLContextId,
- target: webrender_api::TextureTarget,
- ) -> webrender_api::ImageKey {
+ target: TextureTarget,
+ ) -> ImageKey {
let descriptor = Self::image_descriptor(size, alpha);
let data = Self::external_image_data(context_id, target);
let image_key = webrender_api.generate_image_key();
- let mut txn = webrender_api::Transaction::new();
+ let mut txn = Transaction::new();
txn.add_image(image_key, descriptor, data, None);
webrender_api.send_transaction(webrender_doc, txn);
image_key
}
- /// Updates a `webrender_api::ImageKey` that uses shared textures.
+ /// Updates a `ImageKey` that uses shared textures.
fn update_wr_external_image(
- webrender_api: &mut webrender_api::RenderApi,
- webrender_doc: webrender_api::DocumentId,
+ webrender_api: &mut RenderApi,
+ webrender_doc: DocumentId,
size: Size2D<i32>,
alpha: bool,
context_id: WebGLContextId,
- image_key: webrender_api::ImageKey,
- target: webrender_api::TextureTarget,
+ image_key: ImageKey,
+ target: TextureTarget,
) {
let descriptor = Self::image_descriptor(size, alpha);
let data = Self::external_image_data(context_id, target);
- let mut txn = webrender_api::Transaction::new();
- txn.update_image(image_key, descriptor, data, &webrender_api::DirtyRect::All);
+ let mut txn = Transaction::new();
+ txn.update_image(image_key, descriptor, data, &DirtyRect::All);
webrender_api.send_transaction(webrender_doc, txn);
}
- /// Helper function to create a `webrender_api::ImageDescriptor`.
- fn image_descriptor(size: Size2D<i32>, alpha: bool) -> webrender_api::ImageDescriptor {
- let mut flags = webrender_api::ImageDescriptorFlags::empty();
- flags.set(webrender_api::ImageDescriptorFlags::IS_OPAQUE, !alpha);
- webrender_api::ImageDescriptor {
- size: webrender_api::units::DeviceIntSize::new(size.width, size.height),
+ /// Helper function to create a `ImageDescriptor`.
+ fn image_descriptor(size: Size2D<i32>, alpha: bool) -> ImageDescriptor {
+ let mut flags = ImageDescriptorFlags::empty();
+ flags.set(ImageDescriptorFlags::IS_OPAQUE, !alpha);
+ ImageDescriptor {
+ size: DeviceIntSize::new(size.width, size.height),
stride: None,
- format: webrender_api::ImageFormat::BGRA8,
+ format: ImageFormat::BGRA8,
offset: 0,
flags,
}
}
- /// Helper function to create a `webrender_api::ImageData::External` instance.
- fn external_image_data(
- context_id: WebGLContextId,
- target: webrender_api::TextureTarget,
- ) -> webrender_api::ImageData {
- let data = webrender_api::ExternalImageData {
- id: webrender_api::ExternalImageId(context_id.0 as u64),
+ /// Helper function to create a `ImageData::External` instance.
+ fn external_image_data(context_id: WebGLContextId, target: TextureTarget) -> ImageData {
+ let data = ExternalImageData {
+ id: ExternalImageId(context_id.0 as u64),
channel_index: 0,
- image_type: webrender_api::ExternalImageType::TextureHandle(target),
+ image_type: ExternalImageType::TextureHandle(target),
};
- webrender_api::ImageData::External(data)
+ ImageData::External(data)
}
/// Gets the GLSL Version supported by a GLContext.
@@ -1006,14 +1008,14 @@ impl WebGLThread {
/// Helper struct to store cached WebGLContext information.
struct WebGLContextInfo {
/// Currently used WebRender image key.
- image_key: webrender_api::ImageKey,
+ image_key: ImageKey,
}
// TODO(pcwalton): Add `GL_TEXTURE_EXTERNAL_OES`?
-fn current_wr_texture_target(device: &Device) -> webrender_api::TextureTarget {
+fn current_wr_texture_target(device: &Device) -> TextureTarget {
match device.surface_gl_texture_target() {
- gl::TEXTURE_RECTANGLE => webrender_api::TextureTarget::Rect,
- _ => webrender_api::TextureTarget::Default,
+ gl::TEXTURE_RECTANGLE => TextureTarget::Rect,
+ _ => TextureTarget::Default,
}
}
diff --git a/components/canvas_traits/canvas.rs b/components/canvas_traits/canvas.rs
index f302aaa8e3e..a7a8ec12a0a 100644
--- a/components/canvas_traits/canvas.rs
+++ b/components/canvas_traits/canvas.rs
@@ -9,6 +9,7 @@ use serde_bytes::ByteBuf;
use std::default::Default;
use std::str::FromStr;
use style::properties::style_structs::Font as FontStyleStruct;
+use webrender_api::ImageKey;
#[derive(Clone, Debug, Deserialize, Serialize)]
pub enum FillRule {
@@ -30,7 +31,7 @@ pub enum CanvasMsg {
#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct CanvasImageData {
- pub image_key: webrender_api::ImageKey,
+ pub image_key: ImageKey,
}
#[derive(Debug, Deserialize, Serialize)]
diff --git a/components/compositing/compositor.rs b/components/compositing/compositor.rs
index 6d59babe4da..ce6b2bdd4d7 100644
--- a/components/compositing/compositor.rs
+++ b/components/compositing/compositor.rs
@@ -51,7 +51,11 @@ use time::{now, precise_time_ns, precise_time_s};
use webrender_api::units::{
DeviceIntPoint, DeviceIntSize, DevicePoint, LayoutPoint, LayoutVector2D, WorldPoint,
};
-use webrender_api::{self, ExternalScrollId, HitTestFlags, ScrollClamping, ScrollLocation};
+use webrender_api::{
+ self, BuiltDisplayList, CaptureBits, DirtyRect, DocumentId, Epoch as WebRenderEpoch,
+ ExternalScrollId, HitTestFlags, PipelineId as WebRenderPipelineId, RenderApi, ScrollClamping,
+ ScrollLocation, Transaction, ZoomFactor,
+};
use webrender_surfman::WebrenderSurfman;
#[derive(Debug, PartialEq)]
@@ -74,7 +78,7 @@ trait ConvertPipelineIdFromWebRender {
fn from_webrender(&self) -> PipelineId;
}
-impl ConvertPipelineIdFromWebRender for webrender_api::PipelineId {
+impl ConvertPipelineIdFromWebRender for WebRenderPipelineId {
fn from_webrender(&self) -> PipelineId {
PipelineId {
namespace_id: PipelineNamespaceId(self.0),
@@ -182,10 +186,10 @@ pub struct IOCompositor<Window: WindowMethods + ?Sized> {
webrender: webrender::Renderer,
/// The active webrender document.
- webrender_document: webrender_api::DocumentId,
+ webrender_document: DocumentId,
/// The webrender interface, if enabled.
- webrender_api: webrender_api::RenderApi,
+ webrender_api: RenderApi,
/// The surfman instance that webrender targets
webrender_surfman: WebrenderSurfman,
@@ -628,9 +632,9 @@ impl<Window: WindowMethods + ?Sized> IOCompositor<Window> {
match msg {
WebrenderMsg::Layout(script_traits::WebrenderMsg::SendInitialTransaction(pipeline)) => {
self.waiting_on_pending_frame = true;
- let mut txn = webrender_api::Transaction::new();
+ let mut txn = Transaction::new();
txn.set_display_list(
- webrender_api::Epoch(0),
+ WebRenderEpoch(0),
None,
Default::default(),
(pipeline, Default::default(), Default::default()),
@@ -647,7 +651,7 @@ impl<Window: WindowMethods + ?Sized> IOCompositor<Window> {
)) => {
self.waiting_for_results_of_scroll = true;
- let mut txn = webrender_api::Transaction::new();
+ let mut txn = Transaction::new();
txn.scroll_node_with_id(point, scroll_id, clamping);
txn.generate_frame();
self.webrender_api
@@ -668,7 +672,7 @@ impl<Window: WindowMethods + ?Sized> IOCompositor<Window> {
details.hit_test_items = display_list_info.hit_test_info;
details.install_new_scroll_tree(display_list_info.scroll_tree);
- let mut txn = webrender_api::Transaction::new();
+ let mut txn = Transaction::new();
txn.set_display_list(
display_list_info.epoch,
None,
@@ -676,10 +680,7 @@ impl<Window: WindowMethods + ?Sized> IOCompositor<Window> {
(
pipeline_id,
content_size,
- webrender_api::BuiltDisplayList::from_data(
- data,
- display_list_descriptor,
- ),
+ BuiltDisplayList::from_data(data, display_list_descriptor),
),
true,
);
@@ -718,7 +719,7 @@ impl<Window: WindowMethods + ?Sized> IOCompositor<Window> {
},
WebrenderMsg::Layout(script_traits::WebrenderMsg::UpdateImages(updates)) => {
- let mut txn = webrender_api::Transaction::new();
+ let mut txn = Transaction::new();
for update in updates {
match update {
script_traits::SerializedImageUpdate::AddImage(key, desc, data) => {
@@ -732,12 +733,7 @@ impl<Window: WindowMethods + ?Sized> IOCompositor<Window> {
},
script_traits::SerializedImageUpdate::UpdateImage(key, desc, data) => {
match data.to_image_data() {
- Ok(data) => txn.update_image(
- key,
- desc,
- data,
- &webrender_api::DirtyRect::All,
- ),
+ Ok(data) => txn.update_image(key, desc, data, &DirtyRect::All),
Err(e) => warn!("error when sending image data: {:?}", e),
}
},
@@ -748,7 +744,7 @@ impl<Window: WindowMethods + ?Sized> IOCompositor<Window> {
},
WebrenderMsg::Net(net_traits::WebrenderImageMsg::AddImage(key, desc, data)) => {
- let mut txn = webrender_api::Transaction::new();
+ let mut txn = Transaction::new();
txn.add_image(key, desc, data, None);
self.webrender_api
.send_transaction(self.webrender_document, txn);
@@ -756,7 +752,7 @@ impl<Window: WindowMethods + ?Sized> IOCompositor<Window> {
WebrenderMsg::Font(WebrenderFontMsg::AddFontInstance(font_key, size, sender)) => {
let key = self.webrender_api.generate_font_instance_key();
- let mut txn = webrender_api::Transaction::new();
+ let mut txn = Transaction::new();
txn.add_font_instance(key, font_key, size, None, None, Vec::new());
self.webrender_api
.send_transaction(self.webrender_document, txn);
@@ -765,7 +761,7 @@ impl<Window: WindowMethods + ?Sized> IOCompositor<Window> {
WebrenderMsg::Font(WebrenderFontMsg::AddFont(data, sender)) => {
let font_key = self.webrender_api.generate_font_key();
- let mut txn = webrender_api::Transaction::new();
+ let mut txn = Transaction::new();
match data {
FontData::Raw(bytes) => txn.add_raw_font(font_key, bytes, 0),
FontData::Native(native_font) => txn.add_native_font(font_key, native_font),
@@ -780,14 +776,14 @@ impl<Window: WindowMethods + ?Sized> IOCompositor<Window> {
},
WebrenderMsg::Canvas(WebrenderCanvasMsg::UpdateImages(updates)) => {
- let mut txn = webrender_api::Transaction::new();
+ let mut txn = Transaction::new();
for update in updates {
match update {
ImageUpdate::Add(key, descriptor, data) => {
txn.add_image(key, descriptor, data, None)
},
ImageUpdate::Update(key, descriptor, data) => {
- txn.update_image(key, descriptor, data, &webrender_api::DirtyRect::All)
+ txn.update_image(key, descriptor, data, &DirtyRect::All)
},
ImageUpdate::Delete(key) => txn.delete_image(key),
}
@@ -866,7 +862,7 @@ impl<Window: WindowMethods + ?Sized> IOCompositor<Window> {
};
let pipeline_id = frame_tree.pipeline.id.to_webrender();
- let mut txn = webrender_api::Transaction::new();
+ let mut txn = Transaction::new();
txn.set_root_pipeline(pipeline_id);
txn.generate_frame();
self.webrender_api
@@ -1026,7 +1022,7 @@ impl<Window: WindowMethods + ?Sized> IOCompositor<Window> {
&self,
point: WorldPoint,
flags: HitTestFlags,
- pipeline_id: Option<webrender_api::PipelineId>,
+ pipeline_id: Option<WebRenderPipelineId>,
) -> Vec<CompositorHitTestResult> {
let root_pipeline_id = match self.root_pipeline.id {
Some(root_pipeline_id) => root_pipeline_id,
@@ -1271,7 +1267,7 @@ impl<Window: WindowMethods + ?Sized> IOCompositor<Window> {
};
let cursor = (combined_event.cursor.to_f32() / self.scale).to_untyped();
let cursor = WorldPoint::from_untyped(cursor);
- let mut txn = webrender_api::Transaction::new();
+ let mut txn = Transaction::new();
let result = match self.hit_test_at_point(cursor) {
Some(result) => result,
@@ -1298,7 +1294,7 @@ impl<Window: WindowMethods + ?Sized> IOCompositor<Window> {
if combined_event.magnification != 1.0 {
let old_zoom = self.pinch_zoom_level();
self.set_pinch_zoom_level(old_zoom * combined_event.magnification);
- txn.set_pinch_zoom(webrender_api::ZoomFactor::new(self.pinch_zoom_level()));
+ txn.set_pinch_zoom(ZoomFactor::new(self.pinch_zoom_level()));
}
txn.generate_frame();
self.webrender_api
@@ -1390,9 +1386,9 @@ impl<Window: WindowMethods + ?Sized> IOCompositor<Window> {
}
fn update_page_zoom_for_webrender(&mut self) {
- let page_zoom = webrender_api::ZoomFactor::new(self.page_zoom.get());
+ let page_zoom = ZoomFactor::new(self.page_zoom.get());
- let mut txn = webrender_api::Transaction::new();
+ let mut txn = Transaction::new();
txn.set_page_zoom(page_zoom);
self.webrender_api
.send_transaction(self.webrender_document, txn);
@@ -1464,7 +1460,7 @@ impl<Window: WindowMethods + ?Sized> IOCompositor<Window> {
let mut pipeline_epochs = HashMap::new();
for (id, _) in &self.pipeline_details {
let webrender_pipeline_id = id.to_webrender();
- if let Some(webrender_api::Epoch(epoch)) = self
+ if let Some(WebRenderEpoch(epoch)) = self
.webrender
.current_epoch(self.webrender_document, webrender_pipeline_id)
{
@@ -1613,7 +1609,7 @@ impl<Window: WindowMethods + ?Sized> IOCompositor<Window> {
// For each pending paint metrics pipeline id
for (id, pending_epoch) in &self.pending_paint_metrics {
// we get the last painted frame id from webrender
- if let Some(webrender_api::Epoch(epoch)) = self
+ if let Some(WebRenderEpoch(epoch)) = self
.webrender
.current_epoch(self.webrender_document, id.to_webrender())
{
@@ -1877,7 +1873,7 @@ impl<Window: WindowMethods + ?Sized> IOCompositor<Window> {
flags.toggle(flag);
self.webrender.set_debug_flags(flags);
- let mut txn = webrender_api::Transaction::new();
+ let mut txn = Transaction::new();
txn.generate_frame();
self.webrender_api
.send_transaction(self.webrender_document, txn);
@@ -1909,7 +1905,7 @@ impl<Window: WindowMethods + ?Sized> IOCompositor<Window> {
&revision_file_path
);
self.webrender_api
- .save_capture(capture_path, webrender_api::CaptureBits::all());
+ .save_capture(capture_path, CaptureBits::all());
match File::create(revision_file_path) {
Ok(mut file) => {
diff --git a/components/compositing/compositor_thread.rs b/components/compositing/compositor_thread.rs
index fd0c7d14ded..fc7e7c12bab 100644
--- a/components/compositing/compositor_thread.rs
+++ b/components/compositing/compositor_thread.rs
@@ -20,8 +20,8 @@ use script_traits::{AnimationState, EventResult, MouseButton, MouseEventType};
use std::fmt::{Debug, Error, Formatter};
use std::rc::Rc;
use style_traits::CSSPixel;
-use webrender_api;
use webrender_api::units::{DeviceIntPoint, DeviceIntSize};
+use webrender_api::{self, DocumentId, FontInstanceKey, FontKey, ImageKey, RenderApi};
use webrender_surfman::WebrenderSurfman;
/// Sends messages to the compositor.
@@ -124,16 +124,12 @@ pub enum Msg {
}
pub enum WebrenderFontMsg {
- AddFontInstance(
- webrender_api::FontKey,
- f32,
- Sender<webrender_api::FontInstanceKey>,
- ),
- AddFont(gfx_traits::FontData, Sender<webrender_api::FontKey>),
+ AddFontInstance(FontKey, f32, Sender<FontInstanceKey>),
+ AddFont(gfx_traits::FontData, Sender<FontKey>),
}
pub enum WebrenderCanvasMsg {
- GenerateKey(Sender<webrender_api::ImageKey>),
+ GenerateKey(Sender<ImageKey>),
UpdateImages(Vec<ImageUpdate>),
}
@@ -186,8 +182,8 @@ pub struct InitialCompositorState {
pub mem_profiler_chan: mem::ProfilerChan,
/// Instance of webrender API
pub webrender: webrender::Renderer,
- pub webrender_document: webrender_api::DocumentId,
- pub webrender_api: webrender_api::RenderApi,
+ pub webrender_document: DocumentId,
+ pub webrender_api: RenderApi,
pub webrender_surfman: WebrenderSurfman,
pub webrender_gl: Rc<dyn gleam::gl::Gl>,
pub webxr_main_thread: webxr::MainThreadRegistry,
diff --git a/components/compositing/windowing.rs b/components/compositing/windowing.rs
index 571ff7181a8..efe8d537123 100644
--- a/components/compositing/windowing.rs
+++ b/components/compositing/windowing.rs
@@ -16,8 +16,7 @@ use std::fmt::{Debug, Error, Formatter};
use std::time::Duration;
use style_traits::DevicePixel;
-use webrender_api::units::DevicePoint;
-use webrender_api::units::{DeviceIntPoint, DeviceIntRect, DeviceIntSize};
+use webrender_api::units::{DeviceIntPoint, DeviceIntRect, DeviceIntSize, DevicePoint};
use webrender_api::ScrollLocation;
use webrender_surfman::WebrenderSurfman;
diff --git a/components/constellation/constellation.rs b/components/constellation/constellation.rs
index 6742b6d4aed..5982f5ce76d 100644
--- a/components/constellation/constellation.rs
+++ b/components/constellation/constellation.rs
@@ -178,6 +178,7 @@ use std::sync::{Arc, Mutex};
use std::thread;
use style_traits::CSSPixel;
use webgpu::{self, WebGPU, WebGPURequest};
+use webrender_api::{DocumentId, RenderApi, RenderApiSender};
use webrender_traits::WebrenderExternalImageRegistry;
type PendingApprovalNavigations = HashMap<PipelineId, (LoadData, HistoryEntryReplacement)>;
@@ -221,7 +222,7 @@ struct MessagePortInfo {
/// Webrender related objects required by WebGPU threads
struct WebrenderWGPU {
/// Webrender API.
- webrender_api: webrender_api::RenderApi,
+ webrender_api: RenderApi,
/// List of Webrender external images
webrender_external_images: Arc<Mutex<WebrenderExternalImageRegistry>>,
@@ -394,7 +395,7 @@ pub struct Constellation<Message, LTF, STF, SWF> {
timer_scheduler: TimerScheduler,
/// A single WebRender document the constellation operates on.
- webrender_document: webrender_api::DocumentId,
+ webrender_document: DocumentId,
/// Webrender related objects required by WebGPU threads
webrender_wgpu: WebrenderWGPU,
@@ -543,10 +544,10 @@ pub struct InitialConstellationState {
pub mem_profiler_chan: mem::ProfilerChan,
/// Webrender document ID.
- pub webrender_document: webrender_api::DocumentId,
+ pub webrender_document: DocumentId,
/// Webrender API.
- pub webrender_api_sender: webrender_api::RenderApiSender,
+ pub webrender_api_sender: RenderApiSender,
/// Webrender external images
pub webrender_external_images: Arc<Mutex<WebrenderExternalImageRegistry>>,
diff --git a/components/constellation/pipeline.rs b/components/constellation/pipeline.rs
index 7f2983501af..df05d709924 100644
--- a/components/constellation/pipeline.rs
+++ b/components/constellation/pipeline.rs
@@ -48,6 +48,7 @@ use std::collections::{HashMap, HashSet};
use std::rc::Rc;
use std::sync::atomic::AtomicBool;
use std::sync::Arc;
+use webrender_api::DocumentId;
/// A `Pipeline` is the constellation's view of a `Document`. Each pipeline has an
/// event loop (executed by a script thread) and a layout thread. A script thread
@@ -190,7 +191,7 @@ pub struct InitialPipelineState {
pub webrender_api_sender: script_traits::WebrenderIpcSender,
/// The ID of the document processed by this script thread.
- pub webrender_document: webrender_api::DocumentId,
+ pub webrender_document: DocumentId,
/// A channel to the WebGL thread.
pub webgl_chan: Option<WebGLPipeline>,
@@ -514,7 +515,7 @@ pub struct UnprivilegedPipelineContent {
pipeline_namespace_id: PipelineNamespaceId,
webrender_api_sender: script_traits::WebrenderIpcSender,
webrender_image_api_sender: net_traits::WebrenderIpcSender,
- webrender_document: webrender_api::DocumentId,
+ webrender_document: DocumentId,
webgl_chan: Option<WebGLPipeline>,
webxr_registry: webxr_api::Registry,
player_context: WindowGLContext,
diff --git a/components/gfx/font.rs b/components/gfx/font.rs
index 05ffb897a4e..7feb66fcaa3 100644
--- a/components/gfx/font.rs
+++ b/components/gfx/font.rs
@@ -27,6 +27,7 @@ use style::computed_values::{font_stretch, font_style, font_variant_caps, font_w
use style::properties::style_structs::Font as FontStyleStruct;
use style::values::computed::font::{GenericFontFamily, SingleFontFamily};
use unicode_script::Script;
+use webrender_api::FontInstanceKey;
macro_rules! ot_tag {
($t1:expr, $t2:expr, $t3:expr, $t4:expr) => {
@@ -145,7 +146,7 @@ pub struct Font {
shaper: Option<Shaper>,
shape_cache: RefCell<HashMap<ShapeCacheEntry, Arc<GlyphStore>>>,
glyph_advance_cache: RefCell<HashMap<u32, FractionalPixel>>,
- pub font_key: webrender_api::FontInstanceKey,
+ pub font_key: FontInstanceKey,
}
impl Font {
@@ -153,7 +154,7 @@ impl Font {
handle: FontHandle,
descriptor: FontDescriptor,
actual_pt_size: Au,
- font_key: webrender_api::FontInstanceKey,
+ font_key: FontInstanceKey,
) -> Font {
let metrics = handle.metrics();
diff --git a/components/gfx/font_cache_thread.rs b/components/gfx/font_cache_thread.rs
index f6d375e883b..325018102c9 100644
--- a/components/gfx/font_cache_thread.rs
+++ b/components/gfx/font_cache_thread.rs
@@ -25,6 +25,7 @@ use std::sync::{Arc, Mutex};
use std::{f32, fmt, mem, thread};
use style::font_face::{EffectiveSources, Source};
use style::values::computed::font::FamilyName;
+use webrender_api::{FontInstanceKey, FontKey};
/// A list of font templates that make up a given font family.
pub struct FontTemplates {
@@ -34,13 +35,13 @@ pub struct FontTemplates {
#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct FontTemplateInfo {
pub font_template: Arc<FontTemplateData>,
- pub font_key: webrender_api::FontKey,
+ pub font_key: FontKey,
}
#[derive(Debug, Deserialize, Serialize)]
pub struct SerializedFontTemplateInfo {
pub serialized_font_template: SerializedFontTemplate,
- pub font_key: webrender_api::FontKey,
+ pub font_key: FontKey,
}
#[derive(Debug, Deserialize, Serialize)]
@@ -128,11 +129,7 @@ pub enum Command {
FontFamilyDescriptor,
IpcSender<Reply>,
),
- GetFontInstance(
- webrender_api::FontKey,
- Au,
- IpcSender<webrender_api::FontInstanceKey>,
- ),
+ GetFontInstance(FontKey, Au, IpcSender<FontInstanceKey>),
AddWebFont(LowercaseString, EffectiveSources, IpcSender<()>),
AddDownloadedWebFont(LowercaseString, ServoUrl, Vec<u8>, IpcSender<()>),
Exit(IpcSender<()>),
@@ -156,8 +153,8 @@ struct FontCache {
font_context: FontContextHandle,
core_resource_thread: CoreResourceThread,
webrender_api: Box<dyn WebrenderApi>,
- webrender_fonts: HashMap<Atom, webrender_api::FontKey>,
- font_instances: HashMap<(webrender_api::FontKey, Au), webrender_api::FontInstanceKey>,
+ webrender_fonts: HashMap<Atom, FontKey>,
+ font_instances: HashMap<(FontKey, Au), FontInstanceKey>,
}
fn populate_generic_fonts() -> HashMap<FontFamilyName, LowercaseString> {
@@ -536,11 +533,7 @@ impl FontCacheThread {
}
impl FontSource for FontCacheThread {
- fn get_font_instance(
- &mut self,
- key: webrender_api::FontKey,
- size: Au,
- ) -> webrender_api::FontInstanceKey {
+ fn get_font_instance(&mut self, key: FontKey, size: Au) -> FontInstanceKey {
let (response_chan, response_port) = ipc::channel().expect("failed to create IPC channel");
self.chan
.send(Command::GetFontInstance(key, size, response_chan))
diff --git a/components/gfx/font_context.rs b/components/gfx/font_context.rs
index 113b384f84d..6a975e6b12f 100644
--- a/components/gfx/font_context.rs
+++ b/components/gfx/font_context.rs
@@ -21,6 +21,7 @@ use std::rc::Rc;
use std::sync::atomic::{AtomicUsize, Ordering};
use style::computed_values::font_variant_caps::T as FontVariantCaps;
use style::properties::style_structs::Font as FontStyleStruct;
+use webrender_api::{FontInstanceKey, FontKey};
static SMALL_CAPS_SCALE_FACTOR: f32 = 0.8; // Matches FireFox (see gfxFont.h)
@@ -29,11 +30,7 @@ static SMALL_CAPS_SCALE_FACTOR: f32 = 0.8; // Matches FireFox (see gfxFont.h)
static FONT_CACHE_EPOCH: AtomicUsize = AtomicUsize::new(0);
pub trait FontSource {
- fn get_font_instance(
- &mut self,
- key: webrender_api::FontKey,
- size: Au,
- ) -> webrender_api::FontInstanceKey;
+ fn get_font_instance(&mut self, key: FontKey, size: Au) -> FontInstanceKey;
fn font_template(
&mut self,
diff --git a/components/gfx/tests/font_context.rs b/components/gfx/tests/font_context.rs
index 796f693f418..72dbb7a0bb8 100644
--- a/components/gfx/tests/font_context.rs
+++ b/components/gfx/tests/font_context.rs
@@ -24,6 +24,7 @@ use style::values::computed::font::{
};
use style::values::computed::font::{FontStretch, FontWeight, SingleFontFamily};
use style::values::generics::font::FontStyle;
+use webrender_api::{FontInstanceKey, FontKey, IdNamespace};
struct TestFontSource {
handle: FontContextHandle,
@@ -68,12 +69,8 @@ impl TestFontSource {
}
impl FontSource for TestFontSource {
- fn get_font_instance(
- &mut self,
- _key: webrender_api::FontKey,
- _size: Au,
- ) -> webrender_api::FontInstanceKey {
- webrender_api::FontInstanceKey(webrender_api::IdNamespace(0), 0)
+ fn get_font_instance(&mut self, _key: FontKey, _size: Au) -> FontInstanceKey {
+ FontInstanceKey(IdNamespace(0), 0)
}
fn font_template(
@@ -89,7 +86,7 @@ impl FontSource for TestFontSource {
.and_then(|family| family.find_font_for_style(&template_descriptor, handle))
.map(|template| FontTemplateInfo {
font_template: template,
- font_key: webrender_api::FontKey(webrender_api::IdNamespace(0), 0),
+ font_key: FontKey(IdNamespace(0), 0),
})
}
}
diff --git a/components/gfx/text/text_run.rs b/components/gfx/text/text_run.rs
index 17eb5bf623a..cf340a2e3dc 100644
--- a/components/gfx/text/text_run.rs
+++ b/components/gfx/text/text_run.rs
@@ -14,6 +14,7 @@ use std::slice::Iter;
use std::sync::Arc;
use style::str::char_is_whitespace;
use unicode_bidi as bidi;
+use webrender_api::FontInstanceKey;
use xi_unicode::LineBreakLeafIter;
thread_local! {
@@ -29,7 +30,7 @@ pub struct TextRun {
pub font_template: Arc<FontTemplateData>,
pub actual_pt_size: Au,
pub font_metrics: FontMetrics,
- pub font_key: webrender_api::FontInstanceKey,
+ pub font_key: FontInstanceKey,
/// The glyph runs that make up this text run.
pub glyphs: Arc<Vec<GlyphRun>>,
pub bidi_level: bidi::Level,
diff --git a/components/gfx_traits/lib.rs b/components/gfx_traits/lib.rs
index a7fae65f87e..a20c5a0c34c 100644
--- a/components/gfx_traits/lib.rs
+++ b/components/gfx_traits/lib.rs
@@ -17,6 +17,7 @@ pub mod print_tree;
use range::RangeIndex;
use std::sync::atomic::{AtomicUsize, Ordering};
+use webrender_api::{Epoch as WebRenderEpoch, FontInstanceKey, FontKey, NativeFontHandle};
/// A newtype struct for denoting the age of messages; prevents race conditions.
#[derive(Clone, Copy, Debug, Deserialize, Eq, Hash, Ord, PartialEq, PartialOrd, Serialize)]
@@ -28,9 +29,9 @@ impl Epoch {
}
}
-impl Into<webrender_api::Epoch> for Epoch {
- fn into(self) -> webrender_api::Epoch {
- webrender_api::Epoch(self.0)
+impl Into<WebRenderEpoch> for Epoch {
+ fn into(self) -> WebRenderEpoch {
+ WebRenderEpoch(self.0)
}
}
@@ -112,14 +113,10 @@ pub fn node_id_from_scroll_id(id: usize) -> Option<usize> {
pub enum FontData {
Raw(Vec<u8>),
- Native(webrender_api::NativeFontHandle),
+ Native(NativeFontHandle),
}
pub trait WebrenderApi {
- fn add_font_instance(
- &self,
- font_key: webrender_api::FontKey,
- size: f32,
- ) -> webrender_api::FontInstanceKey;
- fn add_font(&self, data: FontData) -> webrender_api::FontKey;
+ fn add_font_instance(&self, font_key: FontKey, size: f32) -> FontInstanceKey;
+ fn add_font(&self, data: FontData) -> FontKey;
}
diff --git a/components/layout/display_list/webrender_helpers.rs b/components/layout/display_list/webrender_helpers.rs
index d84ce7739b7..4605b6b0a2f 100644
--- a/components/layout/display_list/webrender_helpers.rs
+++ b/components/layout/display_list/webrender_helpers.rs
@@ -258,7 +258,7 @@ impl DisplayItem {
let stacking_context = &item.stacking_context;
debug_assert_eq!(stacking_context.context_type, StackingContextType::Real);
- //let mut info = webrender_api::LayoutPrimitiveInfo::new(stacking_context.bounds);
+ //let mut info = LayoutPrimitiveInfo::new(stacking_context.bounds);
let mut bounds = stacking_context.bounds;
let spatial_id =
if let Some(frame_index) = stacking_context.established_reference_frame {
diff --git a/components/layout/fragment.rs b/components/layout/fragment.rs
index ed2cd58cdab..5cf56b6cbdf 100644
--- a/components/layout/fragment.rs
+++ b/components/layout/fragment.rs
@@ -64,8 +64,8 @@ use style::values::computed::counters::ContentItem;
use style::values::computed::{Length, Size, VerticalAlign};
use style::values::generics::box_::{Perspective, VerticalAlignKeyword};
use style::values::generics::transform;
-use webrender_api;
use webrender_api::units::LayoutTransform;
+use webrender_api::{self, ImageKey};
// From gfxFontConstants.h in Firefox.
static FONT_SUBSCRIPT_OFFSET_RATIO: f32 = 0.20;
@@ -336,9 +336,9 @@ impl InlineAbsoluteFragmentInfo {
#[derive(Clone)]
pub enum CanvasFragmentSource {
- WebGL(webrender_api::ImageKey),
+ WebGL(ImageKey),
Image(Option<Arc<Mutex<IpcSender<CanvasMsg>>>>),
- WebGPU(webrender_api::ImageKey),
+ WebGPU(ImageKey),
}
#[derive(Clone)]
diff --git a/components/layout/sequential.rs b/components/layout/sequential.rs
index 9de4dada75b..d8b4f19b430 100644
--- a/components/layout/sequential.rs
+++ b/components/layout/sequential.rs
@@ -20,7 +20,7 @@ use euclid::default::{Point2D, Rect, Size2D, Vector2D};
use servo_config::opts;
use style::servo::restyle_damage::ServoRestyleDamage;
use webrender_api::units::LayoutPoint;
-use webrender_api::PropertyBinding;
+use webrender_api::{ColorF, PropertyBinding, RectangleDisplayItem};
pub fn resolve_generated_content(root: &mut dyn Flow, layout_context: &LayoutContext) {
ResolveGeneratedContent::new(&layout_context).traverse(root, 0);
@@ -75,7 +75,7 @@ pub fn reflow(root: &mut dyn Flow, layout_context: &LayoutContext, relayout_mode
pub fn build_display_list_for_subtree<'a>(
flow_root: &mut dyn Flow,
layout_context: &'a LayoutContext,
- background_color: webrender_api::ColorF,
+ background_color: ColorF,
client_size: Size2D<Au>,
) -> DisplayListBuildState<'a> {
let mut state = StackingContextCollectionState::new(layout_context.id);
@@ -94,7 +94,7 @@ pub fn build_display_list_for_subtree<'a>(
);
state.add_display_item(DisplayItem::Rectangle(CommonDisplayItem::new(
base,
- webrender_api::RectangleDisplayItem {
+ RectangleDisplayItem {
color: PropertyBinding::Value(background_color),
common: items::empty_common_item_properties(),
bounds: bounds.to_layout(),
diff --git a/components/layout_2020/display_list/conversions.rs b/components/layout_2020/display_list/conversions.rs
index 0b6dff8506c..859b5b5ce2e 100644
--- a/components/layout_2020/display_list/conversions.rs
+++ b/components/layout_2020/display_list/conversions.rs
@@ -8,7 +8,7 @@ use style::computed_values::text_decoration_style::T as ComputedTextDecorationSt
use style::computed_values::transform_style::T as ComputedTransformStyle;
use style::values::computed::Filter as ComputedFilter;
use style::values::computed::Length;
-use webrender_api as wr;
+use webrender_api::{units, FilterOp, LineStyle, MixBlendMode, TransformStyle};
pub trait ToWebRender {
type Type;
@@ -16,18 +16,18 @@ pub trait ToWebRender {
}
impl ToWebRender for ComputedFilter {
- type Type = wr::FilterOp;
+ type Type = FilterOp;
fn to_webrender(&self) -> Self::Type {
match *self {
- ComputedFilter::Blur(radius) => wr::FilterOp::Blur(radius.px()),
- ComputedFilter::Brightness(amount) => wr::FilterOp::Brightness(amount.0),
- ComputedFilter::Contrast(amount) => wr::FilterOp::Contrast(amount.0),
- ComputedFilter::Grayscale(amount) => wr::FilterOp::Grayscale(amount.0),
- ComputedFilter::HueRotate(angle) => wr::FilterOp::HueRotate(angle.radians()),
- ComputedFilter::Invert(amount) => wr::FilterOp::Invert(amount.0),
- ComputedFilter::Opacity(amount) => wr::FilterOp::Opacity(amount.0.into(), amount.0),
- ComputedFilter::Saturate(amount) => wr::FilterOp::Saturate(amount.0),
- ComputedFilter::Sepia(amount) => wr::FilterOp::Sepia(amount.0),
+ ComputedFilter::Blur(radius) => FilterOp::Blur(radius.px()),
+ ComputedFilter::Brightness(amount) => FilterOp::Brightness(amount.0),
+ ComputedFilter::Contrast(amount) => FilterOp::Contrast(amount.0),
+ ComputedFilter::Grayscale(amount) => FilterOp::Grayscale(amount.0),
+ ComputedFilter::HueRotate(angle) => FilterOp::HueRotate(angle.radians()),
+ ComputedFilter::Invert(amount) => FilterOp::Invert(amount.0),
+ ComputedFilter::Opacity(amount) => FilterOp::Opacity(amount.0.into(), amount.0),
+ ComputedFilter::Saturate(amount) => FilterOp::Saturate(amount.0),
+ ComputedFilter::Sepia(amount) => FilterOp::Sepia(amount.0),
// Statically check that DropShadow is impossible.
ComputedFilter::DropShadow(ref shadow) => match *shadow {},
// Statically check that Url is impossible.
@@ -36,64 +36,64 @@ impl ToWebRender for ComputedFilter {
}
}
impl ToWebRender for ComputedMixBlendMode {
- type Type = wr::MixBlendMode;
+ type Type = MixBlendMode;
fn to_webrender(&self) -> Self::Type {
match *self {
- ComputedMixBlendMode::Normal => wr::MixBlendMode::Normal,
- ComputedMixBlendMode::Multiply => wr::MixBlendMode::Multiply,
- ComputedMixBlendMode::Screen => wr::MixBlendMode::Screen,
- ComputedMixBlendMode::Overlay => wr::MixBlendMode::Overlay,
- ComputedMixBlendMode::Darken => wr::MixBlendMode::Darken,
- ComputedMixBlendMode::Lighten => wr::MixBlendMode::Lighten,
- ComputedMixBlendMode::ColorDodge => wr::MixBlendMode::ColorDodge,
- ComputedMixBlendMode::ColorBurn => wr::MixBlendMode::ColorBurn,
- ComputedMixBlendMode::HardLight => wr::MixBlendMode::HardLight,
- ComputedMixBlendMode::SoftLight => wr::MixBlendMode::SoftLight,
- ComputedMixBlendMode::Difference => wr::MixBlendMode::Difference,
- ComputedMixBlendMode::Exclusion => wr::MixBlendMode::Exclusion,
- ComputedMixBlendMode::Hue => wr::MixBlendMode::Hue,
- ComputedMixBlendMode::Saturation => wr::MixBlendMode::Saturation,
- ComputedMixBlendMode::Color => wr::MixBlendMode::Color,
- ComputedMixBlendMode::Luminosity => wr::MixBlendMode::Luminosity,
+ ComputedMixBlendMode::Normal => MixBlendMode::Normal,
+ ComputedMixBlendMode::Multiply => MixBlendMode::Multiply,
+ ComputedMixBlendMode::Screen => MixBlendMode::Screen,
+ ComputedMixBlendMode::Overlay => MixBlendMode::Overlay,
+ ComputedMixBlendMode::Darken => MixBlendMode::Darken,
+ ComputedMixBlendMode::Lighten => MixBlendMode::Lighten,
+ ComputedMixBlendMode::ColorDodge => MixBlendMode::ColorDodge,
+ ComputedMixBlendMode::ColorBurn => MixBlendMode::ColorBurn,
+ ComputedMixBlendMode::HardLight => MixBlendMode::HardLight,
+ ComputedMixBlendMode::SoftLight => MixBlendMode::SoftLight,
+ ComputedMixBlendMode::Difference => MixBlendMode::Difference,
+ ComputedMixBlendMode::Exclusion => MixBlendMode::Exclusion,
+ ComputedMixBlendMode::Hue => MixBlendMode::Hue,
+ ComputedMixBlendMode::Saturation => MixBlendMode::Saturation,
+ ComputedMixBlendMode::Color => MixBlendMode::Color,
+ ComputedMixBlendMode::Luminosity => MixBlendMode::Luminosity,
}
}
}
impl ToWebRender for ComputedTransformStyle {
- type Type = wr::TransformStyle;
+ type Type = TransformStyle;
fn to_webrender(&self) -> Self::Type {
match *self {
- ComputedTransformStyle::Flat => wr::TransformStyle::Flat,
- ComputedTransformStyle::Preserve3d => wr::TransformStyle::Preserve3D,
+ ComputedTransformStyle::Flat => TransformStyle::Flat,
+ ComputedTransformStyle::Preserve3d => TransformStyle::Preserve3D,
}
}
}
impl ToWebRender for PhysicalPoint<Length> {
- type Type = webrender_api::units::LayoutPoint;
+ type Type = units::LayoutPoint;
fn to_webrender(&self) -> Self::Type {
- webrender_api::units::LayoutPoint::new(self.x.px(), self.y.px())
+ units::LayoutPoint::new(self.x.px(), self.y.px())
}
}
impl ToWebRender for PhysicalSize<Length> {
- type Type = webrender_api::units::LayoutSize;
+ type Type = units::LayoutSize;
fn to_webrender(&self) -> Self::Type {
- webrender_api::units::LayoutSize::new(self.width.px(), self.height.px())
+ units::LayoutSize::new(self.width.px(), self.height.px())
}
}
impl ToWebRender for PhysicalRect<Length> {
- type Type = webrender_api::units::LayoutRect;
+ type Type = units::LayoutRect;
fn to_webrender(&self) -> Self::Type {
- webrender_api::units::LayoutRect::new(self.origin.to_webrender(), self.size.to_webrender())
+ units::LayoutRect::new(self.origin.to_webrender(), self.size.to_webrender())
}
}
impl ToWebRender for PhysicalSides<Length> {
- type Type = webrender_api::units::LayoutSideOffsets;
+ type Type = units::LayoutSideOffsets;
fn to_webrender(&self) -> Self::Type {
- webrender_api::units::LayoutSideOffsets::new(
+ units::LayoutSideOffsets::new(
self.top.px(),
self.right.px(),
self.bottom.px(),
@@ -103,14 +103,14 @@ impl ToWebRender for PhysicalSides<Length> {
}
impl ToWebRender for ComputedTextDecorationStyle {
- type Type = webrender_api::LineStyle;
+ type Type = LineStyle;
fn to_webrender(&self) -> Self::Type {
match *self {
- ComputedTextDecorationStyle::Solid => wr::LineStyle::Solid,
- ComputedTextDecorationStyle::Dotted => wr::LineStyle::Dotted,
- ComputedTextDecorationStyle::Dashed => wr::LineStyle::Dashed,
- ComputedTextDecorationStyle::Wavy => wr::LineStyle::Wavy,
- _ => wr::LineStyle::Solid,
+ ComputedTextDecorationStyle::Solid => LineStyle::Solid,
+ ComputedTextDecorationStyle::Dotted => LineStyle::Dotted,
+ ComputedTextDecorationStyle::Dashed => LineStyle::Dashed,
+ ComputedTextDecorationStyle::Wavy => LineStyle::Wavy,
+ _ => LineStyle::Solid,
}
}
}
diff --git a/components/layout_2020/display_list/gradient.rs b/components/layout_2020/display_list/gradient.rs
index bc057330023..c9738da49be 100644
--- a/components/layout_2020/display_list/gradient.rs
+++ b/components/layout_2020/display_list/gradient.rs
@@ -66,7 +66,7 @@ pub(super) fn build_linear(
) {
use style::values::specified::position::HorizontalPositionKeyword::*;
use style::values::specified::position::VerticalPositionKeyword::*;
- use webrender_api::units::LayoutVector2D as Vec2;
+ use units::LayoutVector2D as Vec2;
let gradient_box = layer.tile_size;
// A vector of length 1.0 in the direction of the gradient line
diff --git a/components/layout_2020/display_list/mod.rs b/components/layout_2020/display_list/mod.rs
index b06308a4e84..da65577f34c 100644
--- a/components/layout_2020/display_list/mod.rs
+++ b/components/layout_2020/display_list/mod.rs
@@ -42,7 +42,7 @@ pub struct WebRenderImageInfo {
pub key: Option<wr::ImageKey>,
}
-// `webrender_api::display_item::ItemTag` is private
+// webrender's `ItemTag` is private.
type ItemTag = (u64, u16);
type HitInfo = Option<ItemTag>;
diff --git a/components/layout_2020/fragment_tree/fragment_tree.rs b/components/layout_2020/fragment_tree/fragment_tree.rs
index 6234d9e3390..799eddc3dbd 100644
--- a/components/layout_2020/fragment_tree/fragment_tree.rs
+++ b/components/layout_2020/fragment_tree/fragment_tree.rs
@@ -14,6 +14,7 @@ use gfx_traits::print_tree::PrintTree;
use style::animation::AnimationSetKey;
use style::dom::OpaqueNode;
use style::values::computed::Length;
+use webrender_api::units;
#[derive(Serialize)]
pub struct FragmentTree {
@@ -61,8 +62,8 @@ impl FragmentTree {
}
}
- pub fn scrollable_overflow(&self) -> webrender_api::units::LayoutSize {
- webrender_api::units::LayoutSize::from_untyped(Size2D::new(
+ pub fn scrollable_overflow(&self) -> units::LayoutSize {
+ units::LayoutSize::from_untyped(Size2D::new(
self.scrollable_overflow.size.width.px(),
self.scrollable_overflow.size.height.px(),
))
diff --git a/components/layout_2020/query.rs b/components/layout_2020/query.rs
index d766709f6f8..a2524bb6bcd 100644
--- a/components/layout_2020/query.rs
+++ b/components/layout_2020/query.rs
@@ -34,14 +34,14 @@ use style::values::generics::text::LineHeight;
use style_traits::CSSPixel;
use style_traits::ToCss;
use webrender_api::units::LayoutPixel;
-use webrender_api::ExternalScrollId;
+use webrender_api::{DisplayListBuilder, ExternalScrollId};
/// Mutable data belonging to the LayoutThread.
///
/// This needs to be protected by a mutex so we can do fast RPCs.
pub struct LayoutThreadData {
/// The root stacking context.
- pub display_list: Option<webrender_api::DisplayListBuilder>,
+ pub display_list: Option<DisplayListBuilder>,
/// A queued response for the union of the content boxes of a node.
pub content_box_response: Option<Rect<Au>>,
diff --git a/components/layout_thread/lib.rs b/components/layout_thread/lib.rs
index 4ada89155ee..3d0bc1a1cc7 100644
--- a/components/layout_thread/lib.rs
+++ b/components/layout_thread/lib.rs
@@ -117,6 +117,7 @@ use style::traversal_flags::TraversalFlags;
use style_traits::CSSPixel;
use style_traits::DevicePixel;
use style_traits::SpeculativePainter;
+use webrender_api::{units, ColorF, HitTestFlags, ScrollClamping};
/// Information needed by the layout thread.
pub struct LayoutThread {
@@ -1060,7 +1061,7 @@ impl LayoutThread {
debug!("Layout done!");
- let viewport_size = webrender_api::units::LayoutSize::new(
+ let viewport_size = units::LayoutSize::new(
self.viewport_size.width.to_f32_px(),
self.viewport_size.height.to_f32_px(),
);
@@ -1471,15 +1472,15 @@ impl LayoutThread {
&QueryMsg::StyleQuery => {},
&QueryMsg::NodesFromPointQuery(client_point, ref reflow_goal) => {
let mut flags = match reflow_goal {
- &NodesFromPointQueryType::Topmost => webrender_api::HitTestFlags::empty(),
- &NodesFromPointQueryType::All => webrender_api::HitTestFlags::FIND_ALL,
+ &NodesFromPointQueryType::Topmost => HitTestFlags::empty(),
+ &NodesFromPointQueryType::All => HitTestFlags::FIND_ALL,
};
// The point we get is not relative to the entire WebRender scene, but to this
// particular pipeline, so we need to tell WebRender about that.
- flags.insert(webrender_api::HitTestFlags::POINT_RELATIVE_TO_PIPELINE_VIEWPORT);
+ flags.insert(HitTestFlags::POINT_RELATIVE_TO_PIPELINE_VIEWPORT);
- let client_point = webrender_api::units::WorldPoint::from_untyped(client_point);
+ let client_point = units::WorldPoint::from_untyped(client_point);
let results = self.webrender_api.hit_test(
Some(self.id.to_webrender()),
client_point,
@@ -1516,9 +1517,9 @@ impl LayoutThread {
let point = Point2D::new(-state.scroll_offset.x, -state.scroll_offset.y);
self.webrender_api.send_scroll_node(
- webrender_api::units::LayoutPoint::from_untyped(point),
+ units::LayoutPoint::from_untyped(point),
state.scroll_id,
- webrender_api::ScrollClamping::ToContentBounds,
+ ScrollClamping::ToContentBounds,
);
}
@@ -1769,8 +1770,8 @@ impl ProfilerMetadataFactory for LayoutThread {
// clearing the frame buffer to white. This ensures that setting a background
// color on an iframe element, while the iframe content itself has a default
// transparent background color is handled correctly.
-fn get_root_flow_background_color(flow: &mut dyn Flow) -> webrender_api::ColorF {
- let transparent = webrender_api::ColorF {
+fn get_root_flow_background_color(flow: &mut dyn Flow) -> ColorF {
+ let transparent = ColorF {
r: 0.0,
g: 0.0,
b: 0.0,
@@ -1797,7 +1798,7 @@ fn get_root_flow_background_color(flow: &mut dyn Flow) -> webrender_api::ColorF
.get_background()
.background_color,
);
- webrender_api::ColorF::new(
+ ColorF::new(
color.red_f32(),
color.green_f32(),
color.blue_f32(),
diff --git a/components/layout_thread_2020/lib.rs b/components/layout_thread_2020/lib.rs
index b0b09a7cefb..955faa68597 100644
--- a/components/layout_thread_2020/lib.rs
+++ b/components/layout_thread_2020/lib.rs
@@ -100,6 +100,7 @@ use style::traversal_flags::TraversalFlags;
use style_traits::CSSPixel;
use style_traits::DevicePixel;
use style_traits::SpeculativePainter;
+use webrender_api::{units, HitTestFlags, ScrollClamping};
/// Information needed by the layout thread.
pub struct LayoutThread {
@@ -1136,15 +1137,15 @@ impl LayoutThread {
&QueryMsg::StyleQuery => {},
&QueryMsg::NodesFromPointQuery(client_point, ref reflow_goal) => {
let mut flags = match reflow_goal {
- &NodesFromPointQueryType::Topmost => webrender_api::HitTestFlags::empty(),
- &NodesFromPointQueryType::All => webrender_api::HitTestFlags::FIND_ALL,
+ &NodesFromPointQueryType::Topmost => HitTestFlags::empty(),
+ &NodesFromPointQueryType::All => HitTestFlags::FIND_ALL,
};
// The point we get is not relative to the entire WebRender scene, but to this
// particular pipeline, so we need to tell WebRender about that.
- flags.insert(webrender_api::HitTestFlags::POINT_RELATIVE_TO_PIPELINE_VIEWPORT);
+ flags.insert(HitTestFlags::POINT_RELATIVE_TO_PIPELINE_VIEWPORT);
- let client_point = webrender_api::units::WorldPoint::from_untyped(client_point);
+ let client_point = units::WorldPoint::from_untyped(client_point);
let results = self.webrender_api.hit_test(
Some(self.id.to_webrender()),
client_point,
@@ -1178,9 +1179,9 @@ impl LayoutThread {
let point = Point2D::new(-state.scroll_offset.x, -state.scroll_offset.y);
self.webrender_api.send_scroll_node(
- webrender_api::units::LayoutPoint::from_untyped(point),
+ units::LayoutPoint::from_untyped(point),
state.scroll_id,
- webrender_api::ScrollClamping::ToContentBounds,
+ ScrollClamping::ToContentBounds,
);
}
@@ -1248,7 +1249,7 @@ impl LayoutThread {
epoch.next();
self.epoch.set(epoch);
- let viewport_size = webrender_api::units::LayoutSize::from_untyped(Size2D::new(
+ let viewport_size = units::LayoutSize::from_untyped(Size2D::new(
self.viewport_size.width.to_f32_px(),
self.viewport_size.height.to_f32_px(),
));
diff --git a/components/malloc_size_of/lib.rs b/components/malloc_size_of/lib.rs
index 2a684ac73d1..8a2b0f19fd8 100644
--- a/components/malloc_size_of/lib.rs
+++ b/components/malloc_size_of/lib.rs
@@ -58,6 +58,12 @@ use std::os::raw::c_void;
#[cfg(feature = "servo")]
use uuid::Uuid;
use void::Void;
+use webrender_api::{
+ BorderRadius, BorderStyle, BoxShadowClipMode, ColorF, ComplexClipRegion, ExtendMode,
+ ExternalScrollId, FilterOp, FontInstanceKey, GlyphInstance, GradientStop, ImageKey,
+ ImageRendering, LineStyle, MixBlendMode, NinePatchBorder, NormalBorder, RepeatMode,
+ ScrollSensitivity, StickyOffsetBounds, TransformStyle,
+};
/// A C function that takes a pointer to a heap allocation and returns its size.
type VoidPtrToSizeFn = unsafe extern "C" fn(ptr: *const c_void) -> usize;
@@ -800,47 +806,47 @@ impl MallocSizeOf for url::Host {
}
}
#[cfg(feature = "webrender_api")]
-malloc_size_of_is_0!(webrender_api::BorderRadius);
+malloc_size_of_is_0!(BorderRadius);
#[cfg(feature = "webrender_api")]
-malloc_size_of_is_0!(webrender_api::BorderStyle);
+malloc_size_of_is_0!(BorderStyle);
#[cfg(feature = "webrender_api")]
-malloc_size_of_is_0!(webrender_api::BoxShadowClipMode);
+malloc_size_of_is_0!(BoxShadowClipMode);
#[cfg(feature = "webrender_api")]
-malloc_size_of_is_0!(webrender_api::ColorF);
+malloc_size_of_is_0!(ColorF);
#[cfg(feature = "webrender_api")]
-malloc_size_of_is_0!(webrender_api::ComplexClipRegion);
+malloc_size_of_is_0!(ComplexClipRegion);
#[cfg(feature = "webrender_api")]
-malloc_size_of_is_0!(webrender_api::ExtendMode);
+malloc_size_of_is_0!(ExtendMode);
#[cfg(feature = "webrender_api")]
-malloc_size_of_is_0!(webrender_api::FilterOp);
+malloc_size_of_is_0!(FilterOp);
#[cfg(feature = "webrender_api")]
-malloc_size_of_is_0!(webrender_api::ExternalScrollId);
+malloc_size_of_is_0!(ExternalScrollId);
#[cfg(feature = "webrender_api")]
-malloc_size_of_is_0!(webrender_api::FontInstanceKey);
+malloc_size_of_is_0!(FontInstanceKey);
#[cfg(feature = "webrender_api")]
-malloc_size_of_is_0!(webrender_api::GradientStop);
+malloc_size_of_is_0!(GradientStop);
#[cfg(feature = "webrender_api")]
-malloc_size_of_is_0!(webrender_api::GlyphInstance);
+malloc_size_of_is_0!(GlyphInstance);
#[cfg(feature = "webrender_api")]
-malloc_size_of_is_0!(webrender_api::NinePatchBorder);
+malloc_size_of_is_0!(NinePatchBorder);
#[cfg(feature = "webrender_api")]
-malloc_size_of_is_0!(webrender_api::ImageKey);
+malloc_size_of_is_0!(ImageKey);
#[cfg(feature = "webrender_api")]
-malloc_size_of_is_0!(webrender_api::ImageRendering);
+malloc_size_of_is_0!(ImageRendering);
#[cfg(feature = "webrender_api")]
-malloc_size_of_is_0!(webrender_api::LineStyle);
+malloc_size_of_is_0!(LineStyle);
#[cfg(feature = "webrender_api")]
-malloc_size_of_is_0!(webrender_api::MixBlendMode);
+malloc_size_of_is_0!(MixBlendMode);
#[cfg(feature = "webrender_api")]
-malloc_size_of_is_0!(webrender_api::NormalBorder);
+malloc_size_of_is_0!(NormalBorder);
#[cfg(feature = "webrender_api")]
-malloc_size_of_is_0!(webrender_api::RepeatMode);
+malloc_size_of_is_0!(RepeatMode);
#[cfg(feature = "webrender_api")]
-malloc_size_of_is_0!(webrender_api::ScrollSensitivity);
+malloc_size_of_is_0!(ScrollSensitivity);
#[cfg(feature = "webrender_api")]
-malloc_size_of_is_0!(webrender_api::StickyOffsetBounds);
+malloc_size_of_is_0!(StickyOffsetBounds);
#[cfg(feature = "webrender_api")]
-malloc_size_of_is_0!(webrender_api::TransformStyle);
+malloc_size_of_is_0!(TransformStyle);
#[cfg(feature = "servo")]
impl MallocSizeOf for keyboard_types::Key {
diff --git a/components/media/media_thread.rs b/components/media/media_thread.rs
index 41bbaa6e99f..a5c889a6286 100644
--- a/components/media/media_thread.rs
+++ b/components/media/media_thread.rs
@@ -9,6 +9,7 @@ use crate::{GLPlayerMsg, GLPlayerMsgForward};
use fnv::FnvHashMap;
use std::sync::{Arc, Mutex};
use std::thread;
+use webrender_api::ExternalImageId;
use webrender_traits::{WebrenderExternalImageRegistry, WebrenderImageHandlerType};
/// A GLPlayerThread manages the life cycle and message demultiplexing of
@@ -69,7 +70,7 @@ impl GLPlayerThread {
self.external_images
.lock()
.unwrap()
- .remove(&webrender_api::ExternalImageId(id));
+ .remove(&ExternalImageId(id));
if self.players.remove(&id).is_none() {
warn!("Tried to remove an unknown player");
}
diff --git a/components/msg/constellation_msg.rs b/components/msg/constellation_msg.rs
index 61894aa6a8b..72223cdb387 100644
--- a/components/msg/constellation_msg.rs
+++ b/components/msg/constellation_msg.rs
@@ -13,6 +13,8 @@ use std::mem;
use std::num::NonZeroU32;
use std::sync::Arc;
use std::time::Duration;
+use webrender_api::ExternalScrollId;
+use webrender_api::PipelineId as WebRenderPipelineId;
macro_rules! namespace_id_method {
($func_name:ident, $func_return_data_type:ident, $self:ident, $index_name:ident) => {
@@ -206,15 +208,15 @@ impl PipelineId {
})
}
- pub fn to_webrender(&self) -> webrender_api::PipelineId {
+ pub fn to_webrender(&self) -> WebRenderPipelineId {
let PipelineNamespaceId(namespace_id) = self.namespace_id;
let PipelineIndex(index) = self.index;
- webrender_api::PipelineId(namespace_id, index.get())
+ WebRenderPipelineId(namespace_id, index.get())
}
#[allow(unsafe_code)]
- pub fn from_webrender(pipeline: webrender_api::PipelineId) -> PipelineId {
- let webrender_api::PipelineId(namespace_id, index) = pipeline;
+ pub fn from_webrender(pipeline: WebRenderPipelineId) -> PipelineId {
+ let WebRenderPipelineId(namespace_id, index) = pipeline;
unsafe {
PipelineId {
namespace_id: PipelineNamespaceId(namespace_id),
@@ -224,7 +226,7 @@ impl PipelineId {
}
pub fn root_scroll_id(&self) -> webrender_api::ExternalScrollId {
- webrender_api::ExternalScrollId(0, self.to_webrender())
+ ExternalScrollId(0, self.to_webrender())
}
}
diff --git a/components/net/image_cache.rs b/components/net/image_cache.rs
index 4b88fd5755e..08765d13d63 100644
--- a/components/net/image_cache.rs
+++ b/components/net/image_cache.rs
@@ -22,8 +22,9 @@ use std::collections::HashMap;
use std::mem;
use std::sync::{Arc, Mutex};
use std::thread;
-use webrender_api::units::DeviceIntSize;
-use webrender_api::ImageDescriptorFlags;
+use webrender_api::{
+ units::DeviceIntSize, ImageData, ImageDescriptor, ImageDescriptorFlags, ImageFormat,
+};
///
/// TODO(gw): Remaining work on image cache:
@@ -77,14 +78,14 @@ fn set_webrender_image_key(webrender_api: &WebrenderIpcSender, image: &mut Image
};
let mut flags = ImageDescriptorFlags::ALLOW_MIPMAPS;
flags.set(ImageDescriptorFlags::IS_OPAQUE, is_opaque);
- let descriptor = webrender_api::ImageDescriptor {
+ let descriptor = ImageDescriptor {
size: DeviceIntSize::new(image.width as i32, image.height as i32),
stride: None,
- format: webrender_api::ImageFormat::BGRA8,
+ format: ImageFormat::BGRA8,
offset: 0,
flags,
};
- let data = webrender_api::ImageData::new(bytes);
+ let data = ImageData::new(bytes);
let image_key = webrender_api.generate_image_key();
webrender_api.add_image(image_key, descriptor, data);
image.id = Some(image_key);
diff --git a/components/net_traits/image/base.rs b/components/net_traits/image/base.rs
index 0fd2f357d2b..4f5285b065a 100644
--- a/components/net_traits/image/base.rs
+++ b/components/net_traits/image/base.rs
@@ -7,6 +7,7 @@ use image::ImageFormat;
use ipc_channel::ipc::IpcSharedMemory;
use pixels::PixelFormat;
use std::fmt;
+use webrender_api::ImageKey;
#[derive(Clone, Deserialize, MallocSizeOf, Serialize)]
pub struct Image {
@@ -16,7 +17,7 @@ pub struct Image {
#[ignore_malloc_size_of = "Defined in ipc-channel"]
pub bytes: IpcSharedMemory,
#[ignore_malloc_size_of = "Defined in webrender_api"]
- pub id: Option<webrender_api::ImageKey>,
+ pub id: Option<ImageKey>,
pub cors_status: CorsStatus,
}
diff --git a/components/script/dom/gpucanvascontext.rs b/components/script/dom/gpucanvascontext.rs
index 6cb5592a9fc..9679479394e 100644
--- a/components/script/dom/gpucanvascontext.rs
+++ b/components/script/dom/gpucanvascontext.rs
@@ -25,6 +25,10 @@ use ipc_channel::ipc;
use script_layout_interface::HTMLCanvasDataSource;
use std::cell::Cell;
use webgpu::{wgpu::id, wgt, WebGPU, WebGPURequest, PRESENTATION_BUFFER_COUNT};
+use webrender_api::{
+ units, ExternalImageData, ExternalImageId, ExternalImageType, ImageData, ImageDescriptor,
+ ImageDescriptorFlags, ImageFormat, ImageKey,
+};
#[derive(Clone, Copy, Debug, Eq, Hash, MallocSizeOf, Ord, PartialEq, PartialOrd)]
pub struct WebGPUContextId(pub u64);
@@ -78,7 +82,7 @@ impl GPUCanvasContext {
let image_key = if self.webrender_image.get().is_some() {
self.webrender_image.get().unwrap()
} else {
- webrender_api::ImageKey::DUMMY
+ ImageKey::DUMMY
};
HTMLCanvasDataSource::WebGPU(image_key)
}
@@ -145,13 +149,13 @@ impl GPUCanvasContextMethods for GPUCanvasContext {
);
}
- let image_desc = webrender_api::ImageDescriptor {
+ let image_desc = ImageDescriptor {
format: match descriptor.format {
- GPUTextureFormat::Rgba8unorm => webrender_api::ImageFormat::RGBA8,
- GPUTextureFormat::Bgra8unorm => webrender_api::ImageFormat::BGRA8,
+ GPUTextureFormat::Rgba8unorm => ImageFormat::RGBA8,
+ GPUTextureFormat::Bgra8unorm => ImageFormat::BGRA8,
_ => panic!("SwapChain format({:?}) not supported", descriptor.format),
},
- size: webrender_api::units::DeviceIntSize::new(
+ size: units::DeviceIntSize::new(
self.size.get().width as i32,
self.size.get().height as i32,
),
@@ -160,13 +164,13 @@ impl GPUCanvasContextMethods for GPUCanvasContext {
as i32,
),
offset: 0,
- flags: webrender_api::ImageDescriptorFlags::from_bits(1).unwrap(),
+ flags: ImageDescriptorFlags::from_bits(1).unwrap(),
};
- let image_data = webrender_api::ImageData::External(webrender_api::ExternalImageData {
- id: webrender_api::ExternalImageId(self.context_id.0),
+ let image_data = ImageData::External(ExternalImageData {
+ id: ExternalImageId(self.context_id.0),
channel_index: 0,
- image_type: webrender_api::ExternalImageType::Buffer,
+ image_type: ExternalImageType::Buffer,
});
let (sender, receiver) = ipc::channel().unwrap();
diff --git a/components/script/dom/gpuswapchain.rs b/components/script/dom/gpuswapchain.rs
index a60449ae616..9b8e9aab588 100644
--- a/components/script/dom/gpuswapchain.rs
+++ b/components/script/dom/gpuswapchain.rs
@@ -12,6 +12,7 @@ use crate::dom::gpucanvascontext::GPUCanvasContext;
use crate::dom::gputexture::GPUTexture;
use dom_struct::dom_struct;
use webgpu::{WebGPU, WebGPURequest, WebGPUTexture};
+use webrender_api::ImageKey;
#[dom_struct]
pub struct GPUSwapChain {
@@ -56,7 +57,7 @@ impl GPUSwapChain {
}
impl GPUSwapChain {
- pub fn destroy(&self, external_id: u64, image_key: webrender_api::ImageKey) {
+ pub fn destroy(&self, external_id: u64, image_key: ImageKey) {
if let Err(e) = self.channel.0.send((
None,
WebGPURequest::DestroySwapChain {
diff --git a/components/script/dom/webglrenderingcontext.rs b/components/script/dom/webglrenderingcontext.rs
index 2a9c3584a89..9a2b561adae 100644
--- a/components/script/dom/webglrenderingcontext.rs
+++ b/components/script/dom/webglrenderingcontext.rs
@@ -83,6 +83,7 @@ use std::cell::Cell;
use std::cmp;
use std::ptr::{self, NonNull};
use std::rc::Rc;
+use webrender_api::ImageKey;
// From the GLES 2.0.25 spec, page 85:
//
@@ -165,7 +166,7 @@ pub struct WebGLRenderingContext {
#[ignore_malloc_size_of = "Channels are hard"]
webgl_sender: WebGLMessageSender,
#[ignore_malloc_size_of = "Defined in webrender"]
- webrender_image: webrender_api::ImageKey,
+ webrender_image: ImageKey,
webgl_version: WebGLVersion,
glsl_version: WebGLSLVersion,
#[ignore_malloc_size_of = "Defined in surfman"]
diff --git a/components/script_layout_interface/lib.rs b/components/script_layout_interface/lib.rs
index bdf6ae9e884..375377262d7 100644
--- a/components/script_layout_interface/lib.rs
+++ b/components/script_layout_interface/lib.rs
@@ -27,6 +27,7 @@ use servo_url::{ImmutableOrigin, ServoUrl};
use std::any::Any;
use std::sync::atomic::AtomicIsize;
use style::data::ElementData;
+use webrender_api::ImageKey;
#[derive(MallocSizeOf)]
pub struct StyleData {
@@ -121,9 +122,9 @@ pub enum LayoutElementType {
}
pub enum HTMLCanvasDataSource {
- WebGL(webrender_api::ImageKey),
+ WebGL(ImageKey),
Image(Option<IpcSender<CanvasMsg>>),
- WebGPU(webrender_api::ImageKey),
+ WebGPU(ImageKey),
}
pub struct HTMLCanvasData {
@@ -162,5 +163,5 @@ pub struct PendingImage {
}
pub struct HTMLMediaData {
- pub current_frame: Option<(webrender_api::ImageKey, i32, i32)>,
+ pub current_frame: Option<(ImageKey, i32, i32)>,
}
diff --git a/components/script_traits/lib.rs b/components/script_traits/lib.rs
index 838a699a3be..f85a833df94 100644
--- a/components/script_traits/lib.rs
+++ b/components/script_traits/lib.rs
@@ -25,6 +25,11 @@ pub mod transferable;
pub mod webdriver_msg;
use crate::compositor::CompositorDisplayListInfo;
+pub use crate::script_msg::{
+ DOMMessage, EventResult, HistoryEntryReplacement, IFrameSizeMsg, Job, JobError, JobResult,
+ JobResultValue, JobType, LayoutMsg, LogEntry, SWManagerMsg, SWManagerSenders, ScopeThings,
+ ScriptMsg, ServiceWorkerMsg,
+};
use crate::serializable::{BlobData, BlobImpl};
use crate::transferable::MessagePortImpl;
use crate::webdriver_msg::{LoadStatus, WebDriverScriptCommand};
@@ -74,16 +79,10 @@ use webrender_api::units::{
DeviceIntSize, DevicePixel, LayoutPixel, LayoutPoint, LayoutSize, WorldPoint,
};
use webrender_api::{
- BuiltDisplayList, DocumentId, ExternalImageData, ExternalScrollId, ImageData, ImageDescriptor,
- ImageKey, ScrollClamping,
-};
-use webrender_api::{BuiltDisplayListDescriptor, HitTestFlags};
-
-pub use crate::script_msg::{
- DOMMessage, HistoryEntryReplacement, Job, JobError, JobResult, JobResultValue, JobType,
- SWManagerMsg, SWManagerSenders, ScopeThings, ServiceWorkerMsg,
+ BuiltDisplayList, BuiltDisplayListDescriptor, DocumentId, ExternalImageData, ExternalScrollId,
+ HitTestFlags, ImageData, ImageDescriptor, ImageKey, PipelineId as WebRenderPipelineId,
+ ScrollClamping,
};
-pub use crate::script_msg::{EventResult, IFrameSizeMsg, LayoutMsg, LogEntry, ScriptMsg};
/// The address of a node. Layout sends these back. They must be validated via
/// `from_untrusted_node_address` before they can be used, because we do not trust layout.
@@ -1128,7 +1127,7 @@ pub struct CompositorHitTestResult {
#[derive(Deserialize, Serialize)]
pub enum WebrenderMsg {
/// Inform WebRender of the existence of this pipeline.
- SendInitialTransaction(webrender_api::PipelineId),
+ SendInitialTransaction(WebRenderPipelineId),
/// Perform a scroll operation.
SendScrollNode(LayoutPoint, ExternalScrollId, ScrollClamping),
/// Inform WebRender of a new display list for the given pipeline.
@@ -1145,7 +1144,7 @@ pub enum WebrenderMsg {
/// Perform a hit test operation. The result will be returned via
/// the provided channel sender.
HitTest(
- Option<webrender_api::PipelineId>,
+ Option<WebRenderPipelineId>,
WorldPoint,
HitTestFlags,
IpcSender<Vec<CompositorHitTestResult>>,
@@ -1168,7 +1167,7 @@ impl WebrenderIpcSender {
}
/// Inform WebRender of the existence of this pipeline.
- pub fn send_initial_transaction(&self, pipeline: webrender_api::PipelineId) {
+ pub fn send_initial_transaction(&self, pipeline: WebRenderPipelineId) {
if let Err(e) = self.0.send(WebrenderMsg::SendInitialTransaction(pipeline)) {
warn!("Error sending initial transaction: {}", e);
}
@@ -1193,7 +1192,7 @@ impl WebrenderIpcSender {
pub fn send_display_list(
&self,
display_list_info: CompositorDisplayListInfo,
- (_, content_size, list): (webrender_api::PipelineId, LayoutSize, BuiltDisplayList),
+ (_, content_size, list): (WebRenderPipelineId, LayoutSize, BuiltDisplayList),
) {
let (display_list_data, display_list_descriptor) = list.into_data();
let (display_list_sender, display_list_receiver) = ipc::bytes_channel().unwrap();
@@ -1215,7 +1214,7 @@ impl WebrenderIpcSender {
/// and a result is available.
pub fn hit_test(
&self,
- pipeline: Option<webrender_api::PipelineId>,
+ pipeline: Option<WebRenderPipelineId>,
point: WorldPoint,
flags: HitTestFlags,
) -> Vec<CompositorHitTestResult> {
diff --git a/components/servo/lib.rs b/components/servo/lib.rs
index 4b9b37a178b..78a737f0007 100644
--- a/components/servo/lib.rs
+++ b/components/servo/lib.rs
@@ -51,6 +51,7 @@ pub use style;
pub use style_traits;
pub use webgpu;
pub use webrender_api;
+use webrender_api::{DocumentId, FontInstanceKey, FontKey, ImageKey, RenderApiSender};
pub use webrender_surfman;
pub use webrender_traits;
@@ -226,7 +227,7 @@ impl webrender_api::RenderNotifier for RenderNotifier {
fn new_frame_ready(
&self,
- _document_id: webrender_api::DocumentId,
+ _document_id: DocumentId,
scrolled: bool,
composite_needed: bool,
_render_time_ns: Option<u64>,
@@ -829,8 +830,8 @@ fn create_constellation(
time_profiler_chan: time::ProfilerChan,
mem_profiler_chan: mem::ProfilerChan,
devtools_sender: Option<Sender<devtools_traits::DevtoolsControlMsg>>,
- webrender_document: webrender_api::DocumentId,
- webrender_api_sender: webrender_api::RenderApiSender,
+ webrender_document: DocumentId,
+ webrender_api_sender: RenderApiSender,
webxr_registry: webxr_api::Registry,
player_context: WindowGLContext,
webgl_threads: Option<WebGLThreads>,
@@ -920,18 +921,14 @@ fn create_constellation(
struct FontCacheWR(CompositorProxy);
impl gfx_traits::WebrenderApi for FontCacheWR {
- fn add_font_instance(
- &self,
- font_key: webrender_api::FontKey,
- size: f32,
- ) -> webrender_api::FontInstanceKey {
+ fn add_font_instance(&self, font_key: FontKey, size: f32) -> FontInstanceKey {
let (sender, receiver) = unbounded();
let _ = self.0.send(Msg::Webrender(WebrenderMsg::Font(
WebrenderFontMsg::AddFontInstance(font_key, size, sender),
)));
receiver.recv().unwrap()
}
- fn add_font(&self, data: gfx_traits::FontData) -> webrender_api::FontKey {
+ fn add_font(&self, data: gfx_traits::FontData) -> FontKey {
let (sender, receiver) = unbounded();
let _ = self.0.send(Msg::Webrender(WebrenderMsg::Font(
WebrenderFontMsg::AddFont(data, sender),
@@ -944,7 +941,7 @@ impl gfx_traits::WebrenderApi for FontCacheWR {
struct CanvasWebrenderApi(CompositorProxy);
impl canvas_paint_thread::WebrenderApi for CanvasWebrenderApi {
- fn generate_key(&self) -> Result<webrender_api::ImageKey, ()> {
+ fn generate_key(&self) -> Result<ImageKey, ()> {
let (sender, receiver) = unbounded();
let _ = self.0.send(Msg::Webrender(WebrenderMsg::Canvas(
WebrenderCanvasMsg::GenerateKey(sender),
diff --git a/components/webgpu/lib.rs b/components/webgpu/lib.rs
index 2e510a6c6ec..4bd4e21e97d 100644
--- a/components/webgpu/lib.rs
+++ b/components/webgpu/lib.rs
@@ -27,6 +27,10 @@ use std::rc::Rc;
use std::slice;
use std::sync::{Arc, Mutex};
use std::time::{Duration, Instant};
+use webrender_api::{
+ DirtyRect, DocumentId, ExternalImageId, ImageData, ImageDescriptor, ImageKey, RenderApi,
+ RenderApiSender, Transaction,
+};
use webrender_traits::{
WebrenderExternalImageApi, WebrenderExternalImageRegistry, WebrenderImageHandlerType,
WebrenderImageSource,
@@ -140,7 +144,7 @@ pub enum WebGPURequest {
descriptor: ComputePipelineDescriptor<'static>,
implicit_ids: Option<(id::PipelineLayoutId, Vec<id::BindGroupLayoutId>)>,
},
- CreateContext(IpcSender<webrender_api::ExternalImageId>),
+ CreateContext(IpcSender<ExternalImageId>),
CreatePipelineLayout {
device_id: id::DeviceId,
pipeline_layout_id: id::PipelineLayoutId,
@@ -166,9 +170,9 @@ pub enum WebGPURequest {
device_id: id::DeviceId,
buffer_ids: ArrayVec<id::BufferId, PRESENTATION_BUFFER_COUNT>,
external_id: u64,
- sender: IpcSender<webrender_api::ImageKey>,
- image_desc: webrender_api::ImageDescriptor,
- image_data: webrender_api::ImageData,
+ sender: IpcSender<ImageKey>,
+ image_desc: ImageDescriptor,
+ image_data: ImageData,
},
CreateTexture {
device_id: id::DeviceId,
@@ -184,7 +188,7 @@ pub enum WebGPURequest {
DestroyBuffer(id::BufferId),
DestroySwapChain {
external_id: u64,
- image_key: webrender_api::ImageKey,
+ image_key: ImageKey,
},
DestroyTexture(id::TextureId),
Exit(IpcSender<()>),
@@ -267,8 +271,8 @@ pub struct WebGPU(pub IpcSender<(Option<ErrorScopeId>, WebGPURequest)>);
impl WebGPU {
pub fn new(
- webrender_api_sender: webrender_api::RenderApiSender,
- webrender_document: webrender_api::DocumentId,
+ webrender_api_sender: RenderApiSender,
+ webrender_document: DocumentId,
external_images: Arc<Mutex<WebrenderExternalImageRegistry>>,
wgpu_image_map: Arc<Mutex<HashMap<u64, PresentationData>>>,
) -> Option<(Self, IpcReceiver<WebGPUMsg>)> {
@@ -342,8 +346,8 @@ struct WGPU<'a> {
HashMap<id::BufferId, Rc<BufferMapInfo<'a, (Option<ErrorScopeId>, WebGPURequest)>>>,
//TODO: Remove this (https://github.com/gfx-rs/wgpu/issues/867)
error_command_encoders: RefCell<HashMap<id::CommandEncoderId, String>>,
- webrender_api: webrender_api::RenderApi,
- webrender_document: webrender_api::DocumentId,
+ webrender_api: RenderApi,
+ webrender_document: DocumentId,
external_images: Arc<Mutex<WebrenderExternalImageRegistry>>,
wgpu_image_map: Arc<Mutex<HashMap<u64, PresentationData>>>,
last_poll: Instant,
@@ -354,8 +358,8 @@ impl<'a> WGPU<'a> {
receiver: IpcReceiver<(Option<ErrorScopeId>, WebGPURequest)>,
sender: IpcSender<(Option<ErrorScopeId>, WebGPURequest)>,
script_sender: IpcSender<WebGPUMsg>,
- webrender_api_sender: webrender_api::RenderApiSender,
- webrender_document: webrender_api::DocumentId,
+ webrender_api_sender: RenderApiSender,
+ webrender_document: DocumentId,
external_images: Arc<Mutex<WebrenderExternalImageRegistry>>,
wgpu_image_map: Arc<Mutex<HashMap<u64, PresentationData>>>,
) -> Self {
@@ -769,7 +773,7 @@ impl<'a> WGPU<'a> {
},
);
- let mut txn = webrender_api::Transaction::new();
+ let mut txn = Transaction::new();
txn.add_image(image_key, image_desc, image_data, None);
self.webrender_api
.send_transaction(self.webrender_document, txn);
@@ -841,7 +845,7 @@ impl<'a> WGPU<'a> {
warn!("Unable to send FreeBuffer({:?}) ({:?})", *b_id, e);
};
}
- let mut txn = webrender_api::Transaction::new();
+ let mut txn = Transaction::new();
txn.delete_image(image_key);
self.webrender_api
.send_transaction(self.webrender_document, txn);
@@ -1191,12 +1195,12 @@ impl<'a> WGPU<'a> {
self.wgpu_image_map.lock().unwrap().get_mut(&external_id)
{
present_data.data = data;
- let mut txn = webrender_api::Transaction::new();
+ let mut txn = Transaction::new();
txn.update_image(
present_data.image_key,
present_data.image_desc,
present_data.image_data.clone(),
- &webrender_api::DirtyRect::All,
+ &DirtyRect::All,
);
self.webrender_api
.send_transaction(self.webrender_document, txn);
@@ -1372,7 +1376,7 @@ pub struct PresentationData {
available_buffer_ids: ArrayVec<id::BufferId, PRESENTATION_BUFFER_COUNT>,
queued_buffer_ids: ArrayVec<id::BufferId, PRESENTATION_BUFFER_COUNT>,
buffer_stride: u32,
- image_key: webrender_api::ImageKey,
- image_desc: webrender_api::ImageDescriptor,
- image_data: webrender_api::ImageData,
+ image_key: ImageKey,
+ image_desc: ImageDescriptor,
+ image_data: ImageData,
}
diff --git a/components/webrender_traits/lib.rs b/components/webrender_traits/lib.rs
index bd981074da8..d30853d19d4 100644
--- a/components/webrender_traits/lib.rs
+++ b/components/webrender_traits/lib.rs
@@ -5,11 +5,12 @@
#![deny(unsafe_code)]
use euclid::default::Size2D;
-
use std::collections::HashMap;
use std::sync::{Arc, Mutex};
-
use webrender_api::units::TexelRect;
+use webrender_api::{
+ ExternalImage, ExternalImageHandler, ExternalImageId, ExternalImageSource, ImageRendering,
+};
/// This trait is used as a bridge between the different GL clients
/// in Servo that handles WebRender ExternalImages and the WebRender
@@ -39,7 +40,7 @@ pub enum WebrenderImageHandlerType {
/// It ensures that external image identifiers are unique.
pub struct WebrenderExternalImageRegistry {
/// Map of all generated external images.
- external_images: HashMap<webrender_api::ExternalImageId, WebrenderImageHandlerType>,
+ external_images: HashMap<ExternalImageId, WebrenderImageHandlerType>,
/// Id generator for the next external image identifier.
next_image_id: u64,
}
@@ -52,21 +53,18 @@ impl WebrenderExternalImageRegistry {
}
}
- pub fn next_id(
- &mut self,
- handler_type: WebrenderImageHandlerType,
- ) -> webrender_api::ExternalImageId {
+ pub fn next_id(&mut self, handler_type: WebrenderImageHandlerType) -> ExternalImageId {
self.next_image_id += 1;
- let key = webrender_api::ExternalImageId(self.next_image_id);
+ let key = ExternalImageId(self.next_image_id);
self.external_images.insert(key, handler_type);
key
}
- pub fn remove(&mut self, key: &webrender_api::ExternalImageId) {
+ pub fn remove(&mut self, key: &ExternalImageId) {
self.external_images.remove(key);
}
- pub fn get(&self, key: &webrender_api::ExternalImageId) -> Option<&WebrenderImageHandlerType> {
+ pub fn get(&self, key: &ExternalImageId) -> Option<&WebrenderImageHandlerType> {
self.external_images.get(key)
}
}
@@ -110,17 +108,17 @@ impl WebrenderExternalImageHandlers {
}
}
-impl webrender_api::ExternalImageHandler for WebrenderExternalImageHandlers {
+impl ExternalImageHandler for WebrenderExternalImageHandlers {
/// Lock the external image. Then, WR could start to read the
/// image content.
/// The WR client should not change the image content until the
/// unlock() call.
fn lock(
&mut self,
- key: webrender_api::ExternalImageId,
+ key: ExternalImageId,
_channel_index: u8,
- _rendering: webrender_api::ImageRendering,
- ) -> webrender_api::ExternalImage {
+ _rendering: ImageRendering,
+ ) -> ExternalImage {
let external_images = self.external_images.lock().unwrap();
let handler_type = external_images
.get(&key)
@@ -132,9 +130,9 @@ impl webrender_api::ExternalImageHandler for WebrenderExternalImageHandlers {
WebrenderImageSource::TextureHandle(b) => b,
_ => panic!("Wrong type"),
};
- webrender_api::ExternalImage {
+ ExternalImage {
uv: TexelRect::new(0.0, size.height as f32, size.width as f32, 0.0),
- source: webrender_api::ExternalImageSource::NativeTexture(texture_id),
+ source: ExternalImageSource::NativeTexture(texture_id),
}
},
WebrenderImageHandlerType::Media => {
@@ -143,9 +141,9 @@ impl webrender_api::ExternalImageHandler for WebrenderExternalImageHandlers {
WebrenderImageSource::TextureHandle(b) => b,
_ => panic!("Wrong type"),
};
- webrender_api::ExternalImage {
+ ExternalImage {
uv: TexelRect::new(0.0, size.height as f32, size.width as f32, 0.0),
- source: webrender_api::ExternalImageSource::NativeTexture(texture_id),
+ source: ExternalImageSource::NativeTexture(texture_id),
}
},
WebrenderImageHandlerType::WebGPU => {
@@ -154,9 +152,9 @@ impl webrender_api::ExternalImageHandler for WebrenderExternalImageHandlers {
WebrenderImageSource::Raw(b) => b,
_ => panic!("Wrong type"),
};
- webrender_api::ExternalImage {
+ ExternalImage {
uv: TexelRect::new(0.0, size.height as f32, size.width as f32, 0.0),
- source: webrender_api::ExternalImageSource::RawData(buffer),
+ source: ExternalImageSource::RawData(buffer),
}
},
}
@@ -164,7 +162,7 @@ impl webrender_api::ExternalImageHandler for WebrenderExternalImageHandlers {
/// Unlock the external image. The WR should not read the image
/// content after this call.
- fn unlock(&mut self, key: webrender_api::ExternalImageId, _channel_index: u8) {
+ fn unlock(&mut self, key: ExternalImageId, _channel_index: u8) {
let external_images = self.external_images.lock().unwrap();
let handler_type = external_images
.get(&key)