зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1456114 - Update webrender to commit 751236199b39bb8dac78522713133ca18c603fb3. r=jrmuizel
MozReview-Commit-ID: 5Zz7LwyLExN --HG-- extra : rebase_source : 4aa78eb7c49570a8c404f0ded36795eb787179a6
This commit is contained in:
Родитель
c594214666
Коммит
8248fea792
|
@ -34,7 +34,7 @@ impl RenderNotifier for Notifier {
|
|||
let _ = self.events_proxy.wakeup();
|
||||
}
|
||||
|
||||
fn new_document_ready(&self, _: DocumentId, _scrolled: bool, _composite_needed: bool) {
|
||||
fn new_frame_ready(&self, _: DocumentId, _scrolled: bool, _composite_needed: bool) {
|
||||
self.wake_up();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -37,7 +37,7 @@ impl RenderNotifier for Notifier {
|
|||
let _ = self.events_proxy.wakeup();
|
||||
}
|
||||
|
||||
fn new_document_ready(&self, _: DocumentId, _scrolled: bool, _composite_needed: bool) {
|
||||
fn new_frame_ready(&self, _: DocumentId, _scrolled: bool, _composite_needed: bool) {
|
||||
self.wake_up();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -157,18 +157,31 @@ void main(void) {
|
|||
|
||||
#ifdef WR_FRAGMENT_SHADER
|
||||
|
||||
vec4 brush_fs();
|
||||
struct Fragment {
|
||||
vec4 color;
|
||||
#ifdef WR_FEATURE_DUAL_SOURCE_BLENDING
|
||||
vec4 blend;
|
||||
#endif
|
||||
};
|
||||
|
||||
Fragment brush_fs();
|
||||
|
||||
void main(void) {
|
||||
// Run the specific brush FS code to output the color.
|
||||
vec4 color = brush_fs();
|
||||
Fragment frag = brush_fs();
|
||||
|
||||
#ifdef WR_FEATURE_ALPHA_PASS
|
||||
// Apply the clip mask
|
||||
color *= do_clip();
|
||||
float clip_alpha = do_clip();
|
||||
|
||||
frag.color *= clip_alpha;
|
||||
|
||||
#ifdef WR_FEATURE_DUAL_SOURCE_BLENDING
|
||||
oFragBlend = frag.blend * clip_alpha;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
// TODO(gw): Handle pre-multiply common code here as required.
|
||||
oFragColor = color;
|
||||
oFragColor = frag.color;
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -122,11 +122,11 @@ vec3 Brightness(vec3 Cs, float amount) {
|
|||
return clamp(Cs.rgb * amount, vec3(0.0), vec3(1.0));
|
||||
}
|
||||
|
||||
vec4 brush_fs() {
|
||||
Fragment brush_fs() {
|
||||
vec4 Cs = texture(sColor0, vUv);
|
||||
|
||||
if (Cs.a == 0.0) {
|
||||
return vec4(0.0); // could also `discard`
|
||||
return Fragment(vec4(0.0)); // could also `discard`
|
||||
}
|
||||
|
||||
// Un-premultiply the input.
|
||||
|
@ -157,6 +157,6 @@ vec4 brush_fs() {
|
|||
alpha *= point_inside_rect(vUv.xy, vUvClipBounds.xy, vUvClipBounds.zw);
|
||||
|
||||
// Pre-multiply the alpha into the output value.
|
||||
return alpha * vec4(color, 1.0);
|
||||
return Fragment(alpha * vec4(color, 1.0));
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -112,6 +112,10 @@ void brush_vs(
|
|||
int raster_space = user_data.y & 0xffff;
|
||||
ImageBrushData image_data = fetch_image_data(prim_address);
|
||||
|
||||
if (color_mode == COLOR_MODE_FROM_PASS) {
|
||||
color_mode = uMode;
|
||||
}
|
||||
|
||||
// Derive the texture coordinates for this image, based on
|
||||
// whether the source image is a local-space or screen-space
|
||||
// image.
|
||||
|
@ -200,8 +204,8 @@ void brush_vs(
|
|||
#endif
|
||||
|
||||
#ifdef WR_FRAGMENT_SHADER
|
||||
vec4 brush_fs() {
|
||||
|
||||
Fragment brush_fs() {
|
||||
vec2 uv_size = vUvBounds.zw - vUvBounds.xy;
|
||||
|
||||
#ifdef WR_FEATURE_ALPHA_PASS
|
||||
|
@ -232,14 +236,22 @@ vec4 brush_fs() {
|
|||
|
||||
vec4 texel = TEX_SAMPLE(sColor0, vec3(uv, vUv.z));
|
||||
|
||||
Fragment frag;
|
||||
|
||||
#ifdef WR_FEATURE_ALPHA_PASS
|
||||
float alpha = init_transform_fs(vLocalPos);
|
||||
texel.rgb = texel.rgb * vMaskSwizzle.x + texel.aaa * vMaskSwizzle.y;
|
||||
vec4 color = vColor * texel * alpha;
|
||||
|
||||
vec4 alpha_mask = texel * alpha;
|
||||
frag.color = vColor * alpha_mask;
|
||||
|
||||
#ifdef WR_FEATURE_DUAL_SOURCE_BLENDING
|
||||
frag.blend = alpha_mask * vColor.a;
|
||||
#endif
|
||||
#else
|
||||
vec4 color = texel;
|
||||
frag.color = texel;
|
||||
#endif
|
||||
|
||||
return color;
|
||||
return frag;
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -70,7 +70,7 @@ void brush_vs(
|
|||
#endif
|
||||
|
||||
#ifdef WR_FRAGMENT_SHADER
|
||||
vec4 brush_fs() {
|
||||
Fragment brush_fs() {
|
||||
|
||||
#ifdef WR_FEATURE_ALPHA_PASS
|
||||
// Handle top and left inflated edges (see brush_image).
|
||||
|
@ -102,6 +102,6 @@ vec4 brush_fs() {
|
|||
color *= init_transform_fs(vLocalPos);
|
||||
#endif
|
||||
|
||||
return color;
|
||||
return Fragment(color);
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -196,15 +196,15 @@ const int MixBlendMode_Saturation = 13;
|
|||
const int MixBlendMode_Color = 14;
|
||||
const int MixBlendMode_Luminosity = 15;
|
||||
|
||||
vec4 brush_fs() {
|
||||
Fragment brush_fs() {
|
||||
vec4 Cb = textureLod(sCacheRGBA8, vBackdropUv, 0.0);
|
||||
vec4 Cs = textureLod(sCacheRGBA8, vSrcUv, 0.0);
|
||||
|
||||
if (Cb.a == 0.0) {
|
||||
return Cs;
|
||||
return Fragment(Cs);
|
||||
}
|
||||
if (Cs.a == 0.0) {
|
||||
return vec4(0.0);
|
||||
return Fragment(vec4(0.0));
|
||||
}
|
||||
|
||||
// The mix-blend-mode functions assume no premultiplied alpha
|
||||
|
@ -275,6 +275,6 @@ vec4 brush_fs() {
|
|||
|
||||
result.rgb *= result.a;
|
||||
|
||||
return result;
|
||||
return Fragment(result);
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -73,7 +73,7 @@ void brush_vs(
|
|||
#endif
|
||||
|
||||
#ifdef WR_FRAGMENT_SHADER
|
||||
vec4 brush_fs() {
|
||||
Fragment brush_fs() {
|
||||
|
||||
#ifdef WR_FEATURE_ALPHA_PASS
|
||||
// Handle top and left inflated edges (see brush_image).
|
||||
|
@ -141,6 +141,6 @@ vec4 brush_fs() {
|
|||
color *= init_transform_fs(vLocalPos);
|
||||
#endif
|
||||
|
||||
return color;
|
||||
return Fragment(color);
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -42,11 +42,11 @@ void brush_vs(
|
|||
#endif
|
||||
|
||||
#ifdef WR_FRAGMENT_SHADER
|
||||
vec4 brush_fs() {
|
||||
Fragment brush_fs() {
|
||||
vec4 color = vColor;
|
||||
#ifdef WR_FEATURE_ALPHA_PASS
|
||||
color *= init_transform_fs(vLocalPos);
|
||||
#endif
|
||||
return color;
|
||||
return Fragment(color);
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -135,7 +135,7 @@ const mat3 YuvColorMatrix = mat3(
|
|||
);
|
||||
#endif
|
||||
|
||||
vec4 brush_fs() {
|
||||
Fragment brush_fs() {
|
||||
vec3 yuv_value;
|
||||
|
||||
#if defined (WR_FEATURE_YUV_PLANAR)
|
||||
|
@ -169,6 +169,6 @@ vec4 brush_fs() {
|
|||
color *= init_transform_fs(vLocalPos);
|
||||
#endif
|
||||
|
||||
return color;
|
||||
return Fragment(color);
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -4,6 +4,9 @@
|
|||
|
||||
#include shared,clip_shared
|
||||
|
||||
in vec4 aDashOrDot0;
|
||||
in vec4 aDashOrDot1;
|
||||
|
||||
varying vec3 vPos;
|
||||
|
||||
flat varying vec2 vClipCenter;
|
||||
|
@ -46,9 +49,8 @@ struct BorderClipDash {
|
|||
vec4 point_tangent_1;
|
||||
};
|
||||
|
||||
BorderClipDash fetch_border_clip_dash(ivec2 address, int segment) {
|
||||
vec4 data[2] = fetch_from_resource_cache_2_direct(address + ivec2(2 + 2 * (segment - 1), 0));
|
||||
return BorderClipDash(data[0], data[1]);
|
||||
BorderClipDash fetch_border_clip_dash(ivec2 address) {
|
||||
return BorderClipDash(aDashOrDot0, aDashOrDot1);
|
||||
}
|
||||
|
||||
// Per-dot clip information.
|
||||
|
@ -56,9 +58,8 @@ struct BorderClipDot {
|
|||
vec3 center_radius;
|
||||
};
|
||||
|
||||
BorderClipDot fetch_border_clip_dot(ivec2 address, int segment) {
|
||||
vec4 data = fetch_from_resource_cache_1_direct(address + ivec2(2 + (segment - 1), 0));
|
||||
return BorderClipDot(data.xyz);
|
||||
BorderClipDot fetch_border_clip_dot(ivec2 address) {
|
||||
return BorderClipDot(aDashOrDot0.xyz);
|
||||
}
|
||||
|
||||
void main(void) {
|
||||
|
@ -70,6 +71,11 @@ void main(void) {
|
|||
BorderCorner corner = fetch_border_corner(cmi.clip_data_address);
|
||||
vClipCenter = corner.clip_center;
|
||||
|
||||
// Get local vertex position for the corner rect.
|
||||
// TODO(gw): We could reduce the number of pixels written here by calculating a tight
|
||||
// fitting bounding box of the dash itself like we do for dots below.
|
||||
vec2 pos = corner.rect.p0 + aPosition.xy * corner.rect.size;
|
||||
|
||||
if (cmi.segment == 0) {
|
||||
// The first segment is used to zero out the border corner.
|
||||
vAlphaMask = vec2(0.0);
|
||||
|
@ -98,7 +104,7 @@ void main(void) {
|
|||
switch (corner.clip_mode) {
|
||||
case CLIP_MODE_DASH: {
|
||||
// Fetch the information about this particular dash.
|
||||
BorderClipDash dash = fetch_border_clip_dash(cmi.clip_data_address, cmi.segment);
|
||||
BorderClipDash dash = fetch_border_clip_dash(cmi.clip_data_address);
|
||||
vPoint_Tangent0 = dash.point_tangent_0 * sign_modifier.xyxy;
|
||||
vPoint_Tangent1 = dash.point_tangent_1 * sign_modifier.xyxy;
|
||||
vDotParams = vec3(0.0);
|
||||
|
@ -106,11 +112,22 @@ void main(void) {
|
|||
break;
|
||||
}
|
||||
case CLIP_MODE_DOT: {
|
||||
BorderClipDot cdot = fetch_border_clip_dot(cmi.clip_data_address, cmi.segment);
|
||||
BorderClipDot cdot = fetch_border_clip_dot(cmi.clip_data_address);
|
||||
vPoint_Tangent0 = vec4(1.0);
|
||||
vPoint_Tangent1 = vec4(1.0);
|
||||
vDotParams = vec3(cdot.center_radius.xy * sign_modifier, cdot.center_radius.z);
|
||||
vAlphaMask = vec2(1.0, 1.0);
|
||||
|
||||
// Generate a tighter bounding rect for dots based on their position. Dot
|
||||
// centers are given relative to clip center, so we need to move the dot
|
||||
// rectangle into the clip space with an origin at the top left. First,
|
||||
// we expand the radius slightly to ensure we get full coverage on all the pixels
|
||||
// of the dots.
|
||||
float expanded_radius = cdot.center_radius.z + 2.0;
|
||||
pos = (vClipCenter + vDotParams.xy - vec2(expanded_radius));
|
||||
pos += (aPosition.xy * vec2(expanded_radius * 2.0));
|
||||
pos = clamp(pos, corner.rect.p0, corner.rect.p0 + corner.rect.size);
|
||||
|
||||
break;
|
||||
}
|
||||
default:
|
||||
|
@ -120,11 +137,6 @@ void main(void) {
|
|||
}
|
||||
}
|
||||
|
||||
// Get local vertex position for the corner rect.
|
||||
// TODO(gw): We could reduce the number of pixels written here
|
||||
// by calculating a tight fitting bounding box of the dash itself.
|
||||
vec2 pos = corner.rect.p0 + aPosition.xy * corner.rect.size;
|
||||
|
||||
// Transform to world pos
|
||||
vec4 world_pos = scroll_node.transform * vec4(pos, 0.0, 1.0);
|
||||
world_pos.xyz /= world_pos.w;
|
||||
|
|
|
@ -43,6 +43,7 @@ varying vec3 vClipMaskUv;
|
|||
#define VECS_PER_TEXT_RUN 3
|
||||
#define VECS_PER_GRADIENT_STOP 2
|
||||
|
||||
#define COLOR_MODE_FROM_PASS 0
|
||||
#define COLOR_MODE_ALPHA 1
|
||||
#define COLOR_MODE_SUBPX_CONST_COLOR 2
|
||||
#define COLOR_MODE_SUBPX_BG_PASS0 3
|
||||
|
|
|
@ -64,7 +64,12 @@ void main(void) {
|
|||
|
||||
int glyph_index = prim.user_data0;
|
||||
int resource_address = prim.user_data1;
|
||||
int subpx_dir = prim.user_data2;
|
||||
int subpx_dir = prim.user_data2 >> 16;
|
||||
int color_mode = prim.user_data2 & 0xffff;
|
||||
|
||||
if (color_mode == COLOR_MODE_FROM_PASS) {
|
||||
color_mode = uMode;
|
||||
}
|
||||
|
||||
Glyph glyph = fetch_glyph(prim.specific_prim_address,
|
||||
glyph_index,
|
||||
|
@ -123,7 +128,7 @@ void main(void) {
|
|||
|
||||
write_clip(vi.screen_pos, prim.clip_area);
|
||||
|
||||
switch (uMode) {
|
||||
switch (color_mode) {
|
||||
case COLOR_MODE_ALPHA:
|
||||
case COLOR_MODE_BITMAP:
|
||||
vMaskSwizzle = vec2(0.0, 1.0);
|
||||
|
|
|
@ -3,18 +3,19 @@
|
|||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
use api::{AlphaType, ClipMode, DeviceIntRect, DeviceIntSize};
|
||||
use api::{DeviceUintRect, DeviceUintPoint, DeviceUintSize, ExternalImageType, FilterOp, ImageRendering, LayerRect};
|
||||
use api::{DeviceUintRect, DeviceUintPoint, DeviceUintSize, ExternalImageType, FilterOp, ImageRendering, LayoutRect};
|
||||
use api::{DeviceIntPoint, SubpixelDirection, YuvColorSpace, YuvFormat};
|
||||
use api::{LayerToWorldTransform, WorldPixel};
|
||||
use api::{LayoutToWorldTransform, WorldPixel};
|
||||
use border::{BorderCornerInstance, BorderCornerSide, BorderEdgeKind};
|
||||
use clip::{ClipSource, ClipStore, ClipWorkItem};
|
||||
use clip_scroll_tree::{CoordinateSystemId};
|
||||
use euclid::{TypedTransform3D, vec3};
|
||||
use glyph_rasterizer::GlyphFormat;
|
||||
use gpu_cache::{GpuCache, GpuCacheAddress};
|
||||
use gpu_types::{BrushFlags, BrushInstance, ClipChainRectIndex, ZBufferId, ZBufferIdGenerator};
|
||||
use gpu_types::{ClipMaskInstance, ClipScrollNodeIndex, RasterizationSpace};
|
||||
use gpu_types::{CompositePrimitiveInstance, PrimitiveInstance, SimplePrimitiveInstance};
|
||||
use gpu_types::{BrushFlags, BrushInstance, ClipChainRectIndex, ClipMaskBorderCornerDotDash};
|
||||
use gpu_types::{ClipMaskInstance, ClipScrollNodeIndex, CompositePrimitiveInstance};
|
||||
use gpu_types::{PrimitiveInstance, RasterizationSpace, SimplePrimitiveInstance, ZBufferId};
|
||||
use gpu_types::ZBufferIdGenerator;
|
||||
use internal_types::{FastHashMap, SavedTargetIndex, SourceTexture};
|
||||
use picture::{PictureCompositeMode, PicturePrimitive, PictureSurface};
|
||||
use picture::{IMAGE_BRUSH_BLOCKS, IMAGE_BRUSH_EXTRA_BLOCKS};
|
||||
|
@ -1155,21 +1156,45 @@ impl AlphaBatchBuilder {
|
|||
TransformBatchKind::TextRun(glyph_format),
|
||||
);
|
||||
|
||||
let blend_mode = match glyph_format {
|
||||
let (blend_mode, color_mode) = match glyph_format {
|
||||
GlyphFormat::Subpixel |
|
||||
GlyphFormat::TransformedSubpixel => {
|
||||
if text_cpu.font.bg_color.a != 0 {
|
||||
BlendMode::SubpixelWithBgColor
|
||||
(
|
||||
BlendMode::SubpixelWithBgColor,
|
||||
ShaderColorMode::FromRenderPassMode,
|
||||
)
|
||||
} else if ctx.use_dual_source_blending {
|
||||
BlendMode::SubpixelDualSource
|
||||
(
|
||||
BlendMode::SubpixelDualSource,
|
||||
ShaderColorMode::SubpixelDualSource,
|
||||
)
|
||||
} else {
|
||||
BlendMode::SubpixelConstantTextColor(text_cpu.font.color.into())
|
||||
(
|
||||
BlendMode::SubpixelConstantTextColor(text_cpu.font.color.into()),
|
||||
ShaderColorMode::SubpixelConstantTextColor,
|
||||
)
|
||||
}
|
||||
}
|
||||
GlyphFormat::Alpha |
|
||||
GlyphFormat::TransformedAlpha |
|
||||
GlyphFormat::Bitmap |
|
||||
GlyphFormat::ColorBitmap => BlendMode::PremultipliedAlpha,
|
||||
GlyphFormat::TransformedAlpha => {
|
||||
(
|
||||
BlendMode::PremultipliedAlpha,
|
||||
ShaderColorMode::Alpha,
|
||||
)
|
||||
}
|
||||
GlyphFormat::Bitmap => {
|
||||
(
|
||||
BlendMode::PremultipliedAlpha,
|
||||
ShaderColorMode::Bitmap,
|
||||
)
|
||||
}
|
||||
GlyphFormat::ColorBitmap => {
|
||||
(
|
||||
BlendMode::PremultipliedAlpha,
|
||||
ShaderColorMode::ColorBitmap,
|
||||
)
|
||||
}
|
||||
};
|
||||
|
||||
let key = BatchKey::new(kind, blend_mode, textures);
|
||||
|
@ -1179,7 +1204,8 @@ impl AlphaBatchBuilder {
|
|||
batch.push(base_instance.build(
|
||||
glyph.index_in_text_run,
|
||||
glyph.uv_rect_address.as_int(),
|
||||
subpx_dir as u32 as i32,
|
||||
(subpx_dir as u32 as i32) << 16 |
|
||||
(color_mode as u32 as i32),
|
||||
));
|
||||
}
|
||||
},
|
||||
|
@ -1587,8 +1613,8 @@ pub fn resolve_image(
|
|||
/// `anchor` here is an index that's going to be preserved in all the
|
||||
/// splits of the polygon.
|
||||
fn make_polygon(
|
||||
rect: LayerRect,
|
||||
transform: &LayerToWorldTransform,
|
||||
rect: LayoutRect,
|
||||
transform: &LayoutToWorldTransform,
|
||||
anchor: usize,
|
||||
) -> Polygon<f64, WorldPixel> {
|
||||
let mat = TypedTransform3D::row_major(
|
||||
|
@ -1620,8 +1646,8 @@ pub struct ClipBatcher {
|
|||
pub rectangles: Vec<ClipMaskInstance>,
|
||||
/// Image draws apply the image masking.
|
||||
pub images: FastHashMap<SourceTexture, Vec<ClipMaskInstance>>,
|
||||
pub border_clears: Vec<ClipMaskInstance>,
|
||||
pub borders: Vec<ClipMaskInstance>,
|
||||
pub border_clears: Vec<ClipMaskBorderCornerDotDash>,
|
||||
pub borders: Vec<ClipMaskBorderCornerDotDash>,
|
||||
pub box_shadows: FastHashMap<SourceTexture, Vec<ClipMaskInstance>>,
|
||||
pub line_decorations: Vec<ClipMaskInstance>,
|
||||
}
|
||||
|
@ -1745,16 +1771,26 @@ impl ClipBatcher {
|
|||
});
|
||||
}
|
||||
ClipSource::BorderCorner(ref source) => {
|
||||
self.border_clears.push(ClipMaskInstance {
|
||||
clip_data_address: gpu_address,
|
||||
segment: 0,
|
||||
..instance
|
||||
});
|
||||
for clip_index in 0 .. source.actual_clip_count {
|
||||
self.borders.push(ClipMaskInstance {
|
||||
let instance = ClipMaskBorderCornerDotDash {
|
||||
clip_mask_instance: ClipMaskInstance {
|
||||
clip_data_address: gpu_address,
|
||||
segment: 1 + clip_index as i32,
|
||||
segment: 0,
|
||||
..instance
|
||||
},
|
||||
dot_dash_data: [0.; 8],
|
||||
};
|
||||
|
||||
self.border_clears.push(instance);
|
||||
|
||||
for data in source.dot_dash_data.iter() {
|
||||
self.borders.push(ClipMaskBorderCornerDotDash {
|
||||
clip_mask_instance: ClipMaskInstance {
|
||||
// The shader understands segment=0 as the clear, so the
|
||||
// segment here just needs to be non-zero.
|
||||
segment: 1,
|
||||
..instance.clip_mask_instance
|
||||
},
|
||||
dot_dash_data: *data,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,8 +2,8 @@
|
|||
* 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::{BorderRadius, BorderSide, BorderStyle, BorderWidths, ClipMode, ColorF, LayerPoint};
|
||||
use api::{LayerPrimitiveInfo, LayerRect, LayerSize, NormalBorder, RepeatMode, TexelRect};
|
||||
use api::{BorderRadius, BorderSide, BorderStyle, BorderWidths, ClipMode, ColorF, LayoutPoint};
|
||||
use api::{LayoutPrimitiveInfo, LayoutRect, LayoutSize, NormalBorder, RepeatMode, TexelRect};
|
||||
use clip::ClipSource;
|
||||
use ellipse::Ellipse;
|
||||
use display_list_flattener::DisplayListFlattener;
|
||||
|
@ -42,8 +42,8 @@ pub enum BorderCornerKind {
|
|||
Clip(BorderCornerInstance),
|
||||
Mask(
|
||||
BorderCornerClipData,
|
||||
LayerSize,
|
||||
LayerSize,
|
||||
LayoutSize,
|
||||
LayoutSize,
|
||||
BorderCornerClipKind,
|
||||
),
|
||||
}
|
||||
|
@ -54,10 +54,10 @@ impl BorderCornerKind {
|
|||
width0: f32,
|
||||
width1: f32,
|
||||
corner: BorderCorner,
|
||||
radius: LayerSize,
|
||||
border_rect: LayerRect,
|
||||
radius: LayoutSize,
|
||||
border_rect: LayoutRect,
|
||||
) -> BorderCornerKind {
|
||||
let size = LayerSize::new(width0.max(radius.width), width1.max(radius.height));
|
||||
let size = LayoutSize::new(width0.max(radius.width), width1.max(radius.height));
|
||||
let (origin, clip_center) = match corner {
|
||||
BorderCorner::TopLeft => {
|
||||
let origin = border_rect.origin;
|
||||
|
@ -65,11 +65,11 @@ impl BorderCornerKind {
|
|||
(origin, clip_center)
|
||||
}
|
||||
BorderCorner::TopRight => {
|
||||
let origin = LayerPoint::new(
|
||||
let origin = LayoutPoint::new(
|
||||
border_rect.origin.x + border_rect.size.width - size.width,
|
||||
border_rect.origin.y,
|
||||
);
|
||||
let clip_center = origin + LayerSize::new(0.0, size.height);
|
||||
let clip_center = origin + LayoutSize::new(0.0, size.height);
|
||||
(origin, clip_center)
|
||||
}
|
||||
BorderCorner::BottomRight => {
|
||||
|
@ -78,24 +78,24 @@ impl BorderCornerKind {
|
|||
(origin, clip_center)
|
||||
}
|
||||
BorderCorner::BottomLeft => {
|
||||
let origin = LayerPoint::new(
|
||||
let origin = LayoutPoint::new(
|
||||
border_rect.origin.x,
|
||||
border_rect.origin.y + border_rect.size.height - size.height,
|
||||
);
|
||||
let clip_center = origin + LayerSize::new(size.width, 0.0);
|
||||
let clip_center = origin + LayoutSize::new(size.width, 0.0);
|
||||
(origin, clip_center)
|
||||
}
|
||||
};
|
||||
let clip_data = BorderCornerClipData {
|
||||
corner_rect: LayerRect::new(origin, size),
|
||||
corner_rect: LayoutRect::new(origin, size),
|
||||
clip_center,
|
||||
corner: pack_as_float(corner as u32),
|
||||
kind: pack_as_float(kind as u32),
|
||||
};
|
||||
BorderCornerKind::Mask(clip_data, radius, LayerSize::new(width0, width1), kind)
|
||||
BorderCornerKind::Mask(clip_data, radius, LayoutSize::new(width0, width1), kind)
|
||||
}
|
||||
|
||||
fn get_radius(&self, original_radius: &LayerSize) -> LayerSize {
|
||||
fn get_radius(&self, original_radius: &LayoutSize) -> LayoutSize {
|
||||
match *self {
|
||||
BorderCornerKind::Solid => *original_radius,
|
||||
BorderCornerKind::Clip(..) => *original_radius,
|
||||
|
@ -117,9 +117,9 @@ fn get_corner(
|
|||
width0: f32,
|
||||
edge1: &BorderSide,
|
||||
width1: f32,
|
||||
radius: &LayerSize,
|
||||
radius: &LayoutSize,
|
||||
corner: BorderCorner,
|
||||
border_rect: &LayerRect,
|
||||
border_rect: &LayoutRect,
|
||||
) -> BorderCornerKind {
|
||||
// If both widths are zero, a corner isn't formed.
|
||||
if width0 == 0.0 && width1 == 0.0 {
|
||||
|
@ -236,7 +236,7 @@ fn get_edge(edge: &BorderSide, width: f32, height: f32) -> (BorderEdgeKind, f32)
|
|||
|
||||
pub fn ensure_no_corner_overlap(
|
||||
radius: &mut BorderRadius,
|
||||
rect: &LayerRect,
|
||||
rect: &LayoutRect,
|
||||
) {
|
||||
let mut ratio = 1.0;
|
||||
let top_left_radius = &mut radius.top_left;
|
||||
|
@ -282,7 +282,7 @@ pub fn ensure_no_corner_overlap(
|
|||
impl<'a> DisplayListFlattener<'a> {
|
||||
fn add_normal_border_primitive(
|
||||
&mut self,
|
||||
info: &LayerPrimitiveInfo,
|
||||
info: &LayoutPrimitiveInfo,
|
||||
border: &NormalBorder,
|
||||
radius: &BorderRadius,
|
||||
widths: &BorderWidths,
|
||||
|
@ -350,7 +350,7 @@ impl<'a> DisplayListFlattener<'a> {
|
|||
// border code path.
|
||||
pub fn add_normal_border(
|
||||
&mut self,
|
||||
info: &LayerPrimitiveInfo,
|
||||
info: &LayoutPrimitiveInfo,
|
||||
border: &NormalBorder,
|
||||
widths: &BorderWidths,
|
||||
clip_and_scroll: ScrollNodeAndClipChain,
|
||||
|
@ -387,30 +387,30 @@ impl<'a> DisplayListFlattener<'a> {
|
|||
ClipMode::Clip,
|
||||
),
|
||||
ClipSource::new_rounded_rect(
|
||||
LayerRect::new(
|
||||
LayerPoint::new(
|
||||
LayoutRect::new(
|
||||
LayoutPoint::new(
|
||||
info.rect.origin.x + widths.left,
|
||||
info.rect.origin.y + widths.top,
|
||||
),
|
||||
LayerSize::new(
|
||||
LayoutSize::new(
|
||||
info.rect.size.width - widths.left - widths.right,
|
||||
info.rect.size.height - widths.top - widths.bottom,
|
||||
),
|
||||
),
|
||||
BorderRadius {
|
||||
top_left: LayerSize::new(
|
||||
top_left: LayoutSize::new(
|
||||
(border.radius.top_left.width - widths.left).max(0.0),
|
||||
(border.radius.top_left.height - widths.top).max(0.0),
|
||||
),
|
||||
top_right: LayerSize::new(
|
||||
top_right: LayoutSize::new(
|
||||
(border.radius.top_right.width - widths.right).max(0.0),
|
||||
(border.radius.top_right.height - widths.top).max(0.0),
|
||||
),
|
||||
bottom_left: LayerSize::new(
|
||||
bottom_left: LayoutSize::new(
|
||||
(border.radius.bottom_left.width - widths.left).max(0.0),
|
||||
(border.radius.bottom_left.height - widths.bottom).max(0.0),
|
||||
),
|
||||
bottom_right: LayerSize::new(
|
||||
bottom_right: LayoutSize::new(
|
||||
(border.radius.bottom_right.width - widths.right).max(0.0),
|
||||
(border.radius.bottom_right.height - widths.bottom).max(0.0),
|
||||
),
|
||||
|
@ -493,19 +493,19 @@ impl<'a> DisplayListFlattener<'a> {
|
|||
|
||||
if has_no_curve && all_corners_simple && all_edges_simple {
|
||||
let p0 = info.rect.origin;
|
||||
let p1 = LayerPoint::new(
|
||||
let p1 = LayoutPoint::new(
|
||||
info.rect.origin.x + left_len,
|
||||
info.rect.origin.y + top_len,
|
||||
);
|
||||
let p2 = LayerPoint::new(
|
||||
let p2 = LayoutPoint::new(
|
||||
info.rect.origin.x + info.rect.size.width - right_len,
|
||||
info.rect.origin.y + info.rect.size.height - bottom_len,
|
||||
);
|
||||
let p3 = info.rect.bottom_right();
|
||||
|
||||
let segment = |x0, y0, x1, y1| BrushSegment::new(
|
||||
LayerPoint::new(x0, y0),
|
||||
LayerSize::new(x1-x0, y1-y0),
|
||||
LayoutPoint::new(x0, y0),
|
||||
LayoutSize::new(x1-x0, y1-y0),
|
||||
true,
|
||||
EdgeAaSegmentMask::all() // Note: this doesn't seem right, needs revision
|
||||
);
|
||||
|
@ -677,17 +677,17 @@ pub enum BorderCornerClipKind {
|
|||
pub struct BorderCornerClipSource {
|
||||
pub corner_data: BorderCornerClipData,
|
||||
pub max_clip_count: usize,
|
||||
pub actual_clip_count: usize,
|
||||
kind: BorderCornerClipKind,
|
||||
widths: LayerSize,
|
||||
widths: LayoutSize,
|
||||
ellipse: Ellipse,
|
||||
pub dot_dash_data: Vec<[f32; 8]>,
|
||||
}
|
||||
|
||||
impl BorderCornerClipSource {
|
||||
pub fn new(
|
||||
corner_data: BorderCornerClipData,
|
||||
corner_radius: LayerSize,
|
||||
widths: LayerSize,
|
||||
corner_radius: LayoutSize,
|
||||
widths: LayoutSize,
|
||||
kind: BorderCornerClipKind,
|
||||
) -> BorderCornerClipSource {
|
||||
// Work out a dash length (and therefore dash count)
|
||||
|
@ -753,45 +753,49 @@ impl BorderCornerClipSource {
|
|||
kind,
|
||||
corner_data,
|
||||
max_clip_count,
|
||||
actual_clip_count: 0,
|
||||
ellipse,
|
||||
widths,
|
||||
dot_dash_data: Vec::new(),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn write(&mut self, mut request: GpuDataRequest) {
|
||||
self.corner_data.write(&mut request);
|
||||
assert_eq!(request.close(), 2);
|
||||
|
||||
match self.kind {
|
||||
BorderCornerClipKind::Dash => {
|
||||
// Get the correct dash arc length.
|
||||
self.actual_clip_count = self.max_clip_count;
|
||||
let dash_arc_length =
|
||||
0.5 * self.ellipse.total_arc_length / (self.actual_clip_count - 1) as f32;
|
||||
0.5 * self.ellipse.total_arc_length / (self.max_clip_count - 1) as f32;
|
||||
self.dot_dash_data.clear();
|
||||
let mut current_arc_length = -0.5 * dash_arc_length;
|
||||
for _ in 0 .. self.actual_clip_count {
|
||||
for _ in 0 .. self.max_clip_count {
|
||||
let arc_length0 = current_arc_length;
|
||||
current_arc_length += dash_arc_length;
|
||||
|
||||
let arc_length1 = current_arc_length;
|
||||
current_arc_length += dash_arc_length;
|
||||
|
||||
let dash_data =
|
||||
BorderCornerDashClipData::new(arc_length0, arc_length1, &self.ellipse);
|
||||
dash_data.write(&mut request);
|
||||
}
|
||||
let alpha = self.ellipse.find_angle_for_arc_length(arc_length0);
|
||||
let beta = self.ellipse.find_angle_for_arc_length(arc_length1);
|
||||
|
||||
assert_eq!(request.close(), 2 + 2 * self.actual_clip_count);
|
||||
let (point0, tangent0) = self.ellipse.get_point_and_tangent(alpha);
|
||||
let (point1, tangent1) = self.ellipse.get_point_and_tangent(beta);
|
||||
|
||||
self.dot_dash_data.push([
|
||||
point0.x, point0.y, tangent0.x, tangent0.y,
|
||||
point1.x, point1.y, tangent1.x, tangent1.y
|
||||
]);
|
||||
}
|
||||
}
|
||||
BorderCornerClipKind::Dot if self.max_clip_count == 1 => {
|
||||
let dot_diameter = lerp(self.widths.width, self.widths.height, 0.5);
|
||||
let dot = BorderCornerDotClipData {
|
||||
center: LayerPoint::new(self.widths.width / 2.0, self.widths.height / 2.0),
|
||||
radius: 0.5 * dot_diameter,
|
||||
};
|
||||
self.actual_clip_count = 1;
|
||||
dot.write(&mut request);
|
||||
assert_eq!(request.close(), 3);
|
||||
self.dot_dash_data.clear();
|
||||
self.dot_dash_data.push([
|
||||
self.widths.width / 2.0, self.widths.height / 2.0, 0.5 * dot_diameter, 0.,
|
||||
0., 0., 0., 0.,
|
||||
]);
|
||||
}
|
||||
BorderCornerClipKind::Dot => {
|
||||
let mut forward_dots = Vec::new();
|
||||
|
@ -852,30 +856,31 @@ impl BorderCornerClipSource {
|
|||
// leftover space on the arc between them evenly. Once
|
||||
// the final arc position is determined, generate the correct
|
||||
// arc positions and angles that get passed to the clip shader.
|
||||
self.actual_clip_count = forward_dots.len() + back_dots.len();
|
||||
let extra_space_per_dot = leftover_arc_length / (self.actual_clip_count - 1) as f32;
|
||||
let number_of_dots = forward_dots.len() + back_dots.len();
|
||||
let extra_space_per_dot = leftover_arc_length / (number_of_dots - 1) as f32;
|
||||
|
||||
self.dot_dash_data.clear();
|
||||
|
||||
let create_dot_data = |ellipse: &Ellipse, arc_length: f32, radius: f32| -> [f32; 8] {
|
||||
// Represents the GPU data for drawing a single dot to a clip mask. The order
|
||||
// these are specified must stay in sync with the way this data is read in the
|
||||
// dot clip shader.
|
||||
let theta = ellipse.find_angle_for_arc_length(arc_length);
|
||||
let (center, _) = ellipse.get_point_and_tangent(theta);
|
||||
[center.x, center.y, radius, 0., 0., 0., 0., 0.,]
|
||||
};
|
||||
|
||||
for (i, dot) in forward_dots.iter().enumerate() {
|
||||
let extra_dist = i as f32 * extra_space_per_dot;
|
||||
let dot = BorderCornerDotClipData::new(
|
||||
dot.arc_pos + extra_dist,
|
||||
0.5 * dot.diameter,
|
||||
&self.ellipse,
|
||||
);
|
||||
dot.write(&mut request);
|
||||
let dot_data = create_dot_data(&self.ellipse, dot.arc_pos + extra_dist, 0.5 * dot.diameter);
|
||||
self.dot_dash_data.push(dot_data);
|
||||
}
|
||||
|
||||
for (i, dot) in back_dots.iter().enumerate() {
|
||||
let extra_dist = i as f32 * extra_space_per_dot;
|
||||
let dot = BorderCornerDotClipData::new(
|
||||
dot.arc_pos - extra_dist,
|
||||
0.5 * dot.diameter,
|
||||
&self.ellipse,
|
||||
);
|
||||
dot.write(&mut request);
|
||||
let dot_data = create_dot_data(&self.ellipse, dot.arc_pos - extra_dist, 0.5 * dot.diameter);
|
||||
self.dot_dash_data.push(dot_data);
|
||||
}
|
||||
|
||||
assert_eq!(request.close(), 2 + self.actual_clip_count);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -887,10 +892,10 @@ impl BorderCornerClipSource {
|
|||
#[repr(C)]
|
||||
pub struct BorderCornerClipData {
|
||||
/// Local space rect of the border corner.
|
||||
corner_rect: LayerRect,
|
||||
corner_rect: LayoutRect,
|
||||
/// Local space point that is the center of the
|
||||
/// circle or ellipse that we are clipping against.
|
||||
clip_center: LayerPoint,
|
||||
clip_center: LayoutPoint,
|
||||
/// The shader needs to know which corner, to
|
||||
/// be able to flip the dash tangents to the
|
||||
/// right orientation.
|
||||
|
@ -910,74 +915,6 @@ impl BorderCornerClipData {
|
|||
}
|
||||
}
|
||||
|
||||
/// Represents the GPU data for drawing a single dash
|
||||
/// to a clip mask. A dash clip is defined by two lines.
|
||||
/// We store a point on the ellipse curve, and a tangent
|
||||
/// to that point, which allows for efficient line-distance
|
||||
/// calculations in the fragment shader.
|
||||
#[derive(Debug, Clone)]
|
||||
#[repr(C)]
|
||||
pub struct BorderCornerDashClipData {
|
||||
pub point0: LayerPoint,
|
||||
pub tangent0: LayerPoint,
|
||||
pub point1: LayerPoint,
|
||||
pub tangent1: LayerPoint,
|
||||
}
|
||||
|
||||
impl BorderCornerDashClipData {
|
||||
pub fn new(arc_length0: f32, arc_length1: f32, ellipse: &Ellipse) -> BorderCornerDashClipData {
|
||||
let alpha = ellipse.find_angle_for_arc_length(arc_length0);
|
||||
let beta = ellipse.find_angle_for_arc_length(arc_length1);
|
||||
|
||||
let (p0, t0) = ellipse.get_point_and_tangent(alpha);
|
||||
let (p1, t1) = ellipse.get_point_and_tangent(beta);
|
||||
|
||||
BorderCornerDashClipData {
|
||||
point0: p0,
|
||||
tangent0: t0,
|
||||
point1: p1,
|
||||
tangent1: t1,
|
||||
}
|
||||
}
|
||||
|
||||
fn write(&self, request: &mut GpuDataRequest) {
|
||||
request.push([
|
||||
self.point0.x,
|
||||
self.point0.y,
|
||||
self.tangent0.x,
|
||||
self.tangent0.y,
|
||||
]);
|
||||
request.push([
|
||||
self.point1.x,
|
||||
self.point1.y,
|
||||
self.tangent1.x,
|
||||
self.tangent1.y,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
/// Represents the GPU data for drawing a single dot
|
||||
/// to a clip mask.
|
||||
#[derive(Debug, Clone)]
|
||||
#[repr(C)]
|
||||
pub struct BorderCornerDotClipData {
|
||||
pub center: LayerPoint,
|
||||
pub radius: f32,
|
||||
}
|
||||
|
||||
impl BorderCornerDotClipData {
|
||||
pub fn new(arc_length: f32, radius: f32, ellipse: &Ellipse) -> BorderCornerDotClipData {
|
||||
let theta = ellipse.find_angle_for_arc_length(arc_length);
|
||||
let (center, _) = ellipse.get_point_and_tangent(theta);
|
||||
|
||||
BorderCornerDotClipData { center, radius }
|
||||
}
|
||||
|
||||
fn write(&self, request: &mut GpuDataRequest) {
|
||||
request.push([self.center.x, self.center.y, self.radius, 0.0]);
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone, Debug)]
|
||||
struct DotInfo {
|
||||
arc_pos: f32,
|
||||
|
@ -992,25 +929,25 @@ impl DotInfo {
|
|||
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct ImageBorderSegment {
|
||||
pub geom_rect: LayerRect,
|
||||
pub geom_rect: LayoutRect,
|
||||
pub sub_rect: TexelRect,
|
||||
pub stretch_size: LayerSize,
|
||||
pub tile_spacing: LayerSize,
|
||||
pub stretch_size: LayoutSize,
|
||||
pub tile_spacing: LayoutSize,
|
||||
}
|
||||
|
||||
impl ImageBorderSegment {
|
||||
pub fn new(
|
||||
rect: LayerRect,
|
||||
rect: LayoutRect,
|
||||
sub_rect: TexelRect,
|
||||
repeat_horizontal: RepeatMode,
|
||||
repeat_vertical: RepeatMode,
|
||||
) -> ImageBorderSegment {
|
||||
let tile_spacing = LayerSize::zero();
|
||||
let tile_spacing = LayoutSize::zero();
|
||||
|
||||
debug_assert!(sub_rect.uv1.x >= sub_rect.uv0.x);
|
||||
debug_assert!(sub_rect.uv1.y >= sub_rect.uv0.y);
|
||||
|
||||
let image_size = LayerSize::new(
|
||||
let image_size = LayoutSize::new(
|
||||
sub_rect.uv1.x - sub_rect.uv0.x,
|
||||
sub_rect.uv1.y - sub_rect.uv0.y,
|
||||
);
|
||||
|
@ -1036,7 +973,7 @@ impl ImageBorderSegment {
|
|||
ImageBorderSegment {
|
||||
geom_rect: rect,
|
||||
sub_rect,
|
||||
stretch_size: LayerSize::new(stretch_size_x, stretch_size_y),
|
||||
stretch_size: LayoutSize::new(stretch_size_x, stretch_size_y),
|
||||
tile_spacing,
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,8 +2,8 @@
|
|||
* 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::{BorderRadius, BoxShadowClipMode, ClipMode, ColorF, DeviceIntSize, LayerPrimitiveInfo};
|
||||
use api::{LayerRect, LayerSize, LayerVector2D, LayoutSize};
|
||||
use api::{BorderRadius, BoxShadowClipMode, ClipMode, ColorF, DeviceIntSize, LayoutPrimitiveInfo};
|
||||
use api::{LayoutRect, LayoutSize, LayoutVector2D};
|
||||
use clip::ClipSource;
|
||||
use display_list_flattener::DisplayListFlattener;
|
||||
use gpu_cache::GpuCacheHandle;
|
||||
|
@ -29,15 +29,15 @@ pub struct BoxShadowClipSource {
|
|||
pub clip_data_handle: GpuCacheHandle,
|
||||
|
||||
// Local-space size of the required render task size.
|
||||
pub shadow_rect_alloc_size: LayerSize,
|
||||
pub shadow_rect_alloc_size: LayoutSize,
|
||||
|
||||
// The minimal shadow rect for the parameters above,
|
||||
// used when drawing the shadow rect to be blurred.
|
||||
pub minimal_shadow_rect: LayerRect,
|
||||
pub minimal_shadow_rect: LayoutRect,
|
||||
|
||||
// Local space rect for the shadow to be drawn or
|
||||
// stretched in the shadow primitive.
|
||||
pub prim_shadow_rect: LayerRect,
|
||||
pub prim_shadow_rect: LayoutRect,
|
||||
}
|
||||
|
||||
// The blur shader samples BLUR_SAMPLE_SCALE * blur_radius surrounding texels.
|
||||
|
@ -67,8 +67,8 @@ impl<'a> DisplayListFlattener<'a> {
|
|||
pub fn add_box_shadow(
|
||||
&mut self,
|
||||
clip_and_scroll: ScrollNodeAndClipChain,
|
||||
prim_info: &LayerPrimitiveInfo,
|
||||
box_offset: &LayerVector2D,
|
||||
prim_info: &LayoutPrimitiveInfo,
|
||||
box_offset: &LayoutVector2D,
|
||||
color: &ColorF,
|
||||
mut blur_radius: f32,
|
||||
spread_radius: f32,
|
||||
|
@ -147,12 +147,11 @@ impl<'a> DisplayListFlattener<'a> {
|
|||
|
||||
self.add_primitive(
|
||||
clip_and_scroll,
|
||||
&LayerPrimitiveInfo::with_clip_rect(final_prim_rect, prim_info.clip_rect),
|
||||
&LayoutPrimitiveInfo::with_clip_rect(final_prim_rect, prim_info.clip_rect),
|
||||
clips,
|
||||
PrimitiveContainer::Brush(
|
||||
BrushPrimitive::new(BrushKind::Solid {
|
||||
color: *color,
|
||||
},
|
||||
BrushPrimitive::new(
|
||||
BrushKind::new_solid(*color),
|
||||
None,
|
||||
)
|
||||
),
|
||||
|
@ -177,9 +176,7 @@ impl<'a> DisplayListFlattener<'a> {
|
|||
// Draw the box-shadow as a solid rect, using a box-shadow
|
||||
// clip mask source.
|
||||
let prim = BrushPrimitive::new(
|
||||
BrushKind::Solid {
|
||||
color: *color,
|
||||
},
|
||||
BrushKind::new_solid(*color),
|
||||
None,
|
||||
);
|
||||
|
||||
|
@ -204,7 +201,7 @@ impl<'a> DisplayListFlattener<'a> {
|
|||
|
||||
// Outset shadows are expanded by the shadow
|
||||
// region from the original primitive.
|
||||
LayerPrimitiveInfo::with_clip_rect(dest_rect, prim_info.clip_rect)
|
||||
LayoutPrimitiveInfo::with_clip_rect(dest_rect, prim_info.clip_rect)
|
||||
}
|
||||
BoxShadowClipMode::Inset => {
|
||||
// If the inner shadow rect contains the prim
|
||||
|
|
|
@ -3,8 +3,8 @@
|
|||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
use api::{BorderRadius, ClipMode, ComplexClipRegion, DeviceIntRect, DevicePixelScale, ImageMask};
|
||||
use api::{ImageRendering, LayerRect, LayerSize, LayoutPoint, LayoutVector2D, LocalClip};
|
||||
use api::{BoxShadowClipMode, LayerPoint, LayerToWorldScale, LineOrientation, LineStyle};
|
||||
use api::{ImageRendering, LayoutRect, LayoutSize, LayoutPoint, LayoutVector2D, LocalClip};
|
||||
use api::{BoxShadowClipMode, LayoutToWorldScale, LineOrientation, LineStyle};
|
||||
use border::{BorderCornerClipSource, ensure_no_corner_overlap};
|
||||
use box_shadow::{BLUR_SAMPLE_SCALE, BoxShadowClipSource, BoxShadowCacheKey};
|
||||
use clip_scroll_tree::{ClipChainIndex, CoordinateSystemId};
|
||||
|
@ -15,7 +15,7 @@ use gpu_types::{BoxShadowStretchMode, ClipScrollNodeIndex};
|
|||
use prim_store::{ClipData, ImageMaskData};
|
||||
use render_task::to_cache_size;
|
||||
use resource_cache::{ImageRequest, ResourceCache};
|
||||
use util::{LayerToWorldFastTransform, MaxRect, calculate_screen_bounding_rect};
|
||||
use util::{LayoutToWorldFastTransform, MaxRect, calculate_screen_bounding_rect};
|
||||
use util::{extract_inner_rect_safe, pack_as_float};
|
||||
use std::sync::Arc;
|
||||
|
||||
|
@ -28,7 +28,7 @@ pub type ClipSourcesWeakHandle = WeakFreeListHandle<ClipStoreMarker>;
|
|||
|
||||
#[derive(Debug)]
|
||||
pub struct LineDecorationClipSource {
|
||||
rect: LayerRect,
|
||||
rect: LayoutRect,
|
||||
style: LineStyle,
|
||||
orientation: LineOrientation,
|
||||
wavy_line_thickness: f32,
|
||||
|
@ -36,14 +36,14 @@ pub struct LineDecorationClipSource {
|
|||
|
||||
#[derive(Clone, Debug)]
|
||||
pub struct ClipRegion {
|
||||
pub main: LayerRect,
|
||||
pub main: LayoutRect,
|
||||
pub image_mask: Option<ImageMask>,
|
||||
pub complex_clips: Vec<ComplexClipRegion>,
|
||||
}
|
||||
|
||||
impl ClipRegion {
|
||||
pub fn create_for_clip_node(
|
||||
rect: LayerRect,
|
||||
rect: LayoutRect,
|
||||
mut complex_clips: Vec<ComplexClipRegion>,
|
||||
mut image_mask: Option<ImageMask>,
|
||||
reference_frame_relative_offset: &LayoutVector2D,
|
||||
|
@ -84,8 +84,8 @@ impl ClipRegion {
|
|||
|
||||
#[derive(Debug)]
|
||||
pub enum ClipSource {
|
||||
Rectangle(LayerRect, ClipMode),
|
||||
RoundedRectangle(LayerRect, BorderRadius, ClipMode),
|
||||
Rectangle(LayoutRect, ClipMode),
|
||||
RoundedRectangle(LayoutRect, BorderRadius, ClipMode),
|
||||
Image(ImageMask),
|
||||
/// TODO(gw): This currently only handles dashed style
|
||||
/// clips, where the border style is dashed for both
|
||||
|
@ -120,7 +120,7 @@ impl From<ClipRegion> for ClipSources {
|
|||
|
||||
impl ClipSource {
|
||||
pub fn new_rounded_rect(
|
||||
rect: LayerRect,
|
||||
rect: LayoutRect,
|
||||
mut radii: BorderRadius,
|
||||
clip_mode: ClipMode
|
||||
) -> ClipSource {
|
||||
|
@ -137,7 +137,7 @@ impl ClipSource {
|
|||
}
|
||||
|
||||
pub fn new_line_decoration(
|
||||
rect: LayerRect,
|
||||
rect: LayoutRect,
|
||||
style: LineStyle,
|
||||
orientation: LineOrientation,
|
||||
wavy_line_thickness: f32,
|
||||
|
@ -153,19 +153,19 @@ impl ClipSource {
|
|||
}
|
||||
|
||||
pub fn new_box_shadow(
|
||||
shadow_rect: LayerRect,
|
||||
shadow_rect: LayoutRect,
|
||||
shadow_radius: BorderRadius,
|
||||
prim_shadow_rect: LayerRect,
|
||||
prim_shadow_rect: LayoutRect,
|
||||
blur_radius: f32,
|
||||
clip_mode: BoxShadowClipMode,
|
||||
) -> ClipSource {
|
||||
// Get the fractional offsets required to match the
|
||||
// source rect with a minimal rect.
|
||||
let fract_offset = LayerPoint::new(
|
||||
let fract_offset = LayoutPoint::new(
|
||||
shadow_rect.origin.x.fract().abs(),
|
||||
shadow_rect.origin.y.fract().abs(),
|
||||
);
|
||||
let fract_size = LayerSize::new(
|
||||
let fract_size = LayoutSize::new(
|
||||
shadow_rect.size.width.fract().abs(),
|
||||
shadow_rect.size.height.fract().abs(),
|
||||
);
|
||||
|
@ -192,18 +192,18 @@ impl ClipSource {
|
|||
let used_corner_height = max_corner_height.max(blur_region);
|
||||
|
||||
// Minimal nine-patch size, corner + internal + corner.
|
||||
let min_shadow_rect_size = LayerSize::new(
|
||||
let min_shadow_rect_size = LayoutSize::new(
|
||||
2.0 * used_corner_width + blur_region,
|
||||
2.0 * used_corner_height + blur_region,
|
||||
);
|
||||
|
||||
// The minimal rect to blur.
|
||||
let mut minimal_shadow_rect = LayerRect::new(
|
||||
LayerPoint::new(
|
||||
let mut minimal_shadow_rect = LayoutRect::new(
|
||||
LayoutPoint::new(
|
||||
blur_region + fract_offset.x,
|
||||
blur_region + fract_offset.y,
|
||||
),
|
||||
LayerSize::new(
|
||||
LayoutSize::new(
|
||||
min_shadow_rect_size.width + fract_size.width,
|
||||
min_shadow_rect_size.height + fract_size.height,
|
||||
),
|
||||
|
@ -227,7 +227,7 @@ impl ClipSource {
|
|||
}
|
||||
|
||||
// Expand the shadow rect by enough room for the blur to take effect.
|
||||
let shadow_rect_alloc_size = LayerSize::new(
|
||||
let shadow_rect_alloc_size = LayoutSize::new(
|
||||
2.0 * blur_region + minimal_shadow_rect.size.width.ceil(),
|
||||
2.0 * blur_region + minimal_shadow_rect.size.height.ceil(),
|
||||
);
|
||||
|
@ -267,8 +267,8 @@ impl ClipSource {
|
|||
#[derive(Debug)]
|
||||
pub struct ClipSources {
|
||||
pub clips: Vec<(ClipSource, GpuCacheHandle)>,
|
||||
pub local_inner_rect: LayerRect,
|
||||
pub local_outer_rect: Option<LayerRect>
|
||||
pub local_inner_rect: LayoutRect,
|
||||
pub local_outer_rect: Option<LayoutRect>
|
||||
}
|
||||
|
||||
impl ClipSources {
|
||||
|
@ -291,16 +291,16 @@ impl ClipSources {
|
|||
&self.clips
|
||||
}
|
||||
|
||||
fn calculate_inner_and_outer_rects(clips: &Vec<ClipSource>) -> (LayerRect, Option<LayerRect>) {
|
||||
fn calculate_inner_and_outer_rects(clips: &Vec<ClipSource>) -> (LayoutRect, Option<LayoutRect>) {
|
||||
if clips.is_empty() {
|
||||
return (LayerRect::zero(), None);
|
||||
return (LayoutRect::zero(), None);
|
||||
}
|
||||
|
||||
// Depending on the complexity of the clip, we may either know the outer and/or inner
|
||||
// rect, or neither or these. In the case of a clip-out, we currently set the mask bounds
|
||||
// to be unknown. This is conservative, but ensures correctness. In the future we can make
|
||||
// this a lot more clever with some proper region handling.
|
||||
let mut local_outer = Some(LayerRect::max_rect());
|
||||
let mut local_outer = Some(LayoutRect::max_rect());
|
||||
let mut local_inner = local_outer;
|
||||
let mut can_calculate_inner_rect = true;
|
||||
let mut can_calculate_outer_rect = false;
|
||||
|
@ -350,15 +350,15 @@ impl ClipSources {
|
|||
}
|
||||
|
||||
let outer = if can_calculate_outer_rect {
|
||||
Some(local_outer.unwrap_or_else(LayerRect::zero))
|
||||
Some(local_outer.unwrap_or_else(LayoutRect::zero))
|
||||
} else {
|
||||
None
|
||||
};
|
||||
|
||||
let inner = if can_calculate_inner_rect {
|
||||
local_inner.unwrap_or_else(LayerRect::zero)
|
||||
local_inner.unwrap_or_else(LayoutRect::zero)
|
||||
} else {
|
||||
LayerRect::zero()
|
||||
LayoutRect::zero()
|
||||
};
|
||||
|
||||
(inner, outer)
|
||||
|
@ -433,7 +433,7 @@ impl ClipSources {
|
|||
let blur_radius_dp = (info.blur_radius * 0.5 * device_pixel_scale.0).round();
|
||||
|
||||
// Create the cache key for this box-shadow render task.
|
||||
let content_scale = LayerToWorldScale::new(1.0) * device_pixel_scale;
|
||||
let content_scale = LayoutToWorldScale::new(1.0) * device_pixel_scale;
|
||||
let cache_size = to_cache_size(info.shadow_rect_alloc_size * content_scale);
|
||||
let bs_cache_key = BoxShadowCacheKey {
|
||||
blur_radius_dp: blur_radius_dp as i32,
|
||||
|
@ -464,7 +464,7 @@ impl ClipSources {
|
|||
|
||||
pub fn get_screen_bounds(
|
||||
&self,
|
||||
transform: &LayerToWorldFastTransform,
|
||||
transform: &LayoutToWorldFastTransform,
|
||||
device_pixel_scale: DevicePixelScale,
|
||||
) -> (DeviceIntRect, Option<DeviceIntRect>) {
|
||||
// If this translation isn't axis aligned or has a perspective component, don't try to
|
||||
|
@ -493,12 +493,12 @@ impl ClipSources {
|
|||
/// rectangles that are either outside or inside bounds.
|
||||
#[derive(Clone, Debug, PartialEq)]
|
||||
pub struct Geometry {
|
||||
pub local_rect: LayerRect,
|
||||
pub local_rect: LayoutRect,
|
||||
pub device_rect: DeviceIntRect,
|
||||
}
|
||||
|
||||
impl From<LayerRect> for Geometry {
|
||||
fn from(local_rect: LayerRect) -> Self {
|
||||
impl From<LayoutRect> for Geometry {
|
||||
fn from(local_rect: LayoutRect) -> Self {
|
||||
Geometry {
|
||||
local_rect,
|
||||
device_rect: DeviceIntRect::zero(),
|
||||
|
@ -508,7 +508,7 @@ impl From<LayerRect> for Geometry {
|
|||
|
||||
pub fn rounded_rectangle_contains_point(
|
||||
point: &LayoutPoint,
|
||||
rect: &LayerRect,
|
||||
rect: &LayoutRect,
|
||||
radii: &BorderRadius
|
||||
) -> bool {
|
||||
if !rect.contains(point) {
|
||||
|
@ -549,7 +549,7 @@ pub type ClipChainNodeRef = Option<Arc<ClipChainNode>>;
|
|||
#[derive(Debug, Clone)]
|
||||
pub struct ClipChainNode {
|
||||
pub work_item: ClipWorkItem,
|
||||
pub local_clip_rect: LayerRect,
|
||||
pub local_clip_rect: LayoutRect,
|
||||
pub screen_outer_rect: DeviceIntRect,
|
||||
pub screen_inner_rect: DeviceIntRect,
|
||||
pub prev: ClipChainNodeRef,
|
||||
|
|
|
@ -2,8 +2,8 @@
|
|||
* 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::{DevicePixelScale, ExternalScrollId, LayerPixel, LayerPoint, LayerRect, LayerSize};
|
||||
use api::{LayerVector2D, LayoutTransform, LayoutVector2D, PipelineId, PropertyBinding};
|
||||
use api::{DevicePixelScale, ExternalScrollId, LayoutPixel, LayoutPoint, LayoutRect, LayoutSize};
|
||||
use api::{LayoutVector2D, LayoutTransform, PipelineId, PropertyBinding};
|
||||
use api::{ScrollClamping, ScrollLocation, ScrollSensitivity, StickyOffsetBounds};
|
||||
use api::WorldPoint;
|
||||
use clip::{ClipChain, ClipChainNode, ClipSourcesHandle, ClipStore, ClipWorkItem};
|
||||
|
@ -15,7 +15,7 @@ use gpu_cache::GpuCache;
|
|||
use gpu_types::{ClipScrollNodeIndex as GPUClipScrollNodeIndex, ClipScrollNodeData};
|
||||
use resource_cache::ResourceCache;
|
||||
use scene::SceneProperties;
|
||||
use util::{LayerToWorldFastTransform, LayerFastTransform, LayoutFastTransform};
|
||||
use util::{LayoutToWorldFastTransform, LayoutFastTransform};
|
||||
use util::{TransformedRectKind};
|
||||
|
||||
#[derive(Debug)]
|
||||
|
@ -24,7 +24,7 @@ pub struct StickyFrameInfo {
|
|||
pub vertical_offset_bounds: StickyOffsetBounds,
|
||||
pub horizontal_offset_bounds: StickyOffsetBounds,
|
||||
pub previously_applied_offset: LayoutVector2D,
|
||||
pub current_offset: LayerVector2D,
|
||||
pub current_offset: LayoutVector2D,
|
||||
}
|
||||
|
||||
impl StickyFrameInfo {
|
||||
|
@ -39,7 +39,7 @@ impl StickyFrameInfo {
|
|||
vertical_offset_bounds,
|
||||
horizontal_offset_bounds,
|
||||
previously_applied_offset,
|
||||
current_offset: LayerVector2D::zero(),
|
||||
current_offset: LayoutVector2D::zero(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -89,17 +89,17 @@ impl NodeType {
|
|||
#[derive(Debug)]
|
||||
pub struct ClipScrollNode {
|
||||
/// Viewing rectangle in the coordinate system of the parent reference frame.
|
||||
pub local_viewport_rect: LayerRect,
|
||||
pub local_viewport_rect: LayoutRect,
|
||||
|
||||
/// The transformation for this viewport in world coordinates is the transformation for
|
||||
/// our parent reference frame, plus any accumulated scrolling offsets from nodes
|
||||
/// between our reference frame and this node. For reference frames, we also include
|
||||
/// whatever local transformation this reference frame provides. This can be combined
|
||||
/// with the local_viewport_rect to get its position in world space.
|
||||
pub world_viewport_transform: LayerToWorldFastTransform,
|
||||
pub world_viewport_transform: LayoutToWorldFastTransform,
|
||||
|
||||
/// World transform for content transformed by this node.
|
||||
pub world_content_transform: LayerToWorldFastTransform,
|
||||
pub world_content_transform: LayoutToWorldFastTransform,
|
||||
|
||||
/// Pipeline that this layer belongs to
|
||||
pub pipeline_id: PipelineId,
|
||||
|
@ -124,7 +124,7 @@ pub struct ClipScrollNode {
|
|||
/// The transformation from the coordinate system which established our compatible coordinate
|
||||
/// system (same coordinate system id) and us. This can change via scroll offsets and via new
|
||||
/// reference frame transforms.
|
||||
pub coordinate_system_relative_transform: LayerFastTransform,
|
||||
pub coordinate_system_relative_transform: LayoutFastTransform,
|
||||
|
||||
/// A linear ID / index of this clip-scroll node. Used as a reference to
|
||||
/// pass to shaders, to allow them to fetch a given clip-scroll node.
|
||||
|
@ -135,39 +135,39 @@ impl ClipScrollNode {
|
|||
pub fn new(
|
||||
pipeline_id: PipelineId,
|
||||
parent_index: Option<ClipScrollNodeIndex>,
|
||||
rect: &LayerRect,
|
||||
rect: &LayoutRect,
|
||||
node_type: NodeType
|
||||
) -> Self {
|
||||
ClipScrollNode {
|
||||
local_viewport_rect: *rect,
|
||||
world_viewport_transform: LayerToWorldFastTransform::identity(),
|
||||
world_content_transform: LayerToWorldFastTransform::identity(),
|
||||
world_viewport_transform: LayoutToWorldFastTransform::identity(),
|
||||
world_content_transform: LayoutToWorldFastTransform::identity(),
|
||||
parent: parent_index,
|
||||
children: Vec::new(),
|
||||
pipeline_id,
|
||||
node_type: node_type,
|
||||
node_type,
|
||||
invertible: true,
|
||||
coordinate_system_id: CoordinateSystemId(0),
|
||||
coordinate_system_relative_transform: LayerFastTransform::identity(),
|
||||
coordinate_system_relative_transform: LayoutFastTransform::identity(),
|
||||
node_data_index: GPUClipScrollNodeIndex(0),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn empty() -> ClipScrollNode {
|
||||
ClipScrollNode::new(PipelineId::dummy(), None, &LayerRect::zero(), NodeType::Empty)
|
||||
ClipScrollNode::new(PipelineId::dummy(), None, &LayoutRect::zero(), NodeType::Empty)
|
||||
}
|
||||
|
||||
pub fn new_scroll_frame(
|
||||
pipeline_id: PipelineId,
|
||||
parent_index: ClipScrollNodeIndex,
|
||||
external_id: Option<ExternalScrollId>,
|
||||
frame_rect: &LayerRect,
|
||||
content_size: &LayerSize,
|
||||
frame_rect: &LayoutRect,
|
||||
content_size: &LayoutSize,
|
||||
scroll_sensitivity: ScrollSensitivity,
|
||||
) -> Self {
|
||||
let node_type = NodeType::ScrollFrame(ScrollFrameInfo::new(
|
||||
scroll_sensitivity,
|
||||
LayerSize::new(
|
||||
LayoutSize::new(
|
||||
(content_size.width - frame_rect.size.width).max(0.0),
|
||||
(content_size.height - frame_rect.size.height).max(0.0)
|
||||
),
|
||||
|
@ -179,19 +179,19 @@ impl ClipScrollNode {
|
|||
|
||||
pub fn new_reference_frame(
|
||||
parent_index: Option<ClipScrollNodeIndex>,
|
||||
frame_rect: &LayerRect,
|
||||
frame_rect: &LayoutRect,
|
||||
source_transform: Option<PropertyBinding<LayoutTransform>>,
|
||||
source_perspective: Option<LayoutTransform>,
|
||||
origin_in_parent_reference_frame: LayerVector2D,
|
||||
origin_in_parent_reference_frame: LayoutVector2D,
|
||||
pipeline_id: PipelineId,
|
||||
) -> Self {
|
||||
let identity = LayoutTransform::identity();
|
||||
let source_perspective = source_perspective.map_or_else(
|
||||
LayoutFastTransform::identity, |perspective| perspective.into());
|
||||
let info = ReferenceFrameInfo {
|
||||
resolved_transform: LayerFastTransform::identity(),
|
||||
resolved_transform: LayoutFastTransform::identity(),
|
||||
source_transform: source_transform.unwrap_or(PropertyBinding::Value(identity)),
|
||||
source_perspective: source_perspective,
|
||||
source_perspective,
|
||||
origin_in_parent_reference_frame,
|
||||
invertible: true,
|
||||
};
|
||||
|
@ -200,7 +200,7 @@ impl ClipScrollNode {
|
|||
|
||||
pub fn new_sticky_frame(
|
||||
parent_index: ClipScrollNodeIndex,
|
||||
frame_rect: LayerRect,
|
||||
frame_rect: LayoutRect,
|
||||
sticky_frame_info: StickyFrameInfo,
|
||||
pipeline_id: PipelineId,
|
||||
) -> Self {
|
||||
|
@ -222,14 +222,14 @@ impl ClipScrollNode {
|
|||
scrolling.scroll_sensitivity = scroll_sensitivity;
|
||||
scrolling.scrollable_size = scrollable_size;
|
||||
}
|
||||
_ if old_scrolling_state.offset != LayerVector2D::zero() => {
|
||||
_ if old_scrolling_state.offset != LayoutVector2D::zero() => {
|
||||
warn!("Tried to scroll a non-scroll node.")
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn set_scroll_origin(&mut self, origin: &LayerPoint, clamp: ScrollClamping) -> bool {
|
||||
pub fn set_scroll_origin(&mut self, origin: &LayoutPoint, clamp: ScrollClamping) -> bool {
|
||||
let scrollable_size = self.scrollable_size();
|
||||
let scrollable_width = scrollable_size.width;
|
||||
let scrollable_height = scrollable_size.height;
|
||||
|
@ -248,13 +248,13 @@ impl ClipScrollNode {
|
|||
return false;
|
||||
}
|
||||
|
||||
let origin = LayerPoint::new(origin.x.max(0.0), origin.y.max(0.0));
|
||||
LayerVector2D::new(
|
||||
let origin = LayoutPoint::new(origin.x.max(0.0), origin.y.max(0.0));
|
||||
LayoutVector2D::new(
|
||||
(-origin.x).max(-scrollable_width).min(0.0).round(),
|
||||
(-origin.y).max(-scrollable_height).min(0.0).round(),
|
||||
)
|
||||
}
|
||||
ScrollClamping::NoClamping => LayerPoint::zero() - *origin,
|
||||
ScrollClamping::NoClamping => LayoutPoint::zero() - *origin,
|
||||
};
|
||||
|
||||
if new_offset == scrolling.offset {
|
||||
|
@ -267,8 +267,8 @@ impl ClipScrollNode {
|
|||
|
||||
pub fn mark_uninvertible(&mut self) {
|
||||
self.invertible = false;
|
||||
self.world_content_transform = LayerToWorldFastTransform::identity();
|
||||
self.world_viewport_transform = LayerToWorldFastTransform::identity();
|
||||
self.world_content_transform = LayoutToWorldFastTransform::identity();
|
||||
self.world_viewport_transform = LayoutToWorldFastTransform::identity();
|
||||
}
|
||||
|
||||
pub fn push_gpu_node_data(&mut self, node_data: &mut Vec<ClipScrollNodeData>) {
|
||||
|
@ -424,7 +424,7 @@ impl ClipScrollNode {
|
|||
// transform, plus any accumulated scroll offset from our parents, plus any offset
|
||||
// provided by our own sticky positioning.
|
||||
let accumulated_offset = state.parent_accumulated_scroll_offset + sticky_offset;
|
||||
self.world_viewport_transform = if accumulated_offset != LayerVector2D::zero() {
|
||||
self.world_viewport_transform = if accumulated_offset != LayoutVector2D::zero() {
|
||||
state.parent_reference_frame_transform.pre_translate(&accumulated_offset)
|
||||
} else {
|
||||
state.parent_reference_frame_transform
|
||||
|
@ -433,7 +433,7 @@ impl ClipScrollNode {
|
|||
// The transformation for any content inside of us is the viewport transformation, plus
|
||||
// whatever scrolling offset we supply as well.
|
||||
let scroll_offset = self.scroll_offset();
|
||||
self.world_content_transform = if scroll_offset != LayerVector2D::zero() {
|
||||
self.world_content_transform = if scroll_offset != LayoutVector2D::zero() {
|
||||
self.world_viewport_transform.pre_translate(&scroll_offset)
|
||||
} else {
|
||||
self.world_viewport_transform
|
||||
|
@ -465,7 +465,7 @@ impl ClipScrollNode {
|
|||
// Resolve the transform against any property bindings.
|
||||
let source_transform = scene_properties.resolve_layout_transform(&info.source_transform);
|
||||
info.resolved_transform =
|
||||
LayerFastTransform::with_vector(info.origin_in_parent_reference_frame)
|
||||
LayoutFastTransform::with_vector(info.origin_in_parent_reference_frame)
|
||||
.pre_mul(&source_transform.into())
|
||||
.pre_mul(&info.source_perspective);
|
||||
|
||||
|
@ -477,7 +477,7 @@ impl ClipScrollNode {
|
|||
let relative_transform = info.resolved_transform
|
||||
.post_translate(state.parent_accumulated_scroll_offset)
|
||||
.to_transform()
|
||||
.with_destination::<LayerPixel>();
|
||||
.with_destination::<LayoutPixel>();
|
||||
self.world_viewport_transform =
|
||||
state.parent_reference_frame_transform.pre_mul(&relative_transform.into());
|
||||
self.world_content_transform = self.world_viewport_transform;
|
||||
|
@ -492,7 +492,7 @@ impl ClipScrollNode {
|
|||
match state.coordinate_system_relative_transform.update(relative_transform) {
|
||||
Some(offset) => self.coordinate_system_relative_transform = offset,
|
||||
None => {
|
||||
self.coordinate_system_relative_transform = LayerFastTransform::identity();
|
||||
self.coordinate_system_relative_transform = LayoutFastTransform::identity();
|
||||
state.current_coordinate_system_id = *next_coordinate_system_id;
|
||||
next_coordinate_system_id.advance();
|
||||
}
|
||||
|
@ -503,17 +503,17 @@ impl ClipScrollNode {
|
|||
|
||||
fn calculate_sticky_offset(
|
||||
&self,
|
||||
viewport_scroll_offset: &LayerVector2D,
|
||||
viewport_rect: &LayerRect,
|
||||
) -> LayerVector2D {
|
||||
viewport_scroll_offset: &LayoutVector2D,
|
||||
viewport_rect: &LayoutRect,
|
||||
) -> LayoutVector2D {
|
||||
let info = match self.node_type {
|
||||
NodeType::StickyFrame(ref info) => info,
|
||||
_ => return LayerVector2D::zero(),
|
||||
_ => return LayoutVector2D::zero(),
|
||||
};
|
||||
|
||||
if info.margins.top.is_none() && info.margins.bottom.is_none() &&
|
||||
info.margins.left.is_none() && info.margins.right.is_none() {
|
||||
return LayerVector2D::zero();
|
||||
return LayoutVector2D::zero();
|
||||
}
|
||||
|
||||
// The viewport and margins of the item establishes the maximum amount that it can
|
||||
|
@ -523,7 +523,7 @@ impl ClipScrollNode {
|
|||
// page.
|
||||
let sticky_rect = self.local_viewport_rect.translate(viewport_scroll_offset);
|
||||
|
||||
let mut sticky_offset = LayerVector2D::zero();
|
||||
let mut sticky_offset = LayoutVector2D::zero();
|
||||
if let Some(margin) = info.margins.top {
|
||||
let top_viewport_edge = viewport_rect.min_y() + margin;
|
||||
if sticky_rect.min_y() < top_viewport_edge {
|
||||
|
@ -623,7 +623,7 @@ impl ClipScrollNode {
|
|||
match self.node_type {
|
||||
NodeType::ReferenceFrame(ref info) => {
|
||||
state.parent_reference_frame_transform = self.world_viewport_transform;
|
||||
state.parent_accumulated_scroll_offset = LayerVector2D::zero();
|
||||
state.parent_accumulated_scroll_offset = LayoutVector2D::zero();
|
||||
state.coordinate_system_relative_transform =
|
||||
self.coordinate_system_relative_transform.clone();
|
||||
let translation = -info.origin_in_parent_reference_frame;
|
||||
|
@ -649,10 +649,10 @@ impl ClipScrollNode {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn scrollable_size(&self) -> LayerSize {
|
||||
pub fn scrollable_size(&self) -> LayoutSize {
|
||||
match self.node_type {
|
||||
NodeType:: ScrollFrame(state) => state.scrollable_size,
|
||||
_ => LayerSize::zero(),
|
||||
_ => LayoutSize::zero(),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -719,7 +719,7 @@ impl ClipScrollNode {
|
|||
let p0 = inv.transform_point3d(&cursor.extend(z0));
|
||||
let p1 = inv.transform_point3d(&cursor.extend(z1));
|
||||
|
||||
if self.scrollable_size() == LayerSize::zero() {
|
||||
if self.scrollable_size() == LayoutSize::zero() {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -730,10 +730,10 @@ impl ClipScrollNode {
|
|||
)
|
||||
}
|
||||
|
||||
pub fn scroll_offset(&self) -> LayerVector2D {
|
||||
pub fn scroll_offset(&self) -> LayoutVector2D {
|
||||
match self.node_type {
|
||||
NodeType::ScrollFrame(ref scrolling) => scrolling.offset,
|
||||
_ => LayerVector2D::zero(),
|
||||
_ => LayoutVector2D::zero(),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -747,11 +747,11 @@ impl ClipScrollNode {
|
|||
|
||||
#[derive(Copy, Clone, Debug)]
|
||||
pub struct ScrollFrameInfo {
|
||||
pub offset: LayerVector2D,
|
||||
pub offset: LayoutVector2D,
|
||||
pub scroll_sensitivity: ScrollSensitivity,
|
||||
|
||||
/// Amount that this ScrollFrame can scroll in both directions.
|
||||
pub scrollable_size: LayerSize,
|
||||
pub scrollable_size: LayoutSize,
|
||||
|
||||
/// An external id to identify this scroll frame to API clients. This
|
||||
/// allows setting scroll positions via the API without relying on ClipsIds
|
||||
|
@ -764,11 +764,11 @@ pub struct ScrollFrameInfo {
|
|||
impl ScrollFrameInfo {
|
||||
pub fn new(
|
||||
scroll_sensitivity: ScrollSensitivity,
|
||||
scrollable_size: LayerSize,
|
||||
scrollable_size: LayoutSize,
|
||||
external_id: Option<ExternalScrollId>,
|
||||
) -> ScrollFrameInfo {
|
||||
ScrollFrameInfo {
|
||||
offset: LayerVector2D::zero(),
|
||||
offset: LayoutVector2D::zero(),
|
||||
scroll_sensitivity,
|
||||
scrollable_size,
|
||||
external_id,
|
||||
|
@ -788,7 +788,7 @@ impl ScrollFrameInfo {
|
|||
pub struct ReferenceFrameInfo {
|
||||
/// The transformation that establishes this reference frame, relative to the parent
|
||||
/// reference frame. The origin of the reference frame is included in the transformation.
|
||||
pub resolved_transform: LayerFastTransform,
|
||||
pub resolved_transform: LayoutFastTransform,
|
||||
|
||||
/// The source transform and perspective matrices provided by the stacking context
|
||||
/// that forms this reference frame. We maintain the property binding information
|
||||
|
@ -800,7 +800,7 @@ pub struct ReferenceFrameInfo {
|
|||
/// The original, not including the transform and relative to the parent reference frame,
|
||||
/// origin of this reference frame. This is already rolled into the `transform' property, but
|
||||
/// we also store it here to properly transform the viewport for sticky positioning.
|
||||
pub origin_in_parent_reference_frame: LayerVector2D,
|
||||
pub origin_in_parent_reference_frame: LayoutVector2D,
|
||||
|
||||
/// True if the resolved transform is invertible.
|
||||
pub invertible: bool,
|
||||
|
|
|
@ -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::{DeviceIntRect, DevicePixelScale, ExternalScrollId, LayerPoint, LayerRect, LayerVector2D};
|
||||
use api::{DeviceIntRect, DevicePixelScale, ExternalScrollId, LayoutPoint, LayoutRect, LayoutVector2D};
|
||||
use api::{PipelineId, ScrollClamping, ScrollLocation, ScrollNodeState};
|
||||
use api::WorldPoint;
|
||||
use clip::{ClipChain, ClipSourcesHandle, ClipStore};
|
||||
|
@ -13,7 +13,7 @@ use internal_types::{FastHashMap, FastHashSet};
|
|||
use print_tree::{PrintTree, PrintTreePrinter};
|
||||
use resource_cache::ResourceCache;
|
||||
use scene::SceneProperties;
|
||||
use util::{LayerFastTransform, LayerToWorldFastTransform};
|
||||
use util::{LayoutFastTransform, LayoutToWorldFastTransform};
|
||||
|
||||
pub type ScrollStates = FastHashMap<ExternalScrollId, ScrollFrameInfo>;
|
||||
|
||||
|
@ -68,7 +68,7 @@ pub struct ClipScrollTree {
|
|||
/// ClipChainDescriptors and also those defined by the clipping node hierarchy.
|
||||
pub clip_chains: Vec<ClipChain>,
|
||||
|
||||
pub pending_scroll_offsets: FastHashMap<ExternalScrollId, (LayerPoint, ScrollClamping)>,
|
||||
pub pending_scroll_offsets: FastHashMap<ExternalScrollId, (LayoutPoint, ScrollClamping)>,
|
||||
|
||||
/// The current frame id, used for giving a unique id to all new dynamically
|
||||
/// added frames and clips. The ClipScrollTree increments this by one every
|
||||
|
@ -82,10 +82,10 @@ pub struct ClipScrollTree {
|
|||
|
||||
#[derive(Clone)]
|
||||
pub struct TransformUpdateState {
|
||||
pub parent_reference_frame_transform: LayerToWorldFastTransform,
|
||||
pub parent_accumulated_scroll_offset: LayerVector2D,
|
||||
pub nearest_scrolling_ancestor_offset: LayerVector2D,
|
||||
pub nearest_scrolling_ancestor_viewport: LayerRect,
|
||||
pub parent_reference_frame_transform: LayoutToWorldFastTransform,
|
||||
pub parent_accumulated_scroll_offset: LayoutVector2D,
|
||||
pub nearest_scrolling_ancestor_offset: LayoutVector2D,
|
||||
pub nearest_scrolling_ancestor_viewport: LayoutRect,
|
||||
|
||||
/// The index of the current parent's clip chain.
|
||||
pub parent_clip_chain_index: ClipChainIndex,
|
||||
|
@ -97,7 +97,7 @@ pub struct TransformUpdateState {
|
|||
pub current_coordinate_system_id: CoordinateSystemId,
|
||||
|
||||
/// Transform from the coordinate system that started this compatible coordinate system.
|
||||
pub coordinate_system_relative_transform: LayerFastTransform,
|
||||
pub coordinate_system_relative_transform: LayoutFastTransform,
|
||||
|
||||
/// True if this node is transformed by an invertible transform. If not, display items
|
||||
/// transformed by this node will not be displayed and display items not transformed by this
|
||||
|
@ -200,7 +200,7 @@ impl ClipScrollTree {
|
|||
|
||||
pub fn scroll_node(
|
||||
&mut self,
|
||||
origin: LayerPoint,
|
||||
origin: LayoutPoint,
|
||||
id: ExternalScrollId,
|
||||
clamp: ScrollClamping
|
||||
) -> bool {
|
||||
|
@ -246,13 +246,13 @@ impl ClipScrollTree {
|
|||
|
||||
let root_reference_frame_index = self.root_reference_frame_index();
|
||||
let mut state = TransformUpdateState {
|
||||
parent_reference_frame_transform: LayerVector2D::new(pan.x, pan.y).into(),
|
||||
parent_accumulated_scroll_offset: LayerVector2D::zero(),
|
||||
nearest_scrolling_ancestor_offset: LayerVector2D::zero(),
|
||||
nearest_scrolling_ancestor_viewport: LayerRect::zero(),
|
||||
parent_reference_frame_transform: LayoutVector2D::new(pan.x, pan.y).into(),
|
||||
parent_accumulated_scroll_offset: LayoutVector2D::zero(),
|
||||
nearest_scrolling_ancestor_offset: LayoutVector2D::zero(),
|
||||
nearest_scrolling_ancestor_viewport: LayoutRect::zero(),
|
||||
parent_clip_chain_index: ClipChainIndex(0),
|
||||
current_coordinate_system_id: CoordinateSystemId::root(),
|
||||
coordinate_system_relative_transform: LayerFastTransform::identity(),
|
||||
coordinate_system_relative_transform: LayoutFastTransform::identity(),
|
||||
invertible: true,
|
||||
};
|
||||
let mut next_coordinate_system_id = state.current_coordinate_system_id.next();
|
||||
|
@ -380,7 +380,7 @@ impl ClipScrollTree {
|
|||
index: ClipScrollNodeIndex,
|
||||
parent_index: ClipScrollNodeIndex,
|
||||
handle: ClipSourcesHandle,
|
||||
clip_rect: LayerRect,
|
||||
clip_rect: LayoutRect,
|
||||
pipeline_id: PipelineId,
|
||||
) -> ClipChainIndex {
|
||||
let clip_chain_index = self.allocate_clip_chain();
|
||||
|
@ -394,7 +394,7 @@ impl ClipScrollTree {
|
|||
&mut self,
|
||||
index: ClipScrollNodeIndex,
|
||||
parent_index: ClipScrollNodeIndex,
|
||||
frame_rect: LayerRect,
|
||||
frame_rect: LayoutRect,
|
||||
sticky_frame_info: StickyFrameInfo,
|
||||
pipeline_id: PipelineId,
|
||||
) {
|
||||
|
|
|
@ -6,10 +6,10 @@
|
|||
use api::{AlphaType, BorderDetails, BorderDisplayItem, BuiltDisplayListIter, ClipAndScrollInfo};
|
||||
use api::{ClipId, ColorF, ComplexClipRegion, DeviceIntPoint, DeviceIntRect, DeviceIntSize};
|
||||
use api::{DevicePixelScale, DeviceUintRect, DisplayItemRef, Epoch, ExtendMode, ExternalScrollId};
|
||||
use api::{FilterOp, FontInstanceKey, FontRenderMode, GlyphInstance, GlyphOptions, GlyphRasterSpace, GradientStop};
|
||||
use api::{IframeDisplayItem, ImageKey, ImageRendering, ItemRange, LayerPoint, LayerPrimitiveInfo};
|
||||
use api::{LayerRect, LayerSize, LayerVector2D, LayoutRect, LayoutSize, LayoutTransform};
|
||||
use api::{LayoutVector2D, LineOrientation, LineStyle, LocalClip, PipelineId, PropertyBinding};
|
||||
use api::{FilterOp, FontInstanceKey, GlyphInstance, GlyphOptions, GlyphRasterSpace, GradientStop};
|
||||
use api::{IframeDisplayItem, ImageKey, ImageRendering, ItemRange, LayoutPoint, LayoutPrimitiveInfo};
|
||||
use api::{LayoutRect, LayoutVector2D, LayoutSize, LayoutTransform};
|
||||
use api::{LineOrientation, LineStyle, LocalClip, PipelineId, PropertyBinding};
|
||||
use api::{RepeatMode, ScrollFrameDisplayItem, ScrollPolicy, ScrollSensitivity, Shadow};
|
||||
use api::{SpecificDisplayItem, StackingContext, StickyFrameDisplayItem, TexelRect, TileOffset};
|
||||
use api::{TransformStyle, YuvColorSpace, YuvData};
|
||||
|
@ -28,7 +28,7 @@ use picture::PictureCompositeMode;
|
|||
use prim_store::{BrushKind, BrushPrimitive, BrushSegmentDescriptor, CachedGradient};
|
||||
use prim_store::{CachedGradientIndex, ImageCacheKey, ImagePrimitiveCpu, ImageSource};
|
||||
use prim_store::{PictureIndex, PrimitiveContainer, PrimitiveIndex, PrimitiveStore};
|
||||
use prim_store::{ScrollNodeAndClipChain, TextRunPrimitiveCpu};
|
||||
use prim_store::{OpacityBinding, ScrollNodeAndClipChain, TextRunPrimitiveCpu};
|
||||
use render_backend::{DocumentView};
|
||||
use resource_cache::{FontInstanceMap, ImageRequest, TiledImageMap};
|
||||
use scene::{Scene, ScenePipeline, StackingContextHelpers};
|
||||
|
@ -342,8 +342,8 @@ impl<'a> DisplayListFlattener<'a> {
|
|||
if self.scene.root_pipeline_id != Some(pipeline_id) {
|
||||
if let Some(pipeline) = self.scene.pipelines.get(&pipeline_id) {
|
||||
if let Some(bg_color) = pipeline.background_color {
|
||||
let root_bounds = LayerRect::new(LayerPoint::zero(), *frame_size);
|
||||
let info = LayerPrimitiveInfo::new(root_bounds);
|
||||
let root_bounds = LayoutRect::new(LayoutPoint::zero(), *frame_size);
|
||||
let info = LayoutPrimitiveInfo::new(root_bounds);
|
||||
self.add_solid_rectangle(
|
||||
reference_frame_info,
|
||||
&info,
|
||||
|
@ -355,14 +355,14 @@ impl<'a> DisplayListFlattener<'a> {
|
|||
}
|
||||
}
|
||||
|
||||
self.flatten_items(&mut pipeline.display_list.iter(), pipeline_id, LayerVector2D::zero());
|
||||
self.flatten_items(&mut pipeline.display_list.iter(), pipeline_id, LayoutVector2D::zero());
|
||||
|
||||
if self.config.enable_scrollbars {
|
||||
let scrollbar_rect = LayerRect::new(LayerPoint::zero(), LayerSize::new(10.0, 70.0));
|
||||
let container_rect = LayerRect::new(LayerPoint::zero(), *frame_size);
|
||||
let scrollbar_rect = LayoutRect::new(LayoutPoint::zero(), LayoutSize::new(10.0, 70.0));
|
||||
let container_rect = LayoutRect::new(LayoutPoint::zero(), *frame_size);
|
||||
self.add_scroll_bar(
|
||||
reference_frame_info,
|
||||
&LayerPrimitiveInfo::new(scrollbar_rect),
|
||||
&LayoutPrimitiveInfo::new(scrollbar_rect),
|
||||
DEFAULT_SCROLLBAR_COLOR,
|
||||
ScrollbarInfo(scroll_frame_info.scroll_node_id, container_rect),
|
||||
);
|
||||
|
@ -375,7 +375,7 @@ impl<'a> DisplayListFlattener<'a> {
|
|||
&mut self,
|
||||
traversal: &mut BuiltDisplayListIter<'a>,
|
||||
pipeline_id: PipelineId,
|
||||
reference_frame_relative_offset: LayerVector2D,
|
||||
reference_frame_relative_offset: LayoutVector2D,
|
||||
) {
|
||||
loop {
|
||||
let subtraversal = {
|
||||
|
@ -409,7 +409,7 @@ impl<'a> DisplayListFlattener<'a> {
|
|||
info: &StickyFrameDisplayItem,
|
||||
clip_and_scroll: &ScrollNodeAndClipChain,
|
||||
parent_id: &ClipId,
|
||||
reference_frame_relative_offset: &LayerVector2D,
|
||||
reference_frame_relative_offset: &LayoutVector2D,
|
||||
) {
|
||||
let frame_rect = item.rect().translate(reference_frame_relative_offset);
|
||||
let sticky_frame_info = StickyFrameInfo::new(
|
||||
|
@ -436,7 +436,7 @@ impl<'a> DisplayListFlattener<'a> {
|
|||
info: &ScrollFrameDisplayItem,
|
||||
pipeline_id: PipelineId,
|
||||
clip_and_scroll_ids: &ClipAndScrollInfo,
|
||||
reference_frame_relative_offset: &LayerVector2D,
|
||||
reference_frame_relative_offset: &LayoutVector2D,
|
||||
) {
|
||||
let complex_clips = self.get_complex_clips(pipeline_id, item.complex_clip().0);
|
||||
let clip_region = ClipRegion::create_for_clip_node(
|
||||
|
@ -475,7 +475,7 @@ impl<'a> DisplayListFlattener<'a> {
|
|||
stacking_context: &StackingContext,
|
||||
unreplaced_scroll_id: ClipId,
|
||||
mut scroll_node_id: ClipId,
|
||||
mut reference_frame_relative_offset: LayerVector2D,
|
||||
mut reference_frame_relative_offset: LayoutVector2D,
|
||||
is_backface_visible: bool,
|
||||
) {
|
||||
// Avoid doing unnecessary work for empty stacking contexts.
|
||||
|
@ -515,7 +515,7 @@ impl<'a> DisplayListFlattener<'a> {
|
|||
stacking_context.perspective.is_some()
|
||||
);
|
||||
|
||||
let reference_frame_bounds = LayerRect::new(LayerPoint::zero(), bounds.size);
|
||||
let reference_frame_bounds = LayoutRect::new(LayoutPoint::zero(), bounds.size);
|
||||
self.push_reference_frame(
|
||||
reference_frame_id,
|
||||
Some(scroll_node_id),
|
||||
|
@ -526,7 +526,7 @@ impl<'a> DisplayListFlattener<'a> {
|
|||
reference_frame_relative_offset,
|
||||
);
|
||||
self.replacements.push((unreplaced_scroll_id, reference_frame_id));
|
||||
reference_frame_relative_offset = LayerVector2D::zero();
|
||||
reference_frame_relative_offset = LayoutVector2D::zero();
|
||||
}
|
||||
|
||||
// We apply the replacements one more time in case we need to set it to a replacement
|
||||
|
@ -566,7 +566,7 @@ impl<'a> DisplayListFlattener<'a> {
|
|||
item: &DisplayItemRef,
|
||||
info: &IframeDisplayItem,
|
||||
clip_and_scroll_ids: &ClipAndScrollInfo,
|
||||
reference_frame_relative_offset: &LayerVector2D,
|
||||
reference_frame_relative_offset: &LayoutVector2D,
|
||||
) {
|
||||
let iframe_pipeline_id = info.pipeline_id;
|
||||
let pipeline = match self.scene.pipelines.get(&iframe_pipeline_id) {
|
||||
|
@ -593,7 +593,7 @@ impl<'a> DisplayListFlattener<'a> {
|
|||
self.pipeline_epochs.push((iframe_pipeline_id, epoch));
|
||||
|
||||
let bounds = item.rect();
|
||||
let iframe_rect = LayerRect::new(LayerPoint::zero(), bounds.size);
|
||||
let iframe_rect = LayoutRect::new(LayoutPoint::zero(), bounds.size);
|
||||
let origin = *reference_frame_relative_offset + bounds.origin.to_vector();
|
||||
self.push_reference_frame(
|
||||
ClipId::root_reference_frame(iframe_pipeline_id),
|
||||
|
@ -624,7 +624,7 @@ impl<'a> DisplayListFlattener<'a> {
|
|||
&'b mut self,
|
||||
item: DisplayItemRef<'a, 'b>,
|
||||
pipeline_id: PipelineId,
|
||||
reference_frame_relative_offset: LayerVector2D,
|
||||
reference_frame_relative_offset: LayoutVector2D,
|
||||
) -> Option<BuiltDisplayListIter<'a>> {
|
||||
let mut clip_and_scroll_ids = item.clip_and_scroll();
|
||||
let unreplaced_scroll_id = clip_and_scroll_ids.scroll_node_id;
|
||||
|
@ -632,7 +632,7 @@ impl<'a> DisplayListFlattener<'a> {
|
|||
self.apply_scroll_frame_id_replacement(clip_and_scroll_ids.scroll_node_id);
|
||||
let clip_and_scroll = self.id_to_index_mapper.map_clip_and_scroll(&clip_and_scroll_ids);
|
||||
|
||||
let prim_info = item.get_layer_primitive_info(&reference_frame_relative_offset);
|
||||
let prim_info = item.get_layout_primitive_info(&reference_frame_relative_offset);
|
||||
match *item.item() {
|
||||
SpecificDisplayItem::Image(ref info) => {
|
||||
match self.tiled_image_map.get(&info.image_key).cloned() {
|
||||
|
@ -848,7 +848,7 @@ impl<'a> DisplayListFlattener<'a> {
|
|||
}
|
||||
SpecificDisplayItem::PushShadow(shadow) => {
|
||||
let mut prim_info = prim_info.clone();
|
||||
prim_info.rect = LayerRect::zero();
|
||||
prim_info.rect = LayoutRect::zero();
|
||||
self
|
||||
.push_shadow(shadow, clip_and_scroll, &prim_info);
|
||||
}
|
||||
|
@ -864,7 +864,7 @@ impl<'a> DisplayListFlattener<'a> {
|
|||
/// sub-primitives.
|
||||
pub fn create_primitive(
|
||||
&mut self,
|
||||
info: &LayerPrimitiveInfo,
|
||||
info: &LayoutPrimitiveInfo,
|
||||
clip_sources: Vec<ClipSource>,
|
||||
container: PrimitiveContainer,
|
||||
) -> PrimitiveIndex {
|
||||
|
@ -888,7 +888,7 @@ impl<'a> DisplayListFlattener<'a> {
|
|||
|
||||
pub fn add_primitive_to_hit_testing_list(
|
||||
&mut self,
|
||||
info: &LayerPrimitiveInfo,
|
||||
info: &LayoutPrimitiveInfo,
|
||||
clip_and_scroll: ScrollNodeAndClipChain
|
||||
) {
|
||||
let tag = match info.tag {
|
||||
|
@ -926,7 +926,7 @@ impl<'a> DisplayListFlattener<'a> {
|
|||
pub fn add_primitive(
|
||||
&mut self,
|
||||
clip_and_scroll: ScrollNodeAndClipChain,
|
||||
info: &LayerPrimitiveInfo,
|
||||
info: &LayoutPrimitiveInfo,
|
||||
clip_sources: Vec<ClipSource>,
|
||||
container: PrimitiveContainer,
|
||||
) {
|
||||
|
@ -997,7 +997,7 @@ impl<'a> DisplayListFlattener<'a> {
|
|||
// primitives, we can apply any kind of clip mask
|
||||
// to them, as for a normal primitive. This is needed
|
||||
// to correctly handle some CSS cases (see #1957).
|
||||
let max_clip = LayerRect::max_rect();
|
||||
let max_clip = LayoutRect::max_rect();
|
||||
|
||||
// If there is no root picture, create one for the main framebuffer.
|
||||
if self.sc_stack.is_empty() {
|
||||
|
@ -1075,7 +1075,7 @@ impl<'a> DisplayListFlattener<'a> {
|
|||
let prim = BrushPrimitive::new_picture(container_index);
|
||||
|
||||
let prim_index = self.prim_store.add_primitive(
|
||||
&LayerRect::zero(),
|
||||
&LayoutRect::zero(),
|
||||
&max_clip,
|
||||
is_backface_visible,
|
||||
None,
|
||||
|
@ -1124,7 +1124,7 @@ impl<'a> DisplayListFlattener<'a> {
|
|||
|
||||
let src_prim = BrushPrimitive::new_picture(src_pic_index);
|
||||
let src_prim_index = self.prim_store.add_primitive(
|
||||
&LayerRect::zero(),
|
||||
&LayoutRect::zero(),
|
||||
&max_clip,
|
||||
is_backface_visible,
|
||||
None,
|
||||
|
@ -1154,7 +1154,7 @@ impl<'a> DisplayListFlattener<'a> {
|
|||
let src_prim = BrushPrimitive::new_picture(src_pic_index);
|
||||
|
||||
let src_prim_index = self.prim_store.add_primitive(
|
||||
&LayerRect::zero(),
|
||||
&LayoutRect::zero(),
|
||||
&max_clip,
|
||||
is_backface_visible,
|
||||
None,
|
||||
|
@ -1211,7 +1211,7 @@ impl<'a> DisplayListFlattener<'a> {
|
|||
|
||||
// Add the brush to the parent picture.
|
||||
let sc_prim_index = self.prim_store.add_primitive(
|
||||
&LayerRect::zero(),
|
||||
&LayoutRect::zero(),
|
||||
&max_clip,
|
||||
is_backface_visible,
|
||||
None,
|
||||
|
@ -1225,19 +1225,12 @@ impl<'a> DisplayListFlattener<'a> {
|
|||
// Add this as the top-most picture for primitives to be added to.
|
||||
self.picture_stack.push(pic_index);
|
||||
|
||||
// TODO(gw): This is super conservative. We can expand on this a lot
|
||||
// once all the picture code is in place and landed.
|
||||
let allow_subpixel_aa = composite_ops.count() == 0 &&
|
||||
transform_style == TransformStyle::Flat &&
|
||||
composite_mode.is_none();
|
||||
|
||||
// Push the SC onto the stack, so we know how to handle things in
|
||||
// pop_stacking_context.
|
||||
let sc = FlattenedStackingContext {
|
||||
composite_ops,
|
||||
is_backface_visible,
|
||||
pipeline_id,
|
||||
allow_subpixel_aa,
|
||||
transform_style,
|
||||
rendering_context_3d_pic_index,
|
||||
glyph_raster_space,
|
||||
|
@ -1261,7 +1254,11 @@ impl<'a> DisplayListFlattener<'a> {
|
|||
}
|
||||
|
||||
for _ in 0 .. pop_count {
|
||||
self.picture_stack.pop().expect("bug: mismatched picture stack");
|
||||
let pic_index = self
|
||||
.picture_stack
|
||||
.pop()
|
||||
.expect("bug: mismatched picture stack");
|
||||
self.prim_store.optimize_picture_if_possible(pic_index);
|
||||
}
|
||||
|
||||
// By the time the stacking context stack is empty, we should
|
||||
|
@ -1282,10 +1279,10 @@ impl<'a> DisplayListFlattener<'a> {
|
|||
reference_frame_id: ClipId,
|
||||
parent_id: Option<ClipId>,
|
||||
pipeline_id: PipelineId,
|
||||
rect: &LayerRect,
|
||||
rect: &LayoutRect,
|
||||
source_transform: Option<PropertyBinding<LayoutTransform>>,
|
||||
source_perspective: Option<LayoutTransform>,
|
||||
origin_in_parent_reference_frame: LayerVector2D,
|
||||
origin_in_parent_reference_frame: LayoutVector2D,
|
||||
) -> ClipScrollNodeIndex {
|
||||
let index = self.id_to_index_mapper.get_node_index(reference_frame_id);
|
||||
let node = ClipScrollNode::new_reference_frame(
|
||||
|
@ -1325,17 +1322,17 @@ impl<'a> DisplayListFlattener<'a> {
|
|||
let root_node = &mut self.clip_scroll_tree.nodes[root_id.0];
|
||||
if let NodeType::ReferenceFrame(ref mut info) = root_node.node_type {
|
||||
info.resolved_transform =
|
||||
LayerVector2D::new(viewport_offset.x, viewport_offset.y).into();
|
||||
LayoutVector2D::new(viewport_offset.x, viewport_offset.y).into();
|
||||
}
|
||||
}
|
||||
|
||||
pub fn push_root(
|
||||
&mut self,
|
||||
pipeline_id: PipelineId,
|
||||
viewport_size: &LayerSize,
|
||||
content_size: &LayerSize,
|
||||
viewport_size: &LayoutSize,
|
||||
content_size: &LayoutSize,
|
||||
) {
|
||||
let viewport_rect = LayerRect::new(LayerPoint::zero(), *viewport_size);
|
||||
let viewport_rect = LayoutRect::new(LayoutPoint::zero(), *viewport_size);
|
||||
|
||||
self.push_reference_frame(
|
||||
ClipId::root_reference_frame(pipeline_id),
|
||||
|
@ -1344,7 +1341,7 @@ impl<'a> DisplayListFlattener<'a> {
|
|||
&viewport_rect,
|
||||
None,
|
||||
None,
|
||||
LayerVector2D::zero(),
|
||||
LayoutVector2D::zero(),
|
||||
);
|
||||
|
||||
self.add_scroll_frame(
|
||||
|
@ -1386,8 +1383,8 @@ impl<'a> DisplayListFlattener<'a> {
|
|||
parent_id: ClipId,
|
||||
external_id: Option<ExternalScrollId>,
|
||||
pipeline_id: PipelineId,
|
||||
frame_rect: &LayerRect,
|
||||
content_size: &LayerSize,
|
||||
frame_rect: &LayoutRect,
|
||||
content_size: &LayoutSize,
|
||||
scroll_sensitivity: ScrollSensitivity,
|
||||
) -> ClipScrollNodeIndex {
|
||||
let node_index = self.id_to_index_mapper.get_node_index(new_node_id);
|
||||
|
@ -1413,11 +1410,11 @@ impl<'a> DisplayListFlattener<'a> {
|
|||
&mut self,
|
||||
shadow: Shadow,
|
||||
clip_and_scroll: ScrollNodeAndClipChain,
|
||||
info: &LayerPrimitiveInfo,
|
||||
info: &LayoutPrimitiveInfo,
|
||||
) {
|
||||
let pipeline_id = self.sc_stack.last().unwrap().pipeline_id;
|
||||
let current_reference_frame_index = self.current_reference_frame_index();
|
||||
let max_clip = LayerRect::max_rect();
|
||||
let max_clip = LayoutRect::max_rect();
|
||||
|
||||
// Quote from https://drafts.csswg.org/css-backgrounds-3/#shadow-blur
|
||||
// "the image that would be generated by applying to the shadow a
|
||||
|
@ -1446,7 +1443,7 @@ impl<'a> DisplayListFlattener<'a> {
|
|||
// Create the primitive to draw the shadow picture into the scene.
|
||||
let shadow_prim = BrushPrimitive::new_picture(shadow_pic_index);
|
||||
let shadow_prim_index = self.prim_store.add_primitive(
|
||||
&LayerRect::zero(),
|
||||
&LayoutRect::zero(),
|
||||
&max_clip,
|
||||
info.is_backface_visible,
|
||||
None,
|
||||
|
@ -1468,7 +1465,7 @@ impl<'a> DisplayListFlattener<'a> {
|
|||
pub fn add_solid_rectangle(
|
||||
&mut self,
|
||||
clip_and_scroll: ScrollNodeAndClipChain,
|
||||
info: &LayerPrimitiveInfo,
|
||||
info: &LayoutPrimitiveInfo,
|
||||
color: ColorF,
|
||||
segments: Option<BrushSegmentDescriptor>,
|
||||
extra_clips: Vec<ClipSource>,
|
||||
|
@ -1481,9 +1478,7 @@ impl<'a> DisplayListFlattener<'a> {
|
|||
}
|
||||
|
||||
let prim = BrushPrimitive::new(
|
||||
BrushKind::Solid {
|
||||
color,
|
||||
},
|
||||
BrushKind::new_solid(color),
|
||||
segments,
|
||||
);
|
||||
|
||||
|
@ -1498,7 +1493,7 @@ impl<'a> DisplayListFlattener<'a> {
|
|||
pub fn add_clear_rectangle(
|
||||
&mut self,
|
||||
clip_and_scroll: ScrollNodeAndClipChain,
|
||||
info: &LayerPrimitiveInfo,
|
||||
info: &LayoutPrimitiveInfo,
|
||||
) {
|
||||
let prim = BrushPrimitive::new(
|
||||
BrushKind::Clear,
|
||||
|
@ -1516,7 +1511,7 @@ impl<'a> DisplayListFlattener<'a> {
|
|||
pub fn add_scroll_bar(
|
||||
&mut self,
|
||||
clip_and_scroll: ScrollNodeAndClipChain,
|
||||
info: &LayerPrimitiveInfo,
|
||||
info: &LayoutPrimitiveInfo,
|
||||
color: ColorF,
|
||||
scrollbar_info: ScrollbarInfo,
|
||||
) {
|
||||
|
@ -1525,9 +1520,7 @@ impl<'a> DisplayListFlattener<'a> {
|
|||
}
|
||||
|
||||
let prim = BrushPrimitive::new(
|
||||
BrushKind::Solid {
|
||||
color,
|
||||
},
|
||||
BrushKind::new_solid(color),
|
||||
None,
|
||||
);
|
||||
|
||||
|
@ -1552,16 +1545,14 @@ impl<'a> DisplayListFlattener<'a> {
|
|||
pub fn add_line(
|
||||
&mut self,
|
||||
clip_and_scroll: ScrollNodeAndClipChain,
|
||||
info: &LayerPrimitiveInfo,
|
||||
info: &LayoutPrimitiveInfo,
|
||||
wavy_line_thickness: f32,
|
||||
orientation: LineOrientation,
|
||||
line_color: &ColorF,
|
||||
style: LineStyle,
|
||||
) {
|
||||
let prim = BrushPrimitive::new(
|
||||
BrushKind::Solid {
|
||||
color: *line_color,
|
||||
},
|
||||
BrushKind::new_solid(*line_color),
|
||||
None,
|
||||
);
|
||||
|
||||
|
@ -1594,7 +1585,7 @@ impl<'a> DisplayListFlattener<'a> {
|
|||
pub fn add_border(
|
||||
&mut self,
|
||||
clip_and_scroll: ScrollNodeAndClipChain,
|
||||
info: &LayerPrimitiveInfo,
|
||||
info: &LayoutPrimitiveInfo,
|
||||
border_item: &BorderDisplayItem,
|
||||
gradient_stops: ItemRange<GradientStop>,
|
||||
gradient_stops_count: usize,
|
||||
|
@ -1602,23 +1593,23 @@ impl<'a> DisplayListFlattener<'a> {
|
|||
let rect = info.rect;
|
||||
let create_segments = |outset: SideOffsets2D<f32>| {
|
||||
// Calculate the modified rect as specific by border-image-outset
|
||||
let origin = LayerPoint::new(rect.origin.x - outset.left, rect.origin.y - outset.top);
|
||||
let size = LayerSize::new(
|
||||
let origin = LayoutPoint::new(rect.origin.x - outset.left, rect.origin.y - outset.top);
|
||||
let size = LayoutSize::new(
|
||||
rect.size.width + outset.left + outset.right,
|
||||
rect.size.height + outset.top + outset.bottom,
|
||||
);
|
||||
let rect = LayerRect::new(origin, size);
|
||||
let rect = LayoutRect::new(origin, size);
|
||||
|
||||
let tl_outer = LayerPoint::new(rect.origin.x, rect.origin.y);
|
||||
let tl_outer = LayoutPoint::new(rect.origin.x, rect.origin.y);
|
||||
let tl_inner = tl_outer + vec2(border_item.widths.left, border_item.widths.top);
|
||||
|
||||
let tr_outer = LayerPoint::new(rect.origin.x + rect.size.width, rect.origin.y);
|
||||
let tr_outer = LayoutPoint::new(rect.origin.x + rect.size.width, rect.origin.y);
|
||||
let tr_inner = tr_outer + vec2(-border_item.widths.right, border_item.widths.top);
|
||||
|
||||
let bl_outer = LayerPoint::new(rect.origin.x, rect.origin.y + rect.size.height);
|
||||
let bl_outer = LayoutPoint::new(rect.origin.x, rect.origin.y + rect.size.height);
|
||||
let bl_inner = bl_outer + vec2(border_item.widths.left, -border_item.widths.bottom);
|
||||
|
||||
let br_outer = LayerPoint::new(
|
||||
let br_outer = LayoutPoint::new(
|
||||
rect.origin.x + rect.size.width,
|
||||
rect.origin.y + rect.size.height,
|
||||
);
|
||||
|
@ -1627,36 +1618,36 @@ impl<'a> DisplayListFlattener<'a> {
|
|||
// Build the list of gradient segments
|
||||
vec![
|
||||
// Top left
|
||||
LayerRect::from_floats(tl_outer.x, tl_outer.y, tl_inner.x, tl_inner.y),
|
||||
LayoutRect::from_floats(tl_outer.x, tl_outer.y, tl_inner.x, tl_inner.y),
|
||||
// Top right
|
||||
LayerRect::from_floats(tr_inner.x, tr_outer.y, tr_outer.x, tr_inner.y),
|
||||
LayoutRect::from_floats(tr_inner.x, tr_outer.y, tr_outer.x, tr_inner.y),
|
||||
// Bottom right
|
||||
LayerRect::from_floats(br_inner.x, br_inner.y, br_outer.x, br_outer.y),
|
||||
LayoutRect::from_floats(br_inner.x, br_inner.y, br_outer.x, br_outer.y),
|
||||
// Bottom left
|
||||
LayerRect::from_floats(bl_outer.x, bl_inner.y, bl_inner.x, bl_outer.y),
|
||||
LayoutRect::from_floats(bl_outer.x, bl_inner.y, bl_inner.x, bl_outer.y),
|
||||
// Top
|
||||
LayerRect::from_floats(tl_inner.x, tl_outer.y, tr_inner.x, tl_inner.y),
|
||||
LayoutRect::from_floats(tl_inner.x, tl_outer.y, tr_inner.x, tl_inner.y),
|
||||
// Bottom
|
||||
LayerRect::from_floats(bl_inner.x, bl_inner.y, br_inner.x, bl_outer.y),
|
||||
LayoutRect::from_floats(bl_inner.x, bl_inner.y, br_inner.x, bl_outer.y),
|
||||
// Left
|
||||
LayerRect::from_floats(tl_outer.x, tl_inner.y, tl_inner.x, bl_inner.y),
|
||||
LayoutRect::from_floats(tl_outer.x, tl_inner.y, tl_inner.x, bl_inner.y),
|
||||
// Right
|
||||
LayerRect::from_floats(tr_inner.x, tr_inner.y, br_outer.x, br_inner.y),
|
||||
LayoutRect::from_floats(tr_inner.x, tr_inner.y, br_outer.x, br_inner.y),
|
||||
]
|
||||
};
|
||||
|
||||
match border_item.details {
|
||||
BorderDetails::Image(ref border) => {
|
||||
// Calculate the modified rect as specific by border-image-outset
|
||||
let origin = LayerPoint::new(
|
||||
let origin = LayoutPoint::new(
|
||||
rect.origin.x - border.outset.left,
|
||||
rect.origin.y - border.outset.top,
|
||||
);
|
||||
let size = LayerSize::new(
|
||||
let size = LayoutSize::new(
|
||||
rect.size.width + border.outset.left + border.outset.right,
|
||||
rect.size.height + border.outset.top + border.outset.bottom,
|
||||
);
|
||||
let rect = LayerRect::new(origin, size);
|
||||
let rect = LayoutRect::new(origin, size);
|
||||
|
||||
// Calculate the local texel coords of the slices.
|
||||
let px0 = 0.0;
|
||||
|
@ -1669,16 +1660,16 @@ impl<'a> DisplayListFlattener<'a> {
|
|||
let py2 = border.patch.height as f32 - border.patch.slice.bottom as f32;
|
||||
let py3 = border.patch.height as f32;
|
||||
|
||||
let tl_outer = LayerPoint::new(rect.origin.x, rect.origin.y);
|
||||
let tl_outer = LayoutPoint::new(rect.origin.x, rect.origin.y);
|
||||
let tl_inner = tl_outer + vec2(border_item.widths.left, border_item.widths.top);
|
||||
|
||||
let tr_outer = LayerPoint::new(rect.origin.x + rect.size.width, rect.origin.y);
|
||||
let tr_outer = LayoutPoint::new(rect.origin.x + rect.size.width, rect.origin.y);
|
||||
let tr_inner = tr_outer + vec2(-border_item.widths.right, border_item.widths.top);
|
||||
|
||||
let bl_outer = LayerPoint::new(rect.origin.x, rect.origin.y + rect.size.height);
|
||||
let bl_outer = LayoutPoint::new(rect.origin.x, rect.origin.y + rect.size.height);
|
||||
let bl_inner = bl_outer + vec2(border_item.widths.left, -border_item.widths.bottom);
|
||||
|
||||
let br_outer = LayerPoint::new(
|
||||
let br_outer = LayoutPoint::new(
|
||||
rect.origin.x + rect.size.width,
|
||||
rect.origin.y + rect.size.height,
|
||||
);
|
||||
|
@ -1686,7 +1677,7 @@ impl<'a> DisplayListFlattener<'a> {
|
|||
|
||||
fn add_segment(
|
||||
segments: &mut Vec<ImageBorderSegment>,
|
||||
rect: LayerRect,
|
||||
rect: LayoutRect,
|
||||
uv_rect: TexelRect,
|
||||
repeat_horizontal: RepeatMode,
|
||||
repeat_vertical: RepeatMode) {
|
||||
|
@ -1707,7 +1698,7 @@ impl<'a> DisplayListFlattener<'a> {
|
|||
// Top left
|
||||
add_segment(
|
||||
&mut segments,
|
||||
LayerRect::from_floats(tl_outer.x, tl_outer.y, tl_inner.x, tl_inner.y),
|
||||
LayoutRect::from_floats(tl_outer.x, tl_outer.y, tl_inner.x, tl_inner.y),
|
||||
TexelRect::new(px0, py0, px1, py1),
|
||||
RepeatMode::Stretch,
|
||||
RepeatMode::Stretch
|
||||
|
@ -1715,7 +1706,7 @@ impl<'a> DisplayListFlattener<'a> {
|
|||
// Top right
|
||||
add_segment(
|
||||
&mut segments,
|
||||
LayerRect::from_floats(tr_inner.x, tr_outer.y, tr_outer.x, tr_inner.y),
|
||||
LayoutRect::from_floats(tr_inner.x, tr_outer.y, tr_outer.x, tr_inner.y),
|
||||
TexelRect::new(px2, py0, px3, py1),
|
||||
RepeatMode::Stretch,
|
||||
RepeatMode::Stretch
|
||||
|
@ -1723,7 +1714,7 @@ impl<'a> DisplayListFlattener<'a> {
|
|||
// Bottom right
|
||||
add_segment(
|
||||
&mut segments,
|
||||
LayerRect::from_floats(br_inner.x, br_inner.y, br_outer.x, br_outer.y),
|
||||
LayoutRect::from_floats(br_inner.x, br_inner.y, br_outer.x, br_outer.y),
|
||||
TexelRect::new(px2, py2, px3, py3),
|
||||
RepeatMode::Stretch,
|
||||
RepeatMode::Stretch
|
||||
|
@ -1731,7 +1722,7 @@ impl<'a> DisplayListFlattener<'a> {
|
|||
// Bottom left
|
||||
add_segment(
|
||||
&mut segments,
|
||||
LayerRect::from_floats(bl_outer.x, bl_inner.y, bl_inner.x, bl_outer.y),
|
||||
LayoutRect::from_floats(bl_outer.x, bl_inner.y, bl_inner.x, bl_outer.y),
|
||||
TexelRect::new(px0, py2, px1, py3),
|
||||
RepeatMode::Stretch,
|
||||
RepeatMode::Stretch
|
||||
|
@ -1741,7 +1732,7 @@ impl<'a> DisplayListFlattener<'a> {
|
|||
if border.fill {
|
||||
add_segment(
|
||||
&mut segments,
|
||||
LayerRect::from_floats(tl_inner.x, tl_inner.y, tr_inner.x, bl_inner.y),
|
||||
LayoutRect::from_floats(tl_inner.x, tl_inner.y, tr_inner.x, bl_inner.y),
|
||||
TexelRect::new(px1, py1, px2, py2),
|
||||
border.repeat_horizontal,
|
||||
border.repeat_vertical
|
||||
|
@ -1753,7 +1744,7 @@ impl<'a> DisplayListFlattener<'a> {
|
|||
// Top
|
||||
add_segment(
|
||||
&mut segments,
|
||||
LayerRect::from_floats(tl_inner.x, tl_outer.y, tr_inner.x, tl_inner.y),
|
||||
LayoutRect::from_floats(tl_inner.x, tl_outer.y, tr_inner.x, tl_inner.y),
|
||||
TexelRect::new(px1, py0, px2, py1),
|
||||
border.repeat_horizontal,
|
||||
RepeatMode::Stretch,
|
||||
|
@ -1761,7 +1752,7 @@ impl<'a> DisplayListFlattener<'a> {
|
|||
// Bottom
|
||||
add_segment(
|
||||
&mut segments,
|
||||
LayerRect::from_floats(bl_inner.x, bl_inner.y, br_inner.x, bl_outer.y),
|
||||
LayoutRect::from_floats(bl_inner.x, bl_inner.y, br_inner.x, bl_outer.y),
|
||||
TexelRect::new(px1, py2, px2, py3),
|
||||
border.repeat_horizontal,
|
||||
RepeatMode::Stretch,
|
||||
|
@ -1769,7 +1760,7 @@ impl<'a> DisplayListFlattener<'a> {
|
|||
// Left
|
||||
add_segment(
|
||||
&mut segments,
|
||||
LayerRect::from_floats(tl_outer.x, tl_inner.y, tl_inner.x, bl_inner.y),
|
||||
LayoutRect::from_floats(tl_outer.x, tl_inner.y, tl_inner.x, bl_inner.y),
|
||||
TexelRect::new(px0, py1, px1, py2),
|
||||
RepeatMode::Stretch,
|
||||
border.repeat_vertical,
|
||||
|
@ -1777,7 +1768,7 @@ impl<'a> DisplayListFlattener<'a> {
|
|||
// Right
|
||||
add_segment(
|
||||
&mut segments,
|
||||
LayerRect::from_floats(tr_inner.x, tr_inner.y, br_outer.x, br_inner.y),
|
||||
LayoutRect::from_floats(tr_inner.x, tr_inner.y, br_outer.x, br_inner.y),
|
||||
TexelRect::new(px2, py1, px3, py2),
|
||||
RepeatMode::Stretch,
|
||||
border.repeat_vertical,
|
||||
|
@ -1816,7 +1807,7 @@ impl<'a> DisplayListFlattener<'a> {
|
|||
gradient_stops_count,
|
||||
border.gradient.extend_mode,
|
||||
segment.size,
|
||||
LayerSize::zero(),
|
||||
LayoutSize::zero(),
|
||||
);
|
||||
},
|
||||
BorderDetails::RadialGradient(ref border) => {
|
||||
|
@ -1835,7 +1826,7 @@ impl<'a> DisplayListFlattener<'a> {
|
|||
gradient_stops,
|
||||
border.gradient.extend_mode,
|
||||
segment.size,
|
||||
LayerSize::zero(),
|
||||
LayoutSize::zero(),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -1845,9 +1836,9 @@ impl<'a> DisplayListFlattener<'a> {
|
|||
fn add_gradient_impl(
|
||||
&mut self,
|
||||
clip_and_scroll: ScrollNodeAndClipChain,
|
||||
info: &LayerPrimitiveInfo,
|
||||
start_point: LayerPoint,
|
||||
end_point: LayerPoint,
|
||||
info: &LayoutPrimitiveInfo,
|
||||
start_point: LayoutPoint,
|
||||
end_point: LayoutPoint,
|
||||
stops: ItemRange<GradientStop>,
|
||||
stops_count: usize,
|
||||
extend_mode: ExtendMode,
|
||||
|
@ -1892,14 +1883,14 @@ impl<'a> DisplayListFlattener<'a> {
|
|||
pub fn add_gradient(
|
||||
&mut self,
|
||||
clip_and_scroll: ScrollNodeAndClipChain,
|
||||
info: &LayerPrimitiveInfo,
|
||||
start_point: LayerPoint,
|
||||
end_point: LayerPoint,
|
||||
info: &LayoutPrimitiveInfo,
|
||||
start_point: LayoutPoint,
|
||||
end_point: LayoutPoint,
|
||||
stops: ItemRange<GradientStop>,
|
||||
stops_count: usize,
|
||||
extend_mode: ExtendMode,
|
||||
tile_size: LayerSize,
|
||||
tile_spacing: LayerSize,
|
||||
tile_size: LayoutSize,
|
||||
tile_spacing: LayoutSize,
|
||||
) {
|
||||
let gradient_index = CachedGradientIndex(self.cached_gradients.len());
|
||||
self.cached_gradients.push(CachedGradient::new());
|
||||
|
@ -1940,8 +1931,8 @@ impl<'a> DisplayListFlattener<'a> {
|
|||
fn add_radial_gradient_impl(
|
||||
&mut self,
|
||||
clip_and_scroll: ScrollNodeAndClipChain,
|
||||
info: &LayerPrimitiveInfo,
|
||||
center: LayerPoint,
|
||||
info: &LayoutPrimitiveInfo,
|
||||
center: LayoutPoint,
|
||||
start_radius: f32,
|
||||
end_radius: f32,
|
||||
ratio_xy: f32,
|
||||
|
@ -1973,15 +1964,15 @@ impl<'a> DisplayListFlattener<'a> {
|
|||
pub fn add_radial_gradient(
|
||||
&mut self,
|
||||
clip_and_scroll: ScrollNodeAndClipChain,
|
||||
info: &LayerPrimitiveInfo,
|
||||
center: LayerPoint,
|
||||
info: &LayoutPrimitiveInfo,
|
||||
center: LayoutPoint,
|
||||
start_radius: f32,
|
||||
end_radius: f32,
|
||||
ratio_xy: f32,
|
||||
stops: ItemRange<GradientStop>,
|
||||
extend_mode: ExtendMode,
|
||||
tile_size: LayerSize,
|
||||
tile_spacing: LayerSize,
|
||||
tile_size: LayoutSize,
|
||||
tile_spacing: LayoutSize,
|
||||
) {
|
||||
let gradient_index = CachedGradientIndex(self.cached_gradients.len());
|
||||
self.cached_gradients.push(CachedGradient::new());
|
||||
|
@ -2025,7 +2016,7 @@ impl<'a> DisplayListFlattener<'a> {
|
|||
&mut self,
|
||||
clip_and_scroll: ScrollNodeAndClipChain,
|
||||
run_offset: LayoutVector2D,
|
||||
prim_info: &LayerPrimitiveInfo,
|
||||
prim_info: &LayoutPrimitiveInfo,
|
||||
font_instance_key: &FontInstanceKey,
|
||||
text_color: &ColorF,
|
||||
glyph_range: ItemRange<GlyphInstance>,
|
||||
|
@ -2069,26 +2060,11 @@ impl<'a> DisplayListFlattener<'a> {
|
|||
flags |= options.flags;
|
||||
}
|
||||
|
||||
let (allow_subpixel_aa, glyph_raster_space) = match self.sc_stack.last() {
|
||||
Some(stacking_context) => {
|
||||
(stacking_context.allow_subpixel_aa, stacking_context.glyph_raster_space)
|
||||
}
|
||||
None => {
|
||||
(true, GlyphRasterSpace::Screen)
|
||||
}
|
||||
let glyph_raster_space = match self.sc_stack.last() {
|
||||
Some(stacking_context) => stacking_context.glyph_raster_space,
|
||||
None => GlyphRasterSpace::Screen,
|
||||
};
|
||||
|
||||
// There are some conditions under which we can't use
|
||||
// subpixel text rendering, even if enabled.
|
||||
if !allow_subpixel_aa {
|
||||
// text on a picture that has filters
|
||||
// (e.g. opacity) can't use sub-pixel.
|
||||
// TODO(gw): It's possible we can relax this in
|
||||
// the future, if we modify the way
|
||||
// we handle subpixel blending.
|
||||
render_mode = render_mode.limit_by(FontRenderMode::Alpha);
|
||||
}
|
||||
|
||||
let prim_font = FontInstance::new(
|
||||
font_instance.font_key,
|
||||
font_instance.size,
|
||||
|
@ -2122,9 +2098,9 @@ impl<'a> DisplayListFlattener<'a> {
|
|||
pub fn add_image(
|
||||
&mut self,
|
||||
clip_and_scroll: ScrollNodeAndClipChain,
|
||||
info: &LayerPrimitiveInfo,
|
||||
stretch_size: LayerSize,
|
||||
mut tile_spacing: LayerSize,
|
||||
info: &LayoutPrimitiveInfo,
|
||||
stretch_size: LayoutSize,
|
||||
mut tile_spacing: LayoutSize,
|
||||
sub_rect: Option<TexelRect>,
|
||||
image_key: ImageKey,
|
||||
image_rendering: ImageRendering,
|
||||
|
@ -2136,7 +2112,7 @@ impl<'a> DisplayListFlattener<'a> {
|
|||
// in prim_store to detect if an image can be considered
|
||||
// opaque.
|
||||
if tile_spacing == info.rect.size {
|
||||
tile_spacing = LayerSize::zero();
|
||||
tile_spacing = LayoutSize::zero();
|
||||
}
|
||||
|
||||
let request = ImageRequest {
|
||||
|
@ -2160,7 +2136,7 @@ impl<'a> DisplayListFlattener<'a> {
|
|||
|
||||
// See if conditions are met to run through the new
|
||||
// image brush shader, which supports segments.
|
||||
if tile_spacing == LayerSize::zero() &&
|
||||
if tile_spacing == LayoutSize::zero() &&
|
||||
stretch_size == info.rect.size &&
|
||||
tile_offset.is_none() {
|
||||
let prim = BrushPrimitive::new(
|
||||
|
@ -2172,6 +2148,7 @@ impl<'a> DisplayListFlattener<'a> {
|
|||
tile_spacing,
|
||||
source: ImageSource::Default,
|
||||
sub_rect,
|
||||
opacity_binding: OpacityBinding::new(),
|
||||
},
|
||||
None,
|
||||
);
|
||||
|
@ -2207,7 +2184,7 @@ impl<'a> DisplayListFlattener<'a> {
|
|||
pub fn add_yuv_image(
|
||||
&mut self,
|
||||
clip_and_scroll: ScrollNodeAndClipChain,
|
||||
info: &LayerPrimitiveInfo,
|
||||
info: &LayoutPrimitiveInfo,
|
||||
yuv_data: YuvData,
|
||||
color_space: YuvColorSpace,
|
||||
image_rendering: ImageRendering,
|
||||
|
@ -2266,19 +2243,19 @@ pub fn build_scene(config: &FrameBuilderConfig, request: SceneRequest) -> BuiltS
|
|||
trait PrimitiveInfoTiler {
|
||||
fn decompose(
|
||||
&self,
|
||||
tile_size: LayerSize,
|
||||
tile_spacing: LayerSize,
|
||||
tile_size: LayoutSize,
|
||||
tile_spacing: LayoutSize,
|
||||
max_prims: usize,
|
||||
) -> Vec<LayerPrimitiveInfo>;
|
||||
) -> Vec<LayoutPrimitiveInfo>;
|
||||
}
|
||||
|
||||
impl PrimitiveInfoTiler for LayerPrimitiveInfo {
|
||||
impl PrimitiveInfoTiler for LayoutPrimitiveInfo {
|
||||
fn decompose(
|
||||
&self,
|
||||
tile_size: LayerSize,
|
||||
tile_spacing: LayerSize,
|
||||
tile_size: LayoutSize,
|
||||
tile_spacing: LayoutSize,
|
||||
max_prims: usize,
|
||||
) -> Vec<LayerPrimitiveInfo> {
|
||||
) -> Vec<LayoutPrimitiveInfo> {
|
||||
let mut prims = Vec::new();
|
||||
let tile_repeat = tile_size + tile_spacing;
|
||||
|
||||
|
@ -2300,9 +2277,9 @@ impl PrimitiveInfoTiler for LayerPrimitiveInfo {
|
|||
let mut x0 = rect_p0.x;
|
||||
|
||||
while x0 < rect_p1.x {
|
||||
prims.push(LayerPrimitiveInfo {
|
||||
rect: LayerRect::new(
|
||||
LayerPoint::new(x0, y0),
|
||||
prims.push(LayoutPrimitiveInfo {
|
||||
rect: LayoutRect::new(
|
||||
LayoutPoint::new(x0, y0),
|
||||
tile_size,
|
||||
),
|
||||
clip_rect,
|
||||
|
@ -2342,11 +2319,6 @@ struct FlattenedStackingContext {
|
|||
/// If true, visible when backface is visible.
|
||||
is_backface_visible: bool,
|
||||
|
||||
/// Allow subpixel AA for text runs on this stacking context.
|
||||
/// This is a temporary hack while we don't support subpixel AA
|
||||
/// on transparent stacking contexts.
|
||||
allow_subpixel_aa: bool,
|
||||
|
||||
/// The rasterization mode for any text runs that are part
|
||||
/// of this stacking context.
|
||||
glyph_raster_space: GlyphRasterSpace,
|
||||
|
@ -2361,4 +2333,4 @@ struct FlattenedStackingContext {
|
|||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct ScrollbarInfo(pub ClipScrollNodeIndex, pub LayerRect);
|
||||
pub struct ScrollbarInfo(pub ClipScrollNodeIndex, pub LayoutRect);
|
||||
|
|
|
@ -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::{LayerPoint, LayerSize, LayerVector2D};
|
||||
use api::{LayoutPoint, LayoutSize, LayoutVector2D};
|
||||
use std::f32::consts::FRAC_PI_2;
|
||||
|
||||
/// Number of steps to integrate arc length over.
|
||||
|
@ -11,12 +11,12 @@ const STEP_COUNT: usize = 20;
|
|||
/// Represents an ellipse centred at a local space origin.
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct Ellipse {
|
||||
pub radius: LayerSize,
|
||||
pub radius: LayoutSize,
|
||||
pub total_arc_length: f32,
|
||||
}
|
||||
|
||||
impl Ellipse {
|
||||
pub fn new(radius: LayerSize) -> Ellipse {
|
||||
pub fn new(radius: LayoutSize) -> Ellipse {
|
||||
// Approximate the total length of the first quadrant of this ellipse.
|
||||
let total_arc_length = get_simpson_length(FRAC_PI_2, radius.width, radius.height);
|
||||
|
||||
|
@ -56,32 +56,32 @@ impl Ellipse {
|
|||
|
||||
/// Get a point and tangent on this ellipse from a given angle.
|
||||
/// This only works for the first quadrant of the ellipse.
|
||||
pub fn get_point_and_tangent(&self, theta: f32) -> (LayerPoint, LayerPoint) {
|
||||
pub fn get_point_and_tangent(&self, theta: f32) -> (LayoutPoint, LayoutPoint) {
|
||||
let (sin_theta, cos_theta) = theta.sin_cos();
|
||||
let point = LayerPoint::new(
|
||||
let point = LayoutPoint::new(
|
||||
self.radius.width * cos_theta,
|
||||
self.radius.height * sin_theta,
|
||||
);
|
||||
let tangent = LayerPoint::new(
|
||||
let tangent = LayoutPoint::new(
|
||||
-self.radius.width * sin_theta,
|
||||
self.radius.height * cos_theta,
|
||||
);
|
||||
(point, tangent)
|
||||
}
|
||||
|
||||
pub fn contains(&self, point: LayerPoint) -> bool {
|
||||
pub fn contains(&self, point: LayoutPoint) -> bool {
|
||||
self.signed_distance(point.to_vector()) <= 0.0
|
||||
}
|
||||
|
||||
/// Find the signed distance from this ellipse given a point.
|
||||
/// Taken from http://www.iquilezles.org/www/articles/ellipsedist/ellipsedist.htm
|
||||
fn signed_distance(&self, point: LayerVector2D) -> f32 {
|
||||
fn signed_distance(&self, point: LayoutVector2D) -> f32 {
|
||||
// This algorithm fails for circles, so we handle them here.
|
||||
if self.radius.width == self.radius.height {
|
||||
return point.length() - self.radius.width;
|
||||
}
|
||||
|
||||
let mut p = LayerVector2D::new(point.x.abs(), point.y.abs());
|
||||
let mut p = LayoutVector2D::new(point.x.abs(), point.y.abs());
|
||||
let mut ab = self.radius.to_vector();
|
||||
if p.x > p.y {
|
||||
p = p.yx();
|
||||
|
@ -121,7 +121,7 @@ impl Ellipse {
|
|||
};
|
||||
|
||||
let si = (1.0 - co * co).sqrt();
|
||||
let r = LayerVector2D::new(ab.x * co, ab.y * si);
|
||||
let r = LayoutVector2D::new(ab.x * co, ab.y * si);
|
||||
(r - p).length() * (p.y - r.y).signum()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
|
||||
use api::{BuiltDisplayList, ColorF, DeviceIntPoint, DeviceIntRect, DevicePixelScale};
|
||||
use api::{DeviceUintPoint, DeviceUintRect, DeviceUintSize, DocumentLayer, FontRenderMode};
|
||||
use api::{LayerRect, LayerSize, PipelineId, WorldPoint};
|
||||
use api::{LayoutRect, LayoutSize, PipelineId, WorldPoint};
|
||||
use clip::{ClipChain, ClipStore};
|
||||
use clip_scroll_node::{ClipScrollNode};
|
||||
use clip_scroll_tree::{ClipScrollNodeIndex, ClipScrollTree};
|
||||
|
@ -24,7 +24,7 @@ use std::{mem, f32};
|
|||
use std::sync::Arc;
|
||||
use tiling::{Frame, RenderPass, RenderPassKind, RenderTargetContext};
|
||||
use tiling::{ScrollbarPrimitive, SpecialRenderPasses};
|
||||
use util::{self, MaxRect, WorldToLayerFastTransform};
|
||||
use util::{self, MaxRect, WorldToLayoutFastTransform};
|
||||
|
||||
#[derive(Clone, Copy)]
|
||||
#[cfg_attr(feature = "capture", derive(Serialize))]
|
||||
|
@ -62,7 +62,7 @@ pub struct FrameBuildingState<'a> {
|
|||
pub render_tasks: &'a mut RenderTaskTree,
|
||||
pub profile_counters: &'a mut FrameProfileCounters,
|
||||
pub clip_store: &'a mut ClipStore,
|
||||
pub local_clip_rects: &'a mut Vec<LayerRect>,
|
||||
pub local_clip_rects: &'a mut Vec<LayoutRect>,
|
||||
pub resource_cache: &'a mut ResourceCache,
|
||||
pub gpu_cache: &'a mut GpuCache,
|
||||
pub cached_gradients: &'a mut [CachedGradient],
|
||||
|
@ -74,9 +74,10 @@ pub struct PictureContext<'a> {
|
|||
pub prim_runs: Vec<PrimitiveRun>,
|
||||
pub original_reference_frame_index: Option<ClipScrollNodeIndex>,
|
||||
pub display_list: &'a BuiltDisplayList,
|
||||
pub inv_world_transform: Option<WorldToLayerFastTransform>,
|
||||
pub inv_world_transform: Option<WorldToLayoutFastTransform>,
|
||||
pub apply_local_clip_rect: bool,
|
||||
pub inflation_factor: f32,
|
||||
pub allow_subpixel_aa: bool,
|
||||
}
|
||||
|
||||
pub struct PictureState {
|
||||
|
@ -165,7 +166,7 @@ impl FrameBuilder {
|
|||
profile_counters: &mut FrameProfileCounters,
|
||||
device_pixel_scale: DevicePixelScale,
|
||||
scene_properties: &SceneProperties,
|
||||
local_clip_rects: &mut Vec<LayerRect>,
|
||||
local_clip_rects: &mut Vec<LayoutRect>,
|
||||
node_data: &[ClipScrollNodeData],
|
||||
) -> Option<RenderTaskId> {
|
||||
profile_scope!("cull");
|
||||
|
@ -211,6 +212,7 @@ impl FrameBuilder {
|
|||
inv_world_transform: None,
|
||||
apply_local_clip_rect: true,
|
||||
inflation_factor: 0.0,
|
||||
allow_subpixel_aa: true,
|
||||
};
|
||||
|
||||
let mut pic_state = PictureState::new();
|
||||
|
@ -250,7 +252,7 @@ impl FrameBuilder {
|
|||
|
||||
let scrollable_distance = scroll_frame.scrollable_size().height;
|
||||
if scrollable_distance <= 0.0 {
|
||||
metadata.local_clip_rect.size = LayerSize::zero();
|
||||
metadata.local_clip_rect.size = LayoutSize::zero();
|
||||
continue;
|
||||
}
|
||||
let amount_scrolled = -scroll_frame.scroll_offset().y / scrollable_distance;
|
||||
|
@ -299,7 +301,7 @@ impl FrameBuilder {
|
|||
let total_prim_runs =
|
||||
self.prim_store.pictures.iter().fold(1, |count, pic| count + pic.runs.len());
|
||||
let mut clip_chain_local_clip_rects = Vec::with_capacity(total_prim_runs);
|
||||
clip_chain_local_clip_rects.push(LayerRect::max_rect());
|
||||
clip_chain_local_clip_rects.push(LayoutRect::max_rect());
|
||||
|
||||
clip_scroll_tree.update_tree(
|
||||
&self.screen_rect.to_i32(),
|
||||
|
|
|
@ -7,7 +7,7 @@ use api::{IdNamespace, LayoutPoint};
|
|||
use api::{ColorF, ColorU};
|
||||
use api::{FontInstanceFlags, FontInstancePlatformOptions};
|
||||
use api::{FontKey, FontRenderMode, FontTemplate, FontVariation};
|
||||
use api::{GlyphDimensions, GlyphKey, LayerToWorldTransform, SubpixelDirection};
|
||||
use api::{GlyphDimensions, GlyphKey, LayoutToWorldTransform, SubpixelDirection};
|
||||
#[cfg(feature = "pathfinder")]
|
||||
use api::NativeFontHandle;
|
||||
#[cfg(any(test, feature = "pathfinder"))]
|
||||
|
@ -37,9 +37,9 @@ use rayon::prelude::*;
|
|||
use render_backend::FrameId;
|
||||
use render_task::{RenderTaskCache, RenderTaskTree};
|
||||
#[cfg(feature = "pathfinder")]
|
||||
use render_task::{RenderTask, RenderTaskCacheKey, RenderTaskCacheKeyKind};
|
||||
use render_task::{RenderTask, RenderTaskCacheKey, RenderTaskCacheEntryHandle};
|
||||
#[cfg(feature = "pathfinder")]
|
||||
use render_task::{RenderTaskId, RenderTaskLocation};
|
||||
use render_task::{RenderTaskCacheKeyKind, RenderTaskId, RenderTaskLocation};
|
||||
#[cfg(feature = "pathfinder")]
|
||||
use resource_cache::CacheItem;
|
||||
use std::cmp;
|
||||
|
@ -184,8 +184,8 @@ impl FontTransform {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'a> From<&'a LayerToWorldTransform> for FontTransform {
|
||||
fn from(xform: &'a LayerToWorldTransform) -> Self {
|
||||
impl<'a> From<&'a LayoutToWorldTransform> for FontTransform {
|
||||
fn from(xform: &'a LayoutToWorldTransform) -> Self {
|
||||
FontTransform::new(xform.m11, xform.m21, xform.m12, xform.m22)
|
||||
}
|
||||
}
|
||||
|
@ -417,7 +417,7 @@ impl GlyphRasterizer {
|
|||
font_contexts: Arc::new(FontContexts {
|
||||
worker_contexts: contexts,
|
||||
shared_context: Mutex::new(shared_context),
|
||||
pathfinder_context: pathfinder_context,
|
||||
pathfinder_context,
|
||||
workers: Arc::clone(&workers),
|
||||
}),
|
||||
pending_glyphs: 0,
|
||||
|
@ -504,17 +504,19 @@ impl GlyphRasterizer {
|
|||
render_task_cache: &mut RenderTaskCache,
|
||||
render_task_tree: &mut RenderTaskTree,
|
||||
render_passes: &mut SpecialRenderPasses)
|
||||
-> Result<(CacheItem, GlyphFormat), ()> {
|
||||
-> Result<(RenderTaskCacheEntryHandle,
|
||||
GlyphFormat), ()> {
|
||||
let mut pathfinder_font_context = self.font_contexts.lock_pathfinder_context();
|
||||
let render_task_cache_key = cached_glyph_info.render_task_cache_key;
|
||||
let (glyph_origin, glyph_size) = (cached_glyph_info.origin, render_task_cache_key.size);
|
||||
let user_data = [glyph_origin.x as f32, (glyph_origin.y - glyph_size.height) as f32, 1.0];
|
||||
let cache_item = try!(render_task_cache.request_render_task(render_task_cache_key,
|
||||
texture_cache,
|
||||
gpu_cache,
|
||||
render_task_tree,
|
||||
Some(user_data),
|
||||
|render_tasks| {
|
||||
let handle = try!(render_task_cache.request_render_task(render_task_cache_key,
|
||||
texture_cache,
|
||||
gpu_cache,
|
||||
render_task_tree,
|
||||
Some(user_data),
|
||||
false,
|
||||
|render_tasks| {
|
||||
// TODO(pcwalton): Non-subpixel font render mode.
|
||||
request_render_task_from_pathfinder(glyph_key,
|
||||
font,
|
||||
|
@ -525,7 +527,7 @@ impl GlyphRasterizer {
|
|||
render_tasks,
|
||||
render_passes)
|
||||
}));
|
||||
Ok((cache_item, font.get_glyph_format()))
|
||||
Ok((handle, font.get_glyph_format()))
|
||||
}
|
||||
|
||||
#[cfg(feature = "pathfinder")]
|
||||
|
@ -597,7 +599,7 @@ impl GlyphRasterizer {
|
|||
}
|
||||
};
|
||||
|
||||
let cache_entry =
|
||||
let handle =
|
||||
match self.request_glyph_from_pathfinder_if_necessary(glyph_key,
|
||||
&font,
|
||||
cached_glyph_info.clone(),
|
||||
|
@ -610,7 +612,7 @@ impl GlyphRasterizer {
|
|||
Err(_) => GlyphCacheEntry::Blank,
|
||||
};
|
||||
|
||||
glyph_key_cache.insert(glyph_key.clone(), cache_entry);
|
||||
glyph_key_cache.insert(glyph_key.clone(), handle);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1026,7 +1028,7 @@ fn request_render_task_from_pathfinder(glyph_key: &GlyphKey,
|
|||
render_mode: FontRenderMode,
|
||||
render_tasks: &mut RenderTaskTree,
|
||||
render_passes: &mut SpecialRenderPasses)
|
||||
-> Result<(RenderTaskId, bool), ()> {
|
||||
-> Result<RenderTaskId, ()> {
|
||||
let pathfinder_font_instance = pathfinder_font_renderer::FontInstance {
|
||||
font_key: font.font_key.clone(),
|
||||
size: font.size,
|
||||
|
@ -1053,7 +1055,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(font.size.to_f32_px());
|
||||
|
||||
let location = RenderTaskLocation::Dynamic(None, *glyph_size);
|
||||
let location = RenderTaskLocation::Dynamic(None, Some(*glyph_size));
|
||||
let glyph_render_task = RenderTask::new_glyph(location,
|
||||
mesh,
|
||||
&glyph_origin,
|
||||
|
@ -1068,7 +1070,7 @@ fn request_render_task_from_pathfinder(glyph_key: &GlyphKey,
|
|||
};
|
||||
render_pass.add_render_task(root_task_id, *glyph_size, RenderTargetKind::Color);
|
||||
|
||||
Ok((root_task_id, false))
|
||||
Ok(root_task_id)
|
||||
}
|
||||
|
||||
#[cfg(feature = "pathfinder")]
|
||||
|
|
|
@ -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::{DevicePoint, LayerToWorldTransform, WorldToLayerTransform};
|
||||
use api::{DevicePoint, LayoutToWorldTransform, WorldToLayoutTransform};
|
||||
use gpu_cache::{GpuCacheAddress, GpuDataRequest};
|
||||
use prim_store::EdgeAaSegmentMask;
|
||||
use render_task::RenderTaskAddress;
|
||||
|
@ -83,6 +83,16 @@ pub struct ClipMaskInstance {
|
|||
pub resource_address: GpuCacheAddress,
|
||||
}
|
||||
|
||||
/// A border corner dot or dash drawn into the clipping mask.
|
||||
#[derive(Debug, Copy, Clone)]
|
||||
#[cfg_attr(feature = "capture", derive(Serialize))]
|
||||
#[cfg_attr(feature = "replay", derive(Deserialize))]
|
||||
#[repr(C)]
|
||||
pub struct ClipMaskBorderCornerDotDash {
|
||||
pub clip_mask_instance: ClipMaskInstance,
|
||||
pub dot_dash_data: [f32; 8],
|
||||
}
|
||||
|
||||
// 32 bytes per instance should be enough for anyone!
|
||||
#[derive(Debug, Clone)]
|
||||
#[cfg_attr(feature = "capture", derive(Serialize))]
|
||||
|
@ -246,8 +256,8 @@ pub struct ClipScrollNodeIndex(pub u32);
|
|||
#[cfg_attr(feature = "replay", derive(Deserialize))]
|
||||
#[repr(C)]
|
||||
pub struct ClipScrollNodeData {
|
||||
pub transform: LayerToWorldTransform,
|
||||
pub inv_transform: WorldToLayerTransform,
|
||||
pub transform: LayoutToWorldTransform,
|
||||
pub inv_transform: WorldToLayoutTransform,
|
||||
pub transform_kind: f32,
|
||||
pub padding: [f32; 3],
|
||||
}
|
||||
|
@ -255,8 +265,8 @@ pub struct ClipScrollNodeData {
|
|||
impl ClipScrollNodeData {
|
||||
pub fn invalid() -> Self {
|
||||
ClipScrollNodeData {
|
||||
transform: LayerToWorldTransform::identity(),
|
||||
inv_transform: WorldToLayerTransform::identity(),
|
||||
transform: LayoutToWorldTransform::identity(),
|
||||
inv_transform: WorldToLayoutTransform::identity(),
|
||||
transform_kind: 0.0,
|
||||
padding: [0.0; 3],
|
||||
}
|
||||
|
|
|
@ -2,14 +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 api::{BorderRadius, ClipMode, HitTestFlags, HitTestItem, HitTestResult, ItemTag, LayerPoint};
|
||||
use api::{LayerPrimitiveInfo, LayerRect, PipelineId, WorldPoint};
|
||||
use api::{BorderRadius, ClipMode, HitTestFlags, HitTestItem, HitTestResult, ItemTag, LayoutPoint};
|
||||
use api::{LayoutPrimitiveInfo, LayoutRect, PipelineId, WorldPoint};
|
||||
use clip::{ClipSource, ClipStore, rounded_rectangle_contains_point};
|
||||
use clip_scroll_node::{ClipScrollNode, NodeType};
|
||||
use clip_scroll_tree::{ClipChainIndex, ClipScrollNodeIndex, ClipScrollTree};
|
||||
use internal_types::FastHashMap;
|
||||
use prim_store::ScrollNodeAndClipChain;
|
||||
use util::LayerToWorldFastTransform;
|
||||
use util::LayoutToWorldFastTransform;
|
||||
|
||||
/// A copy of important clip scroll node data to use during hit testing. This a copy of
|
||||
/// data from the ClipScrollTree that will persist as a new frame is under construction,
|
||||
|
@ -23,13 +23,13 @@ pub struct HitTestClipScrollNode {
|
|||
regions: Vec<HitTestRegion>,
|
||||
|
||||
/// World transform for content transformed by this node.
|
||||
world_content_transform: LayerToWorldFastTransform,
|
||||
world_content_transform: LayoutToWorldFastTransform,
|
||||
|
||||
/// World viewport transform for content transformed by this node.
|
||||
world_viewport_transform: LayerToWorldFastTransform,
|
||||
world_viewport_transform: LayoutToWorldFastTransform,
|
||||
|
||||
/// Origin of the viewport of the node, used to calculate node-relative positions.
|
||||
node_origin: LayerPoint,
|
||||
node_origin: LayoutPoint,
|
||||
}
|
||||
|
||||
/// A description of a clip chain in the HitTester. This is used to describe
|
||||
|
@ -54,18 +54,18 @@ impl HitTestClipChainDescriptor {
|
|||
|
||||
#[derive(Clone)]
|
||||
pub struct HitTestingItem {
|
||||
rect: LayerRect,
|
||||
clip_rect: LayerRect,
|
||||
rect: LayoutRect,
|
||||
clip_rect: LayoutRect,
|
||||
tag: ItemTag,
|
||||
is_backface_visible: bool,
|
||||
}
|
||||
|
||||
impl HitTestingItem {
|
||||
pub fn new(tag: ItemTag, info: &LayerPrimitiveInfo) -> HitTestingItem {
|
||||
pub fn new(tag: ItemTag, info: &LayoutPrimitiveInfo) -> HitTestingItem {
|
||||
HitTestingItem {
|
||||
rect: info.rect,
|
||||
clip_rect: info.clip_rect,
|
||||
tag: tag,
|
||||
tag,
|
||||
is_backface_visible: info.is_backface_visible,
|
||||
}
|
||||
}
|
||||
|
@ -75,12 +75,12 @@ impl HitTestingItem {
|
|||
pub struct HitTestingRun(pub Vec<HitTestingItem>, pub ScrollNodeAndClipChain);
|
||||
|
||||
enum HitTestRegion {
|
||||
Rectangle(LayerRect, ClipMode),
|
||||
RoundedRectangle(LayerRect, BorderRadius, ClipMode),
|
||||
Rectangle(LayoutRect, ClipMode),
|
||||
RoundedRectangle(LayoutRect, BorderRadius, ClipMode),
|
||||
}
|
||||
|
||||
impl HitTestRegion {
|
||||
pub fn contains(&self, point: &LayerPoint) -> bool {
|
||||
pub fn contains(&self, point: &LayoutPoint) -> bool {
|
||||
match *self {
|
||||
HitTestRegion::Rectangle(ref rectangle, ClipMode::Clip) =>
|
||||
rectangle.contains(point),
|
||||
|
@ -327,7 +327,7 @@ pub struct HitTest {
|
|||
pipeline_id: Option<PipelineId>,
|
||||
point: WorldPoint,
|
||||
flags: HitTestFlags,
|
||||
node_cache: FastHashMap<ClipScrollNodeIndex, Option<LayerPoint>>,
|
||||
node_cache: FastHashMap<ClipScrollNodeIndex, Option<LayoutPoint>>,
|
||||
clip_chain_cache: Vec<Option<bool>>,
|
||||
}
|
||||
|
||||
|
@ -366,7 +366,7 @@ impl HitTest {
|
|||
return self.point;
|
||||
}
|
||||
|
||||
let point = &LayerPoint::new(self.point.x, self.point.y);
|
||||
let point = &LayoutPoint::new(self.point.x, self.point.y);
|
||||
self.pipeline_id.map(|id|
|
||||
hit_tester.get_pipeline_root(id).world_viewport_transform.transform_point2d(point)
|
||||
).unwrap_or_else(|| WorldPoint::new(self.point.x, self.point.y))
|
||||
|
|
|
@ -2,22 +2,22 @@
|
|||
* 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::{TileOffset, LayerRect, LayerSize, LayerVector2D, DeviceUintSize};
|
||||
use api::{TileOffset, LayoutRect, LayoutSize, LayoutVector2D, DeviceUintSize};
|
||||
use euclid::rect;
|
||||
|
||||
pub struct DecomposedTile {
|
||||
pub rect: LayerRect,
|
||||
pub stretch_size: LayerSize,
|
||||
pub rect: LayoutRect,
|
||||
pub stretch_size: LayoutSize,
|
||||
pub tile_offset: TileOffset,
|
||||
}
|
||||
|
||||
pub struct TiledImageInfo {
|
||||
/// The bounds of the item in layout space.
|
||||
pub rect: LayerRect,
|
||||
pub rect: LayoutRect,
|
||||
/// The space between each repeated pattern in layout space.
|
||||
pub tile_spacing: LayerSize,
|
||||
pub tile_spacing: LayoutSize,
|
||||
/// The size in layout space of each repetition of the image.
|
||||
pub stretch_size: LayerSize,
|
||||
pub stretch_size: LayoutSize,
|
||||
|
||||
/// The size the image occupies in the cache in device space.
|
||||
pub device_image_size: DeviceUintSize,
|
||||
|
@ -69,7 +69,7 @@ pub fn decompose_image(info: &TiledImageInfo, callback: &mut FnMut(&DecomposedTi
|
|||
}
|
||||
|
||||
|
||||
fn decompose_row(item_rect: &LayerRect, info: &TiledImageInfo, callback: &mut FnMut(&DecomposedTile)) {
|
||||
fn decompose_row(item_rect: &LayoutRect, info: &TiledImageInfo, callback: &mut FnMut(&DecomposedTile)) {
|
||||
|
||||
let no_horizontal_tiling = info.device_image_size.width <= info.device_tile_size;
|
||||
let no_horizontal_spacing = info.tile_spacing.width == 0.0;
|
||||
|
@ -98,7 +98,7 @@ fn decompose_row(item_rect: &LayerRect, info: &TiledImageInfo, callback: &mut Fn
|
|||
}
|
||||
|
||||
fn decompose_cache_tiles(
|
||||
item_rect: &LayerRect,
|
||||
item_rect: &LayoutRect,
|
||||
info: &TiledImageInfo,
|
||||
callback: &mut FnMut(&DecomposedTile),
|
||||
) {
|
||||
|
@ -155,7 +155,7 @@ fn decompose_cache_tiles(
|
|||
let img_dh = tile_size_f32 / (info.device_image_size.height as f32);
|
||||
|
||||
// Stretched size of the tile in layout space.
|
||||
let stretched_tile_size = LayerSize::new(
|
||||
let stretched_tile_size = LayoutSize::new(
|
||||
img_dw * info.stretch_size.width,
|
||||
img_dh * info.stretch_size.height,
|
||||
);
|
||||
|
@ -228,8 +228,8 @@ fn decompose_cache_tiles(
|
|||
}
|
||||
|
||||
fn add_device_tile(
|
||||
item_rect: &LayerRect,
|
||||
stretched_tile_size: LayerSize,
|
||||
item_rect: &LayoutRect,
|
||||
stretched_tile_size: LayoutSize,
|
||||
tile_offset: TileOffset,
|
||||
tile_ratio_width: f32,
|
||||
tile_ratio_height: f32,
|
||||
|
@ -246,13 +246,13 @@ fn add_device_tile(
|
|||
// axis).
|
||||
// See the shader_repeat_x/y code below.
|
||||
|
||||
let stretch_size = LayerSize::new(
|
||||
let stretch_size = LayoutSize::new(
|
||||
stretched_tile_size.width * tile_ratio_width,
|
||||
stretched_tile_size.height * tile_ratio_height,
|
||||
);
|
||||
|
||||
let mut prim_rect = LayerRect::new(
|
||||
item_rect.origin + LayerVector2D::new(
|
||||
let mut prim_rect = LayoutRect::new(
|
||||
item_rect.origin + LayoutVector2D::new(
|
||||
tile_offset.x as f32 * stretched_tile_size.width,
|
||||
tile_offset.y as f32 * stretched_tile_size.height,
|
||||
),
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
use api::{FilterOp, MixBlendMode, PipelineId, PremultipliedColorF};
|
||||
use api::{DeviceIntRect, DeviceIntSize, LayerRect};
|
||||
use api::{DeviceIntRect, DeviceIntSize, LayoutRect};
|
||||
use api::{PictureIntPoint, PictureIntRect, PictureIntSize};
|
||||
use box_shadow::{BLUR_SAMPLE_SCALE};
|
||||
use clip_scroll_tree::ClipScrollNodeIndex;
|
||||
|
@ -151,7 +151,7 @@ pub struct PicturePrimitive {
|
|||
// It is only different if this is part of a 3D
|
||||
// rendering context.
|
||||
pub reference_frame_index: ClipScrollNodeIndex,
|
||||
pub real_local_rect: LayerRect,
|
||||
pub real_local_rect: LayoutRect,
|
||||
// An optional cache handle for storing extra data
|
||||
// in the GPU cache, depending on the type of
|
||||
// picture.
|
||||
|
@ -195,7 +195,7 @@ impl PicturePrimitive {
|
|||
is_in_3d_context,
|
||||
frame_output_pipeline_id,
|
||||
reference_frame_index,
|
||||
real_local_rect: LayerRect::zero(),
|
||||
real_local_rect: LayoutRect::zero(),
|
||||
extra_gpu_data_handle: GpuCacheHandle::new(),
|
||||
apply_local_clip_rect,
|
||||
pipeline_id,
|
||||
|
@ -227,7 +227,7 @@ impl PicturePrimitive {
|
|||
pub fn update_local_rect(
|
||||
&mut self,
|
||||
prim_run_rect: PrimitiveRunLocalRect,
|
||||
) -> LayerRect {
|
||||
) -> LayoutRect {
|
||||
let local_content_rect = prim_run_rect.local_rect_in_actual_parent_space;
|
||||
|
||||
self.real_local_rect = prim_run_rect.local_rect_in_original_parent_space;
|
||||
|
@ -272,6 +272,11 @@ impl PicturePrimitive {
|
|||
}
|
||||
}
|
||||
|
||||
// Disallow subpixel AA if an intermediate surface is needed.
|
||||
pub fn allow_subpixel_aa(&self) -> bool {
|
||||
self.can_draw_directly_to_parent_surface()
|
||||
}
|
||||
|
||||
pub fn prepare_for_render_inner(
|
||||
&mut self,
|
||||
prim_index: PrimitiveIndex,
|
||||
|
|
|
@ -5,8 +5,8 @@
|
|||
use api::{AlphaType, BorderRadius, BoxShadowClipMode, BuiltDisplayList, ClipMode, ColorF, ComplexClipRegion};
|
||||
use api::{DeviceIntRect, DeviceIntSize, DevicePixelScale, Epoch, ExtendMode, FontRenderMode};
|
||||
use api::{FilterOp, GlyphInstance, GlyphKey, GradientStop, ImageKey, ImageRendering, ItemRange, ItemTag};
|
||||
use api::{GlyphRasterSpace, LayerPoint, LayerRect, LayerSize, LayerToWorldTransform, LayerVector2D};
|
||||
use api::{PipelineId, PremultipliedColorF, Shadow, YuvColorSpace, YuvFormat};
|
||||
use api::{GlyphRasterSpace, LayoutPoint, LayoutRect, LayoutSize, LayoutToWorldTransform, LayoutVector2D};
|
||||
use api::{PipelineId, PremultipliedColorF, PropertyBinding, Shadow, YuvColorSpace, YuvFormat};
|
||||
use border::{BorderCornerInstance, BorderEdgeKind};
|
||||
use box_shadow::BLUR_SAMPLE_SCALE;
|
||||
use clip_scroll_tree::{ClipChainIndex, ClipScrollNodeIndex, CoordinateSystemId};
|
||||
|
@ -26,10 +26,11 @@ use render_task::{BlitSource, RenderTask, RenderTaskCacheKey};
|
|||
use render_task::{RenderTaskCacheKeyKind, RenderTaskId, RenderTaskCacheEntryHandle};
|
||||
use renderer::{MAX_VERTEX_TEXTURE_WIDTH};
|
||||
use resource_cache::{ImageProperties, ImageRequest};
|
||||
use scene::SceneProperties;
|
||||
use segment::SegmentBuilder;
|
||||
use std::{mem, usize};
|
||||
use std::sync::Arc;
|
||||
use util::{MatrixHelpers, WorldToLayerFastTransform, calculate_screen_bounding_rect};
|
||||
use util::{MatrixHelpers, WorldToLayoutFastTransform, calculate_screen_bounding_rect};
|
||||
use util::{pack_as_float, recycle_vec};
|
||||
|
||||
|
||||
|
@ -110,8 +111,8 @@ impl CachedGradient {
|
|||
// in the picture structure.
|
||||
#[derive(Debug)]
|
||||
pub struct PrimitiveRunLocalRect {
|
||||
pub local_rect_in_actual_parent_space: LayerRect,
|
||||
pub local_rect_in_original_parent_space: LayerRect,
|
||||
pub local_rect_in_actual_parent_space: LayoutRect,
|
||||
pub local_rect_in_original_parent_space: LayoutRect,
|
||||
}
|
||||
|
||||
/// For external images, it's not possible to know the
|
||||
|
@ -184,8 +185,8 @@ pub struct PrimitiveMetadata {
|
|||
// TODO(gw): In the future, we should just pull these
|
||||
// directly from the DL item, instead of
|
||||
// storing them here.
|
||||
pub local_rect: LayerRect,
|
||||
pub local_clip_rect: LayerRect,
|
||||
pub local_rect: LayoutRect,
|
||||
pub local_clip_rect: LayoutRect,
|
||||
pub clip_chain_rect_index: ClipChainRectIndex,
|
||||
pub is_backface_visible: bool,
|
||||
pub screen_rect: Option<ScreenRect>,
|
||||
|
@ -200,10 +201,52 @@ pub struct PrimitiveMetadata {
|
|||
pub prepared_frame_id: FrameId,
|
||||
}
|
||||
|
||||
// Maintains a list of opacity bindings that have been collapsed into
|
||||
// the color of a single primitive. This is an important optimization
|
||||
// that avoids allocating an intermediate surface for most common
|
||||
// uses of opacity filters.
|
||||
#[derive(Debug)]
|
||||
pub struct OpacityBinding {
|
||||
bindings: Vec<PropertyBinding<f32>>,
|
||||
current: f32,
|
||||
}
|
||||
|
||||
impl OpacityBinding {
|
||||
pub fn new() -> OpacityBinding {
|
||||
OpacityBinding {
|
||||
bindings: Vec::new(),
|
||||
current: 1.0,
|
||||
}
|
||||
}
|
||||
|
||||
// Add a new opacity value / binding to the list
|
||||
pub fn push(&mut self, binding: PropertyBinding<f32>) {
|
||||
self.bindings.push(binding);
|
||||
}
|
||||
|
||||
// Resolve the current value of each opacity binding, and
|
||||
// store that as a single combined opacity. Returns true
|
||||
// if the opacity value changed from last time.
|
||||
pub fn update(&mut self, scene_properties: &SceneProperties) -> bool {
|
||||
let mut new_opacity = 1.0;
|
||||
|
||||
for binding in &self.bindings {
|
||||
let opacity = scene_properties.resolve_float(binding, 1.0);
|
||||
new_opacity = new_opacity * opacity;
|
||||
}
|
||||
|
||||
let changed = new_opacity != self.current;
|
||||
self.current = new_opacity;
|
||||
|
||||
changed
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
pub enum BrushKind {
|
||||
Solid {
|
||||
color: ColorF,
|
||||
opacity_binding: OpacityBinding,
|
||||
},
|
||||
Clear,
|
||||
Picture {
|
||||
|
@ -213,10 +256,11 @@ pub enum BrushKind {
|
|||
request: ImageRequest,
|
||||
current_epoch: Epoch,
|
||||
alpha_type: AlphaType,
|
||||
stretch_size: LayerSize,
|
||||
tile_spacing: LayerSize,
|
||||
stretch_size: LayoutSize,
|
||||
tile_spacing: LayoutSize,
|
||||
source: ImageSource,
|
||||
sub_rect: Option<DeviceIntRect>,
|
||||
opacity_binding: OpacityBinding,
|
||||
},
|
||||
YuvImage {
|
||||
yuv_key: [ImageKey; 3],
|
||||
|
@ -228,7 +272,7 @@ pub enum BrushKind {
|
|||
gradient_index: CachedGradientIndex,
|
||||
stops_range: ItemRange<GradientStop>,
|
||||
extend_mode: ExtendMode,
|
||||
center: LayerPoint,
|
||||
center: LayoutPoint,
|
||||
start_radius: f32,
|
||||
end_radius: f32,
|
||||
ratio_xy: f32,
|
||||
|
@ -239,8 +283,8 @@ pub enum BrushKind {
|
|||
stops_count: usize,
|
||||
extend_mode: ExtendMode,
|
||||
reverse_stops: bool,
|
||||
start_point: LayerPoint,
|
||||
end_point: LayerPoint,
|
||||
start_point: LayoutPoint,
|
||||
end_point: LayoutPoint,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -260,6 +304,14 @@ impl BrushKind {
|
|||
BrushKind::Clear => false,
|
||||
}
|
||||
}
|
||||
|
||||
// Construct a brush that is a solid color rectangle.
|
||||
pub fn new_solid(color: ColorF) -> BrushKind {
|
||||
BrushKind::Solid {
|
||||
color,
|
||||
opacity_binding: OpacityBinding::new(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bitflags! {
|
||||
|
@ -279,7 +331,7 @@ bitflags! {
|
|||
|
||||
#[derive(Debug)]
|
||||
pub struct BrushSegment {
|
||||
pub local_rect: LayerRect,
|
||||
pub local_rect: LayoutRect,
|
||||
pub clip_task_id: Option<RenderTaskId>,
|
||||
pub may_need_clip_mask: bool,
|
||||
pub edge_flags: EdgeAaSegmentMask,
|
||||
|
@ -287,13 +339,13 @@ pub struct BrushSegment {
|
|||
|
||||
impl BrushSegment {
|
||||
pub fn new(
|
||||
origin: LayerPoint,
|
||||
size: LayerSize,
|
||||
origin: LayoutPoint,
|
||||
size: LayoutSize,
|
||||
may_need_clip_mask: bool,
|
||||
edge_flags: EdgeAaSegmentMask,
|
||||
) -> BrushSegment {
|
||||
BrushSegment {
|
||||
local_rect: LayerRect::new(origin, size),
|
||||
local_rect: LayoutRect::new(origin, size),
|
||||
clip_task_id: None,
|
||||
may_need_clip_mask,
|
||||
edge_flags,
|
||||
|
@ -347,15 +399,19 @@ impl BrushPrimitive {
|
|||
// has to match VECS_PER_SPECIFIC_BRUSH
|
||||
match self.kind {
|
||||
BrushKind::YuvImage { .. } => {}
|
||||
|
||||
BrushKind::Picture { .. } |
|
||||
BrushKind::Image { .. } => {
|
||||
BrushKind::Picture { .. } => {
|
||||
request.push(PremultipliedColorF::WHITE);
|
||||
request.push(PremultipliedColorF::WHITE);
|
||||
}
|
||||
|
||||
BrushKind::Solid { color } => {
|
||||
request.push(color.premultiplied());
|
||||
// Images are drawn as a white color, modulated by the total
|
||||
// opacity coming from any collapsed property bindings.
|
||||
BrushKind::Image { ref opacity_binding, .. } => {
|
||||
request.push(ColorF::new(1.0, 1.0, 1.0, opacity_binding.current).premultiplied());
|
||||
request.push(PremultipliedColorF::WHITE);
|
||||
}
|
||||
// Solid rects also support opacity collapsing.
|
||||
BrushKind::Solid { color, ref opacity_binding, .. } => {
|
||||
request.push(color.scale_alpha(opacity_binding.current).premultiplied());
|
||||
}
|
||||
BrushKind::Clear => {
|
||||
// Opaque black with operator dest out
|
||||
|
@ -418,9 +474,9 @@ pub enum ImageSource {
|
|||
|
||||
#[derive(Debug)]
|
||||
pub struct ImagePrimitiveCpu {
|
||||
pub tile_spacing: LayerSize,
|
||||
pub tile_spacing: LayoutSize,
|
||||
pub alpha_type: AlphaType,
|
||||
pub stretch_size: LayerSize,
|
||||
pub stretch_size: LayoutSize,
|
||||
pub current_epoch: Epoch,
|
||||
pub source: ImageSource,
|
||||
pub key: ImageCacheKey,
|
||||
|
@ -634,7 +690,7 @@ impl<'a> GradientGpuBlockBuilder<'a> {
|
|||
#[derive(Debug, Clone)]
|
||||
pub struct TextRunPrimitiveCpu {
|
||||
pub font: FontInstance,
|
||||
pub offset: LayerVector2D,
|
||||
pub offset: LayoutVector2D,
|
||||
pub glyph_range: ItemRange<GlyphInstance>,
|
||||
pub glyph_keys: Vec<GlyphKey>,
|
||||
pub glyph_gpu_blocks: Vec<GpuBlockData>,
|
||||
|
@ -646,7 +702,7 @@ impl TextRunPrimitiveCpu {
|
|||
pub fn get_font(
|
||||
&self,
|
||||
device_pixel_scale: DevicePixelScale,
|
||||
transform: Option<LayerToWorldTransform>,
|
||||
transform: Option<LayoutToWorldTransform>,
|
||||
) -> FontInstance {
|
||||
let mut font = self.font.clone();
|
||||
font.size = font.size.scale_by(device_pixel_scale.0);
|
||||
|
@ -665,10 +721,15 @@ impl TextRunPrimitiveCpu {
|
|||
fn prepare_for_render(
|
||||
&mut self,
|
||||
device_pixel_scale: DevicePixelScale,
|
||||
transform: Option<LayerToWorldTransform>,
|
||||
transform: Option<LayoutToWorldTransform>,
|
||||
allow_subpixel_aa: bool,
|
||||
display_list: &BuiltDisplayList,
|
||||
frame_building_state: &mut FrameBuildingState,
|
||||
) {
|
||||
if !allow_subpixel_aa {
|
||||
self.font.render_mode = self.font.render_mode.limit_by(FontRenderMode::Alpha);
|
||||
}
|
||||
|
||||
let font = self.get_font(device_pixel_scale, transform);
|
||||
|
||||
// Cache the glyph positions, if not in the cache already.
|
||||
|
@ -734,14 +795,14 @@ impl TextRunPrimitiveCpu {
|
|||
#[derive(Debug)]
|
||||
#[repr(C)]
|
||||
struct ClipRect {
|
||||
rect: LayerRect,
|
||||
rect: LayoutRect,
|
||||
mode: f32,
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
#[repr(C)]
|
||||
struct ClipCorner {
|
||||
rect: LayerRect,
|
||||
rect: LayoutRect,
|
||||
outer_radius_x: f32,
|
||||
outer_radius_y: f32,
|
||||
inner_radius_x: f32,
|
||||
|
@ -765,7 +826,7 @@ impl ClipCorner {
|
|||
]);
|
||||
}
|
||||
|
||||
fn uniform(rect: LayerRect, outer_radius: f32, inner_radius: f32) -> ClipCorner {
|
||||
fn uniform(rect: LayoutRect, outer_radius: f32, inner_radius: f32) -> ClipCorner {
|
||||
ClipCorner {
|
||||
rect,
|
||||
outer_radius_x: outer_radius,
|
||||
|
@ -779,7 +840,7 @@ impl ClipCorner {
|
|||
#[derive(Debug)]
|
||||
#[repr(C)]
|
||||
pub struct ImageMaskData {
|
||||
pub local_rect: LayerRect,
|
||||
pub local_rect: LayoutRect,
|
||||
}
|
||||
|
||||
impl ToGpuBlocks for ImageMaskData {
|
||||
|
@ -798,16 +859,16 @@ pub struct ClipData {
|
|||
}
|
||||
|
||||
impl ClipData {
|
||||
pub fn rounded_rect(rect: &LayerRect, radii: &BorderRadius, mode: ClipMode) -> ClipData {
|
||||
pub fn rounded_rect(rect: &LayoutRect, radii: &BorderRadius, mode: ClipMode) -> ClipData {
|
||||
ClipData {
|
||||
rect: ClipRect {
|
||||
rect: *rect,
|
||||
mode: mode as u32 as f32,
|
||||
},
|
||||
top_left: ClipCorner {
|
||||
rect: LayerRect::new(
|
||||
LayerPoint::new(rect.origin.x, rect.origin.y),
|
||||
LayerSize::new(radii.top_left.width, radii.top_left.height),
|
||||
rect: LayoutRect::new(
|
||||
LayoutPoint::new(rect.origin.x, rect.origin.y),
|
||||
LayoutSize::new(radii.top_left.width, radii.top_left.height),
|
||||
),
|
||||
outer_radius_x: radii.top_left.width,
|
||||
outer_radius_y: radii.top_left.height,
|
||||
|
@ -815,12 +876,12 @@ impl ClipData {
|
|||
inner_radius_y: 0.0,
|
||||
},
|
||||
top_right: ClipCorner {
|
||||
rect: LayerRect::new(
|
||||
LayerPoint::new(
|
||||
rect: LayoutRect::new(
|
||||
LayoutPoint::new(
|
||||
rect.origin.x + rect.size.width - radii.top_right.width,
|
||||
rect.origin.y,
|
||||
),
|
||||
LayerSize::new(radii.top_right.width, radii.top_right.height),
|
||||
LayoutSize::new(radii.top_right.width, radii.top_right.height),
|
||||
),
|
||||
outer_radius_x: radii.top_right.width,
|
||||
outer_radius_y: radii.top_right.height,
|
||||
|
@ -828,12 +889,12 @@ impl ClipData {
|
|||
inner_radius_y: 0.0,
|
||||
},
|
||||
bottom_left: ClipCorner {
|
||||
rect: LayerRect::new(
|
||||
LayerPoint::new(
|
||||
rect: LayoutRect::new(
|
||||
LayoutPoint::new(
|
||||
rect.origin.x,
|
||||
rect.origin.y + rect.size.height - radii.bottom_left.height,
|
||||
),
|
||||
LayerSize::new(radii.bottom_left.width, radii.bottom_left.height),
|
||||
LayoutSize::new(radii.bottom_left.width, radii.bottom_left.height),
|
||||
),
|
||||
outer_radius_x: radii.bottom_left.width,
|
||||
outer_radius_y: radii.bottom_left.height,
|
||||
|
@ -841,12 +902,12 @@ impl ClipData {
|
|||
inner_radius_y: 0.0,
|
||||
},
|
||||
bottom_right: ClipCorner {
|
||||
rect: LayerRect::new(
|
||||
LayerPoint::new(
|
||||
rect: LayoutRect::new(
|
||||
LayoutPoint::new(
|
||||
rect.origin.x + rect.size.width - radii.bottom_right.width,
|
||||
rect.origin.y + rect.size.height - radii.bottom_right.height,
|
||||
),
|
||||
LayerSize::new(radii.bottom_right.width, radii.bottom_right.height),
|
||||
LayoutSize::new(radii.bottom_right.width, radii.bottom_right.height),
|
||||
),
|
||||
outer_radius_x: radii.bottom_right.width,
|
||||
outer_radius_y: radii.bottom_right.height,
|
||||
|
@ -856,43 +917,43 @@ impl ClipData {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn uniform(rect: LayerRect, radius: f32, mode: ClipMode) -> ClipData {
|
||||
pub fn uniform(rect: LayoutRect, radius: f32, mode: ClipMode) -> ClipData {
|
||||
ClipData {
|
||||
rect: ClipRect {
|
||||
rect,
|
||||
mode: mode as u32 as f32,
|
||||
},
|
||||
top_left: ClipCorner::uniform(
|
||||
LayerRect::new(
|
||||
LayerPoint::new(rect.origin.x, rect.origin.y),
|
||||
LayerSize::new(radius, radius),
|
||||
LayoutRect::new(
|
||||
LayoutPoint::new(rect.origin.x, rect.origin.y),
|
||||
LayoutSize::new(radius, radius),
|
||||
),
|
||||
radius,
|
||||
0.0,
|
||||
),
|
||||
top_right: ClipCorner::uniform(
|
||||
LayerRect::new(
|
||||
LayerPoint::new(rect.origin.x + rect.size.width - radius, rect.origin.y),
|
||||
LayerSize::new(radius, radius),
|
||||
LayoutRect::new(
|
||||
LayoutPoint::new(rect.origin.x + rect.size.width - radius, rect.origin.y),
|
||||
LayoutSize::new(radius, radius),
|
||||
),
|
||||
radius,
|
||||
0.0,
|
||||
),
|
||||
bottom_left: ClipCorner::uniform(
|
||||
LayerRect::new(
|
||||
LayerPoint::new(rect.origin.x, rect.origin.y + rect.size.height - radius),
|
||||
LayerSize::new(radius, radius),
|
||||
LayoutRect::new(
|
||||
LayoutPoint::new(rect.origin.x, rect.origin.y + rect.size.height - radius),
|
||||
LayoutSize::new(radius, radius),
|
||||
),
|
||||
radius,
|
||||
0.0,
|
||||
),
|
||||
bottom_right: ClipCorner::uniform(
|
||||
LayerRect::new(
|
||||
LayerPoint::new(
|
||||
LayoutRect::new(
|
||||
LayoutPoint::new(
|
||||
rect.origin.x + rect.size.width - radius,
|
||||
rect.origin.y + rect.size.height - radius,
|
||||
),
|
||||
LayerSize::new(radius, radius),
|
||||
LayoutSize::new(radius, radius),
|
||||
),
|
||||
radius,
|
||||
0.0,
|
||||
|
@ -937,7 +998,7 @@ impl PrimitiveContainer {
|
|||
}
|
||||
PrimitiveContainer::Brush(ref brush) => {
|
||||
match brush.kind {
|
||||
BrushKind::Solid { ref color } => {
|
||||
BrushKind::Solid { ref color, .. } => {
|
||||
color.a > 0.0
|
||||
}
|
||||
BrushKind::Clear |
|
||||
|
@ -987,9 +1048,7 @@ impl PrimitiveContainer {
|
|||
match brush.kind {
|
||||
BrushKind::Solid { .. } => {
|
||||
PrimitiveContainer::Brush(BrushPrimitive::new(
|
||||
BrushKind::Solid {
|
||||
color: shadow.color,
|
||||
},
|
||||
BrushKind::new_solid(shadow.color),
|
||||
None,
|
||||
))
|
||||
}
|
||||
|
@ -1077,8 +1136,8 @@ impl PrimitiveStore {
|
|||
|
||||
pub fn add_primitive(
|
||||
&mut self,
|
||||
local_rect: &LayerRect,
|
||||
local_clip_rect: &LayerRect,
|
||||
local_rect: &LayoutRect,
|
||||
local_clip_rect: &LayoutRect,
|
||||
is_backface_visible: bool,
|
||||
clip_sources: Option<ClipSourcesHandle>,
|
||||
tag: Option<ItemTag>,
|
||||
|
@ -1093,7 +1152,7 @@ impl PrimitiveStore {
|
|||
local_rect: *local_rect,
|
||||
local_clip_rect: *local_clip_rect,
|
||||
clip_chain_rect_index: ClipChainRectIndex(0),
|
||||
is_backface_visible: is_backface_visible,
|
||||
is_backface_visible,
|
||||
screen_rect: None,
|
||||
tag,
|
||||
opacity: PrimitiveOpacity::translucent(),
|
||||
|
@ -1107,7 +1166,7 @@ impl PrimitiveStore {
|
|||
PrimitiveContainer::Brush(brush) => {
|
||||
let opacity = match brush.kind {
|
||||
BrushKind::Clear => PrimitiveOpacity::translucent(),
|
||||
BrushKind::Solid { ref color } => PrimitiveOpacity::from_alpha(color.a),
|
||||
BrushKind::Solid { ref color, .. } => PrimitiveOpacity::from_alpha(color.a),
|
||||
BrushKind::Image { .. } => PrimitiveOpacity::translucent(),
|
||||
BrushKind::YuvImage { .. } => PrimitiveOpacity::opaque(),
|
||||
BrushKind::RadialGradient { .. } => PrimitiveOpacity::translucent(),
|
||||
|
@ -1166,6 +1225,121 @@ impl PrimitiveStore {
|
|||
PrimitiveIndex(prim_index)
|
||||
}
|
||||
|
||||
// Internal method that retrieves the primitive index of a primitive
|
||||
// that can be the target for collapsing parent opacity filters into.
|
||||
fn get_opacity_collapse_prim(
|
||||
&self,
|
||||
pic_index: PictureIndex,
|
||||
) -> Option<PrimitiveIndex> {
|
||||
let pic = &self.pictures[pic_index.0];
|
||||
|
||||
// We can only collapse opacity if there is a single primitive, otherwise
|
||||
// the opacity needs to be applied to the primitives as a group.
|
||||
if pic.runs.len() != 1 {
|
||||
return None;
|
||||
}
|
||||
|
||||
let run = &pic.runs[0];
|
||||
if run.count != 1 {
|
||||
return None;
|
||||
}
|
||||
|
||||
let prim_metadata = &self.cpu_metadata[run.base_prim_index.0];
|
||||
|
||||
// For now, we only support opacity collapse on solid rects and images.
|
||||
// This covers the most common types of opacity filters that can be
|
||||
// handled by this optimization. In the future, we can easily extend
|
||||
// this to other primitives, such as text runs and gradients.
|
||||
match prim_metadata.prim_kind {
|
||||
PrimitiveKind::Brush => {
|
||||
let brush = &self.cpu_brushes[prim_metadata.cpu_prim_index.0];
|
||||
match brush.kind {
|
||||
BrushKind::Picture { pic_index, .. } => {
|
||||
let pic = &self.pictures[pic_index.0];
|
||||
// If we encounter a picture that is a pass-through
|
||||
// (i.e. no composite mode), then we can recurse into
|
||||
// that to try and find a primitive to collapse to.
|
||||
if pic.composite_mode.is_none() {
|
||||
return self.get_opacity_collapse_prim(pic_index);
|
||||
}
|
||||
}
|
||||
// If we find a single rect or image, we can use that
|
||||
// as the primitive to collapse the opacity into.
|
||||
BrushKind::Solid { .. } | BrushKind::Image { .. } => {
|
||||
return Some(run.base_prim_index)
|
||||
}
|
||||
BrushKind::YuvImage { .. } |
|
||||
BrushKind::LinearGradient { .. } |
|
||||
BrushKind::RadialGradient { .. } |
|
||||
BrushKind::Clear => {}
|
||||
}
|
||||
}
|
||||
PrimitiveKind::TextRun |
|
||||
PrimitiveKind::Image |
|
||||
PrimitiveKind::Border => {}
|
||||
}
|
||||
|
||||
None
|
||||
}
|
||||
|
||||
// Apply any optimizations to drawing this picture. Currently,
|
||||
// we just support collapsing pictures with an opacity filter
|
||||
// by pushing that opacity value into the color of a primitive
|
||||
// if that picture contains one compatible primitive.
|
||||
pub fn optimize_picture_if_possible(
|
||||
&mut self,
|
||||
pic_index: PictureIndex,
|
||||
) {
|
||||
// Only handle opacity filters for now.
|
||||
let binding = match self.pictures[pic_index.0].composite_mode {
|
||||
Some(PictureCompositeMode::Filter(FilterOp::Opacity(binding, _))) => {
|
||||
binding
|
||||
}
|
||||
_ => {
|
||||
return;
|
||||
}
|
||||
};
|
||||
|
||||
// See if this picture contains a single primitive that supports
|
||||
// opacity collapse.
|
||||
if let Some(prim_index) = self.get_opacity_collapse_prim(pic_index) {
|
||||
let prim_metadata = &self.cpu_metadata[prim_index.0];
|
||||
match prim_metadata.prim_kind {
|
||||
PrimitiveKind::Brush => {
|
||||
let brush = &mut self.cpu_brushes[prim_metadata.cpu_prim_index.0];
|
||||
|
||||
// By this point, we know we should only have found a primitive
|
||||
// that supports opacity collapse.
|
||||
match brush.kind {
|
||||
BrushKind::Solid { ref mut opacity_binding, .. } |
|
||||
BrushKind::Image { ref mut opacity_binding, .. } => {
|
||||
opacity_binding.push(binding);
|
||||
}
|
||||
BrushKind::Clear { .. } |
|
||||
BrushKind::Picture { .. } |
|
||||
BrushKind::YuvImage { .. } |
|
||||
BrushKind::LinearGradient { .. } |
|
||||
BrushKind::RadialGradient { .. } => {
|
||||
unreachable!("bug: invalid prim type for opacity collapse");
|
||||
}
|
||||
};
|
||||
}
|
||||
PrimitiveKind::TextRun |
|
||||
PrimitiveKind::Image |
|
||||
PrimitiveKind::Border => {
|
||||
unreachable!("bug: invalid prim type for opacity collapse");
|
||||
}
|
||||
}
|
||||
|
||||
// The opacity filter has been collapsed, so mark this picture
|
||||
// as a pass though. This means it will no longer allocate an
|
||||
// intermediate surface or incur an extra blend / blit. Instead,
|
||||
// the collapsed primitive will be drawn directly into the
|
||||
// parent picture.
|
||||
self.pictures[pic_index.0].composite_mode = None;
|
||||
}
|
||||
}
|
||||
|
||||
pub fn get_metadata(&self, index: PrimitiveIndex) -> &PrimitiveMetadata {
|
||||
&self.cpu_metadata[index.0]
|
||||
}
|
||||
|
@ -1199,6 +1373,7 @@ impl PrimitiveStore {
|
|||
text.prepare_for_render(
|
||||
frame_context.device_pixel_scale,
|
||||
transform,
|
||||
pic_context.allow_subpixel_aa,
|
||||
pic_context.display_list,
|
||||
frame_state,
|
||||
);
|
||||
|
@ -1318,20 +1493,27 @@ impl PrimitiveStore {
|
|||
let brush = &mut self.cpu_brushes[metadata.cpu_prim_index.0];
|
||||
|
||||
match brush.kind {
|
||||
BrushKind::Image { request, sub_rect, ref mut current_epoch, ref mut source, .. } => {
|
||||
BrushKind::Image { request, sub_rect, ref mut current_epoch, ref mut source, ref mut opacity_binding, .. } => {
|
||||
let image_properties = frame_state
|
||||
.resource_cache
|
||||
.get_image_properties(request.key);
|
||||
|
||||
// Set if we need to request the source image from the cache this frame.
|
||||
if let Some(image_properties) = image_properties {
|
||||
// See if this image has been updated since we last hit this code path.
|
||||
// If so, we need to update the opacity.
|
||||
if image_properties.epoch != *current_epoch {
|
||||
*current_epoch = image_properties.epoch;
|
||||
metadata.opacity.is_opaque = image_properties.descriptor.is_opaque;
|
||||
*current_epoch = image_properties.epoch;
|
||||
|
||||
// If the opacity changed, invalidate the GPU cache so that
|
||||
// the new color for this primitive gets uploaded.
|
||||
if opacity_binding.update(frame_context.scene_properties) {
|
||||
frame_state.gpu_cache.invalidate(&mut metadata.gpu_location);
|
||||
}
|
||||
|
||||
// Update opacity for this primitive to ensure the correct
|
||||
// batching parameters are used.
|
||||
metadata.opacity.is_opaque =
|
||||
image_properties.descriptor.is_opaque &&
|
||||
opacity_binding.current == 1.0;
|
||||
|
||||
// Work out whether this image is a normal / simple type, or if
|
||||
// we need to pre-render it to the render task cache.
|
||||
if let Some(rect) = sub_rect {
|
||||
|
@ -1465,7 +1647,16 @@ impl PrimitiveStore {
|
|||
frame_state,
|
||||
);
|
||||
}
|
||||
BrushKind::Solid { .. } |
|
||||
BrushKind::Solid { ref color, ref mut opacity_binding, .. } => {
|
||||
// If the opacity changed, invalidate the GPU cache so that
|
||||
// the new color for this primitive gets uploaded. Also update
|
||||
// the opacity field that controls which batches this primitive
|
||||
// will be added to.
|
||||
if opacity_binding.update(frame_context.scene_properties) {
|
||||
metadata.opacity = PrimitiveOpacity::from_alpha(opacity_binding.current * color.a);
|
||||
frame_state.gpu_cache.invalidate(&mut metadata.gpu_location);
|
||||
}
|
||||
}
|
||||
BrushKind::Clear => {}
|
||||
}
|
||||
}
|
||||
|
@ -1631,7 +1822,7 @@ impl PrimitiveStore {
|
|||
let prim_transform = &prim_run_context.scroll_node.world_content_transform;
|
||||
let relative_transform = prim_transform
|
||||
.inverse()
|
||||
.unwrap_or(WorldToLayerFastTransform::identity())
|
||||
.unwrap_or(WorldToLayoutFastTransform::identity())
|
||||
.pre_mul(&clip_transform.into());
|
||||
|
||||
relative_transform.transform_rect(&local_clip_rect)
|
||||
|
@ -1808,7 +1999,7 @@ impl PrimitiveStore {
|
|||
// It's used to calculate a local clipping rectangle before we reach this
|
||||
// point, so we can set it to zero here. It should be unused from this point
|
||||
// on.
|
||||
local_clip_rect: LayerRect::zero(),
|
||||
local_clip_rect: LayoutRect::zero(),
|
||||
screen_inner_rect,
|
||||
screen_outer_rect: screen_outer_rect.unwrap_or(prim_screen_rect),
|
||||
prev: None,
|
||||
|
@ -1899,7 +2090,7 @@ impl PrimitiveStore {
|
|||
pic_state: &mut PictureState,
|
||||
frame_context: &FrameBuildingContext,
|
||||
frame_state: &mut FrameBuildingState,
|
||||
) -> Option<LayerRect> {
|
||||
) -> Option<LayoutRect> {
|
||||
let mut may_need_clip_mask = true;
|
||||
let mut pic_state_for_children = PictureState::new();
|
||||
|
||||
|
@ -1966,6 +2157,8 @@ impl PrimitiveStore {
|
|||
inv_world_transform,
|
||||
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(),
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -2076,8 +2269,8 @@ impl PrimitiveStore {
|
|||
frame_state: &mut FrameBuildingState,
|
||||
) -> PrimitiveRunLocalRect {
|
||||
let mut result = PrimitiveRunLocalRect {
|
||||
local_rect_in_actual_parent_space: LayerRect::zero(),
|
||||
local_rect_in_original_parent_space: LayerRect::zero(),
|
||||
local_rect_in_actual_parent_space: LayoutRect::zero(),
|
||||
local_rect_in_original_parent_space: LayoutRect::zero(),
|
||||
};
|
||||
|
||||
for run in &pic_context.prim_runs {
|
||||
|
@ -2238,17 +2431,17 @@ fn convert_clip_chain_to_clip_vector(
|
|||
fn get_local_clip_rect_for_nodes(
|
||||
scroll_node: &ClipScrollNode,
|
||||
clip_chain: &ClipChain,
|
||||
) -> Option<LayerRect> {
|
||||
) -> Option<LayoutRect> {
|
||||
let local_rect = ClipChainNodeIter { current: clip_chain.nodes.clone() }.fold(
|
||||
None,
|
||||
|combined_local_clip_rect: Option<LayerRect>, node| {
|
||||
|combined_local_clip_rect: Option<LayoutRect>, node| {
|
||||
if node.work_item.coordinate_system_id != scroll_node.coordinate_system_id {
|
||||
return combined_local_clip_rect;
|
||||
}
|
||||
|
||||
Some(match combined_local_clip_rect {
|
||||
Some(combined_rect) =>
|
||||
combined_rect.intersection(&node.local_clip_rect).unwrap_or_else(LayerRect::zero),
|
||||
combined_rect.intersection(&node.local_clip_rect).unwrap_or_else(LayoutRect::zero),
|
||||
None => node.local_clip_rect,
|
||||
})
|
||||
}
|
||||
|
@ -2268,7 +2461,7 @@ impl<'a> GpuDataRequest<'a> {
|
|||
// part of an image.
|
||||
fn write_segment(
|
||||
&mut self,
|
||||
local_rect: LayerRect,
|
||||
local_rect: LayoutRect,
|
||||
) {
|
||||
self.push(local_rect);
|
||||
self.push([
|
||||
|
|
|
@ -7,7 +7,7 @@ use api::{ApiMsg, BuiltDisplayList, ClearCache, DebugCommand};
|
|||
use api::{BuiltDisplayListIter, SpecificDisplayItem};
|
||||
use api::{DeviceIntPoint, DevicePixelScale, DeviceUintPoint, DeviceUintRect, DeviceUintSize};
|
||||
use api::{DocumentId, DocumentLayer, ExternalScrollId, FrameMsg, HitTestResult};
|
||||
use api::{IdNamespace, LayerPoint, PipelineId, RenderNotifier, SceneMsg, ScrollClamping};
|
||||
use api::{IdNamespace, LayoutPoint, PipelineId, RenderNotifier, SceneMsg, ScrollClamping};
|
||||
use api::{ScrollLocation, ScrollNodeState, TransactionMsg, WorldPoint};
|
||||
use api::channel::{MsgReceiver, Payload};
|
||||
#[cfg(feature = "capture")]
|
||||
|
@ -327,7 +327,7 @@ impl Document {
|
|||
/// Returns true if the node actually changed position or false otherwise.
|
||||
pub fn scroll_node(
|
||||
&mut self,
|
||||
origin: LayerPoint,
|
||||
origin: LayoutPoint,
|
||||
id: ExternalScrollId,
|
||||
clamp: ScrollClamping
|
||||
) -> bool {
|
||||
|
@ -731,6 +731,9 @@ impl RenderBackend {
|
|||
&mut profile_counters
|
||||
);
|
||||
}
|
||||
},
|
||||
SceneBuilderResult::Stopped => {
|
||||
panic!("We haven't sent a Stop yet, how did we get a Stopped back?");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -747,6 +750,15 @@ impl RenderBackend {
|
|||
}
|
||||
|
||||
let _ = self.scene_tx.send(SceneBuilderRequest::Stop);
|
||||
// Ensure we read everything the scene builder is sending us from
|
||||
// inflight messages, otherwise the scene builder might panic.
|
||||
while let Ok(msg) = self.scene_rx.recv() {
|
||||
match msg {
|
||||
SceneBuilderResult::Stopped => break,
|
||||
_ => continue,
|
||||
}
|
||||
}
|
||||
|
||||
self.notifier.shut_down();
|
||||
|
||||
if let Some(ref sampler) = self.sampler {
|
||||
|
@ -1034,8 +1046,8 @@ impl RenderBackend {
|
|||
doc.render_on_hittest = false;
|
||||
}
|
||||
|
||||
if op.render || op.scroll {
|
||||
self.notifier.new_document_ready(document_id, op.scroll, op.composite);
|
||||
if transaction_msg.generate_frame {
|
||||
self.notifier.new_frame_ready(document_id, op.scroll, op.composite);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1328,7 +1340,7 @@ impl RenderBackend {
|
|||
self.result_tx.send(msg_publish).unwrap();
|
||||
profile_counters.reset();
|
||||
|
||||
self.notifier.new_document_ready(id, false, true);
|
||||
self.notifier.new_frame_ready(id, false, true);
|
||||
self.documents.insert(id, doc);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,7 +16,7 @@ use api::{RenderApiSender, RenderNotifier, TexelRect, TextureTarget};
|
|||
use api::{channel};
|
||||
use api::DebugCommand;
|
||||
use api::channel::PayloadReceiverHelperMethods;
|
||||
use batch::{BatchKey, BatchKind, BatchTextures, BrushBatchKind, TransformBatchKind};
|
||||
use batch::{BatchKind, BatchTextures, BrushBatchKind, TransformBatchKind};
|
||||
#[cfg(any(feature = "capture", feature = "replay"))]
|
||||
use capture::{CaptureConfig, ExternalCaptureImage, PlainExternalImage};
|
||||
use debug_colors;
|
||||
|
@ -32,7 +32,6 @@ use glyph_rasterizer::{GlyphFormat, GlyphRasterizer};
|
|||
use gpu_cache::{GpuBlockData, GpuCacheUpdate, GpuCacheUpdateList};
|
||||
#[cfg(feature = "pathfinder")]
|
||||
use gpu_glyph_renderer::GpuGlyphRenderer;
|
||||
use gpu_types::PrimitiveInstance;
|
||||
use internal_types::{SourceTexture, ORTHO_FAR_PLANE, ORTHO_NEAR_PLANE, ResourceCacheError};
|
||||
use internal_types::{CacheTextureId, DebugOutput, FastHashMap, RenderedDocument, ResultMsg};
|
||||
use internal_types::{TextureUpdateList, TextureUpdateOp, TextureUpdateSource};
|
||||
|
@ -268,7 +267,10 @@ fn flag_changed(before: DebugFlags, after: DebugFlags, select: DebugFlags) -> Op
|
|||
}
|
||||
|
||||
#[repr(C)]
|
||||
#[derive(Copy, Clone, Debug)]
|
||||
pub enum ShaderColorMode {
|
||||
FromRenderPassMode = 0,
|
||||
|
||||
Alpha = 1,
|
||||
SubpixelConstantTextColor = 2,
|
||||
SubpixelWithBgColorPass0 = 3,
|
||||
|
@ -431,6 +433,48 @@ pub(crate) mod desc {
|
|||
],
|
||||
};
|
||||
|
||||
pub const BORDER_CORNER_DASH_AND_DOT: VertexDescriptor = VertexDescriptor {
|
||||
vertex_attributes: &[
|
||||
VertexAttribute {
|
||||
name: "aPosition",
|
||||
count: 2,
|
||||
kind: VertexAttributeKind::F32,
|
||||
},
|
||||
],
|
||||
instance_attributes: &[
|
||||
VertexAttribute {
|
||||
name: "aClipRenderTaskAddress",
|
||||
count: 1,
|
||||
kind: VertexAttributeKind::I32,
|
||||
},
|
||||
VertexAttribute {
|
||||
name: "aScrollNodeId",
|
||||
count: 1,
|
||||
kind: VertexAttributeKind::I32,
|
||||
},
|
||||
VertexAttribute {
|
||||
name: "aClipSegment",
|
||||
count: 1,
|
||||
kind: VertexAttributeKind::I32,
|
||||
},
|
||||
VertexAttribute {
|
||||
name: "aClipDataResourceAddress",
|
||||
count: 4,
|
||||
kind: VertexAttributeKind::U16,
|
||||
},
|
||||
VertexAttribute {
|
||||
name: "aDashOrDot0",
|
||||
count: 4,
|
||||
kind: VertexAttributeKind::F32,
|
||||
},
|
||||
VertexAttribute {
|
||||
name: "aDashOrDot1",
|
||||
count: 4,
|
||||
kind: VertexAttributeKind::F32,
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
pub const GPU_CACHE_UPDATE: VertexDescriptor = VertexDescriptor {
|
||||
vertex_attributes: &[
|
||||
VertexAttribute {
|
||||
|
@ -537,6 +581,7 @@ pub(crate) enum VertexArrayKind {
|
|||
Primitive,
|
||||
Blur,
|
||||
Clip,
|
||||
DashAndDot,
|
||||
VectorStencil,
|
||||
VectorCover,
|
||||
}
|
||||
|
@ -1258,6 +1303,7 @@ pub struct RendererVAOs {
|
|||
prim_vao: VAO,
|
||||
blur_vao: VAO,
|
||||
clip_vao: VAO,
|
||||
dash_and_dot_vao: VAO,
|
||||
}
|
||||
|
||||
/// The renderer is responsible for submitting to the GPU the work prepared by the
|
||||
|
@ -1544,6 +1590,8 @@ impl Renderer {
|
|||
|
||||
let blur_vao = device.create_vao_with_new_instances(&desc::BLUR, &prim_vao);
|
||||
let clip_vao = device.create_vao_with_new_instances(&desc::CLIP, &prim_vao);
|
||||
let dash_and_dot_vao =
|
||||
device.create_vao_with_new_instances(&desc::BORDER_CORNER_DASH_AND_DOT, &prim_vao);
|
||||
let texture_cache_upload_pbo = device.create_pbo();
|
||||
|
||||
let texture_resolver = SourceTextureResolver::new(&mut device);
|
||||
|
@ -1696,6 +1744,7 @@ impl Renderer {
|
|||
prim_vao,
|
||||
blur_vao,
|
||||
clip_vao,
|
||||
dash_and_dot_vao,
|
||||
},
|
||||
node_data_texture,
|
||||
local_clip_rects_texture,
|
||||
|
@ -2611,48 +2660,6 @@ impl Renderer {
|
|||
}
|
||||
}
|
||||
|
||||
fn submit_batch(
|
||||
&mut self,
|
||||
key: &BatchKey,
|
||||
instances: &[PrimitiveInstance],
|
||||
projection: &Transform3D<f32>,
|
||||
render_tasks: &RenderTaskTree,
|
||||
render_target: Option<(&Texture, i32)>,
|
||||
framebuffer_size: DeviceUintSize,
|
||||
stats: &mut RendererStats,
|
||||
scissor_rect: Option<DeviceIntRect>,
|
||||
) {
|
||||
self.shaders
|
||||
.get(key)
|
||||
.bind(
|
||||
&mut self.device, projection,
|
||||
&mut self.renderer_errors,
|
||||
);
|
||||
|
||||
// Handle special case readback for composites.
|
||||
if let BatchKind::Brush(BrushBatchKind::MixBlend { task_id, source_id, backdrop_id }) = key.kind {
|
||||
// composites can't be grouped together because
|
||||
// they may overlap and affect each other.
|
||||
debug_assert_eq!(instances.len(), 1);
|
||||
self.handle_readback_composite(
|
||||
render_target,
|
||||
framebuffer_size,
|
||||
scissor_rect,
|
||||
&render_tasks[source_id],
|
||||
&render_tasks[task_id],
|
||||
&render_tasks[backdrop_id],
|
||||
);
|
||||
}
|
||||
|
||||
let _timer = self.gpu_profile.start_timer(key.kind.sampler_tag());
|
||||
self.draw_instanced_batch(
|
||||
instances,
|
||||
VertexArrayKind::Primitive,
|
||||
&key.textures,
|
||||
stats
|
||||
);
|
||||
}
|
||||
|
||||
fn handle_blits(
|
||||
&mut self,
|
||||
blits: &[BlitJob],
|
||||
|
@ -2847,15 +2854,19 @@ impl Renderer {
|
|||
.iter()
|
||||
.rev()
|
||||
{
|
||||
self.submit_batch(
|
||||
&batch.key,
|
||||
self.shaders
|
||||
.get(&batch.key)
|
||||
.bind(
|
||||
&mut self.device, projection,
|
||||
&mut self.renderer_errors,
|
||||
);
|
||||
|
||||
let _timer = self.gpu_profile.start_timer(batch.key.kind.sampler_tag());
|
||||
self.draw_instanced_batch(
|
||||
&batch.instances,
|
||||
projection,
|
||||
render_tasks,
|
||||
render_target,
|
||||
target_size,
|
||||
stats,
|
||||
alpha_batch_container.target_rect,
|
||||
VertexArrayKind::Primitive,
|
||||
&batch.key.textures,
|
||||
stats
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -2870,7 +2881,7 @@ impl Renderer {
|
|||
|
||||
let _gl = self.gpu_profile.start_marker("alpha batches");
|
||||
let transparent_sampler = self.gpu_profile.start_sampler(GPU_SAMPLER_TAG_TRANSPARENT);
|
||||
self.device.set_blend(false);
|
||||
self.device.set_blend(true);
|
||||
let mut prev_blend_mode = BlendMode::None;
|
||||
|
||||
for alpha_batch_container in &target.alpha_batch_containers {
|
||||
|
@ -2880,143 +2891,87 @@ impl Renderer {
|
|||
}
|
||||
|
||||
for batch in &alpha_batch_container.alpha_batches {
|
||||
match batch.key.kind {
|
||||
BatchKind::Transformable(transform_kind, TransformBatchKind::TextRun(glyph_format)) => {
|
||||
// Text run batches are handled by this special case branch.
|
||||
// In the case of subpixel text, we draw it as a two pass
|
||||
// effect, to ensure we can apply clip masks correctly.
|
||||
// In the future, there are several optimizations available:
|
||||
// 1) Use dual source blending where available (almost all recent hardware).
|
||||
// 2) Use frame buffer fetch where available (most modern hardware).
|
||||
// 3) Consider the old constant color blend method where no clip is applied.
|
||||
let _timer = self.gpu_profile.start_timer(GPU_TAG_PRIM_TEXT_RUN);
|
||||
|
||||
self.device.set_blend(true);
|
||||
// bind the proper shader first
|
||||
match batch.key.blend_mode {
|
||||
BlendMode::SubpixelDualSource => &mut self.shaders.ps_text_run_dual_source,
|
||||
_ => &mut self.shaders.ps_text_run,
|
||||
if batch.key.blend_mode != prev_blend_mode {
|
||||
match batch.key.blend_mode {
|
||||
BlendMode::None => {
|
||||
unreachable!("bug: opaque blend in alpha pass");
|
||||
}
|
||||
.get(glyph_format, transform_kind)
|
||||
.bind(
|
||||
&mut self.device,
|
||||
projection,
|
||||
&mut self.renderer_errors,
|
||||
);
|
||||
|
||||
match batch.key.blend_mode {
|
||||
BlendMode::Alpha => panic!("Attempt to composite non-premultiplied text primitives."),
|
||||
BlendMode::PremultipliedAlpha => {
|
||||
self.device.set_blend_mode_premultiplied_alpha();
|
||||
self.device.switch_mode(ShaderColorMode::from(glyph_format) as _);
|
||||
|
||||
self.draw_instanced_batch(
|
||||
&batch.instances,
|
||||
VertexArrayKind::Primitive,
|
||||
&batch.key.textures,
|
||||
stats,
|
||||
);
|
||||
}
|
||||
BlendMode::SubpixelDualSource => {
|
||||
self.device.set_blend_mode_subpixel_dual_source();
|
||||
self.device.switch_mode(ShaderColorMode::SubpixelDualSource as _);
|
||||
|
||||
self.draw_instanced_batch(
|
||||
&batch.instances,
|
||||
VertexArrayKind::Primitive,
|
||||
&batch.key.textures,
|
||||
stats,
|
||||
);
|
||||
}
|
||||
BlendMode::SubpixelConstantTextColor(color) => {
|
||||
self.device.set_blend_mode_subpixel_constant_text_color(color);
|
||||
self.device.switch_mode(ShaderColorMode::SubpixelConstantTextColor as _);
|
||||
|
||||
self.draw_instanced_batch(
|
||||
&batch.instances,
|
||||
VertexArrayKind::Primitive,
|
||||
&batch.key.textures,
|
||||
stats,
|
||||
);
|
||||
}
|
||||
BlendMode::SubpixelWithBgColor => {
|
||||
// Using the three pass "component alpha with font smoothing
|
||||
// background color" rendering technique:
|
||||
//
|
||||
// /webrender/doc/text-rendering.md
|
||||
//
|
||||
self.device.set_blend_mode_subpixel_with_bg_color_pass0();
|
||||
self.device.switch_mode(ShaderColorMode::SubpixelWithBgColorPass0 as _);
|
||||
|
||||
self.draw_instanced_batch(
|
||||
&batch.instances,
|
||||
VertexArrayKind::Primitive,
|
||||
&batch.key.textures,
|
||||
stats,
|
||||
);
|
||||
|
||||
self.device.set_blend_mode_subpixel_with_bg_color_pass1();
|
||||
self.device.switch_mode(ShaderColorMode::SubpixelWithBgColorPass1 as _);
|
||||
|
||||
// When drawing the 2nd and 3rd passes, we know that the VAO, textures etc
|
||||
// are all set up from the previous draw_instanced_batch call,
|
||||
// so just issue a draw call here to avoid re-uploading the
|
||||
// instances and re-binding textures etc.
|
||||
self.device
|
||||
.draw_indexed_triangles_instanced_u16(6, batch.instances.len() as i32);
|
||||
|
||||
self.device.set_blend_mode_subpixel_with_bg_color_pass2();
|
||||
self.device.switch_mode(ShaderColorMode::SubpixelWithBgColorPass2 as _);
|
||||
|
||||
self.device
|
||||
.draw_indexed_triangles_instanced_u16(6, batch.instances.len() as i32);
|
||||
}
|
||||
BlendMode::PremultipliedDestOut | BlendMode::None => {
|
||||
unreachable!("bug: bad blend mode for text");
|
||||
}
|
||||
BlendMode::Alpha => {
|
||||
self.device.set_blend_mode_alpha();
|
||||
}
|
||||
BlendMode::PremultipliedAlpha => {
|
||||
self.device.set_blend_mode_premultiplied_alpha();
|
||||
}
|
||||
BlendMode::PremultipliedDestOut => {
|
||||
self.device.set_blend_mode_premultiplied_dest_out();
|
||||
}
|
||||
BlendMode::SubpixelDualSource => {
|
||||
self.device.set_blend_mode_subpixel_dual_source();
|
||||
}
|
||||
BlendMode::SubpixelConstantTextColor(color) => {
|
||||
self.device.set_blend_mode_subpixel_constant_text_color(color);
|
||||
}
|
||||
BlendMode::SubpixelWithBgColor => {
|
||||
// Using the three pass "component alpha with font smoothing
|
||||
// background color" rendering technique:
|
||||
//
|
||||
// /webrender/doc/text-rendering.md
|
||||
//
|
||||
self.device.set_blend_mode_subpixel_with_bg_color_pass0();
|
||||
self.device.switch_mode(ShaderColorMode::SubpixelWithBgColorPass0 as _);
|
||||
}
|
||||
|
||||
prev_blend_mode = BlendMode::None;
|
||||
self.device.set_blend(false);
|
||||
}
|
||||
_ => {
|
||||
if batch.key.blend_mode != prev_blend_mode {
|
||||
match batch.key.blend_mode {
|
||||
BlendMode::None => {
|
||||
self.device.set_blend(false);
|
||||
}
|
||||
BlendMode::Alpha => {
|
||||
self.device.set_blend(true);
|
||||
self.device.set_blend_mode_alpha();
|
||||
}
|
||||
BlendMode::PremultipliedAlpha => {
|
||||
self.device.set_blend(true);
|
||||
self.device.set_blend_mode_premultiplied_alpha();
|
||||
}
|
||||
BlendMode::PremultipliedDestOut => {
|
||||
self.device.set_blend(true);
|
||||
self.device.set_blend_mode_premultiplied_dest_out();
|
||||
}
|
||||
BlendMode::SubpixelConstantTextColor(..) |
|
||||
BlendMode::SubpixelWithBgColor |
|
||||
BlendMode::SubpixelDualSource => {
|
||||
unreachable!("bug: subpx text handled earlier");
|
||||
}
|
||||
}
|
||||
prev_blend_mode = batch.key.blend_mode;
|
||||
}
|
||||
prev_blend_mode = batch.key.blend_mode;
|
||||
}
|
||||
|
||||
self.submit_batch(
|
||||
&batch.key,
|
||||
&batch.instances,
|
||||
projection,
|
||||
render_tasks,
|
||||
render_target,
|
||||
target_size,
|
||||
stats,
|
||||
alpha_batch_container.target_rect,
|
||||
);
|
||||
}
|
||||
self.shaders
|
||||
.get(&batch.key)
|
||||
.bind(
|
||||
&mut self.device, projection,
|
||||
&mut self.renderer_errors,
|
||||
);
|
||||
|
||||
// Handle special case readback for composites.
|
||||
if let BatchKind::Brush(BrushBatchKind::MixBlend { task_id, source_id, backdrop_id }) = batch.key.kind {
|
||||
// composites can't be grouped together because
|
||||
// they may overlap and affect each other.
|
||||
debug_assert_eq!(batch.instances.len(), 1);
|
||||
self.handle_readback_composite(
|
||||
render_target,
|
||||
target_size,
|
||||
alpha_batch_container.target_rect,
|
||||
&render_tasks[source_id],
|
||||
&render_tasks[task_id],
|
||||
&render_tasks[backdrop_id],
|
||||
);
|
||||
}
|
||||
|
||||
let _timer = self.gpu_profile.start_timer(batch.key.kind.sampler_tag());
|
||||
self.draw_instanced_batch(
|
||||
&batch.instances,
|
||||
VertexArrayKind::Primitive,
|
||||
&batch.key.textures,
|
||||
stats
|
||||
);
|
||||
|
||||
if batch.key.blend_mode == BlendMode::SubpixelWithBgColor {
|
||||
self.device.set_blend_mode_subpixel_with_bg_color_pass1();
|
||||
self.device.switch_mode(ShaderColorMode::SubpixelWithBgColorPass1 as _);
|
||||
|
||||
// When drawing the 2nd and 3rd passes, we know that the VAO, textures etc
|
||||
// are all set up from the previous draw_instanced_batch call,
|
||||
// so just issue a draw call here to avoid re-uploading the
|
||||
// instances and re-binding textures etc.
|
||||
self.device
|
||||
.draw_indexed_triangles_instanced_u16(6, batch.instances.len() as i32);
|
||||
|
||||
self.device.set_blend_mode_subpixel_with_bg_color_pass2();
|
||||
self.device.switch_mode(ShaderColorMode::SubpixelWithBgColorPass2 as _);
|
||||
|
||||
self.device
|
||||
.draw_indexed_triangles_instanced_u16(6, batch.instances.len() as i32);
|
||||
|
||||
prev_blend_mode = BlendMode::None;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -3157,7 +3112,7 @@ impl Renderer {
|
|||
.bind(&mut self.device, projection, &mut self.renderer_errors);
|
||||
self.draw_instanced_batch(
|
||||
&target.clip_batcher.border_clears,
|
||||
VertexArrayKind::Clip,
|
||||
VertexArrayKind::DashAndDot,
|
||||
&BatchTextures::no_texture(),
|
||||
stats,
|
||||
);
|
||||
|
@ -3176,7 +3131,7 @@ impl Renderer {
|
|||
.bind(&mut self.device, projection, &mut self.renderer_errors);
|
||||
self.draw_instanced_batch(
|
||||
&target.clip_batcher.borders,
|
||||
VertexArrayKind::Clip,
|
||||
VertexArrayKind::DashAndDot,
|
||||
&BatchTextures::no_texture(),
|
||||
stats,
|
||||
);
|
||||
|
@ -3909,6 +3864,7 @@ impl Renderer {
|
|||
self.device.delete_vao(self.vaos.prim_vao);
|
||||
self.device.delete_vao(self.vaos.clip_vao);
|
||||
self.device.delete_vao(self.vaos.blur_vao);
|
||||
self.device.delete_vao(self.vaos.dash_and_dot_vao);
|
||||
|
||||
#[cfg(feature = "debug_renderer")]
|
||||
{
|
||||
|
@ -4501,6 +4457,7 @@ fn get_vao<'a>(vertex_array_kind: VertexArrayKind,
|
|||
VertexArrayKind::Primitive => &vaos.prim_vao,
|
||||
VertexArrayKind::Clip => &vaos.clip_vao,
|
||||
VertexArrayKind::Blur => &vaos.blur_vao,
|
||||
VertexArrayKind::DashAndDot => &vaos.dash_and_dot_vao,
|
||||
VertexArrayKind::VectorStencil => &gpu_glyph_renderer.vector_stencil_vao,
|
||||
VertexArrayKind::VectorCover => &gpu_glyph_renderer.vector_cover_vao,
|
||||
}
|
||||
|
@ -4515,6 +4472,7 @@ fn get_vao<'a>(vertex_array_kind: VertexArrayKind,
|
|||
VertexArrayKind::Primitive => &vaos.prim_vao,
|
||||
VertexArrayKind::Clip => &vaos.clip_vao,
|
||||
VertexArrayKind::Blur => &vaos.blur_vao,
|
||||
VertexArrayKind::DashAndDot => &vaos.dash_and_dot_vao,
|
||||
VertexArrayKind::VectorStencil | VertexArrayKind::VectorCover => unreachable!(),
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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::{BuiltDisplayList, ColorF, DynamicProperties, Epoch, LayerSize, LayoutSize};
|
||||
use api::{BuiltDisplayList, ColorF, DynamicProperties, Epoch, LayoutSize};
|
||||
use api::{FilterOp, LayoutTransform, PipelineId, PropertyBinding, PropertyBindingId};
|
||||
use api::{ItemRange, MixBlendMode, StackingContext};
|
||||
use internal_types::FastHashMap;
|
||||
|
@ -95,7 +95,7 @@ impl SceneProperties {
|
|||
#[derive(Clone)]
|
||||
pub struct ScenePipeline {
|
||||
pub pipeline_id: PipelineId,
|
||||
pub viewport_size: LayerSize,
|
||||
pub viewport_size: LayoutSize,
|
||||
pub content_size: LayoutSize,
|
||||
pub background_color: Option<ColorF>,
|
||||
pub display_list: BuiltDisplayList,
|
||||
|
@ -130,7 +130,7 @@ impl Scene {
|
|||
epoch: Epoch,
|
||||
display_list: BuiltDisplayList,
|
||||
background_color: Option<ColorF>,
|
||||
viewport_size: LayerSize,
|
||||
viewport_size: LayoutSize,
|
||||
content_size: LayoutSize,
|
||||
) {
|
||||
let new_pipeline = ScenePipeline {
|
||||
|
|
|
@ -38,6 +38,7 @@ pub enum SceneBuilderResult {
|
|||
render: bool,
|
||||
result_tx: Sender<SceneSwapResult>,
|
||||
},
|
||||
Stopped,
|
||||
}
|
||||
|
||||
// Message from render backend to scene builder to indicate the
|
||||
|
@ -170,7 +171,12 @@ impl SceneBuilder {
|
|||
hooks.post_scene_swap(pipeline_info);
|
||||
}
|
||||
}
|
||||
SceneBuilderRequest::Stop => { return false; }
|
||||
SceneBuilderRequest::Stop => {
|
||||
self.tx.send(SceneBuilderResult::Stopped).unwrap();
|
||||
// We don't need to send a WakeUp to api_tx because we only
|
||||
// get the Stop when the RenderBackend loop is exiting.
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
true
|
||||
|
|
|
@ -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::{BorderRadius, ClipMode, LayerPoint, LayerPointAu, LayerRect, LayerSize};
|
||||
use api::{BorderRadius, ClipMode, LayoutPoint, LayoutPointAu, LayoutRect, LayoutSize};
|
||||
use app_units::Au;
|
||||
use prim_store::EdgeAaSegmentMask;
|
||||
use std::{cmp, usize};
|
||||
|
@ -19,7 +19,7 @@ bitflags! {
|
|||
// The segment builder outputs a list of these segments.
|
||||
#[derive(Debug, PartialEq)]
|
||||
pub struct Segment {
|
||||
pub rect: LayerRect,
|
||||
pub rect: LayoutRect,
|
||||
pub has_mask: bool,
|
||||
pub edge_flags: EdgeAaSegmentMask,
|
||||
pub region_x: usize,
|
||||
|
@ -143,14 +143,14 @@ impl Event {
|
|||
// a clip in/out rect, or a mask region).
|
||||
#[derive(Debug)]
|
||||
struct Item {
|
||||
rect: LayerRect,
|
||||
rect: LayoutRect,
|
||||
mode: Option<ClipMode>,
|
||||
flags: ItemFlags,
|
||||
}
|
||||
|
||||
impl Item {
|
||||
fn new(
|
||||
rect: LayerRect,
|
||||
rect: LayoutRect,
|
||||
mode: Option<ClipMode>,
|
||||
has_mask: bool,
|
||||
) -> Item {
|
||||
|
@ -174,17 +174,17 @@ struct ItemIndex(usize);
|
|||
// The main public interface to the segment module.
|
||||
pub struct SegmentBuilder {
|
||||
items: Vec<Item>,
|
||||
inner_rect: Option<LayerRect>,
|
||||
bounding_rect: Option<LayerRect>,
|
||||
inner_rect: Option<LayoutRect>,
|
||||
bounding_rect: Option<LayoutRect>,
|
||||
}
|
||||
|
||||
impl SegmentBuilder {
|
||||
// Create a new segment builder, supplying the primitive
|
||||
// local rect and associated local clip rect.
|
||||
pub fn new(
|
||||
local_rect: LayerRect,
|
||||
inner_rect: Option<LayerRect>,
|
||||
local_clip_rect: LayerRect,
|
||||
local_rect: LayoutRect,
|
||||
inner_rect: Option<LayoutRect>,
|
||||
local_clip_rect: LayoutRect,
|
||||
) -> SegmentBuilder {
|
||||
let mut builder = SegmentBuilder {
|
||||
items: Vec::new(),
|
||||
|
@ -206,8 +206,8 @@ impl SegmentBuilder {
|
|||
// such as dashed and dotted borders in the future.
|
||||
pub fn push_mask_region(
|
||||
&mut self,
|
||||
outer_rect: LayerRect,
|
||||
inner_rect: LayerRect,
|
||||
outer_rect: LayoutRect,
|
||||
inner_rect: LayoutRect,
|
||||
inner_clip_mode: Option<ClipMode>,
|
||||
) {
|
||||
debug_assert!(outer_rect.contains_rect(&inner_rect));
|
||||
|
@ -218,37 +218,37 @@ impl SegmentBuilder {
|
|||
let p3 = outer_rect.bottom_right();
|
||||
|
||||
let segments = &[
|
||||
LayerRect::new(
|
||||
LayerPoint::new(p0.x, p0.y),
|
||||
LayerSize::new(p1.x - p0.x, p1.y - p0.y),
|
||||
LayoutRect::new(
|
||||
LayoutPoint::new(p0.x, p0.y),
|
||||
LayoutSize::new(p1.x - p0.x, p1.y - p0.y),
|
||||
),
|
||||
LayerRect::new(
|
||||
LayerPoint::new(p2.x, p0.y),
|
||||
LayerSize::new(p3.x - p2.x, p1.y - p0.y),
|
||||
LayoutRect::new(
|
||||
LayoutPoint::new(p2.x, p0.y),
|
||||
LayoutSize::new(p3.x - p2.x, p1.y - p0.y),
|
||||
),
|
||||
LayerRect::new(
|
||||
LayerPoint::new(p2.x, p2.y),
|
||||
LayerSize::new(p3.x - p2.x, p3.y - p2.y),
|
||||
LayoutRect::new(
|
||||
LayoutPoint::new(p2.x, p2.y),
|
||||
LayoutSize::new(p3.x - p2.x, p3.y - p2.y),
|
||||
),
|
||||
LayerRect::new(
|
||||
LayerPoint::new(p0.x, p2.y),
|
||||
LayerSize::new(p1.x - p0.x, p3.y - p2.y),
|
||||
LayoutRect::new(
|
||||
LayoutPoint::new(p0.x, p2.y),
|
||||
LayoutSize::new(p1.x - p0.x, p3.y - p2.y),
|
||||
),
|
||||
LayerRect::new(
|
||||
LayerPoint::new(p1.x, p0.y),
|
||||
LayerSize::new(p2.x - p1.x, p1.y - p0.y),
|
||||
LayoutRect::new(
|
||||
LayoutPoint::new(p1.x, p0.y),
|
||||
LayoutSize::new(p2.x - p1.x, p1.y - p0.y),
|
||||
),
|
||||
LayerRect::new(
|
||||
LayerPoint::new(p2.x, p1.y),
|
||||
LayerSize::new(p3.x - p2.x, p2.y - p1.y),
|
||||
LayoutRect::new(
|
||||
LayoutPoint::new(p2.x, p1.y),
|
||||
LayoutSize::new(p3.x - p2.x, p2.y - p1.y),
|
||||
),
|
||||
LayerRect::new(
|
||||
LayerPoint::new(p1.x, p2.y),
|
||||
LayerSize::new(p2.x - p1.x, p3.y - p2.y),
|
||||
LayoutRect::new(
|
||||
LayoutPoint::new(p1.x, p2.y),
|
||||
LayoutSize::new(p2.x - p1.x, p3.y - p2.y),
|
||||
),
|
||||
LayerRect::new(
|
||||
LayerPoint::new(p0.x, p1.y),
|
||||
LayerSize::new(p1.x - p0.x, p2.y - p1.y),
|
||||
LayoutRect::new(
|
||||
LayoutPoint::new(p0.x, p1.y),
|
||||
LayoutSize::new(p1.x - p0.x, p2.y - p1.y),
|
||||
),
|
||||
];
|
||||
|
||||
|
@ -273,7 +273,7 @@ impl SegmentBuilder {
|
|||
// If radius is None, it's a simple rect.
|
||||
pub fn push_clip_rect(
|
||||
&mut self,
|
||||
rect: LayerRect,
|
||||
rect: LayoutRect,
|
||||
radius: Option<BorderRadius>,
|
||||
mode: ClipMode,
|
||||
) {
|
||||
|
@ -298,21 +298,21 @@ impl SegmentBuilder {
|
|||
let p3 = rect.bottom_right();
|
||||
|
||||
let corner_segments = &[
|
||||
LayerRect::new(
|
||||
LayerPoint::new(p0.x, p0.y),
|
||||
LayerSize::new(p1.x - p0.x, p1.y - p0.y),
|
||||
LayoutRect::new(
|
||||
LayoutPoint::new(p0.x, p0.y),
|
||||
LayoutSize::new(p1.x - p0.x, p1.y - p0.y),
|
||||
),
|
||||
LayerRect::new(
|
||||
LayerPoint::new(p2.x, p0.y),
|
||||
LayerSize::new(p3.x - p2.x, p1.y - p0.y),
|
||||
LayoutRect::new(
|
||||
LayoutPoint::new(p2.x, p0.y),
|
||||
LayoutSize::new(p3.x - p2.x, p1.y - p0.y),
|
||||
),
|
||||
LayerRect::new(
|
||||
LayerPoint::new(p2.x, p2.y),
|
||||
LayerSize::new(p3.x - p2.x, p3.y - p2.y),
|
||||
LayoutRect::new(
|
||||
LayoutPoint::new(p2.x, p2.y),
|
||||
LayoutSize::new(p3.x - p2.x, p3.y - p2.y),
|
||||
),
|
||||
LayerRect::new(
|
||||
LayerPoint::new(p0.x, p2.y),
|
||||
LayerSize::new(p1.x - p0.x, p3.y - p2.y),
|
||||
LayoutRect::new(
|
||||
LayoutPoint::new(p0.x, p2.y),
|
||||
LayoutSize::new(p1.x - p0.x, p3.y - p2.y),
|
||||
),
|
||||
];
|
||||
|
||||
|
@ -325,25 +325,25 @@ impl SegmentBuilder {
|
|||
}
|
||||
|
||||
let other_segments = &[
|
||||
LayerRect::new(
|
||||
LayerPoint::new(p1.x, p0.y),
|
||||
LayerSize::new(p2.x - p1.x, p1.y - p0.y),
|
||||
LayoutRect::new(
|
||||
LayoutPoint::new(p1.x, p0.y),
|
||||
LayoutSize::new(p2.x - p1.x, p1.y - p0.y),
|
||||
),
|
||||
LayerRect::new(
|
||||
LayerPoint::new(p2.x, p1.y),
|
||||
LayerSize::new(p3.x - p2.x, p2.y - p1.y),
|
||||
LayoutRect::new(
|
||||
LayoutPoint::new(p2.x, p1.y),
|
||||
LayoutSize::new(p3.x - p2.x, p2.y - p1.y),
|
||||
),
|
||||
LayerRect::new(
|
||||
LayerPoint::new(p1.x, p2.y),
|
||||
LayerSize::new(p2.x - p1.x, p3.y - p2.y),
|
||||
LayoutRect::new(
|
||||
LayoutPoint::new(p1.x, p2.y),
|
||||
LayoutSize::new(p2.x - p1.x, p3.y - p2.y),
|
||||
),
|
||||
LayerRect::new(
|
||||
LayerPoint::new(p0.x, p1.y),
|
||||
LayerSize::new(p1.x - p0.x, p2.y - p1.y),
|
||||
LayoutRect::new(
|
||||
LayoutPoint::new(p0.x, p1.y),
|
||||
LayoutSize::new(p1.x - p0.x, p2.y - p1.y),
|
||||
),
|
||||
LayerRect::new(
|
||||
LayerPoint::new(p1.x, p1.y),
|
||||
LayerSize::new(p2.x - p1.x, p2.y - p1.y),
|
||||
LayoutRect::new(
|
||||
LayoutPoint::new(p1.x, p1.y),
|
||||
LayoutSize::new(p2.x - p1.x, p2.y - p1.y),
|
||||
),
|
||||
];
|
||||
|
||||
|
@ -420,12 +420,12 @@ impl SegmentBuilder {
|
|||
// Get the minimal bounding rect in app units. We will
|
||||
// work in fixed point in order to avoid float precision
|
||||
// error while handling events.
|
||||
let p0 = LayerPointAu::new(
|
||||
let p0 = LayoutPointAu::new(
|
||||
Au::from_f32_px(bounding_rect.origin.x),
|
||||
Au::from_f32_px(bounding_rect.origin.y),
|
||||
);
|
||||
|
||||
let p1 = LayerPointAu::new(
|
||||
let p1 = LayoutPointAu::new(
|
||||
Au::from_f32_px(bounding_rect.origin.x + bounding_rect.size.width),
|
||||
Au::from_f32_px(bounding_rect.origin.y + bounding_rect.size.height),
|
||||
);
|
||||
|
@ -558,12 +558,12 @@ fn emit_segment_if_needed(
|
|||
}
|
||||
}
|
||||
|
||||
let segment_rect = LayerRect::new(
|
||||
LayerPoint::new(
|
||||
let segment_rect = LayoutRect::new(
|
||||
LayoutPoint::new(
|
||||
x0.to_f32_px(),
|
||||
y0.to_f32_px(),
|
||||
),
|
||||
LayerSize::new(
|
||||
LayoutSize::new(
|
||||
(x1 - x0).to_f32_px(),
|
||||
(y1 - y0).to_f32_px(),
|
||||
),
|
||||
|
@ -580,15 +580,15 @@ fn emit_segment_if_needed(
|
|||
|
||||
#[cfg(test)]
|
||||
mod test {
|
||||
use api::{BorderRadius, ClipMode, LayerPoint, LayerRect, LayerSize};
|
||||
use api::{BorderRadius, ClipMode, LayoutPoint, LayoutRect, LayoutSize};
|
||||
use prim_store::EdgeAaSegmentMask;
|
||||
use super::{Segment, SegmentBuilder};
|
||||
use std::cmp;
|
||||
|
||||
fn rect(x0: f32, y0: f32, x1: f32, y1: f32) -> LayerRect {
|
||||
LayerRect::new(
|
||||
LayerPoint::new(x0, y0),
|
||||
LayerSize::new(x1-x0, y1-y0),
|
||||
fn rect(x0: f32, y0: f32, x1: f32, y1: f32) -> LayoutRect {
|
||||
LayoutRect::new(
|
||||
LayoutPoint::new(x0, y0),
|
||||
LayoutSize::new(x1-x0, y1-y0),
|
||||
)
|
||||
}
|
||||
|
||||
|
@ -614,9 +614,9 @@ mod test {
|
|||
edge_flags: Option<EdgeAaSegmentMask>,
|
||||
) -> Segment {
|
||||
Segment {
|
||||
rect: LayerRect::new(
|
||||
LayerPoint::new(x0, y0),
|
||||
LayerSize::new(x1-x0, y1-y0),
|
||||
rect: LayoutRect::new(
|
||||
LayoutPoint::new(x0, y0),
|
||||
LayoutSize::new(x1-x0, y1-y0),
|
||||
),
|
||||
has_mask,
|
||||
edge_flags: edge_flags.unwrap_or(EdgeAaSegmentMask::empty()),
|
||||
|
@ -637,10 +637,10 @@ mod test {
|
|||
}
|
||||
|
||||
fn seg_test(
|
||||
local_rect: LayerRect,
|
||||
inner_rect: Option<LayerRect>,
|
||||
local_clip_rect: LayerRect,
|
||||
clips: &[(LayerRect, Option<BorderRadius>, ClipMode)],
|
||||
local_rect: LayoutRect,
|
||||
inner_rect: Option<LayoutRect>,
|
||||
local_clip_rect: LayoutRect,
|
||||
clips: &[(LayoutRect, Option<BorderRadius>, ClipMode)],
|
||||
expected_segments: &mut [Segment]
|
||||
) {
|
||||
let mut sb = SegmentBuilder::new(
|
||||
|
|
|
@ -53,6 +53,7 @@ pub const IMAGE_BUFFER_KINDS: [ImageBufferKind; 4] = [
|
|||
const TRANSFORM_FEATURE: &str = "TRANSFORM";
|
||||
const ALPHA_FEATURE: &str = "ALPHA_PASS";
|
||||
const DITHERING_FEATURE: &str = "DITHERING";
|
||||
const DUAL_SOURCE_FEATURE: &str = "DUAL_SOURCE_BLENDING";
|
||||
|
||||
pub(crate) enum ShaderKind {
|
||||
Primitive,
|
||||
|
@ -181,6 +182,7 @@ impl LazilyCompiledShader {
|
|||
struct BrushShader {
|
||||
opaque: LazilyCompiledShader,
|
||||
alpha: LazilyCompiledShader,
|
||||
dual_source: Option<LazilyCompiledShader>,
|
||||
}
|
||||
|
||||
impl BrushShader {
|
||||
|
@ -189,6 +191,7 @@ impl BrushShader {
|
|||
device: &mut Device,
|
||||
features: &[&'static str],
|
||||
precache: bool,
|
||||
dual_source: bool,
|
||||
) -> Result<Self, ShaderError> {
|
||||
let opaque = LazilyCompiledShader::new(
|
||||
ShaderKind::Brush,
|
||||
|
@ -209,7 +212,28 @@ impl BrushShader {
|
|||
precache,
|
||||
)?;
|
||||
|
||||
Ok(BrushShader { opaque, alpha })
|
||||
let dual_source = if dual_source {
|
||||
let mut dual_source_features = alpha_features.to_vec();
|
||||
dual_source_features.push(DUAL_SOURCE_FEATURE);
|
||||
|
||||
let shader = LazilyCompiledShader::new(
|
||||
ShaderKind::Brush,
|
||||
name,
|
||||
&dual_source_features,
|
||||
device,
|
||||
precache,
|
||||
)?;
|
||||
|
||||
Some(shader)
|
||||
} else {
|
||||
None
|
||||
};
|
||||
|
||||
Ok(BrushShader {
|
||||
opaque,
|
||||
alpha,
|
||||
dual_source,
|
||||
})
|
||||
}
|
||||
|
||||
fn get(&mut self, blend_mode: BlendMode) -> &mut LazilyCompiledShader {
|
||||
|
@ -218,15 +242,22 @@ impl BrushShader {
|
|||
BlendMode::Alpha |
|
||||
BlendMode::PremultipliedAlpha |
|
||||
BlendMode::PremultipliedDestOut |
|
||||
BlendMode::SubpixelDualSource |
|
||||
BlendMode::SubpixelConstantTextColor(..) |
|
||||
BlendMode::SubpixelWithBgColor => &mut self.alpha,
|
||||
BlendMode::SubpixelDualSource => {
|
||||
self.dual_source
|
||||
.as_mut()
|
||||
.expect("bug: no dual source shader loaded")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn deinit(self, device: &mut Device) {
|
||||
self.opaque.deinit(device);
|
||||
self.alpha.deinit(device);
|
||||
if let Some(dual_source) = self.dual_source {
|
||||
dual_source.deinit(device);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -369,6 +400,7 @@ fn create_prim_shader(
|
|||
VertexArrayKind::Primitive => desc::PRIM_INSTANCES,
|
||||
VertexArrayKind::Blur => desc::BLUR,
|
||||
VertexArrayKind::Clip => desc::CLIP,
|
||||
VertexArrayKind::DashAndDot => desc::BORDER_CORNER_DASH_AND_DOT,
|
||||
VertexArrayKind::VectorStencil => desc::VECTOR_STENCIL,
|
||||
VertexArrayKind::VectorCover => desc::VECTOR_COVER,
|
||||
};
|
||||
|
@ -487,6 +519,7 @@ impl Shaders {
|
|||
device,
|
||||
&[],
|
||||
options.precache_shaders,
|
||||
false,
|
||||
)?;
|
||||
|
||||
let brush_blend = BrushShader::new(
|
||||
|
@ -494,6 +527,7 @@ impl Shaders {
|
|||
device,
|
||||
&[],
|
||||
options.precache_shaders,
|
||||
false,
|
||||
)?;
|
||||
|
||||
let brush_mix_blend = BrushShader::new(
|
||||
|
@ -501,6 +535,7 @@ impl Shaders {
|
|||
device,
|
||||
&[],
|
||||
options.precache_shaders,
|
||||
false,
|
||||
)?;
|
||||
|
||||
let brush_radial_gradient = BrushShader::new(
|
||||
|
@ -512,6 +547,7 @@ impl Shaders {
|
|||
&[]
|
||||
},
|
||||
options.precache_shaders,
|
||||
false,
|
||||
)?;
|
||||
|
||||
let brush_linear_gradient = BrushShader::new(
|
||||
|
@ -523,6 +559,7 @@ impl Shaders {
|
|||
&[]
|
||||
},
|
||||
options.precache_shaders,
|
||||
false,
|
||||
)?;
|
||||
|
||||
let cs_blur_a8 = LazilyCompiledShader::new(
|
||||
|
@ -619,6 +656,7 @@ impl Shaders {
|
|||
device,
|
||||
&image_features,
|
||||
options.precache_shaders,
|
||||
true,
|
||||
)?);
|
||||
}
|
||||
image_features.clear();
|
||||
|
@ -654,6 +692,7 @@ impl Shaders {
|
|||
device,
|
||||
&yuv_features,
|
||||
options.precache_shaders,
|
||||
false,
|
||||
)?;
|
||||
let index = Self::get_yuv_shader_index(
|
||||
*image_buffer_kind,
|
||||
|
@ -765,8 +804,16 @@ impl Shaders {
|
|||
}
|
||||
BatchKind::Transformable(transform_kind, batch_kind) => {
|
||||
let prim_shader = match batch_kind {
|
||||
TransformBatchKind::TextRun(..) => {
|
||||
unreachable!("bug: text batches are special cased");
|
||||
TransformBatchKind::TextRun(glyph_format) => {
|
||||
let text_shader = match key.blend_mode {
|
||||
BlendMode::SubpixelDualSource => {
|
||||
&mut self.ps_text_run_dual_source
|
||||
}
|
||||
_ => {
|
||||
&mut self.ps_text_run
|
||||
}
|
||||
};
|
||||
return text_shader.get(glyph_format, transform_kind);
|
||||
}
|
||||
TransformBatchKind::Image(image_buffer_kind) => {
|
||||
self.ps_image[image_buffer_kind as usize]
|
||||
|
|
|
@ -235,7 +235,7 @@ pub struct TextureCache {
|
|||
|
||||
// A list of updates that need to be applied to the
|
||||
// texture cache in the rendering thread this frame.
|
||||
#[cfg_attr(feature = "serde", serde(skip))]
|
||||
#[cfg_attr(all(feature = "serde", any(feature = "capture", feature = "replay")), serde(skip))]
|
||||
pending_updates: TextureUpdateList,
|
||||
|
||||
// The current frame ID. Used for cache eviction policies.
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
use api::{ColorF, DeviceIntPoint, DeviceIntRect, DeviceIntSize, DevicePixelScale, DeviceUintPoint};
|
||||
use api::{DeviceUintRect, DeviceUintSize, DocumentLayer, FilterOp, ImageFormat, LayerRect};
|
||||
use api::{DeviceUintRect, DeviceUintSize, DocumentLayer, FilterOp, ImageFormat, LayoutRect};
|
||||
use api::{MixBlendMode, PipelineId};
|
||||
use batch::{AlphaBatchBuilder, AlphaBatchContainer, ClipBatcher, resolve_image};
|
||||
use clip::{ClipStore};
|
||||
|
@ -34,7 +34,7 @@ const MIN_TARGET_SIZE: u32 = 2048;
|
|||
pub struct ScrollbarPrimitive {
|
||||
pub scroll_frame_index: ClipScrollNodeIndex,
|
||||
pub prim_index: PrimitiveIndex,
|
||||
pub frame_rect: LayerRect,
|
||||
pub frame_rect: LayoutRect,
|
||||
}
|
||||
|
||||
#[derive(Debug, Copy, Clone)]
|
||||
|
@ -938,7 +938,7 @@ pub struct Frame {
|
|||
pub profile_counters: FrameProfileCounters,
|
||||
|
||||
pub node_data: Vec<ClipScrollNodeData>,
|
||||
pub clip_chain_local_clip_rects: Vec<LayerRect>,
|
||||
pub clip_chain_local_clip_rects: Vec<LayoutRect>,
|
||||
pub render_tasks: RenderTaskTree,
|
||||
|
||||
/// The GPU cache frame that the contents of Self depend on
|
||||
|
|
|
@ -3,8 +3,8 @@
|
|||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
use api::{BorderRadius, DeviceIntPoint, DeviceIntRect, DeviceIntSize, DevicePixelScale};
|
||||
use api::{DevicePoint, DeviceRect, DeviceSize, LayerPixel, LayerPoint, LayerRect, LayerSize};
|
||||
use api::{LayoutPixel, WorldPixel, WorldRect};
|
||||
use api::{DevicePoint, DeviceRect, DeviceSize, LayoutPixel, LayoutPoint, LayoutRect, LayoutSize};
|
||||
use api::{WorldPixel, WorldRect};
|
||||
use euclid::{Point2D, Rect, Size2D, TypedPoint2D, TypedPoint3D, TypedRect, TypedSize2D};
|
||||
use euclid::{TypedTransform2D, TypedTransform3D, TypedVector2D};
|
||||
use num_traits::Zero;
|
||||
|
@ -157,8 +157,8 @@ pub fn lerp(a: f32, b: f32, t: f32) -> f32 {
|
|||
}
|
||||
|
||||
pub fn calculate_screen_bounding_rect(
|
||||
transform: &LayerToWorldFastTransform,
|
||||
rect: &LayerRect,
|
||||
transform: &LayoutToWorldFastTransform,
|
||||
rect: &LayoutRect,
|
||||
device_pixel_scale: DevicePixelScale,
|
||||
) -> DeviceIntRect {
|
||||
let points = [
|
||||
|
@ -309,11 +309,11 @@ pub trait MaxRect {
|
|||
fn max_rect() -> Self;
|
||||
}
|
||||
|
||||
impl MaxRect for LayerRect {
|
||||
impl MaxRect for LayoutRect {
|
||||
fn max_rect() -> Self {
|
||||
LayerRect::new(
|
||||
LayerPoint::new(f32::MIN / 2.0, f32::MIN / 2.0),
|
||||
LayerSize::new(f32::MAX, f32::MAX),
|
||||
LayoutRect::new(
|
||||
LayoutPoint::new(f32::MIN / 2.0, f32::MIN / 2.0),
|
||||
LayoutSize::new(f32::MAX, f32::MAX),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
@ -556,6 +556,5 @@ impl<Src, Dst> From<TypedVector2D<f32, Src>> for FastTransform<Src, Dst> {
|
|||
}
|
||||
|
||||
pub type LayoutFastTransform = FastTransform<LayoutPixel, LayoutPixel>;
|
||||
pub type LayerFastTransform = FastTransform<LayerPixel, LayerPixel>;
|
||||
pub type LayerToWorldFastTransform = FastTransform<LayerPixel, WorldPixel>;
|
||||
pub type WorldToLayerFastTransform = FastTransform<WorldPixel, LayerPixel>;
|
||||
pub type LayoutToWorldFastTransform = FastTransform<LayoutPixel, WorldPixel>;
|
||||
pub type WorldToLayoutFastTransform = FastTransform<WorldPixel, LayoutPixel>;
|
|
@ -219,8 +219,6 @@ impl Transaction {
|
|||
/// Supplies a new frame to WebRender.
|
||||
///
|
||||
/// Non-blocking, it notifies a worker process which processes the display list.
|
||||
/// When it's done and a RenderNotifier has been set in `webrender::Renderer`,
|
||||
/// [new_frame_ready()][notifier] gets called.
|
||||
///
|
||||
/// Note: Scrolling doesn't require an own Frame.
|
||||
///
|
||||
|
@ -236,8 +234,6 @@ impl Transaction {
|
|||
/// * `preserve_frame_state`: If a previous frame exists which matches this pipeline
|
||||
/// id, this setting determines if frame state (such as scrolling
|
||||
/// position) should be preserved for this new display list.
|
||||
///
|
||||
/// [notifier]: trait.RenderNotifier.html#tymethod.new_frame_ready
|
||||
pub fn set_display_list(
|
||||
&mut self,
|
||||
epoch: Epoch,
|
||||
|
@ -313,7 +309,13 @@ impl Transaction {
|
|||
self.frame_ops.push(FrameMsg::SetPan(pan));
|
||||
}
|
||||
|
||||
/// Generate a new frame.
|
||||
/// Generate a new frame. When it's done and a RenderNotifier has been set
|
||||
/// in `webrender::Renderer`, [new_frame_ready()][notifier] gets called.
|
||||
/// Note that the notifier is called even if the frame generation was a
|
||||
/// no-op; the arguments passed to `new_frame_ready` will provide information
|
||||
/// as to what happened.
|
||||
///
|
||||
/// [notifier]: trait.RenderNotifier.html#tymethod.new_frame_ready
|
||||
pub fn generate_frame(&mut self) {
|
||||
self.generate_frame = true;
|
||||
}
|
||||
|
@ -1107,7 +1109,7 @@ pub struct DynamicProperties {
|
|||
pub trait RenderNotifier: Send {
|
||||
fn clone(&self) -> Box<RenderNotifier>;
|
||||
fn wake_up(&self);
|
||||
fn new_document_ready(&self, DocumentId, scrolled: bool, composite_needed: bool);
|
||||
fn new_frame_ready(&self, DocumentId, scrolled: bool, composite_needed: bool);
|
||||
fn external_event(&self, _evt: ExternalEvent) {
|
||||
unimplemented!()
|
||||
}
|
||||
|
|
|
@ -63,6 +63,16 @@ impl ColorF {
|
|||
}
|
||||
}
|
||||
|
||||
// Scale the alpha by a given factor.
|
||||
pub fn scale_alpha(&self, scale: f32) -> Self {
|
||||
ColorF {
|
||||
r: self.r,
|
||||
g: self.g,
|
||||
b: self.b,
|
||||
a: self.a * scale,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn to_array(&self) -> [f32; 4] {
|
||||
[self.r, self.g, self.b, self.a]
|
||||
}
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
use GlyphInstance;
|
||||
use euclid::{SideOffsets2D, TypedRect};
|
||||
use std::ops::Not;
|
||||
use {ColorF, FontInstanceKey, GlyphOptions, ImageKey, LayerPixel, LayoutPixel, LayoutPoint};
|
||||
use {ColorF, FontInstanceKey, GlyphOptions, ImageKey, LayoutPixel, LayoutPoint};
|
||||
use {LayoutRect, LayoutSize, LayoutTransform, LayoutVector2D, PipelineId, PropertyBinding};
|
||||
|
||||
|
||||
|
@ -69,14 +69,14 @@ pub struct PrimitiveInfo<T> {
|
|||
pub tag: Option<ItemTag>,
|
||||
}
|
||||
|
||||
impl LayerPrimitiveInfo {
|
||||
pub fn new(rect: TypedRect<f32, LayerPixel>) -> Self {
|
||||
impl LayoutPrimitiveInfo {
|
||||
pub fn new(rect: TypedRect<f32, LayoutPixel>) -> Self {
|
||||
Self::with_clip_rect(rect, rect)
|
||||
}
|
||||
|
||||
pub fn with_clip_rect(
|
||||
rect: TypedRect<f32, LayerPixel>,
|
||||
clip_rect: TypedRect<f32, LayerPixel>,
|
||||
rect: TypedRect<f32, LayoutPixel>,
|
||||
clip_rect: TypedRect<f32, LayoutPixel>,
|
||||
) -> Self {
|
||||
PrimitiveInfo {
|
||||
rect,
|
||||
|
@ -88,7 +88,6 @@ impl LayerPrimitiveInfo {
|
|||
}
|
||||
|
||||
pub type LayoutPrimitiveInfo = PrimitiveInfo<LayoutPixel>;
|
||||
pub type LayerPrimitiveInfo = PrimitiveInfo<LayerPixel>;
|
||||
|
||||
#[repr(u8)]
|
||||
#[derive(Clone, Copy, Debug, Deserialize, PartialEq, Serialize)]
|
||||
|
@ -668,12 +667,12 @@ impl LocalClip {
|
|||
match *self {
|
||||
LocalClip::Rect(clip_rect) => {
|
||||
LocalClip::Rect(
|
||||
clip_rect.intersection(rect).unwrap_or(LayoutRect::zero())
|
||||
clip_rect.intersection(rect).unwrap_or_else(LayoutRect::zero)
|
||||
)
|
||||
}
|
||||
LocalClip::RoundedRect(clip_rect, complex) => {
|
||||
LocalClip::RoundedRect(
|
||||
clip_rect.intersection(rect).unwrap_or(LayoutRect::zero()),
|
||||
clip_rect.intersection(rect).unwrap_or_else(LayoutRect::zero),
|
||||
complex,
|
||||
)
|
||||
}
|
||||
|
|
|
@ -17,7 +17,7 @@ use {AlphaType, BorderDetails, BorderDisplayItem, BorderRadius, BorderWidths, Bo
|
|||
use {BoxShadowDisplayItem, ClipAndScrollInfo, ClipChainId, ClipChainItem, ClipDisplayItem, ClipId};
|
||||
use {ColorF, ComplexClipRegion, DisplayItem, ExtendMode, ExternalScrollId, FilterOp};
|
||||
use {FontInstanceKey, GlyphInstance, GlyphOptions, GlyphRasterSpace, Gradient, GradientDisplayItem, GradientStop};
|
||||
use {IframeDisplayItem, ImageDisplayItem, ImageKey, ImageMask, ImageRendering, LayerPrimitiveInfo};
|
||||
use {IframeDisplayItem, ImageDisplayItem, ImageKey, ImageMask, ImageRendering};
|
||||
use {LayoutPoint, LayoutPrimitiveInfo, LayoutRect, LayoutSize, LayoutTransform, LayoutVector2D};
|
||||
use {LineDisplayItem, LineOrientation, LineStyle, MixBlendMode, PipelineId, PropertyBinding};
|
||||
use {PushStackingContextDisplayItem, RadialGradient, RadialGradientDisplayItem};
|
||||
|
@ -331,9 +331,9 @@ impl<'a, 'b> DisplayItemRef<'a, 'b> {
|
|||
self.iter.cur_item.info.rect
|
||||
}
|
||||
|
||||
pub fn get_layer_primitive_info(&self, offset: &LayoutVector2D) -> LayerPrimitiveInfo {
|
||||
pub fn get_layout_primitive_info(&self, offset: &LayoutVector2D) -> LayoutPrimitiveInfo {
|
||||
let info = self.iter.cur_item.info;
|
||||
LayerPrimitiveInfo {
|
||||
LayoutPrimitiveInfo {
|
||||
rect: info.rect.translate(offset),
|
||||
clip_rect: info.clip_rect.translate(offset),
|
||||
is_backface_visible: info.is_backface_visible,
|
||||
|
|
|
@ -123,7 +123,7 @@ mod serde_image_data_raw {
|
|||
use std::sync::Arc;
|
||||
use serde::{Deserializer, Serializer};
|
||||
|
||||
pub fn serialize<'a, S: Serializer>(bytes: &'a Arc<Vec<u8>>, serializer: S) -> Result<S::Ok, S::Error> {
|
||||
pub fn serialize<S: Serializer>(bytes: &Arc<Vec<u8>>, serializer: S) -> Result<S::Ok, S::Error> {
|
||||
serde_bytes::serialize(bytes.as_slice(), serializer)
|
||||
}
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#![cfg_attr(feature = "nightly", feature(nonzero))]
|
||||
#![cfg_attr(feature = "cargo-clippy", allow(too_many_arguments, float_cmp))]
|
||||
#![cfg_attr(feature = "cargo-clippy", allow(float_cmp, too_many_arguments, unreadable_literal))]
|
||||
|
||||
extern crate app_units;
|
||||
extern crate bincode;
|
||||
|
|
|
@ -45,26 +45,15 @@ pub type PictureIntPoint = TypedPoint2D<i32, PicturePixel>;
|
|||
pub type PictureIntSize = TypedSize2D<i32, PicturePixel>;
|
||||
|
||||
/// Geometry in a stacking context's local coordinate space (logical pixels).
|
||||
///
|
||||
/// For now layout pixels are equivalent to layer pixels, but it may change.
|
||||
pub type LayoutPixel = LayerPixel;
|
||||
|
||||
pub type LayoutRect = LayerRect;
|
||||
pub type LayoutPoint = LayerPoint;
|
||||
pub type LayoutVector2D = LayerVector2D;
|
||||
pub type LayoutVector3D = LayerVector3D;
|
||||
pub type LayoutSize = LayerSize;
|
||||
|
||||
/// Geometry in a layer's local coordinate space (logical pixels).
|
||||
#[derive(Hash, Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Deserialize, Serialize)]
|
||||
pub struct LayerPixel;
|
||||
pub struct LayoutPixel;
|
||||
|
||||
pub type LayerRect = TypedRect<f32, LayerPixel>;
|
||||
pub type LayerPoint = TypedPoint2D<f32, LayerPixel>;
|
||||
pub type LayerPoint3D = TypedPoint3D<f32, LayerPixel>;
|
||||
pub type LayerVector2D = TypedVector2D<f32, LayerPixel>;
|
||||
pub type LayerVector3D = TypedVector3D<f32, LayerPixel>;
|
||||
pub type LayerSize = TypedSize2D<f32, LayerPixel>;
|
||||
pub type LayoutRect = TypedRect<f32, LayoutPixel>;
|
||||
pub type LayoutPoint = TypedPoint2D<f32, LayoutPixel>;
|
||||
pub type LayoutPoint3D = TypedPoint3D<f32, LayoutPixel>;
|
||||
pub type LayoutVector2D = TypedVector2D<f32, LayoutPixel>;
|
||||
pub type LayoutVector3D = TypedVector3D<f32, LayoutPixel>;
|
||||
pub type LayoutSize = TypedSize2D<f32, LayoutPixel>;
|
||||
|
||||
/// Geometry in a layer's scrollable parent coordinate space (logical pixels).
|
||||
///
|
||||
|
@ -99,28 +88,27 @@ pub type TileOffset = TypedPoint2D<u16, Tiles>;
|
|||
|
||||
/// Scaling ratio from world pixels to device pixels.
|
||||
pub type DevicePixelScale = TypedScale<f32, WorldPixel, DevicePixel>;
|
||||
/// Scaling ratio from layer to world. Used for cases where we know the layer
|
||||
/// Scaling ratio from layout to world. Used for cases where we know the layout
|
||||
/// is in world space, or specifically want to treat it this way.
|
||||
pub type LayerToWorldScale = TypedScale<f32, LayerPixel, WorldPixel>;
|
||||
pub type LayoutToWorldScale = TypedScale<f32, LayoutPixel, WorldPixel>;
|
||||
|
||||
pub type LayoutTransform = TypedTransform3D<f32, LayoutPixel, LayoutPixel>;
|
||||
pub type LayerTransform = TypedTransform3D<f32, LayerPixel, LayerPixel>;
|
||||
pub type LayerToScrollTransform = TypedTransform3D<f32, LayerPixel, ScrollLayerPixel>;
|
||||
pub type ScrollToLayerTransform = TypedTransform3D<f32, ScrollLayerPixel, LayerPixel>;
|
||||
pub type LayerToWorldTransform = TypedTransform3D<f32, LayerPixel, WorldPixel>;
|
||||
pub type WorldToLayerTransform = TypedTransform3D<f32, WorldPixel, LayerPixel>;
|
||||
pub type LayoutToScrollTransform = TypedTransform3D<f32, LayoutPixel, ScrollLayerPixel>;
|
||||
pub type ScrollToLayoutTransform = TypedTransform3D<f32, ScrollLayerPixel, LayoutPixel>;
|
||||
pub type LayoutToWorldTransform = TypedTransform3D<f32, LayoutPixel, WorldPixel>;
|
||||
pub type WorldToLayoutTransform = TypedTransform3D<f32, WorldPixel, LayoutPixel>;
|
||||
pub type ScrollToWorldTransform = TypedTransform3D<f32, ScrollLayerPixel, WorldPixel>;
|
||||
|
||||
// Fixed position coordinates, to avoid float precision errors.
|
||||
pub type LayerPointAu = TypedPoint2D<Au, LayerPixel>;
|
||||
pub type LayerRectAu = TypedRect<Au, LayerPixel>;
|
||||
pub type LayerSizeAu = TypedSize2D<Au, LayerPixel>;
|
||||
pub type LayoutPointAu = TypedPoint2D<Au, LayoutPixel>;
|
||||
pub type LayoutRectAu = TypedRect<Au, LayoutPixel>;
|
||||
pub type LayoutSizeAu = TypedSize2D<Au, LayoutPixel>;
|
||||
|
||||
pub fn as_scroll_parent_rect(rect: &LayerRect) -> ScrollLayerRect {
|
||||
pub fn as_scroll_parent_rect(rect: &LayoutRect) -> ScrollLayerRect {
|
||||
ScrollLayerRect::from_untyped(&rect.to_untyped())
|
||||
}
|
||||
|
||||
pub fn as_scroll_parent_vector(vector: &LayerVector2D) -> ScrollLayerVector2D {
|
||||
pub fn as_scroll_parent_vector(vector: &LayoutVector2D) -> ScrollLayerVector2D {
|
||||
ScrollLayerVector2D::from_untyped(&vector.to_untyped())
|
||||
}
|
||||
|
||||
|
|
|
@ -1 +1 @@
|
|||
ad06d8e05e8475c9788cffa7e6cbac70acbdb399
|
||||
751236199b39bb8dac78522713133ca18c603fb3
|
||||
|
|
|
@ -349,7 +349,7 @@ impl RenderNotifier for Notifier {
|
|||
self.tx.send(NotifierEvent::ShutDown).unwrap();
|
||||
}
|
||||
|
||||
fn new_document_ready(&self, _: DocumentId, _scrolled: bool, composite_needed: bool) {
|
||||
fn new_frame_ready(&self, _: DocumentId, _scrolled: bool, composite_needed: bool) {
|
||||
if composite_needed {
|
||||
self.wake_up();
|
||||
}
|
||||
|
|
|
@ -491,7 +491,11 @@ impl<'a> ReftestHarness<'a> {
|
|||
let stats = self.wrench.render();
|
||||
|
||||
let window_size = self.window.get_inner_size();
|
||||
assert!(size.width <= window_size.width && size.height <= window_size.height);
|
||||
assert!(
|
||||
size.width <= window_size.width &&
|
||||
size.height <= window_size.height,
|
||||
format!("size={:?} ws={:?}", size, window_size)
|
||||
);
|
||||
|
||||
// taking the bottom left sub-rectangle
|
||||
let rect = DeviceUintRect::new(DeviceUintPoint::new(0, window_size.height - size.height), size);
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
|
||||
use std::collections::HashMap;
|
||||
use webrender::api::{BuiltDisplayList, ColorF, Epoch};
|
||||
use webrender::api::{LayerSize, PipelineId};
|
||||
use webrender::api::{LayoutSize, PipelineId};
|
||||
use webrender::api::{PropertyBinding, PropertyBindingId, LayoutTransform, DynamicProperties};
|
||||
|
||||
/// Stores a map of the animated property bindings for the current display list. These
|
||||
|
@ -74,7 +74,7 @@ impl SceneProperties {
|
|||
#[derive(Debug)]
|
||||
pub struct ScenePipeline {
|
||||
pub epoch: Epoch,
|
||||
pub viewport_size: LayerSize,
|
||||
pub viewport_size: LayoutSize,
|
||||
pub background_color: Option<ColorF>,
|
||||
}
|
||||
|
||||
|
@ -113,7 +113,7 @@ impl Scene {
|
|||
pipeline_id: &PipelineId,
|
||||
epoch: &Epoch,
|
||||
background_color: &Option<ColorF>,
|
||||
viewport_size: &LayerSize,
|
||||
viewport_size: &LayoutSize,
|
||||
) {
|
||||
let new_pipeline = ScenePipeline {
|
||||
epoch: epoch.clone(),
|
||||
|
|
|
@ -109,7 +109,7 @@ impl RenderNotifier for Notifier {
|
|||
self.update(false);
|
||||
}
|
||||
|
||||
fn new_document_ready(&self, _: DocumentId, scrolled: bool, _composite_needed: bool) {
|
||||
fn new_frame_ready(&self, _: DocumentId, scrolled: bool, _composite_needed: bool) {
|
||||
self.update(!scrolled);
|
||||
}
|
||||
}
|
||||
|
@ -283,9 +283,9 @@ impl Wrench {
|
|||
render_mode: Option<FontRenderMode>,
|
||||
text: &str,
|
||||
size: Au,
|
||||
origin: LayerPoint,
|
||||
origin: LayoutPoint,
|
||||
flags: FontInstanceFlags,
|
||||
) -> (Vec<u32>, Vec<LayerPoint>, LayoutRect) {
|
||||
) -> (Vec<u32>, Vec<LayoutPoint>, LayoutRect) {
|
||||
// Map the string codepoints to glyph indices in this font.
|
||||
// Just drop any glyph that isn't present in this font.
|
||||
let indices: Vec<u32> = self.api
|
||||
|
@ -302,7 +302,7 @@ impl Wrench {
|
|||
for glyph_index in &indices {
|
||||
keys.push(GlyphKey::new(
|
||||
*glyph_index,
|
||||
LayerPoint::zero(),
|
||||
LayoutPoint::zero(),
|
||||
render_mode,
|
||||
subpx_dir,
|
||||
));
|
||||
|
@ -314,12 +314,12 @@ impl Wrench {
|
|||
|
||||
let mut cursor = origin;
|
||||
let direction = if flags.contains(FontInstanceFlags::TRANSPOSE) {
|
||||
LayerVector2D::new(
|
||||
LayoutVector2D::new(
|
||||
0.0,
|
||||
if flags.contains(FontInstanceFlags::FLIP_Y) { -1.0 } else { 1.0 },
|
||||
)
|
||||
} else {
|
||||
LayerVector2D::new(
|
||||
LayoutVector2D::new(
|
||||
if flags.contains(FontInstanceFlags::FLIP_X) { -1.0 } else { 1.0 },
|
||||
0.0,
|
||||
)
|
||||
|
@ -500,8 +500,8 @@ impl Wrench {
|
|||
pub fn send_lists(
|
||||
&mut self,
|
||||
frame_number: u32,
|
||||
display_lists: Vec<(PipelineId, LayerSize, BuiltDisplayList)>,
|
||||
scroll_offsets: &HashMap<ExternalScrollId, LayerPoint>,
|
||||
display_lists: Vec<(PipelineId, LayoutSize, BuiltDisplayList)>,
|
||||
scroll_offsets: &HashMap<ExternalScrollId, LayoutPoint>,
|
||||
) {
|
||||
let root_background_color = Some(ColorF::new(1.0, 1.0, 1.0, 1.0));
|
||||
|
||||
|
|
|
@ -193,7 +193,7 @@ pub struct YamlFrameReader {
|
|||
|
||||
/// A HashMap of offsets which specify what scroll offsets particular
|
||||
/// scroll layers should be initialized with.
|
||||
scroll_offsets: HashMap<ExternalScrollId, LayerPoint>,
|
||||
scroll_offsets: HashMap<ExternalScrollId, LayoutPoint>,
|
||||
|
||||
image_map: HashMap<(PathBuf, Option<i64>), (ImageKey, LayoutSize)>,
|
||||
|
||||
|
@ -1351,7 +1351,7 @@ impl YamlFrameReader {
|
|||
.as_rect()
|
||||
.expect("scroll frame must have a bounds");
|
||||
let content_size = yaml["content-size"].as_size().unwrap_or(clip_rect.size);
|
||||
let content_rect = LayerRect::new(clip_rect.origin, content_size);
|
||||
let content_rect = LayoutRect::new(clip_rect.origin, content_size);
|
||||
|
||||
let numeric_id = yaml["id"].as_i64().map(|id| id as u64);
|
||||
|
||||
|
@ -1360,7 +1360,7 @@ impl YamlFrameReader {
|
|||
|
||||
let external_id = yaml["scroll-offset"].as_point().map(|size| {
|
||||
let id = ExternalScrollId((self.scroll_offsets.len() + 1) as u64, dl.pipeline_id);
|
||||
self.scroll_offsets.insert(id, LayerPoint::new(size.x, size.y));
|
||||
self.scroll_offsets.insert(id, LayoutPoint::new(size.x, size.y));
|
||||
id
|
||||
});
|
||||
|
||||
|
@ -1541,7 +1541,7 @@ impl YamlFrameReader {
|
|||
if is_root {
|
||||
if let Some(size) = yaml["scroll-offset"].as_point() {
|
||||
let external_id = ExternalScrollId(0, dl.pipeline_id);
|
||||
self.scroll_offsets.insert(external_id, LayerPoint::new(size.x, size.y));
|
||||
self.scroll_offsets.insert(external_id, LayoutPoint::new(size.x, size.y));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -707,7 +707,7 @@ impl YamlFrameWriter {
|
|||
};
|
||||
|
||||
let mut v = new_table();
|
||||
let info = base.get_layer_primitive_info(&LayoutVector2D::zero());
|
||||
let info = base.get_layout_primitive_info(&LayoutVector2D::zero());
|
||||
rect_node(&mut v, "bounds", &info.rect);
|
||||
rect_node(&mut v, "clip-rect", &info.clip_rect);
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче