Bug 1662827 - Move the api senders to the webrender crate. r=gw

Differential Revision: https://phabricator.services.mozilla.com/D89387
This commit is contained in:
Nicolas Silva 2020-09-09 12:45:00 +00:00
Родитель a7ac72998d
Коммит b1c3ab9869
56 изменённых файлов: 875 добавлений и 855 удалений

1
Cargo.lock сгенерированный
Просмотреть файл

@ -5622,6 +5622,7 @@ dependencies = [
"core-graphics",
"core-text",
"cstr",
"derive_more",
"dwrote",
"euclid",
"freetype",

Просмотреть файл

@ -34,7 +34,7 @@ use rayon;
use swgl_bindings::SwCompositor;
use tracy_rs::register_thread_with_profiler;
use webrender::{
api::units::*, api::*, set_profiler_hooks, AsyncPropertySampler, AsyncScreenshotHandle, Compositor,
api::units::*, api::*, render_api::*, set_profiler_hooks, AsyncPropertySampler, AsyncScreenshotHandle, Compositor,
CompositorCapabilities, CompositorConfig, CompositorSurfaceTransform, DebugFlags, Device, FastHashMap,
NativeSurfaceId, NativeSurfaceInfo, NativeTileId, PipelineInfo, ProfilerHooks, RecordedFrameHandle, Renderer,
RendererOptions, RendererStats, SceneBuilderHooks, ShaderPrecacheFlags, Shaders, ThreadListener, UploadMethod,

1
gfx/wr/Cargo.lock сгенерированный
Просмотреть файл

@ -1804,6 +1804,7 @@ dependencies = [
"core-graphics 0.22.0 (registry+https://github.com/rust-lang/crates.io-index)",
"core-text 19.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
"cstr 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)",
"derive_more 0.99.5 (registry+https://github.com/rust-lang/crates.io-index)",
"dwrote 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)",
"euclid 0.22.0 (registry+https://github.com/rust-lang/crates.io-index)",
"freetype 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",

Просмотреть файл

@ -12,6 +12,7 @@ use euclid::size2;
use direct_composition::DirectComposition;
use std::sync::mpsc;
use webrender::api;
use webrender::render_api::*;
use winit::os::windows::{WindowExt, WindowBuilderExt};
use winit::dpi::LogicalSize;
@ -93,7 +94,7 @@ fn direct_composition_from_window(window: &winit::Window) -> DirectComposition {
struct Rectangle {
visual: direct_composition::AngleVisual,
renderer: Option<webrender::Renderer>,
api: api::RenderApi,
api: RenderApi,
document_id: api::DocumentId,
size: api::units::DeviceIntSize,
color: api::ColorF,
@ -160,7 +161,7 @@ impl Rectangle {
self.color,
);
let mut transaction = api::Transaction::new();
let mut transaction = Transaction::new();
transaction.set_display_list(
api::Epoch(0),
None,

Просмотреть файл

@ -14,6 +14,7 @@ mod boilerplate;
use crate::boilerplate::{Example, HandyDandyRectBuilder};
use std::cmp;
use webrender::api::*;
use webrender::render_api::*;
use webrender::api::units::DeviceIntSize;

Просмотреть файл

@ -22,6 +22,7 @@ mod boilerplate;
use crate::boilerplate::{Example, HandyDandyRectBuilder};
use euclid::Angle;
use webrender::api::*;
use webrender::render_api::*;
use webrender::api::units::*;

Просмотреть файл

@ -17,6 +17,7 @@ use winit::TouchPhase;
use std::collections::HashMap;
use webrender::ShaderPrecacheFlags;
use webrender::api::*;
use webrender::render_api::*;
use webrender::api::units::*;

Просмотреть файл

@ -16,9 +16,10 @@ use rayon::{ThreadPool, ThreadPoolBuilder};
use rayon::prelude::*;
use std::collections::HashMap;
use std::sync::Arc;
use webrender::api::{self, DisplayListBuilder, DocumentId, PipelineId, PrimitiveFlags, RenderApi, Transaction};
use webrender::api::{self, DisplayListBuilder, DocumentId, PipelineId, PrimitiveFlags};
use webrender::api::{ColorF, CommonItemProperties, SpaceAndClipInfo, ImageDescriptorFlags};
use webrender::api::units::*;
use webrender::render_api::*;
use webrender::euclid::size2;
// This example shows how to implement a very basic BlobImageHandler that can only render

Просмотреть файл

@ -10,6 +10,7 @@ use webrender;
use winit;
use webrender::{DebugFlags, ShaderPrecacheFlags};
use webrender::api::*;
use webrender::render_api::*;
use webrender::api::units::*;
struct Notifier {

Просмотреть файл

@ -14,6 +14,7 @@ mod boilerplate;
use crate::boilerplate::Example;
use euclid::Scale;
use webrender::api::*;
use webrender::render_api::*;
use webrender::api::units::*;
// This example creates multiple documents overlapping each other with

Просмотреть файл

@ -12,6 +12,7 @@ mod boilerplate;
use crate::boilerplate::{Example, HandyDandyRectBuilder};
use webrender::api::*;
use webrender::render_api::*;
use webrender::api::units::*;
// This example uses the push_iframe API to nest a second pipeline's displaylist

Просмотреть файл

@ -14,6 +14,7 @@ mod image_helper;
use crate::boilerplate::{Example, HandyDandyRectBuilder};
use webrender::api::*;
use webrender::render_api::*;
use webrender::api::units::*;
struct App {

Просмотреть файл

@ -14,6 +14,7 @@ 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;

Просмотреть файл

@ -14,6 +14,7 @@ mod boilerplate;
use crate::boilerplate::{Example, HandyDandyRectBuilder};
use euclid::SideOffsets2D;
use webrender::api::*;
use webrender::render_api::*;
use webrender::api::units::*;
use winit::dpi::LogicalPosition;

Просмотреть файл

@ -14,6 +14,7 @@ use crate::boilerplate::{Example, HandyDandyRectBuilder};
use gleam::gl;
use std::mem;
use webrender::api::*;
use webrender::render_api::*;
use webrender::api::units::*;

Просмотреть файл

@ -13,6 +13,7 @@ mod boilerplate;
use crate::boilerplate::Example;
use gleam::gl;
use webrender::api::*;
use webrender::render_api::*;
use webrender::api::units::*;

Просмотреть файл

@ -36,7 +36,8 @@ use std::io::prelude::*;
use std::path::Path;
use std::ffi::OsString;
use std::collections::HashMap;
use webrender::api::{enumerate_interners, ColorF};
use webrender::enumerate_interners;
use webrender::api::ColorF;
use euclid::{Rect, Transform3D};
use webrender_api::units::{PicturePoint, PictureSize, PicturePixel, WorldPixel};

Просмотреть файл

@ -55,6 +55,7 @@ malloc_size_of = { version = "0.0.1", path = "../wr_malloc_size_of", package = "
ws = { optional = true, version = "0.9" }
svg_fmt = "0.4"
tracy-rs = "0.1.2"
derive_more = "0.99"
[dev-dependencies]
mozangle = "0.3.1"

Просмотреть файл

@ -2,16 +2,14 @@
* 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/. */
use crate::{BlobImageKey, ImageDescriptor, DirtyRect, TileSize, ResourceUpdate};
use crate::{BlobImageHandler, AsyncBlobImageRasterizer, BlobImageData, BlobImageParams};
use crate::{BlobImageRequest, BlobImageDescriptor, BlobImageResources, TransactionMsg};
use crate::{FontKey, FontTemplate, FontInstanceData, FontInstanceKey, AddFont};
use crate::api::{BlobImageKey, ImageDescriptor, DirtyRect, TileSize};
use crate::api::{BlobImageHandler, AsyncBlobImageRasterizer, BlobImageData, BlobImageParams};
use crate::api::{BlobImageRequest, BlobImageDescriptor, BlobImageResources};
use crate::api::{FontKey, FontTemplate, FontInstanceData, FontInstanceKey};
use crate::api::SharedFontInstanceMap;
use crate::api::units::*;
use crate::render_api::{ResourceUpdate, TransactionMsg, AddFont};
use crate::image_tiling::*;
use crate::units::*;
use crate::font::SharedFontInstanceMap;
use crate::euclid::{point2, size2};
pub const DEFAULT_TILE_SIZE: TileSize = 512;
use std::collections::HashMap;
use std::sync::Arc;
@ -288,43 +286,3 @@ impl ApiResources {
(Some(handler.create_blob_rasterizer()), blob_request_params)
}
}
fn compute_valid_tiles_if_bounds_change(
prev_rect: &DeviceIntRect,
new_rect: &DeviceIntRect,
tile_size: u16,
) -> Option<TileRange> {
let intersection = match prev_rect.intersection(new_rect) {
Some(rect) => rect,
None => {
return Some(TileRange::zero());
}
};
let left = prev_rect.min_x() != new_rect.min_x();
let right = prev_rect.max_x() != new_rect.max_x();
let top = prev_rect.min_y() != new_rect.min_y();
let bottom = prev_rect.max_y() != new_rect.max_y();
if !left && !right && !top && !bottom {
// Bounds have not changed.
return None;
}
let tw = 1.0 / (tile_size as f32);
let th = 1.0 / (tile_size as f32);
let tiles = intersection
.cast::<f32>()
.scale(tw, th);
let min_x = if left { f32::ceil(tiles.min_x()) } else { f32::floor(tiles.min_x()) };
let min_y = if top { f32::ceil(tiles.min_y()) } else { f32::floor(tiles.min_y()) };
let max_x = if right { f32::floor(tiles.max_x()) } else { f32::ceil(tiles.max_x()) };
let max_y = if bottom { f32::floor(tiles.max_y()) } else { f32::ceil(tiles.max_y()) };
Some(TileRange {
origin: point2(min_x as i32, min_y as i32),
size: size2((max_x - min_x) as i32, (max_y - min_y) as i32),
})
}

Просмотреть файл

@ -2,7 +2,7 @@
* 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/. */
use api::{AlphaType, ClipMode, ExternalImageType, ImageRendering, EdgeAaSegmentMask};
use api::{AlphaType, ClipMode, ExternalImageType, ImageRendering};
use api::{FontInstanceFlags, YuvColorSpace, YuvFormat, ColorDepth, ColorRange, PremultipliedColorF};
use api::units::*;
use crate::clip::{ClipDataStore, ClipNodeFlags, ClipNodeRange, ClipItemKind, ClipStore};
@ -34,6 +34,7 @@ use crate::visibility::{PrimitiveVisibilityIndex, PrimitiveVisibilityMask, Primi
use smallvec::SmallVec;
use std::{f32, i32, usize};
use crate::util::{project_rect, TransformedRectKind};
use crate::segment::EdgeAaSegmentMask;
// Special sentinel value recognized by the shader. It is considered to be
// a dummy task that doesn't mask out anything.

Просмотреть файл

@ -3,7 +3,7 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
use api::{BorderRadius, BorderSide, BorderStyle, ColorF, ColorU};
use api::{NormalBorder as ApiNormalBorder, RepeatMode, EdgeAaSegmentMask};
use api::{NormalBorder as ApiNormalBorder, RepeatMode};
use api::units::*;
use crate::clip::ClipChainId;
use crate::ellipse::Ellipse;
@ -15,6 +15,7 @@ use crate::prim_store::{BorderSegmentInfo, BrushSegment, NinePatchDescriptor};
use crate::prim_store::borders::{NormalBorderPrim, NormalBorderData};
use crate::util::{lerp, RectHelpers};
use crate::internal_types::LayoutPrimitiveInfo;
use crate::segment::EdgeAaSegmentMask;
// Using 2048 as the maximum radius in device space before which we
// start stretching is up for debate.

Просмотреть файл

@ -5,7 +5,7 @@
use std::fs::File;
use std::path::{Path, PathBuf};
use api::{CaptureBits, ExternalImageData, ImageDescriptor};
use api::{ExternalImageData, ImageDescriptor};
#[cfg(feature = "png")]
use api::ImageFormat;
use api::units::TexelRect;
@ -13,6 +13,7 @@ use api::units::TexelRect;
use api::units::DeviceIntSize;
#[cfg(feature = "capture")]
use crate::print_tree::{PrintableTree, PrintTree};
use crate::render_api::CaptureBits;
use ron;
use serde;

Просмотреть файл

@ -92,10 +92,10 @@
//! [segment.rs]: ../segment/index.html
//!
use api::{BorderRadius, ClipIntern, ClipMode, ComplexClipRegion, ImageMask};
use api::{BorderRadius, ClipMode, ComplexClipRegion, ImageMask};
use api::{BoxShadowClipMode, ClipId, ImageKey, ImageRendering, PipelineId};
use api::units::*;
use api::image_tiling::{self, Repetition};
use crate::image_tiling::{self, Repetition};
use crate::border::{ensure_no_corner_overlap, BorderRadiusAu};
use crate::box_shadow::{BLUR_SAMPLE_SCALE, BoxShadowClipSource, BoxShadowCacheKey};
use crate::spatial_tree::{ROOT_SPATIAL_NODE_INDEX, SpatialTree, SpatialNodeIndex, CoordinateSystemId};
@ -116,6 +116,10 @@ use smallvec::SmallVec;
// Type definitions for interning clip nodes.
#[derive(Copy, Clone, Debug, MallocSizeOf)]
#[cfg_attr(any(feature = "serde"), derive(Deserialize, Serialize))]
pub enum ClipIntern {}
pub type ClipDataStore = intern::DataStore<ClipIntern>;
pub type ClipDataHandle = intern::Handle<ClipIntern>;

Просмотреть файл

@ -2,9 +2,10 @@
* 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/. */
use api::{ApiMsg, DebugCommand, DebugFlags};
use api::units::DeviceIntSize;
use api::crossbeam_channel::{bounded, Sender, Receiver};
use api::DebugFlags;
use crate::render_api::{ApiMsg, DebugCommand};
use crate::print_tree::PrintTreePrinter;
use crate::renderer;
use std::thread;

Просмотреть файл

@ -3,11 +3,12 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
use super::super::shader_source::{OPTIMIZED_SHADERS, UNOPTIMIZED_SHADERS};
use api::{ColorF, ImageDescriptor, ImageFormat, MemoryReport};
use api::{ColorF, ImageDescriptor, ImageFormat};
use api::{MixBlendMode, TextureTarget, VoidPtrToSizeFn};
use api::units::*;
use euclid::default::Transform3D;
use gleam::gl;
use crate::render_api::MemoryReport;
use crate::internal_types::{FastHashMap, LayerIndex, RenderTargetInfo, Swizzle, SwizzleSettings};
use crate::util::round_up_to_multiple;
use crate::profiler;

Просмотреть файл

@ -7,7 +7,7 @@ use crate::gpu_cache::{GpuCacheHandle};
use crate::frame_builder::FrameBuildingState;
use crate::gpu_cache::GpuDataRequest;
use crate::intern;
use api::{FilterDataIntern, ComponentTransferFuncType};
use api::{ComponentTransferFuncType};
pub type FilterDataHandle = intern::Handle<FilterDataIntern>;
@ -154,6 +154,10 @@ impl SFilterDataTemplate {
}
}
#[derive(Copy, Clone, Debug, MallocSizeOf)]
#[cfg_attr(any(feature = "serde"), derive(Deserialize, Serialize))]
pub enum FilterDataIntern {}
impl intern::Internable for FilterDataIntern {
type Key = SFilterDataKey;
type StoreData = SFilterDataTemplate;

Просмотреть файл

@ -3,8 +3,8 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
use api::{AlphaType, PremultipliedColorF, YuvFormat, YuvColorSpace};
use api::EdgeAaSegmentMask;
use api::units::*;
use crate::segment::EdgeAaSegmentMask;
use crate::spatial_tree::{SpatialTree, ROOT_SPATIAL_NODE_INDEX, SpatialNodeIndex};
use crate::gpu_cache::{GpuCacheAddress, GpuDataRequest};
use crate::internal_types::FastHashMap;

Просмотреть файл

@ -2,8 +2,9 @@
* 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/. */
use crate::{TileSize, EdgeAaSegmentMask};
use crate::units::*;
use crate::api::TileSize;
use crate::api::units::*;
use crate::segment::EdgeAaSegmentMask;
use euclid::{point2, size2};
use std::i32;
use std::ops::Range;

Просмотреть файл

@ -372,6 +372,68 @@ impl<I: Internable> ops::Index<Handle<I>> for Interner<I> {
}
}
/// Meta-macro to enumerate the various interner identifiers and types.
///
/// IMPORTANT: Keep this synchronized with the list in mozilla-central located at
/// gfx/webrender_bindings/webrender_ffi.h
///
/// Note that this could be a lot less verbose if concat_idents! were stable. :-(
#[macro_export]
macro_rules! enumerate_interners {
($macro_name: ident) => {
$macro_name! {
clip: ClipIntern,
prim: PrimitiveKeyKind,
normal_border: NormalBorderPrim,
image_border: ImageBorder,
image: Image,
yuv_image: YuvImage,
line_decoration: LineDecoration,
linear_grad: LinearGradient,
radial_grad: RadialGradient,
conic_grad: ConicGradient,
picture: Picture,
text_run: TextRun,
filter_data: FilterDataIntern,
backdrop: Backdrop,
}
}
}
macro_rules! declare_interning_memory_report {
( $( $name:ident: $ty:ident, )+ ) => {
///
#[repr(C)]
#[derive(AddAssign, Clone, Debug, Default)]
pub struct InternerSubReport {
$(
///
pub $name: usize,
)+
}
}
}
enumerate_interners!(declare_interning_memory_report);
/// Memory report for interning-related data structures.
/// cbindgen:derive-eq=false
#[repr(C)]
#[derive(Clone, Debug, Default)]
pub struct InterningMemoryReport {
///
pub interners: InternerSubReport,
///
pub data_stores: InternerSubReport,
}
impl ::std::ops::AddAssign for InterningMemoryReport {
fn add_assign(&mut self, other: InterningMemoryReport) {
self.interners += other.interners;
self.data_stores += other.data_stores;
}
}
// The trick to make trait bounds configurable by features.
mod dummy {
#[cfg(not(feature = "capture"))]

Просмотреть файл

@ -2,10 +2,11 @@
* 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/. */
use api::{ColorF, DebugCommand, DocumentId, ExternalImageData, ExternalImageId, PrimitiveFlags};
use api::{ColorF, DocumentId, ExternalImageData, ExternalImageId, PrimitiveFlags};
use api::{ImageFormat, NotificationRequest, Shadow, FilterOp};
use api::units::*;
use api;
use crate::render_api::DebugCommand;
use crate::composite::NativeSurfaceOperation;
use crate::device::TextureFilter;
use crate::renderer::PipelineInfo;

Просмотреть файл

@ -71,7 +71,8 @@ extern crate malloc_size_of_derive;
extern crate serde;
#[macro_use]
extern crate tracy_rs;
#[macro_use]
extern crate derive_more;
extern crate malloc_size_of;
extern crate svg_fmt;
@ -104,7 +105,6 @@ mod glyph_rasterizer;
mod gpu_cache;
mod gpu_types;
mod hit_test;
mod intern;
mod internal_types;
mod lru_cache;
mod picture;
@ -131,6 +131,12 @@ mod texture_cache;
mod tile_cache;
mod util;
mod visibility;
mod api_resources;
mod image_tiling;
///
pub mod intern;
///
pub mod render_api;
mod shader_source {
include!(concat!(env!("OUT_DIR"), "/shaders.rs"));
@ -199,7 +205,6 @@ extern crate png;
#[cfg(test)]
extern crate rand;
#[macro_use]
pub extern crate api;
extern crate webrender_build;
@ -228,3 +233,4 @@ pub use crate::picture::{TileDescriptor, TileId, InvalidationReason};
pub use crate::picture::{PrimitiveCompareResult, PrimitiveCompareResultDetail, CompareHelperResult};
pub use crate::picture::{TileNode, TileNodeKind, TileSerializer, TileCacheInstanceSerializer, TileOffset, TileCacheLoggerUpdateLists};
pub use crate::intern::ItemUid;
pub use crate::render_api::*;

Просмотреть файл

@ -142,7 +142,11 @@ use crate::scene_builder_thread::InternerUpdates;
#[cfg(any(feature = "capture", feature = "replay"))]
use crate::intern::{Internable, UpdateList};
#[cfg(any(feature = "capture", feature = "replay"))]
use api::{ClipIntern, FilterDataIntern, PrimitiveKeyKind};
use crate::clip::ClipIntern;
#[cfg(any(feature = "capture", feature = "replay"))]
use crate::filterdata::FilterDataIntern;
#[cfg(any(feature = "capture", feature = "replay"))]
use api::PrimitiveKeyKind;
#[cfg(any(feature = "capture", feature = "replay"))]
use crate::prim_store::backdrop::Backdrop;
#[cfg(any(feature = "capture", feature = "replay"))]
@ -2012,7 +2016,7 @@ macro_rules! declare_tile_cache_logger_updatelists {
}
#[cfg(any(feature = "capture", feature = "replay"))]
enumerate_interners!(declare_tile_cache_logger_updatelists);
crate::enumerate_interners!(declare_tile_cache_logger_updatelists);
#[cfg(not(any(feature = "capture", feature = "replay")))]
pub struct TileCacheLoggerUpdateLists {

Просмотреть файл

@ -9,11 +9,11 @@
use std::{cmp, u32, usize};
use api::{PremultipliedColorF, PropertyBinding, GradientStop, ExtendMode};
use api::{BoxShadowClipMode, LineOrientation, BorderStyle, ClipMode};
use api::image_tiling::{self, Repetition};
use api::units::*;
use euclid::Scale;
use euclid::approxeq::ApproxEq;
use smallvec::SmallVec;
use crate::image_tiling::{self, Repetition};
use crate::border::{get_max_scale_for_border, build_border_instances};
use crate::clip::{ClipStore};
use crate::spatial_tree::{ROOT_SPATIAL_NODE_INDEX, SpatialNodeIndex};

Просмотреть файл

@ -5,10 +5,11 @@
use api::{BorderRadius, ClipMode, ColorF, ColorU};
use api::{ImageRendering, RepeatMode, PrimitiveFlags};
use api::{PremultipliedColorF, PropertyBinding, Shadow};
use api::{PrimitiveKeyKind, EdgeAaSegmentMask};
use api::{PrimitiveKeyKind};
use api::units::*;
use euclid::{SideOffsets2D, Size2D};
use malloc_size_of::MallocSizeOf;
use crate::segment::EdgeAaSegmentMask;
use crate::border::BorderSegmentCacheKey;
use crate::clip::{ClipChainId, ClipSet};
use crate::debug_render::DebugItem;

Просмотреть файл

@ -752,7 +752,7 @@ macro_rules! declare_intern_profile_counters {
}
}
enumerate_interners!(declare_intern_profile_counters);
crate::enumerate_interners!(declare_intern_profile_counters);
impl TransactionProfileCounters {
pub fn set(

Разница между файлами не показана из-за своего большого размера Загрузить разницу

Просмотреть файл

@ -8,19 +8,21 @@
//! See the comment at the top of the `renderer` module for a description of
//! how these two pieces interact.
use api::{ApiMsg, ClearCache, DebugCommand, DebugFlags, BlobImageHandler};
use api::{DocumentId, DocumentLayer, ExternalScrollId, FrameMsg, HitTestResult};
use api::{IdNamespace, MemoryReport, PipelineId, RenderNotifier, ScrollClamping};
use api::{TransactionMsg, ResourceUpdate};
use api::{DebugFlags, BlobImageHandler};
use api::{DocumentId, DocumentLayer, ExternalScrollId, HitTestResult};
use api::{IdNamespace, PipelineId, RenderNotifier, ScrollClamping};
use api::{NotificationRequest, Checkpoint, QualitySettings};
use api::{ClipIntern, FilterDataIntern, PrimitiveKeyKind};
use api::{PrimitiveKeyKind};
use api::units::*;
#[cfg(any(feature = "capture", feature = "replay"))]
use api::CaptureBits;
#[cfg(feature = "replay")]
use api::CapturedDocument;
use api::channel::{single_msg_channel, Sender, Receiver};
#[cfg(any(feature = "capture", feature = "replay"))]
use crate::render_api::CaptureBits;
#[cfg(feature = "replay")]
use crate::render_api::CapturedDocument;
use crate::render_api::{MemoryReport, TransactionMsg, ResourceUpdate, ApiMsg, FrameMsg, ClearCache, DebugCommand};
use crate::clip::ClipIntern;
use crate::filterdata::FilterDataIntern;
#[cfg(any(feature = "capture", feature = "replay"))]
use crate::capture::CaptureConfig;
use crate::composite::{CompositorKind, CompositeDescriptor};
#[cfg(feature = "debugger")]
@ -286,7 +288,7 @@ macro_rules! declare_data_stores {
}
}
enumerate_interners!(declare_data_stores);
crate::enumerate_interners!(declare_data_stores);
impl DataStores {
/// Returns the local rect for a primitive. For most primitives, this is

Просмотреть файл

@ -34,18 +34,19 @@
//! up the scissor, are accepting already transformed coordinates, which we can get by
//! calling `DrawTarget::to_framebuffer_rect`
use api::{ApiMsg, BlobImageHandler, ColorF, ColorU, MixBlendMode};
use api::{BlobImageHandler, ColorF, ColorU, MixBlendMode};
use api::{DocumentId, Epoch, ExternalImageHandler, ExternalImageId};
use api::{ExternalImageSource, ExternalImageType, FontRenderMode, FrameMsg, ImageFormat};
use api::{ExternalImageSource, ExternalImageType, FontRenderMode, ImageFormat};
use api::{PipelineId, ImageRendering, Checkpoint, NotificationRequest};
use api::{DebugCommand, MemoryReport, VoidPtrToSizeFn, PremultipliedColorF};
use api::{RenderApiSender, RenderNotifier, TextureTarget, SharedFontInstanceMap};
use api::{VoidPtrToSizeFn, PremultipliedColorF};
use api::{RenderNotifier, TextureTarget, SharedFontInstanceMap};
#[cfg(feature = "replay")]
use api::ExternalImage;
use api::units::*;
use api::channel::{unbounded_channel, Sender, Receiver};
pub use api::DebugFlags;
use core::time::Duration;
use crate::render_api::{RenderApiSender, DebugCommand, ApiMsg, FrameMsg, MemoryReport};
use crate::batch::{AlphaBatchContainer, BatchKind, BatchFeatures, BatchTextures, BrushBatchKind, ClipBatchList};
#[cfg(any(feature = "capture", feature = "replay"))]
use crate::capture::{CaptureConfig, ExternalCaptureImage, PlainExternalImage};
@ -7468,7 +7469,8 @@ impl Renderer {
) {
use std::fs;
use std::io::Write;
use api::{CaptureBits, ExternalImageData};
use api::ExternalImageData;
use crate::render_api::CaptureBits;
let root = config.resource_root();

Просмотреть файл

@ -2,16 +2,16 @@
* 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/. */
use api::{AddFont, BlobImageResources, ResourceUpdate};
use api::{BlobImageRequest, RasterizedBlobImage};
use api::{ClearCache, DebugFlags, FontInstanceKey, FontKey, FontTemplate, GlyphIndex};
use api::{BlobImageResources, BlobImageRequest, RasterizedBlobImage};
use api::{DebugFlags, FontInstanceKey, FontKey, FontTemplate, GlyphIndex};
use api::{ExternalImageData, ExternalImageType, ExternalImageId, BlobImageResult, FontInstanceData};
use api::{DirtyRect, GlyphDimensions, IdNamespace, DEFAULT_TILE_SIZE};
use api::{ImageData, ImageDescriptor, ImageKey, ImageRendering, TileSize};
use api::{BlobImageKey, MemoryReport, VoidPtrToSizeFn};
use api::{BlobImageKey, VoidPtrToSizeFn};
use api::{SharedFontInstanceMap, BaseFontInstance};
use api::image_tiling::{compute_tile_size, compute_tile_range};
use api::units::*;
use crate::render_api::{ClearCache, AddFont, ResourceUpdate, MemoryReport};
use crate::image_tiling::{compute_tile_size, compute_tile_range};
#[cfg(feature = "capture")]
use crate::capture::ExternalCaptureImage;
#[cfg(feature = "replay")]

Просмотреть файл

@ -4,9 +4,9 @@
use api::{BuiltDisplayList, DisplayListWithCache, ColorF, DynamicProperties, Epoch, FontRenderMode};
use api::{PipelineId, PropertyBinding, PropertyBindingId, PropertyValue, MixBlendMode, StackingContext};
use api::MemoryReport;
use api::units::*;
use malloc_size_of::{MallocSizeOf, MallocSizeOfOps};
use crate::render_api::MemoryReport;
use crate::composite::CompositorKind;
use crate::clip::{ClipStore, ClipDataStore};
use crate::spatial_tree::SpatialTree;

Просмотреть файл

@ -2,17 +2,20 @@
* 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/. */
use api::{AsyncBlobImageRasterizer, BlobImageRequest, BlobImageResult};
use api::{DocumentId, PipelineId, ApiMsg, FrameMsg, SceneMsg, ResourceUpdate, ExternalEvent};
use api::{NotificationRequest, Checkpoint, IdNamespace, QualitySettings, TransactionMsg};
use api::{ClipIntern, FilterDataIntern, MemoryReport, PrimitiveKeyKind, SharedFontInstanceMap};
use api::{AsyncBlobImageRasterizer, BlobImageResult};
use api::{DocumentId, PipelineId, ExternalEvent, BlobImageRequest};
use api::{NotificationRequest, Checkpoint, IdNamespace, QualitySettings};
use api::{PrimitiveKeyKind, SharedFontInstanceMap};
use api::{DocumentLayer, GlyphDimensionRequest, GlyphIndexRequest};
use api::channel::{unbounded_channel, single_msg_channel, Receiver, Sender};
use api::units::*;
use crate::render_api::{ApiMsg, FrameMsg, SceneMsg, ResourceUpdate, TransactionMsg, MemoryReport};
#[cfg(feature = "capture")]
use crate::capture::CaptureConfig;
use crate::frame_builder::FrameBuilderConfig;
use crate::scene_building::SceneBuilder;
use crate::clip::ClipIntern;
use crate::filterdata::FilterDataIntern;
use crate::intern::{Internable, Interner, UpdateList};
use crate::internal_types::{FastHashMap, FastHashSet};
use malloc_size_of::{MallocSizeOf, MallocSizeOfOps};
@ -207,7 +210,7 @@ macro_rules! declare_interners {
}
}
enumerate_interners!(declare_interners);
crate::enumerate_interners!(declare_interners);
// A document in the scene builder contains the current scene,
// as well as a persistent clip interner. This allows clips
@ -436,7 +439,8 @@ impl SceneBuilderThread {
let interners_name = format!("interners-{}-{}", id.namespace_id.0, id.id);
config.serialize_for_scene(&doc.interners, interners_name);
if config.bits.contains(api::CaptureBits::SCENE) {
use crate::render_api::CaptureBits;
if config.bits.contains(CaptureBits::SCENE) {
let file_name = format!("scene-{}-{}", id.namespace_id.0, id.id);
config.serialize_for_scene(&doc.scene, file_name);
}
@ -511,7 +515,8 @@ impl SceneBuilderThread {
let interners_name = format!("interners-{}-{}", id.namespace_id.0, id.id);
config.serialize_for_scene(&doc.interners, interners_name);
if config.bits.contains(api::CaptureBits::SCENE) {
use crate::render_api::CaptureBits;
if config.bits.contains(CaptureBits::SCENE) {
let file_name = format!("scene-{}-{}", id.namespace_id.0, id.id);
config.serialize_for_scene(&doc.scene, file_name);
}

Просмотреть файл

@ -12,8 +12,8 @@ use api::{PropertyBinding, ReferenceFrameKind, ScrollFrameDisplayItem, ScrollSen
use api::{Shadow, SpaceAndClipInfo, SpatialId, StickyFrameDisplayItem, ImageMask, ItemTag};
use api::{ClipMode, PrimitiveKeyKind, TransformStyle, YuvColorSpace, ColorRange, YuvData, TempFilterData};
use api::{ReferenceTransformBinding, Rotation};
use api::image_tiling::simplify_repeated_primitive;
use api::units::*;
use crate::image_tiling::simplify_repeated_primitive;
use crate::clip::{ClipChainId, ClipRegion, ClipItemKey, ClipStore, ClipItemKeyKind};
use crate::clip::{ClipInternData, ClipNodeKind, ClipInstance};
use crate::spatial_tree::{ROOT_SPATIAL_NODE_INDEX, SpatialTree, SpatialNodeIndex};

Просмотреть файл

@ -49,12 +49,34 @@
//! [clip.rs]: ../clip/index.html
//!
use api::{BorderRadius, ClipMode, EdgeAaSegmentMask};
use api::{BorderRadius, ClipMode};
use api::units::*;
use std::{cmp, usize};
use crate::util::{extract_inner_rect_safe};
use smallvec::SmallVec;
bitflags! {
/// Each bit of the edge AA mask is:
/// 0, when the edge of the primitive needs to be considered for AA
/// 1, when the edge of the segment needs to be considered for AA
///
/// *Note*: the bit values have to match the shader logic in
/// `write_transform_vertex()` function.
#[cfg_attr(feature = "capture", derive(Serialize))]
#[cfg_attr(feature = "replay", derive(Deserialize))]
#[derive(MallocSizeOf)]
pub struct EdgeAaSegmentMask: u8 {
///
const LEFT = 0x1;
///
const TOP = 0x2;
///
const RIGHT = 0x4;
///
const BOTTOM = 0x8;
}
}
bitflags! {
pub struct ItemFlags: u8 {
const X_ACTIVE = 0x1;
@ -683,9 +705,9 @@ fn emit_segment_if_needed(
#[cfg(test)]
mod test {
use api::{BorderRadius, ClipMode, EdgeAaSegmentMask};
use api::{BorderRadius, ClipMode};
use api::units::{LayoutPoint, LayoutRect, LayoutSize};
use super::{Segment, SegmentBuilder};
use super::{Segment, SegmentBuilder, EdgeAaSegmentMask};
use std::cmp;
fn rect(x0: f32, y0: f32, x1: f32, y1: f32) -> LayoutRect {

Просмотреть файл

@ -7,11 +7,12 @@
//! TODO: document what this pass does!
//!
use api::{ColorF, DebugFlags, EdgeAaSegmentMask};
use api::{ColorF, DebugFlags};
use api::units::*;
use api::image_tiling;
use euclid::Scale;
use std::{u32, usize, mem};
use crate::image_tiling;
use crate::segment::EdgeAaSegmentMask;
use crate::clip::{ClipStore, ClipChainStack};
use crate::composite::CompositeState;
use crate::spatial_tree::{ROOT_SPATIAL_NODE_INDEX, SpatialTree, SpatialNodeIndex};

Просмотреть файл

@ -2,7 +2,7 @@
* 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/. */
use crate::api::{Epoch, PipelineId};
use crate::{Epoch, PipelineId};
use byteorder::{LittleEndian, ReadBytesExt, WriteBytesExt};
use serde::{Deserialize, Deserializer, Serialize, Serializer};
use std::io::{self, Cursor, Error, ErrorKind, Read};

Просмотреть файл

@ -7,7 +7,7 @@ use peek_poke::PeekPoke;
use std::ops::Not;
// local imports
use crate::font;
use crate::api::{PipelineId, PropertyBinding};
use crate::{PipelineId, PropertyBinding};
use crate::color::ColorF;
use crate::image::{ColorDepth, ImageKey};
use crate::units::*;

Просмотреть файл

@ -20,7 +20,7 @@ use malloc_size_of::{MallocSizeOf, MallocSizeOfOps};
// local imports
use crate::display_item as di;
use crate::display_item_cache::*;
use crate::api::{PipelineId, PropertyBinding};
use crate::{PipelineId, PropertyBinding};
use crate::gradient_builder::GradientBuilder;
use crate::color::ColorF;
use crate::font::{FontInstanceKey, GlyphInstance, GlyphOptions};

Просмотреть файл

@ -18,7 +18,7 @@ use std::path::PathBuf;
use std::sync::{Arc, RwLock, RwLockReadGuard};
use std::collections::HashMap;
// local imports
use crate::api::IdNamespace;
use crate::IdNamespace;
use crate::channel::Sender;
use crate::color::ColorU;
use crate::units::LayoutPoint;

Просмотреть файл

@ -9,7 +9,7 @@ use peek_poke::PeekPoke;
use std::ops::{Add, Sub};
use std::sync::Arc;
// local imports
use crate::api::{IdNamespace, TileSize};
use crate::{IdNamespace, TileSize};
use crate::display_item::ImageRendering;
use crate::font::{FontInstanceKey, FontInstanceData, FontKey, FontTemplate};
use crate::units::*;

Просмотреть файл

@ -28,7 +28,6 @@ extern crate core;
extern crate core_foundation;
#[cfg(target_os = "macos")]
extern crate core_graphics;
#[macro_use]
extern crate derive_more;
#[macro_use]
extern crate malloc_size_of_derive;
@ -40,7 +39,6 @@ extern crate time;
extern crate malloc_size_of;
extern crate peek_poke;
mod api;
pub mod channel;
mod color;
mod display_item;
@ -49,13 +47,8 @@ mod display_list;
mod font;
mod gradient_builder;
mod image;
mod resources;
pub mod units;
#[doc(hidden)]
pub mod image_tiling;
pub use crate::api::*;
pub use crate::color::*;
pub use crate::display_item::*;
pub use crate::display_item_cache::DisplayItemCache;
@ -63,4 +56,564 @@ pub use crate::display_list::*;
pub use crate::font::*;
pub use crate::gradient_builder::*;
pub use crate::image::*;
pub use crate::resources::DEFAULT_TILE_SIZE;
use crate::units::*;
use crate::channel::Receiver;
use std::marker::PhantomData;
use std::sync::Arc;
use std::os::raw::c_void;
use peek_poke::PeekPoke;
/// Width and height in device pixels of image tiles.
pub type TileSize = u16;
/// Documents are rendered in the ascending order of their associated layer values.
pub type DocumentLayer = i8;
/// Various settings that the caller can select based on desired tradeoffs
/// between rendering quality and performance / power usage.
#[derive(Copy, Clone, Deserialize, Serialize)]
pub struct QualitySettings {
/// If true, disable creating separate picture cache slices when the
/// scroll root changes. This gives maximum opportunity to find an
/// opaque background, which enables subpixel AA. However, it is
/// usually significantly more expensive to render when scrolling.
pub force_subpixel_aa_where_possible: bool,
}
impl Default for QualitySettings {
fn default() -> Self {
QualitySettings {
// Prefer performance over maximum subpixel AA quality, since WR
// already enables subpixel AA in more situations than other browsers.
force_subpixel_aa_where_possible: false,
}
}
}
/// An epoch identifies the state of a pipeline in time.
///
/// This is mostly used as a synchronization mechanism to observe how/when particular pipeline
/// updates propagate through WebRender and are applied at various stages.
#[repr(C)]
#[derive(Clone, Copy, Debug, Deserialize, Eq, Hash, Ord, PartialEq, PartialOrd, Serialize)]
pub struct Epoch(pub u32);
impl Epoch {
/// Magic invalid epoch value.
pub fn invalid() -> Epoch {
Epoch(u32::MAX)
}
}
/// ID namespaces uniquely identify different users of WebRender's API.
///
/// For example in Gecko each content process uses a separate id namespace.
#[repr(C)]
#[derive(Clone, Copy, Debug, Default, Eq, MallocSizeOf, PartialEq, Hash, Ord, PartialOrd, PeekPoke)]
#[derive(Deserialize, Serialize)]
pub struct IdNamespace(pub u32);
/// A key uniquely identifying a WebRender document.
///
/// Instances can manage one or several documents (using the same render backend thread).
/// Each document will internally correspond to a single scene, and scenes are made of
/// one or several pipelines.
#[repr(C)]
#[derive(Clone, Copy, Debug, Deserialize, Eq, Hash, MallocSizeOf, PartialEq, Serialize, PeekPoke)]
pub struct DocumentId {
///
pub namespace_id: IdNamespace,
///
pub id: u32,
}
impl DocumentId {
///
pub fn new(namespace_id: IdNamespace, id: u32) -> Self {
DocumentId {
namespace_id,
id,
}
}
///
pub const INVALID: DocumentId = DocumentId { namespace_id: IdNamespace(0), id: 0 };
}
/// This type carries no valuable semantics for WR. However, it reflects the fact that
/// clients (Servo) may generate pipelines by different semi-independent sources.
/// These pipelines still belong to the same `IdNamespace` and the same `DocumentId`.
/// Having this extra Id field enables them to generate `PipelineId` without collision.
pub type PipelineSourceId = u32;
/// From the point of view of WR, `PipelineId` is completely opaque and generic as long as
/// it's clonable, serializable, comparable, and hashable.
#[repr(C)]
#[derive(Clone, Copy, Debug, Deserialize, Eq, Hash, MallocSizeOf, PartialEq, Serialize, PeekPoke)]
pub struct PipelineId(pub PipelineSourceId, pub u32);
impl Default for PipelineId {
fn default() -> Self {
PipelineId::dummy()
}
}
impl PipelineId {
///
pub fn dummy() -> Self {
PipelineId(0, 0)
}
}
/// An opaque pointer-sized value.
#[repr(C)]
#[derive(Clone)]
pub struct ExternalEvent {
raw: usize,
}
unsafe impl Send for ExternalEvent {}
impl ExternalEvent {
/// Creates the event from an opaque pointer-sized value.
pub fn from_raw(raw: usize) -> Self {
ExternalEvent { raw }
}
/// Consumes self to make it obvious that the event should be forwarded only once.
pub fn unwrap(self) -> usize {
self.raw
}
}
/// Describe whether or not scrolling should be clamped by the content bounds.
#[derive(Clone, Deserialize, Serialize)]
pub enum ScrollClamping {
///
ToContentBounds,
///
NoClamping,
}
/// A handler to integrate WebRender with the thread that contains the `Renderer`.
pub trait RenderNotifier: Send {
///
fn clone(&self) -> Box<dyn RenderNotifier>;
/// Wake the thread containing the `Renderer` up (after updates have been put
/// in the renderer's queue).
fn wake_up(&self);
/// Notify the thread containing the `Renderer` that a new frame is ready.
fn new_frame_ready(&self, _: DocumentId, scrolled: bool, composite_needed: bool, render_time_ns: Option<u64>);
/// A Gecko-specific notification mechanism to get some code executed on the
/// `Renderer`'s thread, mostly replaced by `NotificationHandler`. You should
/// probably use the latter instead.
fn external_event(&self, _evt: ExternalEvent) {
unimplemented!()
}
/// Notify the thread containing the `Renderer` that the render backend has been
/// shut down.
fn shut_down(&self) {}
}
/// A stage of the rendering pipeline.
#[repr(u32)]
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
pub enum Checkpoint {
///
SceneBuilt,
///
FrameBuilt,
///
FrameTexturesUpdated,
///
FrameRendered,
/// NotificationRequests get notified with this if they get dropped without having been
/// notified. This provides the guarantee that if a request is created it will get notified.
TransactionDropped,
}
/// A handler to notify when a transaction reaches certain stages of the rendering
/// pipeline.
pub trait NotificationHandler : Send + Sync {
/// Entry point of the handler to implement. Invoked by WebRender.
fn notify(&self, when: Checkpoint);
}
/// A request to notify a handler when the transaction reaches certain stages of the
/// rendering pipeline.
///
/// The request is guaranteed to be notified once and only once, even if the transaction
/// is dropped before the requested check-point.
pub struct NotificationRequest {
handler: Option<Box<dyn NotificationHandler>>,
when: Checkpoint,
}
impl NotificationRequest {
/// Constructor.
pub fn new(when: Checkpoint, handler: Box<dyn NotificationHandler>) -> Self {
NotificationRequest {
handler: Some(handler),
when,
}
}
/// The specified stage at which point the handler should be notified.
pub fn when(&self) -> Checkpoint { self.when }
/// Called by WebRender at specified stages to notify the registered handler.
pub fn notify(mut self) {
if let Some(handler) = self.handler.take() {
handler.notify(self.when);
}
}
}
/// An object that can perform hit-testing without doing synchronous queries to
/// the RenderBackendThread.
pub trait ApiHitTester: Send + Sync {
/// Does a hit test on display items in the specified document, at the given
/// point. If a pipeline_id is specified, it is used to further restrict the
/// hit results so that only items inside that pipeline are matched. The vector
/// of hit results will contain all display items that match, ordered from
/// front to back.
fn hit_test(&self, pipeline_id: Option<PipelineId>, point: WorldPoint) -> HitTestResult;
}
/// A hit tester requested to the render backend thread but not necessarily ready yet.
///
/// The request should be resolved as late as possible to reduce the likelihood of blocking.
pub struct HitTesterRequest {
#[doc(hidden)]
pub rx: Receiver<Arc<dyn ApiHitTester>>,
}
impl HitTesterRequest {
/// Block until the hit tester is available and return it, consuming teh request.
pub fn resolve(self) -> Arc<dyn ApiHitTester> {
self.rx.recv().unwrap()
}
}
/// Describe an item that matched a hit-test query.
#[derive(Clone, Debug, Deserialize, PartialEq, Serialize)]
pub struct HitTestItem {
/// The pipeline that the display item that was hit belongs to.
pub pipeline: PipelineId,
/// The tag of the hit display item.
pub tag: ItemTag,
/// The hit point in the coordinate space of the "viewport" of the display item. The
/// viewport is the scroll node formed by the root reference frame of the display item's
/// pipeline.
pub point_in_viewport: LayoutPoint,
/// The coordinates of the original hit test point relative to the origin of this item.
/// This is useful for calculating things like text offsets in the client.
pub point_relative_to_item: LayoutPoint,
}
/// Returned by `RenderApi::hit_test`.
#[derive(Clone, Debug, Default, Deserialize, Serialize)]
pub struct HitTestResult {
/// List of items that are match the hit-test query.
pub items: Vec<HitTestItem>,
}
impl Drop for NotificationRequest {
fn drop(&mut self) {
if let Some(ref mut handler) = self.handler {
handler.notify(Checkpoint::TransactionDropped);
}
}
}
// This Clone impl yields an "empty" request because we don't want the requests
// to be notified twice so the request is owned by only one of the API messages
// (the original one) after the clone.
// This works in practice because the notifications requests are used for
// synchronization so we don't need to include them in the recording mechanism
// in wrench that clones the messages.
impl Clone for NotificationRequest {
fn clone(&self) -> Self {
NotificationRequest {
when: self.when,
handler: None,
}
}
}
/// A key to identify an animated property binding.
#[repr(C)]
#[derive(Clone, Copy, Debug, Default, Deserialize, MallocSizeOf, PartialEq, Serialize, Eq, Hash, PeekPoke)]
pub struct PropertyBindingId {
pub namespace: IdNamespace,
pub uid: u32,
}
impl PropertyBindingId {
/// Constructor.
pub fn new(value: u64) -> Self {
PropertyBindingId {
namespace: IdNamespace((value >> 32) as u32),
uid: value as u32,
}
}
}
/// A unique key that is used for connecting animated property
/// values to bindings in the display list.
#[repr(C)]
#[derive(Clone, Copy, Debug, Default, Deserialize, Eq, Hash, MallocSizeOf, PartialEq, Serialize, PeekPoke)]
pub struct PropertyBindingKey<T> {
///
pub id: PropertyBindingId,
#[doc(hidden)]
pub _phantom: PhantomData<T>,
}
/// Construct a property value from a given key and value.
impl<T: Copy> PropertyBindingKey<T> {
///
pub fn with(self, value: T) -> PropertyValue<T> {
PropertyValue { key: self, value }
}
}
impl<T> PropertyBindingKey<T> {
/// Constructor.
pub fn new(value: u64) -> Self {
PropertyBindingKey {
id: PropertyBindingId::new(value),
_phantom: PhantomData,
}
}
}
/// A binding property can either be a specific value
/// (the normal, non-animated case) or point to a binding location
/// to fetch the current value from.
/// Note that Binding has also a non-animated value, the value is
/// used for the case where the animation is still in-delay phase
/// (i.e. the animation doesn't produce any animation values).
#[repr(C)]
#[derive(Clone, Copy, Debug, Deserialize, Eq, Hash, MallocSizeOf, PartialEq, Serialize, PeekPoke)]
pub enum PropertyBinding<T> {
/// Non-animated value.
Value(T),
/// Animated binding.
Binding(PropertyBindingKey<T>, T),
}
impl<T: Default> Default for PropertyBinding<T> {
fn default() -> Self {
PropertyBinding::Value(Default::default())
}
}
impl<T> From<T> for PropertyBinding<T> {
fn from(value: T) -> PropertyBinding<T> {
PropertyBinding::Value(value)
}
}
impl From<PropertyBindingKey<ColorF>> for PropertyBindingKey<ColorU> {
fn from(key: PropertyBindingKey<ColorF>) -> PropertyBindingKey<ColorU> {
PropertyBindingKey {
id: key.id.clone(),
_phantom: PhantomData,
}
}
}
impl From<PropertyBindingKey<ColorU>> for PropertyBindingKey<ColorF> {
fn from(key: PropertyBindingKey<ColorU>) -> PropertyBindingKey<ColorF> {
PropertyBindingKey {
id: key.id.clone(),
_phantom: PhantomData,
}
}
}
impl From<PropertyBinding<ColorF>> for PropertyBinding<ColorU> {
fn from(value: PropertyBinding<ColorF>) -> PropertyBinding<ColorU> {
match value {
PropertyBinding::Value(value) => PropertyBinding::Value(value.into()),
PropertyBinding::Binding(k, v) => {
PropertyBinding::Binding(k.into(), v.into())
}
}
}
}
impl From<PropertyBinding<ColorU>> for PropertyBinding<ColorF> {
fn from(value: PropertyBinding<ColorU>) -> PropertyBinding<ColorF> {
match value {
PropertyBinding::Value(value) => PropertyBinding::Value(value.into()),
PropertyBinding::Binding(k, v) => {
PropertyBinding::Binding(k.into(), v.into())
}
}
}
}
/// The current value of an animated property. This is
/// supplied by the calling code.
#[derive(Clone, Copy, Debug, Deserialize, Serialize, PartialEq)]
pub struct PropertyValue<T> {
///
pub key: PropertyBindingKey<T>,
///
pub value: T,
}
/// When using `generate_frame()`, a list of `PropertyValue` structures
/// can optionally be supplied to provide the current value of any
/// animated properties.
#[derive(Clone, Deserialize, Serialize, Debug, PartialEq, Default)]
pub struct DynamicProperties {
///
pub transforms: Vec<PropertyValue<LayoutTransform>>,
/// opacity
pub floats: Vec<PropertyValue<f32>>,
/// background color
pub colors: Vec<PropertyValue<ColorF>>,
}
/// A C function that takes a pointer to a heap allocation and returns its size.
///
/// This is borrowed from the malloc_size_of crate, upon which we want to avoid
/// a dependency from WebRender.
pub type VoidPtrToSizeFn = unsafe extern "C" fn(ptr: *const c_void) -> usize;
bitflags! {
/// Flags to enable/disable various builtin debugging tools.
#[repr(C)]
#[derive(Default, Deserialize, MallocSizeOf, Serialize)]
pub struct DebugFlags: u32 {
/// Display the frame profiler on screen.
const PROFILER_DBG = 1 << 0;
/// Display intermediate render targets on screen.
const RENDER_TARGET_DBG = 1 << 1;
/// Display all texture cache pages on screen.
const TEXTURE_CACHE_DBG = 1 << 2;
/// Display GPU timing results.
const GPU_TIME_QUERIES = 1 << 3;
/// Query the number of pixels that pass the depth test divided and show it
/// in the profiler as a percentage of the number of pixels in the screen
/// (window width times height).
const GPU_SAMPLE_QUERIES = 1 << 4;
/// Render each quad with their own draw call.
///
/// Terrible for performance but can help with understanding the drawing
/// order when inspecting renderdoc or apitrace recordings.
const DISABLE_BATCHING = 1 << 5;
/// Display the pipeline epochs.
const EPOCHS = 1 << 6;
/// Reduce the amount of information displayed by the profiler so that
/// it occupies less screen real-estate.
const COMPACT_PROFILER = 1 << 7;
/// Print driver messages to stdout.
const ECHO_DRIVER_MESSAGES = 1 << 8;
/// Show an indicator that moves every time a frame is rendered.
const NEW_FRAME_INDICATOR = 1 << 9;
/// Show an indicator that moves every time a scene is built.
const NEW_SCENE_INDICATOR = 1 << 10;
/// Show an overlay displaying overdraw amount.
const SHOW_OVERDRAW = 1 << 11;
/// Display the contents of GPU cache.
const GPU_CACHE_DBG = 1 << 12;
/// Show a red bar that moves each time a slow frame is detected.
const SLOW_FRAME_INDICATOR = 1 << 13;
/// Clear evicted parts of the texture cache for debugging purposes.
const TEXTURE_CACHE_DBG_CLEAR_EVICTED = 1 << 14;
/// Show picture caching debug overlay
const PICTURE_CACHING_DBG = 1 << 15;
/// Highlight all primitives with colors based on kind.
const PRIMITIVE_DBG = 1 << 16;
/// Draw a zoom widget showing part of the framebuffer zoomed in.
const ZOOM_DBG = 1 << 17;
/// Scale the debug renderer down for a smaller screen. This will disrupt
/// any mapping between debug display items and page content, so shouldn't
/// be used with overlays like the picture caching or primitive display.
const SMALL_SCREEN = 1 << 18;
/// Disable various bits of the WebRender pipeline, to help narrow
/// down where slowness might be coming from.
const DISABLE_OPAQUE_PASS = 1 << 19;
///
const DISABLE_ALPHA_PASS = 1 << 20;
///
const DISABLE_CLIP_MASKS = 1 << 21;
///
const DISABLE_TEXT_PRIMS = 1 << 22;
///
const DISABLE_GRADIENT_PRIMS = 1 << 23;
///
const OBSCURE_IMAGES = 1 << 24;
/// Taint the transparent area of the glyphs with a random opacity to easily
/// see when glyphs are re-rasterized.
const GLYPH_FLASHING = 1 << 25;
/// The profiler only displays information that is out of the ordinary.
const SMART_PROFILER = 1 << 26;
/// Dynamically control whether picture caching is enabled.
const DISABLE_PICTURE_CACHING = 1 << 27;
/// If set, dump picture cache invalidation debug to console.
const INVALIDATION_DBG = 1 << 28;
/// Log tile cache to memory for later saving as part of wr-capture
const TILE_CACHE_LOGGING_DBG = 1 << 29;
/// Collect and dump profiler statistics to captures.
const PROFILER_CAPTURE = (1 as u32) << 31; // need "as u32" until we have cbindgen#556
}
}
/// Information specific to a primitive type that
/// uniquely identifies a primitive template by key.
#[derive(Debug, Clone, Eq, MallocSizeOf, PartialEq, Hash, Serialize, Deserialize)]
pub enum PrimitiveKeyKind {
/// Clear an existing rect, used for special effects on some platforms.
Clear,
///
Rectangle {
///
color: PropertyBinding<ColorU>,
},
}
///
#[derive(Clone)]
pub struct ScrollNodeState {
///
pub id: ExternalScrollId,
///
pub scroll_offset: LayoutVector2D,
}
///
#[derive(Clone, Copy, Debug)]
pub enum ScrollLocation {
/// Scroll by a certain amount.
Delta(LayoutVector2D),
/// Scroll to very top of element.
Start,
/// Scroll to very bottom of element.
End,
}
/// Represents a zoom factor.
#[derive(Clone, Copy, Debug)]
pub struct ZoomFactor(f32);
impl ZoomFactor {
/// Construct a new zoom factor.
pub fn new(scale: f32) -> Self {
ZoomFactor(scale)
}
/// Get the zoom factor as an untyped float.
pub fn get(self) -> f32 {
self.0
}
}

Просмотреть файл

@ -46,6 +46,7 @@ use std::slice;
use std::sync::mpsc::{channel, Sender, Receiver};
use webrender::DebugFlags;
use webrender::api::*;
use webrender::render_api::*;
use webrender::api::units::*;
use winit::dpi::{LogicalPosition, LogicalSize};
use winit::VirtualKeyCode;

Просмотреть файл

@ -14,7 +14,7 @@ use std::sync::mpsc::Receiver;
use crate::wrench::{Wrench, WrenchThing};
use crate::yaml_frame_reader::YamlFrameReader;
use webrender::DebugFlags;
use webrender::api::DebugCommand;
use webrender::render_api::DebugCommand;
const COLOR_DEFAULT: &str = "\x1b[0m";
const COLOR_RED: &str = "\x1b[31m";

Просмотреть файл

@ -7,6 +7,7 @@ use std::sync::Arc;
use std::sync::atomic::{AtomicIsize, Ordering};
use std::sync::mpsc::Receiver;
use webrender::api::*;
use webrender::render_api::*;
use webrender::api::units::*;
use crate::{WindowWrapper, NotifierEvent};
use crate::blob;

Просмотреть файл

@ -19,6 +19,7 @@ use std::process::Command;
use std::sync::mpsc::Receiver;
use webrender::RenderResults;
use webrender::api::*;
use webrender::render_api::*;
use webrender::api::units::*;
use crate::wrench::{Wrench, WrenchThing};
use crate::yaml_frame_reader::YamlFrameReader;

Просмотреть файл

@ -17,6 +17,7 @@ use std::sync::mpsc::Receiver;
use time;
use webrender;
use webrender::api::*;
use webrender::render_api::*;
use webrender::api::units::*;
use webrender::{DebugFlags, RenderResults, ShaderPrecacheFlags};
use crate::{WindowWrapper, NotifierEvent};

Просмотреть файл

@ -15,6 +15,7 @@ use std::io::Read;
use std::path::{Path, PathBuf};
use std::usize;
use webrender::api::*;
use webrender::render_api::*;
use webrender::api::units::*;
use crate::wrench::{FontDescriptor, Wrench, WrenchThing};
use crate::yaml_helper::{StringEnum, YamlHelper, make_perspective};