Bug 1483303. Update webrender to commit e70bae07664def86aefd11c86dac818ab7ea64ea

This commit is contained in:
Jeff Muizelaar 2018-08-20 22:32:50 -04:00
Родитель 0f3c92c7f0
Коммит 3f1b0144a3
25 изменённых файлов: 451 добавлений и 430 удалений

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

@ -4,6 +4,7 @@ version = "0.57.2"
authors = ["Glenn Watson <gw@intuitionlibrary.com>"]
license = "MPL-2.0"
repository = "https://github.com/servo/webrender"
description = "A GPU accelerated 2D renderer for web content"
build = "build.rs"
[features]
@ -40,7 +41,7 @@ serde_json = { optional = true, version = "1.0" }
smallvec = "0.6"
thread_profiler = "0.1.1"
time = "0.1"
webrender_api = {path = "../webrender_api"}
webrender_api = { version = "0.57.2", path = "../webrender_api" }
ws = { optional = true, version = "0.7.3" }
[dependencies.pathfinder_font_renderer]

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

@ -175,6 +175,7 @@ void brush_vs(
break;
case COLOR_MODE_SUBPX_BG_PASS2:
case COLOR_MODE_SUBPX_DUAL_SOURCE:
case COLOR_MODE_IMAGE:
vMaskSwizzle = vec2(1.0, 0.0);
vColor = image_data.color;
break;

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

@ -42,6 +42,7 @@ varying vec4 vClipMaskUv;
#define COLOR_MODE_SUBPX_DUAL_SOURCE 6
#define COLOR_MODE_BITMAP 7
#define COLOR_MODE_COLOR_BITMAP 8
#define COLOR_MODE_IMAGE 9
uniform HIGHP_SAMPLER_FLOAT sampler2D sPrimitiveHeadersF;
uniform HIGHP_SAMPLER_FLOAT isampler2D sPrimitiveHeadersI;

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

@ -263,7 +263,6 @@ impl OpaqueBatchList {
pub struct BatchList {
pub alpha_batch_list: AlphaBatchList,
pub opaque_batch_list: OpaqueBatchList,
pub combined_bounding_rect: DeviceIntRect,
}
impl BatchList {
@ -275,24 +274,14 @@ impl BatchList {
BatchList {
alpha_batch_list: AlphaBatchList::new(),
opaque_batch_list: OpaqueBatchList::new(batch_area_threshold),
combined_bounding_rect: DeviceIntRect::zero(),
}
}
fn add_bounding_rect(
&mut self,
task_relative_bounding_rect: &DeviceIntRect,
) {
self.combined_bounding_rect = self.combined_bounding_rect.union(task_relative_bounding_rect);
}
pub fn get_suitable_batch(
&mut self,
key: BatchKey,
task_relative_bounding_rect: &DeviceIntRect,
) -> &mut Vec<PrimitiveInstance> {
self.add_bounding_rect(task_relative_bounding_rect);
match key.blend_mode {
BlendMode::None => {
self.opaque_batch_list
@ -409,31 +398,27 @@ pub struct AlphaBatchBuilder {
pub batch_list: BatchList,
glyph_fetch_buffer: Vec<GlyphFetchResult>,
target_rect: DeviceIntRect,
can_merge: bool,
}
impl AlphaBatchBuilder {
pub fn new(
screen_size: DeviceIntSize,
target_rect: DeviceIntRect,
can_merge: bool,
) -> Self {
AlphaBatchBuilder {
batch_list: BatchList::new(screen_size),
glyph_fetch_buffer: Vec::new(),
target_rect,
can_merge,
}
}
pub fn build(mut self, merged_batches: &mut AlphaBatchContainer) -> Option<AlphaBatchContainer> {
self.batch_list.finalize();
let task_relative_target_rect = DeviceIntRect::new(
DeviceIntPoint::zero(),
self.target_rect.size,
);
let can_merge = task_relative_target_rect.contains_rect(&self.batch_list.combined_bounding_rect);
if can_merge {
if self.can_merge {
merged_batches.merge(self);
None
} else {
@ -473,12 +458,8 @@ impl AlphaBatchBuilder {
// Add each run in this picture to the batch.
for run in &pic.runs {
let transform_id = ctx
.transforms
.get_id(run.spatial_node_index);
self.add_run_to_batch(
run,
transform_id,
ctx,
gpu_cache,
render_tasks,
@ -540,7 +521,6 @@ impl AlphaBatchBuilder {
fn add_run_to_batch(
&mut self,
run: &PrimitiveRun,
transform_id: TransformPaletteId,
ctx: &RenderTargetContext,
gpu_cache: &mut GpuCache,
render_tasks: &RenderTaskTree,
@ -556,6 +536,10 @@ impl AlphaBatchBuilder {
let metadata = &ctx.prim_store.primitives[prim_index.0].metadata;
if metadata.screen_rect.is_some() {
let transform_id = ctx
.transforms
.get_id(metadata.spatial_node_index);
self.add_prim_to_batch(
transform_id,
prim_index,
@ -670,12 +654,12 @@ impl AlphaBatchBuilder {
// Push into parent plane splitter.
debug_assert!(picture.surface.is_some());
let transform = &ctx.transforms
.get_transform(picture.original_spatial_node_index);
.get_transform_by_id(transform_id);
match transform.transform_kind {
TransformedRectKind::AxisAligned => {
let polygon = Polygon::from_transformed_rect(
picture.real_local_rect.cast(),
prim_metadata.local_rect.cast(),
transform.m.cast(),
prim_index.0,
).unwrap();
@ -686,7 +670,7 @@ impl AlphaBatchBuilder {
let bounds = (screen_rect.clipped.to_f32() / ctx.device_pixel_scale).to_f64();
let matrix = transform.m.cast();
let results = clipper.clip_transformed(
Polygon::from_rect(picture.real_local_rect.cast(), prim_index.0),
Polygon::from_rect(prim_metadata.local_rect.cast(), prim_index.0),
&matrix,
Some(bounds),
);
@ -723,7 +707,7 @@ impl AlphaBatchBuilder {
let batch = self.batch_list.get_suitable_batch(key, &task_relative_bounding_rect);
let prim_header_index = prim_headers.push(&prim_header, [
uv_rect_address.as_int(),
(ShaderColorMode::ColorBitmap as i32) << 16 |
(ShaderColorMode::Image as i32) << 16 |
RasterizationSpace::Screen as i32,
0,
]);
@ -786,7 +770,7 @@ impl AlphaBatchBuilder {
let content_prim_header_index = prim_headers.push(&prim_header, [
content_uv_rect_address,
(ShaderColorMode::ColorBitmap as i32) << 16 |
(ShaderColorMode::Image as i32) << 16 |
RasterizationSpace::Screen as i32,
0,
]);
@ -971,7 +955,7 @@ impl AlphaBatchBuilder {
.as_int();
let prim_header_index = prim_headers.push(&prim_header, [
uv_rect_address,
(ShaderColorMode::ColorBitmap as i32) << 16 |
(ShaderColorMode::Image as i32) << 16 |
RasterizationSpace::Screen as i32,
0,
]);
@ -1203,8 +1187,6 @@ impl AlphaBatchBuilder {
brush_flags: BrushFlags::PERSPECTIVE_INTERPOLATION,
};
self.batch_list.add_bounding_rect(task_relative_bounding_rect);
let batch_key = BatchKey {
blend_mode,
kind: BatchKind::Brush(batch_kind),
@ -1236,8 +1218,6 @@ impl AlphaBatchBuilder {
brush_flags: BrushFlags::PERSPECTIVE_INTERPOLATION,
};
self.batch_list.add_bounding_rect(task_relative_bounding_rect);
match brush.segment_desc {
Some(ref segment_desc) => {
let alpha_batch_key = BatchKey {
@ -1317,7 +1297,6 @@ fn add_gradient_tiles(
base_prim_header: &PrimitiveHeader,
prim_headers: &mut PrimitiveHeaders,
) {
batch_list.add_bounding_rect(task_relative_bounding_rect);
let batch = batch_list.get_suitable_batch(
BatchKey {
blend_mode: blend_mode,
@ -1373,7 +1352,7 @@ fn get_image_tile_params(
textures,
[
cache_item.uv_rect_handle.as_int(gpu_cache),
(ShaderColorMode::ColorBitmap as i32) << 16 |
(ShaderColorMode::Image as i32) << 16 |
RasterizationSpace::Local as i32,
0,
],
@ -1423,7 +1402,7 @@ impl BrushPrimitive {
textures,
[
cache_item.uv_rect_handle.as_int(gpu_cache),
(ShaderColorMode::ColorBitmap as i32) << 16|
(ShaderColorMode::Image as i32) << 16|
RasterizationSpace::Local as i32,
0,
],
@ -1461,7 +1440,7 @@ impl BrushPrimitive {
textures,
[
cache_item.uv_rect_handle.as_int(gpu_cache),
(ShaderColorMode::ColorBitmap as i32) << 16|
(ShaderColorMode::Image as i32) << 16|
RasterizationSpace::Local as i32,
0,
],

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

@ -11,7 +11,7 @@ use clip_scroll_tree::{CoordinateSystemId, SpatialNodeIndex};
use ellipse::Ellipse;
use gpu_cache::{GpuCache, GpuCacheHandle, ToGpuBlocks};
use gpu_types::BoxShadowStretchMode;
use prim_store::{ClipData, ImageMaskData};
use prim_store::{BrushClipMaskKind, ClipData, ImageMaskData};
use render_task::to_cache_size;
use resource_cache::{ImageRequest, ResourceCache};
use spatial_node::SpatialNode;
@ -352,12 +352,13 @@ pub struct ClipStore {
// A clip chain instance is what gets built for a given clip
// chain id + local primitive region + positioning node.
#[derive(Debug)]
pub struct ClipChainInstance {
pub clips_range: ClipNodeRange,
pub local_clip_rect: LayoutRect,
pub has_clips_from_other_coordinate_systems: bool,
pub has_non_root_coord_system: bool,
pub local_bounding_rect: LayoutRect,
pub clip_mask_kind: BrushClipMaskKind,
}
impl ClipStore {
@ -549,12 +550,19 @@ impl ClipStore {
let first_clip_node_index = self.clip_node_indices.len() as u32;
let mut has_non_root_coord_system = false;
let mut has_clips_from_other_coordinate_systems = false;
let mut clip_mask_kind = BrushClipMaskKind::Individual;
// For each potential clip node
for node_info in self.clip_node_info.drain(..) {
let node = &mut self.clip_nodes[node_info.node_index.0 as usize];
// TODO(gw): We can easily extend the segment builder to support these clip sources in
// the future, but they are rarely used.
// We must do this check here in case we continue early below.
if node.item.is_image_or_line_decoration_clip() {
clip_mask_kind = BrushClipMaskKind::Global;
}
// Convert the prim rect into the clip nodes local space
let prim_rect = node_info
.conversion
@ -600,10 +608,15 @@ impl ClipStore {
ClipNodeFlags::SAME_SPATIAL_NODE | ClipNodeFlags::SAME_COORD_SYSTEM
}
ClipSpaceConversion::Offset(..) => {
if !node.item.is_rect() {
clip_mask_kind = BrushClipMaskKind::Global;
}
ClipNodeFlags::SAME_COORD_SYSTEM
}
ClipSpaceConversion::Transform(..) => {
has_clips_from_other_coordinate_systems = true;
// If this primitive is clipped by clips from a different coordinate system, then we
// need to apply a clip mask for the entire primitive.
clip_mask_kind = BrushClipMaskKind::Global;
ClipNodeFlags::empty()
}
};
@ -626,10 +639,10 @@ impl ClipStore {
// Return a valid clip chain instance
Some(ClipChainInstance {
clips_range,
has_clips_from_other_coordinate_systems,
has_non_root_coord_system,
local_clip_rect: current_local_clip_rect,
local_bounding_rect,
clip_mask_kind,
})
}
}

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

@ -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::{ExternalScrollId, LayoutPoint, LayoutRect, LayoutVector2D};
use api::{ExternalScrollId, LayoutPoint, LayoutRect, LayoutVector2D, LayoutVector3D};
use api::{PipelineId, ScrollClamping, ScrollNodeState, ScrollLocation};
use api::{LayoutSize, LayoutTransform, PropertyBinding, ScrollSensitivity, WorldPoint};
use clip::{ClipStore};
@ -24,6 +24,25 @@ pub type ScrollStates = FastHashMap<ExternalScrollId, ScrollFrameInfo>;
#[cfg_attr(feature = "replay", derive(Deserialize))]
pub struct CoordinateSystemId(pub u32);
/// A node in the hierarchy of coordinate system
/// transforms.
#[derive(Debug)]
pub struct CoordinateSystem {
pub offset: LayoutVector3D,
pub transform: LayoutTransform,
pub parent: Option<CoordinateSystemId>,
}
impl CoordinateSystem {
fn root() -> Self {
CoordinateSystem {
offset: LayoutVector3D::zero(),
transform: LayoutTransform::identity(),
parent: None,
}
}
}
#[derive(Debug, Copy, Clone, Eq, Hash, PartialEq)]
#[cfg_attr(feature = "capture", derive(Serialize))]
#[cfg_attr(feature = "replay", derive(Deserialize))]
@ -36,15 +55,6 @@ impl CoordinateSystemId {
pub fn root() -> Self {
CoordinateSystemId(0)
}
pub fn next(&self) -> Self {
let CoordinateSystemId(id) = *self;
CoordinateSystemId(id + 1)
}
pub fn advance(&mut self) {
self.0 += 1;
}
}
pub struct ClipScrollTree {
@ -52,6 +62,11 @@ pub struct ClipScrollTree {
/// and clips.
pub spatial_nodes: Vec<SpatialNode>,
/// A list of transforms that establish new coordinate systems.
/// Spatial nodes only establish a new coordinate system when
/// they have a transform that is not a simple 2d translation.
pub coord_systems: Vec<CoordinateSystem>,
pub pending_scroll_offsets: FastHashMap<ExternalScrollId, (LayoutPoint, ScrollClamping)>,
/// A set of pipelines which should be discarded the next time this
@ -85,11 +100,49 @@ impl ClipScrollTree {
pub fn new() -> Self {
ClipScrollTree {
spatial_nodes: Vec::new(),
coord_systems: Vec::new(),
pending_scroll_offsets: FastHashMap::default(),
pipelines_to_discard: FastHashSet::default(),
}
}
/// Calculate the relative transform from `ref_node_index`
/// to `target_node_index`. It's assumed that `ref_node_index`
/// is a parent of `target_node_index`. This method will
/// panic if that invariant isn't true!
pub fn get_relative_transform(
&self,
ref_node_index: SpatialNodeIndex,
target_node_index: SpatialNodeIndex,
) -> LayoutTransform {
let ref_node = &self.spatial_nodes[ref_node_index.0];
let target_node = &self.spatial_nodes[target_node_index.0];
let mut offset = LayoutVector3D::new(
target_node.coordinate_system_relative_offset.x,
target_node.coordinate_system_relative_offset.y,
0.0,
);
let mut transform = LayoutTransform::identity();
// Walk up the tree of coordinate systems, accumulating each
// relative transform.
let mut current_coordinate_system_id = target_node.coordinate_system_id;
while current_coordinate_system_id != ref_node.coordinate_system_id {
let coord_system = &self.coord_systems[current_coordinate_system_id.0 as usize];
let relative_transform = coord_system
.transform
.post_translate(offset);
transform = transform.pre_mul(&relative_transform);
offset = coord_system.offset;
current_coordinate_system_id = coord_system.parent.expect("invalid parent!");
}
transform
}
/// The root reference frame, which is the true root of the ClipScrollTree. Initially
/// this ID is not valid, which is indicated by ```spatial_nodes``` being empty.
pub fn root_reference_frame_index(&self) -> SpatialNodeIndex {
@ -133,6 +186,7 @@ impl ClipScrollTree {
}
}
self.coord_systems.clear();
self.pipelines_to_discard.clear();
scroll_states
}
@ -191,6 +245,9 @@ impl ClipScrollTree {
return transform_palette;
}
self.coord_systems.clear();
self.coord_systems.push(CoordinateSystem::root());
let root_reference_frame_index = self.root_reference_frame_index();
let mut state = TransformUpdateState {
parent_reference_frame_transform: LayoutVector2D::new(pan.x, pan.y).into(),
@ -202,11 +259,9 @@ impl ClipScrollTree {
invertible: true,
};
let mut next_coordinate_system_id = state.current_coordinate_system_id.next();
self.update_node(
root_reference_frame_index,
&mut state,
&mut next_coordinate_system_id,
&mut transform_palette,
scene_properties,
);
@ -218,7 +273,6 @@ impl ClipScrollTree {
&mut self,
node_index: SpatialNodeIndex,
state: &mut TransformUpdateState,
next_coordinate_system_id: &mut CoordinateSystemId,
transform_palette: &mut TransformPalette,
scene_properties: &SceneProperties,
) {
@ -231,7 +285,7 @@ impl ClipScrollTree {
None => return,
};
node.update(&mut state, next_coordinate_system_id, scene_properties);
node.update(&mut state, &mut self.coord_systems, scene_properties);
node.push_gpu_data(transform_palette, node_index);
if node.children.is_empty() {
@ -246,7 +300,6 @@ impl ClipScrollTree {
self.update_node(
child_node_index,
&mut state,
next_coordinate_system_id,
transform_palette,
scene_properties,
);

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

@ -513,6 +513,7 @@ impl<'a> DisplayListFlattener<'a> {
info.image_key,
info.image_rendering,
info.alpha_type,
info.color,
);
}
SpecificDisplayItem::YuvImage(ref info) => {
@ -776,6 +777,7 @@ impl<'a> DisplayListFlattener<'a> {
&mut self,
info: &LayoutPrimitiveInfo,
clip_chain_id: ClipChainId,
spatial_node_index: SpatialNodeIndex,
container: PrimitiveContainer,
) -> PrimitiveIndex {
let stacking_context = self.sc_stack.last().expect("bug: no stacking context!");
@ -785,6 +787,7 @@ impl<'a> DisplayListFlattener<'a> {
&info.clip_rect,
info.is_backface_visible && stacking_context.is_backface_visible,
clip_chain_id,
spatial_node_index,
info.tag,
container,
)
@ -817,12 +820,11 @@ impl<'a> DisplayListFlattener<'a> {
pub fn add_primitive_to_draw_list(
&mut self,
prim_index: PrimitiveIndex,
spatial_node_index: SpatialNodeIndex,
) {
// Add primitive to the top-most Picture on the stack.
let pic_prim_index = *self.picture_stack.last().unwrap();
let pic = self.prim_store.get_pic_mut(pic_prim_index);
pic.add_primitive(prim_index, spatial_node_index);
pic.add_primitive(prim_index);
}
/// Convenience interface that creates a primitive entry and adds it
@ -859,15 +861,13 @@ impl<'a> DisplayListFlattener<'a> {
let shadow_prim_index = self.create_primitive(
&info,
clip_chain_id,
clip_and_scroll.spatial_node_index,
container.create_shadow(shadow),
);
// Add the new primitive to the shadow picture.
let shadow_pic = self.prim_store.get_pic_mut(shadow_pic_prim_index);
shadow_pic.add_primitive(
shadow_prim_index,
clip_and_scroll.spatial_node_index,
);
shadow_pic.add_primitive(shadow_prim_index);
}
self.shadow_stack = shadow_stack;
}
@ -878,7 +878,12 @@ impl<'a> DisplayListFlattener<'a> {
clip_and_scroll.spatial_node_index,
clip_and_scroll.clip_chain_id,
);
let prim_index = self.create_primitive(info, clip_chain_id, container);
let prim_index = self.create_primitive(
info,
clip_chain_id,
clip_and_scroll.spatial_node_index,
container,
);
if cfg!(debug_assertions) && ChasePrimitive::LocalRect(info.rect) == self.config.chase_primitive {
println!("Chasing {:?}", prim_index);
self.prim_store.chase_id = Some(prim_index);
@ -886,7 +891,6 @@ impl<'a> DisplayListFlattener<'a> {
self.add_primitive_to_hit_testing_list(info, clip_and_scroll);
self.add_primitive_to_draw_list(
prim_index,
clip_and_scroll.spatial_node_index,
);
}
}
@ -935,7 +939,6 @@ impl<'a> DisplayListFlattener<'a> {
None,
false,
pipeline_id,
spatial_node_index,
None,
true,
);
@ -945,6 +948,7 @@ impl<'a> DisplayListFlattener<'a> {
&max_clip,
true,
ClipChainId::NONE,
spatial_node_index,
None,
PrimitiveContainer::Brush(BrushPrimitive::new_picture(picture)),
);
@ -1001,7 +1005,6 @@ impl<'a> DisplayListFlattener<'a> {
None,
false,
pipeline_id,
spatial_node_index,
None,
true,
);
@ -1013,6 +1016,7 @@ impl<'a> DisplayListFlattener<'a> {
&max_clip,
is_backface_visible,
clip_chain_id,
spatial_node_index,
None,
PrimitiveContainer::Brush(prim),
);
@ -1020,7 +1024,7 @@ impl<'a> DisplayListFlattener<'a> {
let parent_prim_index = *self.picture_stack.last().unwrap();
let pic = self.prim_store.get_pic_mut(parent_prim_index);
pic.add_primitive(prim_index, spatial_node_index);
pic.add_primitive(prim_index);
self.picture_stack.push(prim_index);
@ -1052,7 +1056,6 @@ impl<'a> DisplayListFlattener<'a> {
Some(PictureCompositeMode::Filter(*filter)),
false,
pipeline_id,
spatial_node_index,
None,
true,
);
@ -1063,6 +1066,7 @@ impl<'a> DisplayListFlattener<'a> {
&max_clip,
is_backface_visible,
clip_chain_id,
spatial_node_index,
None,
PrimitiveContainer::Brush(src_prim),
);
@ -1070,7 +1074,7 @@ impl<'a> DisplayListFlattener<'a> {
let parent_pic = self.prim_store.get_pic_mut(parent_prim_index);
parent_prim_index = src_prim_index;
parent_pic.add_primitive(src_prim_index, spatial_node_index);
parent_pic.add_primitive(src_prim_index);
self.picture_stack.push(src_prim_index);
}
@ -1082,7 +1086,6 @@ impl<'a> DisplayListFlattener<'a> {
Some(PictureCompositeMode::MixBlend(mix_blend_mode)),
false,
pipeline_id,
spatial_node_index,
None,
true,
);
@ -1094,13 +1097,14 @@ impl<'a> DisplayListFlattener<'a> {
&max_clip,
is_backface_visible,
clip_chain_id,
spatial_node_index,
None,
PrimitiveContainer::Brush(src_prim),
);
let parent_pic = self.prim_store.get_pic_mut(parent_prim_index);
parent_prim_index = src_prim_index;
parent_pic.add_primitive(src_prim_index, spatial_node_index);
parent_pic.add_primitive(src_prim_index);
self.picture_stack.push(src_prim_index);
}
@ -1138,7 +1142,6 @@ impl<'a> DisplayListFlattener<'a> {
composite_mode,
participating_in_3d_context,
pipeline_id,
spatial_node_index,
frame_output_pipeline_id,
true,
);
@ -1152,12 +1155,13 @@ impl<'a> DisplayListFlattener<'a> {
&max_clip,
is_backface_visible,
clip_chain_id,
spatial_node_index,
None,
PrimitiveContainer::Brush(sc_prim),
);
let parent_pic = self.prim_store.get_pic_mut(parent_prim_index);
parent_pic.add_primitive(sc_prim_index, spatial_node_index);
parent_pic.add_primitive(sc_prim_index);
// Add this as the top-most picture for primitives to be added to.
self.picture_stack.push(sc_prim_index);
@ -1384,7 +1388,6 @@ impl<'a> DisplayListFlattener<'a> {
Some(PictureCompositeMode::Filter(FilterOp::Blur(std_deviation))),
false,
pipeline_id,
clip_and_scroll.spatial_node_index,
None,
apply_local_clip_rect,
);
@ -1396,6 +1399,7 @@ impl<'a> DisplayListFlattener<'a> {
&max_clip,
info.is_backface_visible,
clip_and_scroll.clip_chain_id,
clip_and_scroll.spatial_node_index,
None,
PrimitiveContainer::Brush(shadow_prim),
);
@ -1404,7 +1408,6 @@ impl<'a> DisplayListFlattener<'a> {
// picture on to the shadow stack, to avoid infinite recursion!
self.add_primitive_to_draw_list(
shadow_prim_index,
clip_and_scroll.spatial_node_index,
);
self.shadow_stack.push((shadow, shadow_prim_index));
}
@ -1479,12 +1482,12 @@ impl<'a> DisplayListFlattener<'a> {
let prim_index = self.create_primitive(
info,
ClipChainId::NONE,
spatial_node_index,
PrimitiveContainer::Brush(prim),
);
self.add_primitive_to_draw_list(
prim_index,
spatial_node_index,
);
self.scrollbar_prims.push(ScrollbarPrimitive {
@ -1908,6 +1911,7 @@ impl<'a> DisplayListFlattener<'a> {
image_key: ImageKey,
image_rendering: ImageRendering,
alpha_type: AlphaType,
color: ColorF,
) {
let mut prim_rect = info.rect;
simplify_repeated_primitive(&stretch_size, &mut tile_spacing, &mut prim_rect);
@ -1939,6 +1943,7 @@ impl<'a> DisplayListFlattener<'a> {
alpha_type,
stretch_size,
tile_spacing,
color,
source: ImageSource::Default,
sub_rect,
visible_tiles: Vec::new(),

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

@ -13,14 +13,14 @@ use gpu_types::{PrimitiveHeaders, TransformPalette, UvRectKind};
use hit_test::{HitTester, HitTestingRun};
use internal_types::{FastHashMap};
use picture::PictureSurface;
use prim_store::{PrimitiveIndex, PrimitiveRun, PrimitiveStore, Transform};
use prim_store::{PrimitiveIndex, PrimitiveRun, LocalRectBuilder, PrimitiveStore, Transform};
use profiler::{FrameProfileCounters, GpuCacheProfileCounters, TextureCacheProfileCounters};
use render_backend::FrameId;
use render_task::{RenderTask, RenderTaskId, RenderTaskLocation, RenderTaskTree};
use resource_cache::{ResourceCache};
use scene::{ScenePipeline, SceneProperties};
use spatial_node::SpatialNode;
use std::{mem, f32};
use std::f32;
use std::sync::Arc;
use tiling::{Frame, RenderPass, RenderPassKind, RenderTargetContext};
use tiling::{ScrollbarPrimitive, SpecialRenderPasses};
@ -89,8 +89,6 @@ pub struct FrameBuildingState<'a> {
pub struct PictureContext {
pub pipeline_id: PipelineId,
pub prim_runs: Vec<PrimitiveRun>,
pub spatial_node_index: SpatialNodeIndex,
pub original_spatial_node_index: SpatialNodeIndex,
pub apply_local_clip_rect: bool,
pub inflation_factor: f32,
pub allow_subpixel_aa: bool,
@ -112,20 +110,20 @@ impl PictureState {
}
}
pub struct PrimitiveRunContext<'a> {
pub scroll_node: &'a SpatialNode,
pub struct PrimitiveContext<'a> {
pub spatial_node: &'a SpatialNode,
pub spatial_node_index: SpatialNodeIndex,
pub transform: Transform<'a>,
}
impl<'a> PrimitiveRunContext<'a> {
impl<'a> PrimitiveContext<'a> {
pub fn new(
scroll_node: &'a SpatialNode,
spatial_node: &'a SpatialNode,
spatial_node_index: SpatialNodeIndex,
transform: Transform<'a>,
) -> Self {
PrimitiveRunContext {
scroll_node,
PrimitiveContext {
spatial_node,
spatial_node_index,
transform,
}
@ -195,11 +193,11 @@ impl FrameBuilder {
if self.prim_store.primitives.is_empty() {
return None
}
self.prim_store.reset_prim_visibility();
// The root picture is always the first one added.
let root_prim_index = PrimitiveIndex(0);
let root_spatial_node_index = clip_scroll_tree.root_reference_frame_index();
let root_spatial_node = &clip_scroll_tree.spatial_nodes[root_spatial_node_index.0];
const MAX_CLIP_COORD: f32 = 1.0e9;
@ -226,34 +224,33 @@ impl FrameBuilder {
special_render_passes,
};
let pic_context = PictureContext {
pipeline_id: root_spatial_node.pipeline_id,
prim_runs: mem::replace(
&mut self.prim_store.get_pic_mut(root_prim_index).runs,
Vec::new(),
),
spatial_node_index: root_spatial_node_index,
original_spatial_node_index: root_spatial_node_index,
apply_local_clip_rect: true,
inflation_factor: 0.0,
allow_subpixel_aa: true,
};
let mut pic_state = PictureState::new();
self.prim_store.reset_prim_visibility();
let pic_context = self
.prim_store
.get_pic_mut(root_prim_index)
.take_context(true);
let mut local_rect_builder = LocalRectBuilder::new(
root_spatial_node_index,
);
self.prim_store.prepare_prim_runs(
&pic_context,
&mut pic_state,
&frame_context,
&mut frame_state,
&mut local_rect_builder,
);
let pic = self.prim_store.get_pic_mut(root_prim_index);
pic.runs = pic_context.prim_runs;
let pic = self
.prim_store
.get_pic_mut(root_prim_index);
pic.restore_context(pic_context, local_rect_builder);
let root_render_task = RenderTask::new_picture(
RenderTaskLocation::Fixed(frame_context.screen_rect),
frame_context.screen_rect.size,
root_prim_index,
DeviceIntPoint::zero(),
pic_state.tasks,

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

@ -301,7 +301,7 @@ fn request_render_task_from_pathfinder(glyph_key: &GlyphKey,
let subpixel_offset = TypedPoint2D::new(glyph_subpixel_offset as f32, 0.0);
let embolden_amount = compute_embolden_amount(size.to_f32_px());
let location = RenderTaskLocation::Dynamic(None, Some(*glyph_size));
let location = RenderTaskLocation::Dynamic(None, *glyph_size);
let glyph_render_task = RenderTask::new_glyph(location,
mesh,
&glyph_origin,

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

@ -354,7 +354,7 @@ impl TransformPaletteId {
pub const IDENTITY: Self = TransformPaletteId(0);
/// Extract the spatial node index from the id.
pub fn _spatial_node_index(&self) -> SpatialNodeIndex {
pub fn spatial_node_index(&self) -> SpatialNodeIndex {
SpatialNodeIndex(self.0 as usize & 0xFFFFFF)
}
@ -480,6 +480,13 @@ impl TransformPalette {
}
}
pub fn get_transform_by_id(
&self,
id: TransformPaletteId,
) -> Transform {
self.get_transform(id.spatial_node_index())
}
// Get a transform palette id for the given spatial node.
// TODO(gw): In the future, it will be possible to specify
// a coordinate system id here, to allow retrieving

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

@ -6,11 +6,11 @@ use api::{DeviceRect, FilterOp, MixBlendMode, PipelineId, PremultipliedColorF};
use api::{DeviceIntRect, DeviceIntSize, DevicePoint, LayoutPoint, LayoutRect};
use api::{DevicePixelScale, PictureIntPoint, PictureIntRect, PictureIntSize};
use box_shadow::{BLUR_SAMPLE_SCALE};
use clip_scroll_tree::SpatialNodeIndex;
use frame_builder::{FrameBuildingContext, FrameBuildingState, PictureState, PrimitiveRunContext};
use frame_builder::{FrameBuildingContext, FrameBuildingState, PictureState};
use frame_builder::{PictureContext, PrimitiveContext};
use gpu_cache::{GpuCacheHandle};
use gpu_types::UvRectKind;
use prim_store::{PrimitiveIndex, PrimitiveRun, PrimitiveRunLocalRect};
use prim_store::{PrimitiveIndex, PrimitiveRun, LocalRectBuilder};
use prim_store::{PrimitiveMetadata, Transform};
use render_task::{ClearMode, RenderTask, RenderTaskCacheEntryHandle};
use render_task::{RenderTaskCacheKey, RenderTaskCacheKeyKind, RenderTaskId, RenderTaskLocation};
@ -146,11 +146,6 @@ pub struct PicturePrimitive {
// pages to a texture), this is the pipeline this
// picture is the root of.
pub frame_output_pipeline_id: Option<PipelineId>,
// The original reference spatial node for this picture.
// It is only different if this is part of a 3D
// rendering context.
pub original_spatial_node_index: SpatialNodeIndex,
pub real_local_rect: LayoutRect,
// An optional cache handle for storing extra data
// in the GPU cache, depending on the type of
// picture.
@ -182,7 +177,6 @@ impl PicturePrimitive {
composite_mode: Option<PictureCompositeMode>,
is_in_3d_context: bool,
pipeline_id: PipelineId,
original_spatial_node_index: SpatialNodeIndex,
frame_output_pipeline_id: Option<PipelineId>,
apply_local_clip_rect: bool,
) -> Self {
@ -193,8 +187,6 @@ impl PicturePrimitive {
composite_mode,
is_in_3d_context,
frame_output_pipeline_id,
original_spatial_node_index,
real_local_rect: LayoutRect::zero(),
extra_gpu_data_handle: GpuCacheHandle::new(),
apply_local_clip_rect,
pipeline_id,
@ -202,14 +194,39 @@ impl PicturePrimitive {
}
}
pub fn take_context(
&mut self,
allow_subpixel_aa: bool,
) -> PictureContext {
// TODO(lsalzman): allow overriding parent if intermediate surface is opaque
let allow_subpixel_aa = allow_subpixel_aa && self.allow_subpixel_aa();
let inflation_factor = match self.composite_mode {
Some(PictureCompositeMode::Filter(FilterOp::Blur(blur_radius))) => {
// The amount of extra space needed for primitives inside
// this picture to ensure the visibility check is correct.
BLUR_SAMPLE_SCALE * blur_radius
}
_ => {
0.0
}
};
PictureContext {
pipeline_id: self.pipeline_id,
prim_runs: mem::replace(&mut self.runs, Vec::new()),
apply_local_clip_rect: self.apply_local_clip_rect,
inflation_factor,
allow_subpixel_aa,
}
}
pub fn add_primitive(
&mut self,
prim_index: PrimitiveIndex,
spatial_node_index: SpatialNodeIndex,
) {
if let Some(ref mut run) = self.runs.last_mut() {
if run.spatial_node_index == spatial_node_index &&
run.base_prim_index.0 + run.count == prim_index.0 {
if run.base_prim_index.0 + run.count == prim_index.0 {
run.count += 1;
return;
}
@ -218,23 +235,17 @@ impl PicturePrimitive {
self.runs.push(PrimitiveRun {
base_prim_index: prim_index,
count: 1,
spatial_node_index,
});
}
pub fn update_local_rect_and_set_runs(
pub fn restore_context(
&mut self,
prim_run_rect: PrimitiveRunLocalRect,
prim_runs: Vec<PrimitiveRun>,
context: PictureContext,
local_rect_builder: LocalRectBuilder,
) -> LayoutRect {
self.runs = prim_runs;
self.runs = context.prim_runs;
let local_content_rect = prim_run_rect.mapping.local_rect;
self.real_local_rect = match prim_run_rect.original_mapping {
Some(mapping) => mapping.local_rect,
None => local_content_rect,
};
let local_content_rect = local_rect_builder.local_rect;
match self.composite_mode {
Some(PictureCompositeMode::Filter(FilterOp::Blur(blur_radius))) => {
@ -277,7 +288,7 @@ impl PicturePrimitive {
}
// Disallow subpixel AA if an intermediate surface is needed.
pub fn allow_subpixel_aa(&self) -> bool {
fn allow_subpixel_aa(&self) -> bool {
self.can_draw_directly_to_parent_surface()
}
@ -285,7 +296,7 @@ impl PicturePrimitive {
&mut self,
prim_index: PrimitiveIndex,
prim_metadata: &mut PrimitiveMetadata,
prim_run_context: &PrimitiveRunContext,
prim_context: &PrimitiveContext,
mut pic_state_for_children: PictureState,
pic_state: &mut PictureState,
frame_context: &FrameBuildingContext,
@ -328,7 +339,7 @@ impl PicturePrimitive {
let uv_rect_kind = calculate_uv_rect_kind(
&prim_metadata.local_rect,
&prim_run_context.transform,
&prim_context.transform,
&device_rect,
frame_context.device_pixel_scale,
);
@ -341,7 +352,8 @@ impl PicturePrimitive {
// relevant transforms haven't changed from frame to frame.
let surface = if pic_state_for_children.has_non_root_coord_system {
let picture_task = RenderTask::new_picture(
RenderTaskLocation::Dynamic(None, Some(device_rect.size)),
RenderTaskLocation::Dynamic(None, device_rect.size),
prim_screen_rect.unclipped.size,
prim_index,
device_rect.origin,
pic_state_for_children.tasks,
@ -397,7 +409,8 @@ impl PicturePrimitive {
let child_tasks = mem::replace(&mut pic_state_for_children.tasks, Vec::new());
let picture_task = RenderTask::new_picture(
RenderTaskLocation::Dynamic(None, Some(device_rect.size)),
RenderTaskLocation::Dynamic(None, device_rect.size),
prim_screen_rect.unclipped.size,
prim_index,
device_rect.origin,
child_tasks,
@ -447,13 +460,14 @@ impl PicturePrimitive {
let uv_rect_kind = calculate_uv_rect_kind(
&prim_metadata.local_rect,
&prim_run_context.transform,
&prim_context.transform,
&device_rect,
frame_context.device_pixel_scale,
);
let mut picture_task = RenderTask::new_picture(
RenderTaskLocation::Dynamic(None, Some(device_rect.size)),
RenderTaskLocation::Dynamic(None, device_rect.size),
prim_screen_rect.unclipped.size,
prim_index,
device_rect.origin,
pic_state_for_children.tasks,
@ -516,13 +530,14 @@ impl PicturePrimitive {
Some(PictureCompositeMode::MixBlend(..)) => {
let uv_rect_kind = calculate_uv_rect_kind(
&prim_metadata.local_rect,
&prim_run_context.transform,
&prim_context.transform,
&prim_screen_rect.clipped,
frame_context.device_pixel_scale,
);
let picture_task = RenderTask::new_picture(
RenderTaskLocation::Dynamic(None, Some(prim_screen_rect.clipped.size)),
RenderTaskLocation::Dynamic(None, prim_screen_rect.clipped.size),
prim_screen_rect.unclipped.size,
prim_index,
prim_screen_rect.clipped.origin,
pic_state_for_children.tasks,
@ -551,13 +566,14 @@ impl PicturePrimitive {
let uv_rect_kind = calculate_uv_rect_kind(
&prim_metadata.local_rect,
&prim_run_context.transform,
&prim_context.transform,
&prim_screen_rect.clipped,
frame_context.device_pixel_scale,
);
let picture_task = RenderTask::new_picture(
RenderTaskLocation::Dynamic(None, Some(prim_screen_rect.clipped.size)),
RenderTaskLocation::Dynamic(None, prim_screen_rect.clipped.size),
prim_screen_rect.unclipped.size,
prim_index,
prim_screen_rect.clipped.origin,
pic_state_for_children.tasks,
@ -571,13 +587,14 @@ impl PicturePrimitive {
Some(PictureCompositeMode::Blit) | None => {
let uv_rect_kind = calculate_uv_rect_kind(
&prim_metadata.local_rect,
&prim_run_context.transform,
&prim_context.transform,
&prim_screen_rect.clipped,
frame_context.device_pixel_scale,
);
let picture_task = RenderTask::new_picture(
RenderTaskLocation::Dynamic(None, Some(prim_screen_rect.clipped.size)),
RenderTaskLocation::Dynamic(None, prim_screen_rect.clipped.size),
prim_screen_rect.unclipped.size,
prim_index,
prim_screen_rect.clipped.origin,
pic_state_for_children.tasks,

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

@ -10,11 +10,10 @@ use api::{PremultipliedColorF, PropertyBinding, Shadow, YuvColorSpace, YuvFormat
use api::{BorderWidths, BoxShadowClipMode, LayoutToWorldScale, NormalBorder};
use app_units::Au;
use border::{BorderCacheKey, BorderRenderTaskInfo};
use box_shadow::BLUR_SAMPLE_SCALE;
use clip_scroll_tree::{CoordinateSystemId, SpatialNodeIndex};
use clip_scroll_tree::{ClipScrollTree, CoordinateSystemId, SpatialNodeIndex};
use clip::{ClipNodeFlags, ClipChainId, ClipChainInstance, ClipItem};
use frame_builder::{FrameBuildingContext, FrameBuildingState, PictureContext, PictureState};
use frame_builder::PrimitiveRunContext;
use frame_builder::PrimitiveContext;
use glyph_rasterizer::{FontInstance, FontTransform, GlyphKey, FONT_SIZE_LIMIT};
use gpu_cache::{GpuBlockData, GpuCache, GpuCacheAddress, GpuCacheHandle, GpuDataRequest,
ToGpuBlocks};
@ -29,7 +28,6 @@ use renderer::{MAX_VERTEX_TEXTURE_WIDTH};
use resource_cache::{ImageProperties, ImageRequest, ResourceCache};
use scene::SceneProperties;
use segment::SegmentBuilder;
use spatial_node::SpatialNode;
use std::{mem, usize};
use util::{MatrixHelpers, calculate_screen_bounding_rect};
use util::{pack_as_float, recycle_vec, TransformedRectKind};
@ -71,7 +69,6 @@ pub struct Transform<'a> {
pub struct PrimitiveRun {
pub base_prim_index: PrimitiveIndex,
pub count: usize,
pub spatial_node_index: SpatialNodeIndex,
}
impl PrimitiveRun {
@ -107,81 +104,10 @@ impl PrimitiveOpacity {
}
#[derive(Debug)]
pub enum CoordinateSpaceMappingKind {
pub enum CoordinateSpaceMapping {
Local,
Offset(LayoutVector2D),
Transform(Option<LayoutTransform>),
}
#[derive(Debug)]
pub struct CoordinateSpaceMapping {
kind: CoordinateSpaceMappingKind,
pub local_rect: LayoutRect,
ref_spatial_node_index: SpatialNodeIndex,
}
impl CoordinateSpaceMapping {
fn new(
ref_spatial_node_index: SpatialNodeIndex,
) -> Self {
CoordinateSpaceMapping {
kind: CoordinateSpaceMappingKind::Local,
local_rect: LayoutRect::zero(),
ref_spatial_node_index,
}
}
pub fn set_target_spatial_node(
&mut self,
target_node_index: SpatialNodeIndex,
spatial_nodes: &[SpatialNode],
) {
let ref_spatial_node = &spatial_nodes[self.ref_spatial_node_index.0];
let target_spatial_node = &spatial_nodes[target_node_index.0];
self.kind = if self.ref_spatial_node_index == target_node_index {
CoordinateSpaceMappingKind::Local
} else if ref_spatial_node.coordinate_system_id == target_spatial_node.coordinate_system_id {
let offset = target_spatial_node.coordinate_system_relative_offset -
ref_spatial_node.coordinate_system_relative_offset;
CoordinateSpaceMappingKind::Offset(offset)
} else {
let relative_transform = ref_spatial_node
.world_content_transform
.inverse()
.map(|inv_parent| {
inv_parent.pre_mul(&target_spatial_node.world_content_transform)
})
.map(|transform| {
*transform.to_transform()
});
CoordinateSpaceMappingKind::Transform(relative_transform)
}
}
pub fn accumulate(&mut self, rect: &LayoutRect) {
match self.kind {
CoordinateSpaceMappingKind::Local => {
self.local_rect = self.local_rect.union(rect);
}
CoordinateSpaceMappingKind::Offset(ref offset) => {
let rect = rect.translate(offset);
self.local_rect = self.local_rect.union(&rect);
}
CoordinateSpaceMappingKind::Transform(ref transform) => {
if let Some(ref matrix) = transform {
match matrix.transform_rect(rect) {
Some(bounds) => {
self.local_rect = self.local_rect.union(&bounds);
}
None => {
warn!("parent relative transform can't transform the primitive rect for {:?}", rect);
}
}
}
}
}
}
Transform(LayoutTransform),
}
// Represents the local space rect of a list of
@ -200,48 +126,69 @@ impl CoordinateSpaceMapping {
// polygons directly and store internally
// in the picture structure.
#[derive(Debug)]
pub struct PrimitiveRunLocalRect {
pub mapping: CoordinateSpaceMapping,
pub original_mapping: Option<CoordinateSpaceMapping>,
pub struct LocalRectBuilder {
kind: CoordinateSpaceMapping,
ref_spatial_node_index: SpatialNodeIndex,
current_target_spatial_node_index: SpatialNodeIndex,
pub local_rect: LayoutRect,
}
impl PrimitiveRunLocalRect {
pub fn new(
spatial_node_index: SpatialNodeIndex,
original_spatial_node_index: SpatialNodeIndex,
) -> Self {
let mapping = CoordinateSpaceMapping::new(spatial_node_index);
let original_mapping = if spatial_node_index == original_spatial_node_index {
None
} else {
Some(CoordinateSpaceMapping::new(original_spatial_node_index))
};
PrimitiveRunLocalRect {
mapping,
original_mapping,
impl LocalRectBuilder {
pub fn new(ref_spatial_node_index: SpatialNodeIndex) -> Self {
LocalRectBuilder {
kind: CoordinateSpaceMapping::Local,
local_rect: LayoutRect::zero(),
ref_spatial_node_index,
current_target_spatial_node_index: ref_spatial_node_index,
}
}
pub fn set_target_spatial_node(
&mut self,
target_node_index: SpatialNodeIndex,
spatial_nodes: &[SpatialNode],
clip_scroll_tree: &ClipScrollTree,
) {
self.mapping
.set_target_spatial_node(target_node_index, spatial_nodes);
if target_node_index != self.current_target_spatial_node_index {
let spatial_nodes = &clip_scroll_tree.spatial_nodes;
let ref_spatial_node = &spatial_nodes[self.ref_spatial_node_index.0];
let target_spatial_node = &spatial_nodes[target_node_index.0];
self.current_target_spatial_node_index = target_node_index;
if let Some(ref mut mapping) = self.original_mapping {
mapping.set_target_spatial_node(target_node_index, spatial_nodes);
self.kind = if self.ref_spatial_node_index == target_node_index {
CoordinateSpaceMapping::Local
} else if ref_spatial_node.coordinate_system_id == target_spatial_node.coordinate_system_id {
let offset = target_spatial_node.coordinate_system_relative_offset -
ref_spatial_node.coordinate_system_relative_offset;
CoordinateSpaceMapping::Offset(offset)
} else {
let transform = clip_scroll_tree.get_relative_transform(
self.ref_spatial_node_index,
target_node_index,
);
CoordinateSpaceMapping::Transform(transform)
};
}
}
pub fn accumulate(&mut self, rect: &LayoutRect) {
self.mapping.accumulate(rect);
if let Some(ref mut mapping) = self.original_mapping {
mapping.accumulate(rect);
match self.kind {
CoordinateSpaceMapping::Local => {
self.local_rect = self.local_rect.union(rect);
}
CoordinateSpaceMapping::Offset(ref offset) => {
let rect = rect.translate(offset);
self.local_rect = self.local_rect.union(&rect);
}
CoordinateSpaceMapping::Transform(ref transform) => {
match transform.transform_rect(rect) {
Some(bounds) => {
self.local_rect = self.local_rect.union(&bounds);
}
None => {
warn!("parent relative transform can't transform the primitive rect for {:?}", rect);
}
}
}
}
}
}
@ -292,6 +239,7 @@ pub struct ScreenRect {
pub struct PrimitiveMetadata {
pub opacity: PrimitiveOpacity,
pub clip_chain_id: ClipChainId,
pub spatial_node_index: SpatialNodeIndex,
pub gpu_location: GpuCacheHandle,
pub clip_task_id: Option<RenderTaskId>,
@ -400,6 +348,7 @@ pub enum BrushKind {
alpha_type: AlphaType,
stretch_size: LayoutSize,
tile_spacing: LayoutSize,
color: ColorF,
source: ImageSource,
sub_rect: Option<DeviceIntRect>,
opacity_binding: OpacityBinding,
@ -603,8 +552,8 @@ impl BrushPrimitive {
}
// Images are drawn as a white color, modulated by the total
// opacity coming from any collapsed property bindings.
BrushKind::Image { stretch_size, tile_spacing, ref opacity_binding, .. } => {
request.push(ColorF::new(1.0, 1.0, 1.0, opacity_binding.current).premultiplied());
BrushKind::Image { stretch_size, tile_spacing, color, ref opacity_binding, .. } => {
request.push(color.scale_alpha(opacity_binding.current).premultiplied());
request.push(PremultipliedColorF::WHITE);
request.push([
stretch_size.width + tile_spacing.width,
@ -1374,6 +1323,7 @@ impl PrimitiveStore {
local_clip_rect: &LayoutRect,
is_backface_visible: bool,
clip_chain_id: ClipChainId,
spatial_node_index: SpatialNodeIndex,
tag: Option<ItemTag>,
container: PrimitiveContainer,
) -> PrimitiveIndex {
@ -1383,6 +1333,7 @@ impl PrimitiveStore {
clip_chain_id,
gpu_location: GpuCacheHandle::new(),
clip_task_id: None,
spatial_node_index,
local_rect: *local_rect,
local_clip_rect: *local_clip_rect,
combined_local_clip_rect: *local_clip_rect,
@ -1556,16 +1507,16 @@ impl PrimitiveStore {
pub fn prepare_prim_for_render(
&mut self,
prim_index: PrimitiveIndex,
prim_run_context: &PrimitiveRunContext,
prim_context: &PrimitiveContext,
pic_context: &PictureContext,
pic_state: &mut PictureState,
frame_context: &FrameBuildingContext,
frame_state: &mut FrameBuildingState,
display_list: &BuiltDisplayList,
is_chased: bool,
) -> Option<LayoutRect> {
let mut may_need_clip_mask = true;
let mut pic_state_for_children = PictureState::new();
let is_chased = Some(prim_index) == self.chase_id;
// If we have dependencies, we need to prepare them first, in order
// to know the actual rect of this primitive.
@ -1573,18 +1524,7 @@ impl PrimitiveStore {
// local space, which may force us to render this item on a larger
// picture target, if being composited.
let pic_context_for_children = {
let prim = &mut self.primitives[prim_index.0];
// Do some basic checks first, that can early out
// without even knowing the local rect.
if !prim.metadata.is_backface_visible && prim_run_context.transform.backface_is_visible {
if cfg!(debug_assertions) && is_chased {
println!("\tculled for not having visible back faces");
}
return None;
}
match prim.details {
match self.primitives[prim_index.0].details {
PrimitiveDetails::Brush(ref mut brush) => {
match brush.kind {
BrushKind::Picture(ref mut pic) => {
@ -1597,31 +1537,11 @@ impl PrimitiveStore {
may_need_clip_mask = pic.composite_mode.is_some();
let inflation_factor = match pic.composite_mode {
Some(PictureCompositeMode::Filter(FilterOp::Blur(blur_radius))) => {
// The amount of extra space needed for primitives inside
// this picture to ensure the visibility check is correct.
BLUR_SAMPLE_SCALE * blur_radius
}
_ => {
0.0
}
};
// Mark whether this picture has a complex coordinate system.
pic_state_for_children.has_non_root_coord_system |=
prim_run_context.scroll_node.coordinate_system_id != CoordinateSystemId::root();
prim_context.spatial_node.coordinate_system_id != CoordinateSystemId::root();
Some(PictureContext {
pipeline_id: pic.pipeline_id,
prim_runs: mem::replace(&mut pic.runs, Vec::new()),
spatial_node_index: prim_run_context.spatial_node_index,
original_spatial_node_index: pic.original_spatial_node_index,
apply_local_clip_rect: pic.apply_local_clip_rect,
inflation_factor,
// TODO(lsalzman): allow overriding parent if intermediate surface is opaque
allow_subpixel_aa: pic_context.allow_subpixel_aa && pic.allow_subpixel_aa(),
})
Some(pic.take_context(pic_context.allow_subpixel_aa))
}
_ => {
None
@ -1635,20 +1555,25 @@ impl PrimitiveStore {
};
if let Some(pic_context_for_children) = pic_context_for_children {
let result = self.prepare_prim_runs(
let mut local_rect_builder = LocalRectBuilder::new(
prim_context.spatial_node_index,
);
self.prepare_prim_runs(
&pic_context_for_children,
&mut pic_state_for_children,
frame_context,
frame_state,
&mut local_rect_builder,
);
// Restore the dependencies (borrow check dance)
let prim = &mut self.primitives[prim_index.0];
let new_local_rect = prim
.as_pic_mut()
.update_local_rect_and_set_runs(
result,
pic_context_for_children.prim_runs
.restore_context(
pic_context_for_children,
local_rect_builder,
);
if new_local_rect != prim.metadata.local_rect {
@ -1659,7 +1584,6 @@ impl PrimitiveStore {
}
let prim = &mut self.primitives[prim_index.0];
prim.metadata.screen_rect = None;
if prim.metadata.local_rect.size.width <= 0.0 ||
prim.metadata.local_rect.size.height <= 0.0 {
@ -1695,7 +1619,7 @@ impl PrimitiveStore {
prim.metadata.clip_chain_id,
local_rect,
prim.metadata.local_clip_rect,
prim_run_context.spatial_node_index,
prim_context.spatial_node_index,
&frame_context.clip_scroll_tree.spatial_nodes,
frame_state.gpu_cache,
frame_state.resource_cache,
@ -1720,7 +1644,7 @@ impl PrimitiveStore {
pic_state.has_non_root_coord_system |= clip_chain.has_non_root_coord_system;
let unclipped_device_rect = match calculate_screen_bounding_rect(
&prim_run_context.scroll_node.world_content_transform,
&prim_context.spatial_node.world_content_transform,
&local_rect,
frame_context.device_pixel_scale,
None, //TODO: inflate `frame_context.screen_rect` appropriately
@ -1729,14 +1653,14 @@ impl PrimitiveStore {
None => {
if cfg!(debug_assertions) && is_chased {
println!("\tculled for being behind the near plane of transform: {:?}",
prim_run_context.scroll_node.world_content_transform);
prim_context.spatial_node.world_content_transform);
}
return None
}
};
let clipped_device_rect = match calculate_screen_bounding_rect(
&prim_run_context.scroll_node.world_content_transform,
&prim_context.spatial_node.world_content_transform,
&clip_chain.local_bounding_rect,
frame_context.device_pixel_scale,
None,
@ -1745,7 +1669,7 @@ impl PrimitiveStore {
None => {
if cfg!(debug_assertions) && is_chased {
println!("\tculled for being behind the near plane of transform: {:?}",
prim_run_context.scroll_node.world_content_transform);
prim_context.spatial_node.world_content_transform);
}
return None
}
@ -1779,7 +1703,7 @@ impl PrimitiveStore {
);
if may_need_clip_mask && !prim.update_clip_task(
prim_run_context,
prim_context,
&clipped_device_rect,
&clip_chain,
pic_state,
@ -1796,7 +1720,7 @@ impl PrimitiveStore {
prim.prepare_prim_for_render_inner(
prim_index,
prim_run_context,
prim_context,
pic_state_for_children,
pic_context,
pic_state,
@ -1823,12 +1747,8 @@ impl PrimitiveStore {
pic_state: &mut PictureState,
frame_context: &FrameBuildingContext,
frame_state: &mut FrameBuildingState,
) -> PrimitiveRunLocalRect {
let mut result = PrimitiveRunLocalRect::new(
pic_context.spatial_node_index,
pic_context.original_spatial_node_index,
);
local_rect_builder: &mut LocalRectBuilder,
) {
let display_list = &frame_context
.pipelines
.get(&pic_context.pipeline_id)
@ -1836,66 +1756,81 @@ impl PrimitiveStore {
.display_list;
for run in &pic_context.prim_runs {
// TODO(gw): Perhaps we can restructure this to not need to create
// a new primitive context for every run (if the hash
// lookups ever show up in a profile).
let scroll_node = &frame_context
.clip_scroll_tree
.spatial_nodes[run.spatial_node_index.0];
if run.is_chasing(self.chase_id) {
println!("\tpreparing a run of length {} in pipeline {:?}",
run.count, pic_context.pipeline_id);
println!("\trun {:?}", run.spatial_node_index);
println!("\ttransform {:?}", scroll_node.world_content_transform.to_transform());
}
// Mark whether this picture contains any complex coordinate
// systems, due to either the scroll node or the clip-chain.
pic_state.has_non_root_coord_system |=
scroll_node.coordinate_system_id != CoordinateSystemId::root();
if !scroll_node.invertible {
if run.is_chasing(self.chase_id) {
println!("\tculled for the scroll node transform being invertible");
}
continue;
}
result.set_target_spatial_node(
run.spatial_node_index,
&frame_context.clip_scroll_tree.spatial_nodes,
);
let transform = frame_context
.transforms
.get_transform(run.spatial_node_index);
let child_prim_run_context = PrimitiveRunContext::new(
scroll_node,
run.spatial_node_index,
transform,
);
for i in 0 .. run.count {
let prim_index = PrimitiveIndex(run.base_prim_index.0 + i);
let is_chased = Some(prim_index) == self.chase_id;
// TODO(gw): These workarounds for borrowck are unfortunate. We
// should see if we can re-structure these to avoid so
// many special borrow blocks.
let (spatial_node_index, is_backface_visible) = {
let prim = &self.primitives[prim_index.0];
(prim.metadata.spatial_node_index, prim.metadata.is_backface_visible)
};
let spatial_node = &frame_context
.clip_scroll_tree
.spatial_nodes[spatial_node_index.0];
let transform = frame_context
.transforms
.get_transform(spatial_node_index);
// TODO(gw): Although constructing these is cheap, they are often
// the same for many consecutive primitives, so it may
// be worth caching the most recent context.
let prim_context = PrimitiveContext::new(
spatial_node,
spatial_node_index,
transform,
);
// Do some basic checks first, that can early out
// without even knowing the local rect.
if !is_backface_visible && prim_context.transform.backface_is_visible {
if cfg!(debug_assertions) && is_chased {
println!("\tculled for not having visible back faces");
}
continue;
}
if !spatial_node.invertible {
if cfg!(debug_assertions) && is_chased {
println!("\tculled for the scroll node transform being invertible");
}
continue;
}
// Mark whether this picture contains any complex coordinate
// systems, due to either the scroll node or the clip-chain.
pic_state.has_non_root_coord_system |=
spatial_node.coordinate_system_id != CoordinateSystemId::root();
local_rect_builder.set_target_spatial_node(
spatial_node_index,
&frame_context.clip_scroll_tree,
);
if let Some(prim_local_rect) = self.prepare_prim_for_render(
prim_index,
&child_prim_run_context,
&prim_context,
pic_context,
pic_state,
frame_context,
frame_state,
display_list,
is_chased,
) {
frame_state.profile_counters.visible_primitives.inc();
result.accumulate(&prim_local_rect);
local_rect_builder.accumulate(&prim_local_rect);
}
}
}
result
}
}
@ -1923,7 +1858,7 @@ fn decompose_repeated_primitive(
metadata: &mut PrimitiveMetadata,
stretch_size: &LayoutSize,
tile_spacing: &LayoutSize,
prim_run_context: &PrimitiveRunContext,
prim_context: &PrimitiveContext,
frame_context: &FrameBuildingContext,
frame_state: &mut FrameBuildingState,
callback: &mut FnMut(&LayoutRect, GpuDataRequest),
@ -1943,7 +1878,7 @@ fn decompose_repeated_primitive(
.unclipped;
let visible_rect = compute_conservative_visible_rect(
prim_run_context,
prim_context,
frame_context,
unclipped_device_rect,
&tight_clip_rect
@ -1984,7 +1919,7 @@ fn decompose_repeated_primitive(
}
fn compute_conservative_visible_rect(
prim_run_context: &PrimitiveRunContext,
prim_context: &PrimitiveContext,
frame_context: &FrameBuildingContext,
clipped_device_rect: &DeviceIntRect,
local_clip_rect: &LayoutRect,
@ -1992,8 +1927,8 @@ fn compute_conservative_visible_rect(
let world_screen_rect = clipped_device_rect
.to_f32() / frame_context.device_pixel_scale;
if let Some(layer_screen_rect) = prim_run_context
.scroll_node
if let Some(layer_screen_rect) = prim_context
.spatial_node
.world_content_transform
.unapply(&world_screen_rect) {
@ -2039,7 +1974,7 @@ fn write_brush_segment_description(
Some(ref segment_desc) => {
// If we already have a segment descriptor, only run through the
// clips list if we haven't already determined the mask kind.
if segment_desc.clip_mask_kind != BrushClipMaskKind::Unknown {
if segment_desc.clip_mask_kind == clip_chain.clip_mask_kind {
return;
}
}
@ -2070,41 +2005,16 @@ fn write_brush_segment_description(
metadata.local_clip_rect
);
// If this primitive is clipped by clips from a different coordinate system, then we
// need to apply a clip mask for the entire primitive.
let mut clip_mask_kind = if clip_chain.has_clips_from_other_coordinate_systems {
BrushClipMaskKind::Global
} else {
BrushClipMaskKind::Individual
};
// Segment the primitive on all the local-space clip sources that we can.
for i in 0 .. clip_chain.clips_range.count {
let (clip_node, flags) = frame_state.clip_store.get_node_from_range(&clip_chain.clips_range, i);
if !flags.contains(ClipNodeFlags::SAME_COORD_SYSTEM) {
continue;
}
// TODO(gw): We can easily extend the segment builder to support these clip sources in
// the future, but they are rarely used.
// We must do this check here in case we continue early below.
if clip_node.item.is_image_or_line_decoration_clip() {
clip_mask_kind = BrushClipMaskKind::Global;
}
// If this clip item is positioned by another positioning node, its relative position
// could change during scrolling. This means that we would need to resegment. Instead
// of doing that, only segment with clips that have the same positioning node.
// TODO(mrobinson, #2858): It may make sense to include these nodes, resegmenting only
// when necessary while scrolling.
if !flags.contains(ClipNodeFlags::SAME_SPATIAL_NODE) {
// We don't need to generate a global clip mask for rectangle clips because we are
// in the same coordinate system and rectangular clips are handled by the local
// clip chain rectangle.
if !clip_node.item.is_rect() {
clip_mask_kind = BrushClipMaskKind::Global;
}
continue;
}
@ -2155,7 +2065,7 @@ fn write_brush_segment_description(
if is_large || rect_clips_only {
match brush.segment_desc {
Some(ref mut segment_desc) => {
segment_desc.clip_mask_kind = clip_mask_kind;
segment_desc.clip_mask_kind = clip_chain.clip_mask_kind;
}
None => {
// TODO(gw): We can probably make the allocation
@ -2178,7 +2088,7 @@ fn write_brush_segment_description(
brush.segment_desc = Some(BrushSegmentDescriptor {
segments,
clip_mask_kind,
clip_mask_kind: clip_chain.clip_mask_kind,
});
}
}
@ -2188,7 +2098,7 @@ fn write_brush_segment_description(
impl Primitive {
fn update_clip_task_for_brush(
&mut self,
prim_run_context: &PrimitiveRunContext,
prim_context: &PrimitiveContext,
clip_chain: &ClipChainInstance,
combined_outer_rect: &DeviceIntRect,
pic_state: &mut PictureState,
@ -2222,7 +2132,7 @@ impl Primitive {
}
let intersected_rect = calculate_screen_bounding_rect(
&prim_run_context.scroll_node.world_content_transform,
&prim_context.spatial_node.world_content_transform,
&segment.local_rect,
frame_context.device_pixel_scale,
Some(&combined_outer_rect),
@ -2269,7 +2179,7 @@ impl Primitive {
fn prepare_prim_for_render_inner(
&mut self,
prim_index: PrimitiveIndex,
prim_run_context: &PrimitiveRunContext,
prim_context: &PrimitiveContext,
pic_state_for_children: PictureState,
pic_context: &PictureContext,
pic_state: &mut PictureState,
@ -2288,7 +2198,7 @@ impl Primitive {
match self.details {
PrimitiveDetails::TextRun(ref mut text) => {
// The transform only makes sense for screen space rasterization
let transform = prim_run_context.scroll_node.world_content_transform.to_transform();
let transform = prim_context.spatial_node.world_content_transform.to_transform();
text.prepare_for_render(
frame_context.device_pixel_scale,
&transform,
@ -2303,6 +2213,7 @@ impl Primitive {
request,
sub_rect,
stretch_size,
color,
ref mut tile_spacing,
ref mut source,
ref mut opacity_binding,
@ -2328,7 +2239,8 @@ impl Primitive {
// batching parameters are used.
metadata.opacity.is_opaque =
image_properties.descriptor.is_opaque &&
opacity_binding.current == 1.0;
opacity_binding.current == 1.0 &&
color.a == 1.0;
if *tile_spacing != LayoutSize::zero() && !is_tiled {
*source = ImageSource::Cache {
@ -2441,7 +2353,7 @@ impl Primitive {
.intersection(&metadata.local_rect).unwrap();
let visible_rect = compute_conservative_visible_rect(
prim_run_context,
prim_context,
frame_context,
&metadata.screen_rect.unwrap().clipped,
&tight_clip_rect
@ -2581,7 +2493,7 @@ impl Primitive {
metadata,
&stretch_size,
&tile_spacing,
prim_run_context,
prim_context,
frame_context,
frame_state,
&mut |rect, mut request| {
@ -2631,7 +2543,7 @@ impl Primitive {
metadata,
&stretch_size,
&tile_spacing,
prim_run_context,
prim_context,
frame_context,
frame_state,
&mut |rect, mut request| {
@ -2656,7 +2568,7 @@ impl Primitive {
pic.prepare_for_render(
prim_index,
metadata,
prim_run_context,
prim_context,
pic_state_for_children,
pic_state,
frame_context,
@ -2719,7 +2631,7 @@ impl Primitive {
fn update_clip_task(
&mut self,
prim_run_context: &PrimitiveRunContext,
prim_context: &PrimitiveContext,
prim_screen_rect: &DeviceIntRect,
clip_chain: &ClipChainInstance,
pic_state: &mut PictureState,
@ -2735,7 +2647,7 @@ impl Primitive {
// First try to render this primitive's mask using optimized brush rendering.
if self.update_clip_task_for_brush(
prim_run_context,
prim_context,
&clip_chain,
prim_screen_rect,
pic_state,

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

@ -178,7 +178,7 @@ impl ops::IndexMut<RenderTaskId> for RenderTaskTree {
#[cfg_attr(feature = "replay", derive(Deserialize))]
pub enum RenderTaskLocation {
Fixed(DeviceIntRect),
Dynamic(Option<(DeviceIntPoint, RenderTargetIndex)>, Option<DeviceIntSize>),
Dynamic(Option<(DeviceIntPoint, RenderTargetIndex)>, DeviceIntSize),
TextureCache(SourceTexture, i32, DeviceIntRect),
}
@ -202,6 +202,7 @@ pub struct ClipRegionTask {
#[cfg_attr(feature = "replay", derive(Deserialize))]
pub struct PictureTask {
pub prim_index: PrimitiveIndex,
pub can_merge: bool,
pub content_origin: DeviceIntPoint,
pub uv_rect_handle: GpuCacheHandle,
uv_rect_kind: UvRectKind,
@ -330,7 +331,7 @@ impl RenderTask {
render_task_sanity_check(&size);
RenderTask {
location: RenderTaskLocation::Dynamic(None, Some(size)),
location: RenderTaskLocation::Dynamic(None, size),
children,
kind,
clear_mode,
@ -340,21 +341,22 @@ impl RenderTask {
pub fn new_picture(
location: RenderTaskLocation,
unclipped_size: DeviceIntSize,
prim_index: PrimitiveIndex,
content_origin: DeviceIntPoint,
children: Vec<RenderTaskId>,
uv_rect_kind: UvRectKind,
) -> Self {
let size = match location {
RenderTaskLocation::Dynamic(_, Some(size)) => Some(size),
RenderTaskLocation::Fixed(rect) => Some(rect.size),
RenderTaskLocation::TextureCache(_, _, rect) => Some(rect.size),
_ => None,
RenderTaskLocation::Dynamic(_, size) => size,
RenderTaskLocation::Fixed(rect) => rect.size,
RenderTaskLocation::TextureCache(_, _, rect) => rect.size,
};
if let Some(size) = size {
render_task_sanity_check(&size);
}
render_task_sanity_check(&size);
let can_merge = size.width >= unclipped_size.width &&
size.height >= unclipped_size.height;
RenderTask {
location,
@ -362,6 +364,7 @@ impl RenderTask {
kind: RenderTaskKind::Picture(PictureTask {
prim_index,
content_origin,
can_merge,
uv_rect_handle: GpuCacheHandle::new(),
uv_rect_kind,
}),
@ -770,10 +773,7 @@ impl RenderTask {
pub fn get_dynamic_size(&self) -> DeviceIntSize {
match self.location {
RenderTaskLocation::Fixed(..) => DeviceIntSize::zero(),
RenderTaskLocation::Dynamic(_, Some(size)) => size,
RenderTaskLocation::Dynamic(_, None) => {
panic!("bug: render task must have assigned size by now");
}
RenderTaskLocation::Dynamic(_, size) => size,
RenderTaskLocation::TextureCache(_, _, rect) => rect.size,
}
}
@ -798,7 +798,6 @@ impl RenderTask {
// to mark a task as unused explicitly. This
// would allow us to restore this debug check.
RenderTaskLocation::Dynamic(Some((origin, target_index)), size) => {
let size = size.expect("bug: must be assigned a size by now");
(DeviceIntRect::new(origin, size), target_index)
}
RenderTaskLocation::Dynamic(None, _) => {
@ -1096,10 +1095,7 @@ impl RenderTaskCache {
RenderTaskLocation::TextureCache(..) => {
panic!("BUG: dynamic task was expected");
}
RenderTaskLocation::Dynamic(_, None) => {
panic!("BUG: must have assigned size by now");
}
RenderTaskLocation::Dynamic(_, Some(size)) => size,
RenderTaskLocation::Dynamic(_, size) => size,
};
// Select the right texture page to allocate from.

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

@ -248,6 +248,7 @@ pub enum ShaderColorMode {
SubpixelDualSource = 6,
Bitmap = 7,
ColorBitmap = 8,
Image = 9,
}
impl From<GlyphFormat> for ShaderColorMode {

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

@ -5,8 +5,8 @@
use api::{ExternalScrollId, LayoutPixel, LayoutPoint, LayoutRect, LayoutSize, LayoutTransform};
use api::{LayoutVector2D, PipelineId, PropertyBinding, ScrollClamping, ScrollLocation};
use api::{ScrollSensitivity, StickyOffsetBounds};
use clip_scroll_tree::{CoordinateSystemId, SpatialNodeIndex, TransformUpdateState};
use api::{ScrollSensitivity, StickyOffsetBounds, LayoutVector3D};
use clip_scroll_tree::{CoordinateSystem, CoordinateSystemId, SpatialNodeIndex, TransformUpdateState};
use euclid::SideOffsets2D;
use gpu_types::TransformPalette;
use scene::SceneProperties;
@ -214,7 +214,7 @@ impl SpatialNode {
pub fn update(
&mut self,
state: &mut TransformUpdateState,
next_coordinate_system_id: &mut CoordinateSystemId,
coord_systems: &mut Vec<CoordinateSystem>,
scene_properties: &SceneProperties,
) {
// If any of our parents was not rendered, we are not rendered either and can just
@ -224,7 +224,7 @@ impl SpatialNode {
return;
}
self.update_transform(state, next_coordinate_system_id, scene_properties);
self.update_transform(state, coord_systems, scene_properties);
self.transform_kind = self.world_content_transform.kind();
// If this node is a reference frame, we check if it has a non-invertible matrix.
@ -242,7 +242,7 @@ impl SpatialNode {
pub fn update_transform(
&mut self,
state: &mut TransformUpdateState,
next_coordinate_system_id: &mut CoordinateSystemId,
coord_systems: &mut Vec<CoordinateSystem>,
scene_properties: &SceneProperties,
) {
match self.node_type {
@ -281,8 +281,19 @@ impl SpatialNode {
// If we break 2D axis alignment or have a perspective component, we need to start a
// new incompatible coordinate system with which we cannot share clips without masking.
self.coordinate_system_relative_offset = LayoutVector2D::zero();
state.current_coordinate_system_id = *next_coordinate_system_id;
next_coordinate_system_id.advance();
// Push that new coordinate system and record the new id.
let coord_system = CoordinateSystem {
offset: LayoutVector3D::new(
state.coordinate_system_relative_offset.x,
state.coordinate_system_relative_offset.y,
0.0,
),
transform: *info.resolved_transform.to_transform(),
parent: Some(state.current_coordinate_system_id),
};
state.current_coordinate_system_id = CoordinateSystemId(coord_systems.len() as u32);
coord_systems.push(coord_system);
}
self.coordinate_system_id = state.current_coordinate_system_id;

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

@ -351,7 +351,11 @@ impl RenderTarget for ColorRenderTarget {
let (target_rect, _) = task.get_target_rect();
let mut batch_builder = AlphaBatchBuilder::new(self.screen_size, target_rect);
let mut batch_builder = AlphaBatchBuilder::new(
self.screen_size,
target_rect,
pic_task.can_merge,
);
batch_builder.add_pic_to_batch(
pic,
@ -845,7 +849,6 @@ impl RenderPass {
None
}
RenderTaskLocation::Dynamic(ref mut origin, size) => {
let size = size.expect("bug: size must be assigned by now");
let alloc_size = DeviceUintSize::new(size.width as u32, size.height as u32);
let (alloc_origin, target_index) = match target_kind {
RenderTargetKind::Color => color.allocate(alloc_size),

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

@ -4,6 +4,7 @@ version = "0.57.2"
authors = ["Glenn Watson <gw@intuitionlibrary.com>"]
license = "MPL-2.0"
repository = "https://github.com/servo/webrender"
description = "Public API for WebRender"
[features]
nightly = ["euclid/unstable", "serde/unstable"]

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

@ -48,6 +48,13 @@ pub struct ColorF {
}
impl ColorF {
///
pub const BLACK: Self = ColorF { r: 0.0, g: 0.0, b: 0.0, a: 1.0 };
///
pub const TRANSPARENT: Self = ColorF { r: 0.0, g: 0.0, b: 0.0, a: 0.0 };
///
pub const WHITE: Self = ColorF { r: 1.0, g: 1.0, b: 1.0, a: 1.0 };
/// Constructs a new `ColorF` from its components.
pub fn new(r: f32, g: f32, b: f32, a: f32) -> Self {
ColorF { r, g, b, a }

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

@ -558,6 +558,7 @@ pub struct ImageDisplayItem {
pub tile_spacing: LayoutSize,
pub image_rendering: ImageRendering,
pub alpha_type: AlphaType,
pub color: ColorF,
}
#[repr(u32)]

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

@ -1062,6 +1062,7 @@ impl DisplayListBuilder {
image_rendering: ImageRendering,
alpha_type: AlphaType,
key: ImageKey,
color: ColorF,
) {
let item = SpecificDisplayItem::Image(ImageDisplayItem {
image_key: key,
@ -1069,6 +1070,7 @@ impl DisplayListBuilder {
tile_spacing,
image_rendering,
alpha_type,
color,
});
self.push_item(item, info);

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

@ -1 +1 @@
890f3746b798538d201e54b66d2711a70447b781
e70bae07664def86aefd11c86dac818ab7ea64ea

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

@ -86,8 +86,6 @@ use yaml_frame_reader::YamlFrameReader;
lazy_static! {
static ref PLATFORM_DEFAULT_FACE_NAME: String = String::from("Arial");
static ref WHITE_COLOR: ColorF = ColorF::new(1.0, 1.0, 1.0, 1.0);
static ref BLACK_COLOR: ColorF = ColorF::new(0.0, 0.0, 0.0, 1.0);
}
pub static mut CURRENT_FRAME_NUMBER: u32 = 0;

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

@ -114,6 +114,7 @@ impl<'a> RawtestHarness<'a> {
ImageRendering::Auto,
AlphaType::PremultipliedAlpha,
blob_img,
ColorF::WHITE,
);
let mut epoch = Epoch(0);
@ -180,6 +181,7 @@ impl<'a> RawtestHarness<'a> {
ImageRendering::Auto,
AlphaType::PremultipliedAlpha,
blob_img,
ColorF::WHITE,
);
txn.set_image_visible_area(
blob_img,
@ -284,6 +286,7 @@ impl<'a> RawtestHarness<'a> {
ImageRendering::Auto,
AlphaType::PremultipliedAlpha,
blob_img1,
ColorF::WHITE,
);
self.submit_dl(&mut Epoch(0), layout_size, builder, &txn.resource_updates);
@ -319,6 +322,7 @@ impl<'a> RawtestHarness<'a> {
ImageRendering::Auto,
AlphaType::PremultipliedAlpha,
blob_img2,
ColorF::WHITE,
);
self.submit_dl(&mut Epoch(1), layout_size, builder, &txn.resource_updates);
@ -372,6 +376,7 @@ impl<'a> RawtestHarness<'a> {
ImageRendering::Auto,
AlphaType::PremultipliedAlpha,
blob_img,
ColorF::WHITE,
);
let mut epoch = Epoch(0);
@ -396,6 +401,7 @@ impl<'a> RawtestHarness<'a> {
ImageRendering::Auto,
AlphaType::PremultipliedAlpha,
blob_img,
ColorF::WHITE,
);
self.submit_dl(&mut epoch, layout_size, builder, &[]);
@ -425,6 +431,7 @@ impl<'a> RawtestHarness<'a> {
ImageRendering::Auto,
AlphaType::PremultipliedAlpha,
blob_img,
ColorF::WHITE,
);
let mut epoch = Epoch(2);
@ -485,6 +492,7 @@ impl<'a> RawtestHarness<'a> {
ImageRendering::Auto,
AlphaType::PremultipliedAlpha,
blob_img,
ColorF::WHITE,
);
let mut epoch = Epoch(0);
@ -507,6 +515,7 @@ impl<'a> RawtestHarness<'a> {
ImageRendering::Auto,
AlphaType::PremultipliedAlpha,
blob_img,
ColorF::WHITE,
);
txn.resource_updates.clear();
@ -591,6 +600,7 @@ impl<'a> RawtestHarness<'a> {
ImageRendering::Auto,
AlphaType::PremultipliedAlpha,
blob_img,
ColorF::WHITE,
);
builder.push_image(
&info2,
@ -599,6 +609,7 @@ impl<'a> RawtestHarness<'a> {
ImageRendering::Auto,
AlphaType::PremultipliedAlpha,
blob_img2,
ColorF::WHITE,
);
};
@ -689,6 +700,7 @@ impl<'a> RawtestHarness<'a> {
ImageRendering::Auto,
AlphaType::PremultipliedAlpha,
blob_img,
ColorF::WHITE,
);
let mut epoch = Epoch(0);
@ -715,6 +727,7 @@ impl<'a> RawtestHarness<'a> {
ImageRendering::Auto,
AlphaType::PremultipliedAlpha,
blob_img,
ColorF::WHITE,
);
self.submit_dl(&mut epoch, layout_size, builder, &txn.resource_updates);
@ -739,6 +752,7 @@ impl<'a> RawtestHarness<'a> {
ImageRendering::Auto,
AlphaType::PremultipliedAlpha,
blob_img,
ColorF::WHITE,
);
self.submit_dl(&mut epoch, layout_size, builder, &txn.resource_updates);
@ -900,6 +914,7 @@ impl<'a> RawtestHarness<'a> {
ImageRendering::Auto,
AlphaType::PremultipliedAlpha,
image,
ColorF::WHITE,
);
let mut txn = Transaction::new();

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

@ -22,7 +22,7 @@ use webrender;
use webrender::api::*;
use webrender::{DebugFlags, RendererStats};
use yaml_frame_writer::YamlFrameWriterReceiver;
use {WindowWrapper, NotifierEvent, BLACK_COLOR, WHITE_COLOR};
use {WindowWrapper, NotifierEvent};
// TODO(gw): This descriptor matches what we currently support for fonts
// but is quite a mess. We should at least document and
@ -561,7 +561,7 @@ impl Wrench {
"X - Do a hit test at the current cursor position",
];
let color_and_offset = [(*BLACK_COLOR, 2.0), (*WHITE_COLOR, 0.0)];
let color_and_offset = [(ColorF::BLACK, 2.0), (ColorF::WHITE, 0.0)];
let dr = self.renderer.debug_renderer().unwrap();
for ref co in &color_and_offset {

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

@ -17,7 +17,7 @@ use webrender::api::*;
use wrench::{FontDescriptor, Wrench, WrenchThing};
use yaml_helper::{StringEnum, YamlHelper, make_perspective};
use yaml_rust::{Yaml, YamlLoader};
use {BLACK_COLOR, PLATFORM_DEFAULT_FACE_NAME, WHITE_COLOR};
use PLATFORM_DEFAULT_FACE_NAME;
fn rsrc_path(item: &Yaml, aux_dir: &PathBuf) -> PathBuf {
let filename = item.as_str().unwrap();
@ -680,7 +680,7 @@ impl YamlFrameReader {
info.rect = item[bounds_key]
.as_rect()
.expect("rect type must have bounds");
let color = item["color"].as_colorf().unwrap_or(*WHITE_COLOR);
let color = item["color"].as_colorf().unwrap_or(ColorF::WHITE);
dl.push_rect(&info, color);
}
@ -702,7 +702,7 @@ impl YamlFrameReader {
item: &Yaml,
info: &mut LayoutPrimitiveInfo,
) {
let color = item["color"].as_colorf().unwrap_or(*BLACK_COLOR);
let color = item["color"].as_colorf().unwrap_or(ColorF::BLACK);
let orientation = item["orientation"]
.as_str()
.and_then(LineOrientation::from_str)
@ -1123,7 +1123,7 @@ impl YamlFrameReader {
item
),
};
dl.push_image(&info, stretch_size, tile_spacing, rendering, alpha_type, image_key);
dl.push_image(&info, stretch_size, tile_spacing, rendering, alpha_type, image_key, ColorF::WHITE);
}
fn handle_text(
@ -1134,7 +1134,7 @@ impl YamlFrameReader {
info: &mut LayoutPrimitiveInfo,
) {
let size = item["size"].as_pt_to_au().unwrap_or(Au::from_f32_px(16.0));
let color = item["color"].as_colorf().unwrap_or(*BLACK_COLOR);
let color = item["color"].as_colorf().unwrap_or(ColorF::BLACK);
let bg_color = item["bg-color"].as_colorf().map(|c| c.into());
let synthetic_italics = if let Some(angle) = item["synthetic-italics"].as_f32() {
SyntheticItalics::from_degrees(angle)
@ -1452,7 +1452,7 @@ impl YamlFrameReader {
) {
let blur_radius = yaml["blur-radius"].as_f32().unwrap_or(0.0);
let offset = yaml["offset"].as_vector().unwrap_or(LayoutVector2D::zero());
let color = yaml["color"].as_colorf().unwrap_or(*BLACK_COLOR);
let color = yaml["color"].as_colorf().unwrap_or(ColorF::BLACK);
dl.push_shadow(
&info,