зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1711648 - Move LayoutRect to the Box2D representation. r=jrmuizel.
Differential Revision: https://phabricator.services.mozilla.com/D117293
This commit is contained in:
Родитель
8ab34fbadf
Коммит
69c80ddaa7
|
@ -717,8 +717,8 @@ struct DIGroup {
|
|||
void PushImage(wr::DisplayListBuilder& aBuilder,
|
||||
const LayoutDeviceRect& bounds) {
|
||||
wr::LayoutRect dest = wr::ToLayoutRect(bounds);
|
||||
GP("PushImage: %f %f %f %f\n", dest.origin.x, dest.origin.y,
|
||||
dest.size.width, dest.size.height);
|
||||
GP("PushImage: %f %f %f %f\n", dest.min.x, dest.min.y, dest.max.x,
|
||||
dest.max.y);
|
||||
gfx::SamplingFilter sampleFilter = gfx::SamplingFilter::
|
||||
LINEAR; // nsLayoutUtils::GetSamplingFilterForFrame(aItem->Frame());
|
||||
bool backfaceHidden = false;
|
||||
|
|
|
@ -346,7 +346,7 @@ static bool Moz2DRenderCallback(const Range<const uint8_t> aBlob,
|
|||
const mozilla::wr::TileOffset* aTileOffset,
|
||||
const mozilla::wr::LayoutIntRect* aDirtyRect,
|
||||
Range<uint8_t> aOutput) {
|
||||
IntSize size(aRenderRect->size.width, aRenderRect->size.height);
|
||||
IntSize size(aRenderRect->width(), aRenderRect->height());
|
||||
AUTO_PROFILER_TRACING_MARKER("WebRender", "RasterizeSingleBlob", GRAPHICS);
|
||||
MOZ_RELEASE_ASSERT(size.width > 0 && size.height > 0);
|
||||
if (size.width <= 0 || size.height <= 0) {
|
||||
|
@ -378,7 +378,7 @@ static bool Moz2DRenderCallback(const Range<const uint8_t> aBlob,
|
|||
|
||||
// aRenderRect is the part of the blob that we are currently rendering
|
||||
// (for example a tile) in the same coordinate space as aVisibleRect.
|
||||
IntPoint origin = gfx::IntPoint(aRenderRect->origin.x, aRenderRect->origin.y);
|
||||
IntPoint origin = gfx::IntPoint(aRenderRect->min.x, aRenderRect->min.y);
|
||||
|
||||
MOZ_RELEASE_ASSERT(indexOffset <= aBlob.length() - footerSize);
|
||||
Reader reader(aBlob.begin().get() + indexOffset,
|
||||
|
@ -389,12 +389,12 @@ static bool Moz2DRenderCallback(const Range<const uint8_t> aBlob,
|
|||
auto bounds = gfx::IntRect(origin, size);
|
||||
|
||||
if (aDirtyRect) {
|
||||
gfx::Rect dirty(aDirtyRect->origin.x, aDirtyRect->origin.y,
|
||||
aDirtyRect->size.width, aDirtyRect->size.height);
|
||||
gfx::Rect dirty(aDirtyRect->min.x, aDirtyRect->min.y, aDirtyRect->width(),
|
||||
aDirtyRect->height());
|
||||
dt->PushClipRect(dirty);
|
||||
bounds = bounds.Intersect(
|
||||
IntRect(aDirtyRect->origin.x, aDirtyRect->origin.y,
|
||||
aDirtyRect->size.width, aDirtyRect->size.height));
|
||||
bounds =
|
||||
bounds.Intersect(IntRect(aDirtyRect->min.x, aDirtyRect->min.y,
|
||||
aDirtyRect->width(), aDirtyRect->height()));
|
||||
}
|
||||
|
||||
bool ret = true;
|
||||
|
|
|
@ -1206,8 +1206,8 @@ void DisplayListBuilder::PushRoundedRect(const wr::LayoutRect& aBounds,
|
|||
// Made the borders thicker than one half the width/height, to avoid
|
||||
// little white dots at the center at some magnifications.
|
||||
wr::BorderSide side = {aColor, wr::BorderStyle::Solid};
|
||||
float h = aBounds.size.width * 0.6f;
|
||||
float v = aBounds.size.height * 0.6f;
|
||||
float h = aBounds.width() * 0.6f;
|
||||
float v = aBounds.height() * 0.6f;
|
||||
wr::LayoutSideOffsets widths = {v, h, v, h};
|
||||
wr::BorderRadius radii = {{h, v}, {h, v}, {h, v}, {h, v}};
|
||||
|
||||
|
|
|
@ -326,19 +326,19 @@ static inline wr::LayoutVector2D ToLayoutVector2D(
|
|||
static inline wr::LayoutRect ToLayoutRect(
|
||||
const mozilla::LayoutDeviceRect& rect) {
|
||||
wr::LayoutRect r;
|
||||
r.origin.x = rect.X();
|
||||
r.origin.y = rect.Y();
|
||||
r.size.width = rect.Width();
|
||||
r.size.height = rect.Height();
|
||||
r.min.x = rect.X();
|
||||
r.min.y = rect.Y();
|
||||
r.max.x = rect.X() + rect.Width();
|
||||
r.max.y = rect.Y() + rect.Height();
|
||||
return r;
|
||||
}
|
||||
|
||||
static inline wr::LayoutRect ToLayoutRect(const gfx::Rect& rect) {
|
||||
wr::LayoutRect r;
|
||||
r.origin.x = rect.X();
|
||||
r.origin.y = rect.Y();
|
||||
r.size.width = rect.Width();
|
||||
r.size.height = rect.Height();
|
||||
r.min.x = rect.X();
|
||||
r.min.y = rect.Y();
|
||||
r.max.x = rect.X() + rect.Width();
|
||||
r.max.y = rect.Y() + rect.Height();
|
||||
return r;
|
||||
}
|
||||
|
||||
|
@ -356,10 +356,10 @@ static inline wr::DeviceIntRect ToDeviceIntRect(
|
|||
static inline wr::LayoutIntRect ToLayoutIntRect(
|
||||
const mozilla::ImageIntRect& rect) {
|
||||
wr::LayoutIntRect r;
|
||||
r.origin.x = rect.X();
|
||||
r.origin.y = rect.Y();
|
||||
r.size.width = rect.Width();
|
||||
r.size.height = rect.Height();
|
||||
r.min.x = rect.X();
|
||||
r.min.y = rect.Y();
|
||||
r.max.x = rect.X() + rect.Width();
|
||||
r.max.y = rect.Y() + rect.Height();
|
||||
return r;
|
||||
}
|
||||
|
||||
|
@ -371,17 +371,14 @@ static inline wr::LayoutRect ToLayoutRect(
|
|||
static inline wr::LayoutRect IntersectLayoutRect(const wr::LayoutRect& aRect,
|
||||
const wr::LayoutRect& aOther) {
|
||||
wr::LayoutRect r;
|
||||
r.origin.x = std::max(aRect.origin.x, aOther.origin.x);
|
||||
r.origin.y = std::max(aRect.origin.y, aOther.origin.y);
|
||||
r.size.width = std::min(aRect.origin.x + aRect.size.width,
|
||||
aOther.origin.x + aOther.size.width) -
|
||||
r.origin.x;
|
||||
r.size.height = std::min(aRect.origin.y + aRect.size.height,
|
||||
aOther.origin.y + aOther.size.height) -
|
||||
r.origin.y;
|
||||
if (r.size.width < 0 || r.size.height < 0) {
|
||||
r.size.width = 0;
|
||||
r.size.height = 0;
|
||||
r.min.x = std::max(aRect.min.x, aOther.min.x);
|
||||
r.min.y = std::max(aRect.min.y, aOther.min.y);
|
||||
r.max.x = std::min(aRect.max.x, aOther.max.x);
|
||||
r.max.y = std::min(aRect.max.y, aOther.max.y);
|
||||
|
||||
if (r.max.x < r.min.x || r.max.y < r.min.y) {
|
||||
r.max.x = r.min.x;
|
||||
r.max.y = r.min.y;
|
||||
}
|
||||
return r;
|
||||
}
|
||||
|
|
|
@ -2110,7 +2110,7 @@ pub extern "C" fn wr_resource_updates_update_blob_image(
|
|||
descriptor.into(),
|
||||
Arc::new(bytes.flush_into_vec()),
|
||||
visible_rect,
|
||||
&DirtyRect::Partial(dirty_rect.to_box2d()),
|
||||
&DirtyRect::Partial(dirty_rect),
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -2452,7 +2452,7 @@ pub struct WrStackingContextParams {
|
|||
#[no_mangle]
|
||||
pub extern "C" fn wr_dp_push_stacking_context(
|
||||
state: &mut WrState,
|
||||
mut bounds: LayoutRect,
|
||||
bounds: LayoutRect,
|
||||
spatial_id: WrSpatialId,
|
||||
params: &WrStackingContextParams,
|
||||
transform: *const LayoutTransform,
|
||||
|
@ -2526,6 +2526,8 @@ pub extern "C" fn wr_dp_push_stacking_context(
|
|||
let mut wr_spatial_id = spatial_id.to_webrender(state.pipeline_id);
|
||||
let wr_clip_id = params.clip.to_webrender(state.pipeline_id);
|
||||
|
||||
let mut origin = bounds.min;
|
||||
|
||||
// Note: 0 has special meaning in WR land, standing for ROOT_REFERENCE_FRAME.
|
||||
// However, it is never returned by `push_reference_frame`, and we need to return
|
||||
// an option here across FFI, so we take that 0 value for the None semantics.
|
||||
|
@ -2550,14 +2552,14 @@ pub extern "C" fn wr_dp_push_stacking_context(
|
|||
WrReferenceFrameKind::Perspective => ReferenceFrameKind::Perspective { scrolling_relative_to },
|
||||
};
|
||||
wr_spatial_id = state.frame_builder.dl_builder.push_reference_frame(
|
||||
bounds.origin,
|
||||
origin,
|
||||
wr_spatial_id,
|
||||
params.transform_style,
|
||||
transform_binding,
|
||||
reference_frame_kind,
|
||||
);
|
||||
|
||||
bounds.origin = LayoutPoint::zero();
|
||||
origin = LayoutPoint::zero();
|
||||
result.id = wr_spatial_id.0;
|
||||
assert_ne!(wr_spatial_id.0, 0);
|
||||
} else if let Some(data) = computed_ref {
|
||||
|
@ -2568,20 +2570,20 @@ pub extern "C" fn wr_dp_push_stacking_context(
|
|||
WrRotation::Degree270 => Rotation::Degree270,
|
||||
};
|
||||
wr_spatial_id = state.frame_builder.dl_builder.push_computed_frame(
|
||||
bounds.origin,
|
||||
origin,
|
||||
wr_spatial_id,
|
||||
Some(data.scale_from),
|
||||
data.vertical_flip,
|
||||
rotation,
|
||||
);
|
||||
|
||||
bounds.origin = LayoutPoint::zero();
|
||||
origin = LayoutPoint::zero();
|
||||
result.id = wr_spatial_id.0;
|
||||
assert_ne!(wr_spatial_id.0, 0);
|
||||
}
|
||||
|
||||
state.frame_builder.dl_builder.push_stacking_context(
|
||||
bounds.origin,
|
||||
origin,
|
||||
wr_spatial_id,
|
||||
params.prim_flags,
|
||||
wr_clip_id,
|
||||
|
@ -3499,8 +3501,8 @@ pub extern "C" fn wr_dp_push_border_radial_gradient(
|
|||
|
||||
let border_details = BorderDetails::NinePatch(NinePatchBorder {
|
||||
source: NinePatchBorderSource::RadialGradient(gradient),
|
||||
width: rect.size.width as i32,
|
||||
height: rect.size.height as i32,
|
||||
width: rect.width() as i32,
|
||||
height: rect.height() as i32,
|
||||
slice,
|
||||
fill,
|
||||
outset,
|
||||
|
@ -3558,8 +3560,8 @@ pub extern "C" fn wr_dp_push_border_conic_gradient(
|
|||
|
||||
let border_details = BorderDetails::NinePatch(NinePatchBorder {
|
||||
source: NinePatchBorderSource::ConicGradient(gradient),
|
||||
width: rect.size.width as i32,
|
||||
height: rect.size.height as i32,
|
||||
width: rect.width() as i32,
|
||||
height: rect.height() as i32,
|
||||
slice,
|
||||
fill,
|
||||
outset,
|
||||
|
|
|
@ -587,7 +587,7 @@ impl AsyncBlobImageRasterizer for Moz2dBlobRasterizer {
|
|||
.map(|params| {
|
||||
let command = &self.blob_commands[¶ms.request.key];
|
||||
let blob = Arc::clone(&command.data);
|
||||
assert!(params.descriptor.rect.size.width > 0 && params.descriptor.rect.size.height > 0);
|
||||
assert!(!params.descriptor.rect.is_empty());
|
||||
|
||||
Job {
|
||||
request: params.request,
|
||||
|
@ -647,15 +647,15 @@ fn autoreleasepool<T, F: FnOnce() -> T>(f: F) -> T {
|
|||
fn rasterize_blob(job: Job) -> (BlobImageRequest, BlobImageResult) {
|
||||
let descriptor = job.descriptor;
|
||||
let buf_size =
|
||||
(descriptor.rect.size.width * descriptor.rect.size.height * descriptor.format.bytes_per_pixel()) as usize;
|
||||
(descriptor.rect.area() * descriptor.format.bytes_per_pixel()) as usize;
|
||||
|
||||
let mut output = vec![0u8; buf_size];
|
||||
|
||||
let dirty_rect = match job.dirty_rect {
|
||||
DirtyRect::Partial(rect) => Some(rect.to_rect()),
|
||||
DirtyRect::Partial(rect) => Some(rect),
|
||||
DirtyRect::All => None,
|
||||
};
|
||||
assert!(descriptor.rect.size.width > 0 && descriptor.rect.size.height > 0);
|
||||
assert!(!descriptor.rect.is_empty());
|
||||
|
||||
let result = autoreleasepool(|| {
|
||||
unsafe {
|
||||
|
@ -671,8 +671,8 @@ fn rasterize_blob(job: Job) -> (BlobImageRequest, BlobImageResult) {
|
|||
) {
|
||||
// We want the dirty rect local to the tile rather than the whole image.
|
||||
// TODO(nical): move that up and avoid recomupting the tile bounds in the callback
|
||||
let dirty_rect = job.dirty_rect.to_subrect_of(&descriptor.rect.to_box2d());
|
||||
let tx: BlobToDeviceTranslation = (-descriptor.rect.origin.to_vector()).into();
|
||||
let dirty_rect = job.dirty_rect.to_subrect_of(&descriptor.rect);
|
||||
let tx: BlobToDeviceTranslation = (-descriptor.rect.min.to_vector()).into();
|
||||
let rasterized_rect = tx.transform_box(&dirty_rect);
|
||||
|
||||
Ok(RasterizedBlobImage {
|
||||
|
|
|
@ -99,10 +99,10 @@ impl webrender::Compositor for DirectCompositeInterface {
|
|||
id.surface_id.0,
|
||||
id.x,
|
||||
id.y,
|
||||
dirty_rect.origin.x,
|
||||
dirty_rect.origin.y,
|
||||
dirty_rect.size.width,
|
||||
dirty_rect.size.height,
|
||||
dirty_rect.min.x,
|
||||
dirty_rect.min.y,
|
||||
dirty_rect.width(),
|
||||
dirty_rect.height(),
|
||||
);
|
||||
|
||||
webrender::NativeSurfaceInfo {
|
||||
|
@ -131,10 +131,10 @@ impl webrender::Compositor for DirectCompositeInterface {
|
|||
id.0,
|
||||
transform.transform_point2d(point2(0., 0.)).unwrap().x as i32,
|
||||
transform.transform_point2d(point2(0., 0.)).unwrap().y as i32,
|
||||
clip_rect.origin.x,
|
||||
clip_rect.origin.y,
|
||||
clip_rect.size.width,
|
||||
clip_rect.size.height,
|
||||
clip_rect.min.x,
|
||||
clip_rect.min.y,
|
||||
clip_rect.width(),
|
||||
clip_rect.height(),
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -228,11 +228,7 @@ fn push_rotated_rect(
|
|||
1.0,
|
||||
Angle::radians(2.0 * std::f32::consts::PI * angle),
|
||||
);
|
||||
let transform_origin = LayoutVector3D::new(
|
||||
rect.origin.x + rect.size.width * 0.5,
|
||||
rect.origin.y + rect.size.height * 0.5,
|
||||
0.0,
|
||||
);
|
||||
let transform_origin = rect.center().extend(0.0);
|
||||
let transform = rotation
|
||||
.pre_translate(-transform_origin)
|
||||
.then_translate(transform_origin);
|
||||
|
@ -280,24 +276,24 @@ fn build_display_list(
|
|||
let scroll_space_info = builder.define_scroll_frame(
|
||||
&fixed_space_info,
|
||||
scroll_id,
|
||||
LayoutRect::new(LayoutPoint::zero(), layout_size),
|
||||
LayoutRect::new(LayoutPoint::zero(), layout_size),
|
||||
LayoutRect::from_size(layout_size),
|
||||
LayoutRect::from_size(layout_size),
|
||||
ScrollSensitivity::Script,
|
||||
LayoutVector2D::zero(),
|
||||
);
|
||||
|
||||
builder.push_rect(
|
||||
&CommonItemProperties::new(
|
||||
LayoutRect::new(LayoutPoint::zero(), layout_size).inflate(-10.0, -10.0),
|
||||
LayoutRect::from_size(layout_size).inflate(-10.0, -10.0),
|
||||
fixed_space_info,
|
||||
),
|
||||
LayoutRect::new(LayoutPoint::zero(), layout_size).inflate(-10.0, -10.0),
|
||||
LayoutRect::from_size(layout_size).inflate(-10.0, -10.0),
|
||||
ColorF::new(0.8, 0.8, 0.8, 1.0),
|
||||
);
|
||||
|
||||
push_rotated_rect(
|
||||
builder,
|
||||
LayoutRect::new(
|
||||
LayoutRect::from_origin_and_size(
|
||||
LayoutPoint::new(100.0, 100.0),
|
||||
LayoutSize::new(size_factor * 400.0, size_factor * 400.0),
|
||||
),
|
||||
|
@ -310,7 +306,7 @@ fn build_display_list(
|
|||
|
||||
push_rotated_rect(
|
||||
builder,
|
||||
LayoutRect::new(
|
||||
LayoutRect::from_origin_and_size(
|
||||
LayoutPoint::new(800.0, 100.0),
|
||||
LayoutSize::new(size_factor * 100.0, size_factor * 600.0),
|
||||
),
|
||||
|
@ -323,7 +319,7 @@ fn build_display_list(
|
|||
|
||||
push_rotated_rect(
|
||||
builder,
|
||||
LayoutRect::new(
|
||||
LayoutRect::from_origin_and_size(
|
||||
LayoutPoint::new(700.0, 200.0),
|
||||
LayoutSize::new(size_factor * 300.0, size_factor * 300.0),
|
||||
),
|
||||
|
@ -336,7 +332,7 @@ fn build_display_list(
|
|||
|
||||
push_rotated_rect(
|
||||
builder,
|
||||
LayoutRect::new(
|
||||
LayoutRect::from_origin_and_size(
|
||||
LayoutPoint::new(100.0, 600.0),
|
||||
LayoutSize::new(size_factor * 400.0, size_factor * 400.0),
|
||||
),
|
||||
|
@ -349,7 +345,7 @@ fn build_display_list(
|
|||
|
||||
push_rotated_rect(
|
||||
builder,
|
||||
LayoutRect::new(
|
||||
LayoutRect::from_origin_and_size(
|
||||
LayoutPoint::new(700.0, 600.0),
|
||||
LayoutSize::new(size_factor * 400.0, size_factor * 400.0),
|
||||
),
|
||||
|
|
|
@ -36,7 +36,7 @@ impl Example for App {
|
|||
let space_and_clip = SpaceAndClipInfo::root_scroll(pipeline_id);
|
||||
|
||||
builder.push_simple_stacking_context(
|
||||
bounds.origin,
|
||||
bounds.min,
|
||||
space_and_clip.spatial_id,
|
||||
PrimitiveFlags::IS_BACKFACE_VISIBLE,
|
||||
);
|
||||
|
|
|
@ -59,7 +59,7 @@ impl App {
|
|||
};
|
||||
|
||||
let spatial_id = builder.push_reference_frame(
|
||||
bounds.origin,
|
||||
bounds.min,
|
||||
SpatialId::root_scroll_node(pipeline_id),
|
||||
TransformStyle::Flat,
|
||||
PropertyBinding::Binding(property_key, LayoutTransform::identity()),
|
||||
|
@ -82,7 +82,7 @@ impl App {
|
|||
spatial_id,
|
||||
clip_id: ClipId::root(pipeline_id),
|
||||
};
|
||||
let clip_bounds = LayoutRect::new(LayoutPoint::zero(), bounds.size);
|
||||
let clip_bounds = LayoutRect::from_size(bounds.size());
|
||||
let complex_clip = ComplexClipRegion {
|
||||
rect: clip_bounds,
|
||||
radii: BorderRadius::uniform(30.0),
|
||||
|
@ -96,13 +96,13 @@ impl App {
|
|||
// Fill it with a white rect
|
||||
builder.push_rect(
|
||||
&CommonItemProperties::new(
|
||||
LayoutRect::new(LayoutPoint::zero(), bounds.size),
|
||||
LayoutRect::from_size(bounds.size()),
|
||||
SpaceAndClipInfo {
|
||||
spatial_id,
|
||||
clip_id,
|
||||
}
|
||||
),
|
||||
LayoutRect::new(LayoutPoint::zero(), bounds.size),
|
||||
LayoutRect::from_size(bounds.size()),
|
||||
color,
|
||||
);
|
||||
|
||||
|
|
|
@ -40,12 +40,12 @@ impl Example for App {
|
|||
pipeline_id: PipelineId,
|
||||
_document_id: DocumentId,
|
||||
) {
|
||||
let content_bounds = LayoutRect::new(LayoutPoint::zero(), LayoutSize::new(800.0, 600.0));
|
||||
let content_bounds = LayoutRect::from_size(LayoutSize::new(800.0, 600.0));
|
||||
let root_space_and_clip = SpaceAndClipInfo::root_scroll(pipeline_id);
|
||||
let spatial_id = root_space_and_clip.spatial_id;
|
||||
|
||||
builder.push_simple_stacking_context(
|
||||
content_bounds.origin,
|
||||
content_bounds.min,
|
||||
spatial_id,
|
||||
PrimitiveFlags::IS_BACKFACE_VISIBLE,
|
||||
);
|
||||
|
|
|
@ -59,14 +59,14 @@ fn render_blob(
|
|||
// Allocate storage for the result. Right now the resource cache expects the
|
||||
// tiles to have have no stride or offset.
|
||||
let bpp = 4;
|
||||
let mut texels = Vec::with_capacity((descriptor.rect.size.area() * bpp) as usize);
|
||||
let mut texels = Vec::with_capacity((descriptor.rect.area() * bpp) as usize);
|
||||
|
||||
// Generate a per-tile pattern to see it in the demo. For a real use case it would not
|
||||
// make sense for the rendered content to depend on its tile.
|
||||
let tile_checker = (tile.x % 2 == 0) != (tile.y % 2 == 0);
|
||||
|
||||
let [w, h] = descriptor.rect.size.to_array();
|
||||
let offset = descriptor.rect.origin;
|
||||
let [w, h] = descriptor.rect.size().to_array();
|
||||
let offset = descriptor.rect.min;
|
||||
|
||||
for y in 0..h {
|
||||
for x in 0..w {
|
||||
|
|
|
@ -52,14 +52,14 @@ pub trait HandyDandyRectBuilder {
|
|||
// values to build a f32 LayoutRect
|
||||
impl HandyDandyRectBuilder for (i32, i32) {
|
||||
fn to(&self, x2: i32, y2: i32) -> LayoutRect {
|
||||
LayoutRect::new(
|
||||
LayoutRect::from_origin_and_size(
|
||||
LayoutPoint::new(self.0 as f32, self.1 as f32),
|
||||
LayoutSize::new((x2 - self.0) as f32, (y2 - self.1) as f32),
|
||||
)
|
||||
}
|
||||
|
||||
fn by(&self, w: i32, h: i32) -> LayoutRect {
|
||||
LayoutRect::new(
|
||||
LayoutRect::from_origin_and_size(
|
||||
LayoutPoint::new(self.0 as f32, self.1 as f32),
|
||||
LayoutSize::new(w as f32, h as f32),
|
||||
)
|
||||
|
|
|
@ -72,8 +72,7 @@ impl App {
|
|||
self.documents.push(Document {
|
||||
id: document_id,
|
||||
pipeline_id,
|
||||
content_rect: LayoutRect::new(
|
||||
LayoutPoint::origin(),
|
||||
content_rect: LayoutRect::from_size(
|
||||
bounds.size().to_f32() / Scale::new(device_pixel_ratio),
|
||||
),
|
||||
color,
|
||||
|
@ -103,13 +102,10 @@ impl Example for App {
|
|||
let mut builder = DisplayListBuilder::new(
|
||||
doc.pipeline_id,
|
||||
);
|
||||
let local_rect = LayoutRect::new(
|
||||
LayoutPoint::zero(),
|
||||
doc.content_rect.size,
|
||||
);
|
||||
let local_rect = LayoutRect::from_size(doc.content_rect.size());
|
||||
|
||||
builder.push_simple_stacking_context(
|
||||
doc.content_rect.origin,
|
||||
doc.content_rect.min,
|
||||
space_and_clip.spatial_id,
|
||||
PrimitiveFlags::IS_BACKFACE_VISIBLE,
|
||||
);
|
||||
|
@ -124,7 +120,7 @@ impl Example for App {
|
|||
txn.set_display_list(
|
||||
Epoch(0),
|
||||
None,
|
||||
doc.content_rect.size,
|
||||
doc.content_rect.size(),
|
||||
builder.finalize(),
|
||||
true,
|
||||
);
|
||||
|
|
|
@ -40,7 +40,7 @@ impl Example for App {
|
|||
let mut space_and_clip = SpaceAndClipInfo::root_scroll(pipeline_id);
|
||||
|
||||
sub_builder.push_simple_stacking_context(
|
||||
sub_bounds.origin,
|
||||
sub_bounds.min,
|
||||
space_and_clip.spatial_id,
|
||||
PrimitiveFlags::IS_BACKFACE_VISIBLE,
|
||||
);
|
||||
|
@ -57,14 +57,14 @@ impl Example for App {
|
|||
txn.set_display_list(
|
||||
Epoch(0),
|
||||
None,
|
||||
sub_bounds.size,
|
||||
sub_bounds.size(),
|
||||
sub_builder.finalize(),
|
||||
true,
|
||||
);
|
||||
api.send_transaction(document_id, txn);
|
||||
|
||||
space_and_clip.spatial_id = builder.push_reference_frame(
|
||||
sub_bounds.origin,
|
||||
sub_bounds.min,
|
||||
space_and_clip.spatial_id,
|
||||
TransformStyle::Flat,
|
||||
PropertyBinding::Binding(PropertyBindingKey::new(42), LayoutTransform::identity()),
|
||||
|
@ -76,7 +76,7 @@ impl Example for App {
|
|||
|
||||
// And this is for the root pipeline
|
||||
builder.push_simple_stacking_context(
|
||||
sub_bounds.origin,
|
||||
sub_bounds.min,
|
||||
space_and_clip.spatial_id,
|
||||
PrimitiveFlags::IS_BACKFACE_VISIBLE,
|
||||
);
|
||||
|
|
|
@ -43,7 +43,7 @@ impl Example for App {
|
|||
let space_and_clip = SpaceAndClipInfo::root_scroll(pipeline_id);
|
||||
|
||||
builder.push_simple_stacking_context(
|
||||
bounds.origin,
|
||||
bounds.min,
|
||||
space_and_clip.spatial_id,
|
||||
PrimitiveFlags::IS_BACKFACE_VISIBLE,
|
||||
);
|
||||
|
@ -52,7 +52,7 @@ impl Example for App {
|
|||
|
||||
builder.push_image(
|
||||
&CommonItemProperties::new(
|
||||
LayoutRect::new(LayoutPoint::new(100.0, 100.0), image_size),
|
||||
LayoutRect::from_origin_and_size(LayoutPoint::new(100.0, 100.0), image_size),
|
||||
space_and_clip,
|
||||
),
|
||||
bounds,
|
||||
|
@ -64,7 +64,7 @@ impl Example for App {
|
|||
|
||||
builder.push_image(
|
||||
&CommonItemProperties::new(
|
||||
LayoutRect::new(LayoutPoint::new(250.0, 100.0), image_size),
|
||||
LayoutRect::from_origin_and_size(LayoutPoint::new(250.0, 100.0), image_size),
|
||||
space_and_clip,
|
||||
),
|
||||
bounds,
|
||||
|
|
|
@ -186,28 +186,28 @@ impl Window {
|
|||
let mut builder = DisplayListBuilder::new(self.pipeline_id);
|
||||
let space_and_clip = SpaceAndClipInfo::root_scroll(self.pipeline_id);
|
||||
|
||||
let bounds = LayoutRect::new(LayoutPoint::zero(), layout_size);
|
||||
let bounds = LayoutRect::from_size(layout_size);
|
||||
builder.push_simple_stacking_context(
|
||||
bounds.origin,
|
||||
bounds.min,
|
||||
space_and_clip.spatial_id,
|
||||
PrimitiveFlags::IS_BACKFACE_VISIBLE,
|
||||
);
|
||||
|
||||
builder.push_rect(
|
||||
&CommonItemProperties::new(
|
||||
LayoutRect::new(
|
||||
LayoutRect::from_origin_and_size(
|
||||
LayoutPoint::new(100.0, 200.0),
|
||||
LayoutSize::new(100.0, 200.0),
|
||||
),
|
||||
space_and_clip,
|
||||
),
|
||||
LayoutRect::new(
|
||||
LayoutRect::from_origin_and_size(
|
||||
LayoutPoint::new(100.0, 200.0),
|
||||
LayoutSize::new(100.0, 200.0),
|
||||
),
|
||||
ColorF::new(0.0, 1.0, 0.0, 1.0));
|
||||
|
||||
let text_bounds = LayoutRect::new(
|
||||
let text_bounds = LayoutRect::from_origin_and_size(
|
||||
LayoutPoint::new(100.0, 50.0),
|
||||
LayoutSize::new(700.0, 200.0)
|
||||
);
|
||||
|
|
|
@ -101,7 +101,7 @@ impl Example for App {
|
|||
let space_and_clip = SpaceAndClipInfo::root_scroll(pipeline_id);
|
||||
|
||||
builder.push_simple_stacking_context(
|
||||
bounds.origin,
|
||||
bounds.min,
|
||||
space_and_clip.spatial_id,
|
||||
PrimitiveFlags::IS_BACKFACE_VISIBLE,
|
||||
);
|
||||
|
@ -138,7 +138,7 @@ impl Example for App {
|
|||
let x = (i % 128) as f32;
|
||||
let y = (i / 128) as f32;
|
||||
let info = CommonItemProperties::new(
|
||||
LayoutRect::new(
|
||||
LayoutRect::from_origin_and_size(
|
||||
LayoutPoint::new(x0 + image_size.width * x, y0 + image_size.height * y),
|
||||
image_size,
|
||||
),
|
||||
|
@ -158,7 +158,7 @@ impl Example for App {
|
|||
if let Some(image_key) = self.image_key {
|
||||
let image_size = LayoutSize::new(100.0, 100.0);
|
||||
let info = CommonItemProperties::new(
|
||||
LayoutRect::new(LayoutPoint::new(100.0, 100.0), image_size),
|
||||
LayoutRect::from_origin_and_size(LayoutPoint::new(100.0, 100.0), image_size),
|
||||
space_and_clip,
|
||||
);
|
||||
builder.push_image(
|
||||
|
@ -174,7 +174,7 @@ impl Example for App {
|
|||
let swap_key = self.swap_keys[self.swap_index];
|
||||
let image_size = LayoutSize::new(64.0, 64.0);
|
||||
let info = CommonItemProperties::new(
|
||||
LayoutRect::new(LayoutPoint::new(100.0, 400.0), image_size),
|
||||
LayoutRect::from_origin_and_size(LayoutPoint::new(100.0, 400.0), image_size),
|
||||
space_and_clip,
|
||||
);
|
||||
builder.push_image(
|
||||
|
|
|
@ -94,11 +94,11 @@ impl Example for App {
|
|||
pipeline_id: PipelineId,
|
||||
_document_id: DocumentId,
|
||||
) {
|
||||
let bounds = LayoutRect::new(LayoutPoint::zero(), LayoutSize::new(500.0, 500.0));
|
||||
let bounds = LayoutRect::from_size(LayoutSize::new(500.0, 500.0));
|
||||
let space_and_clip = SpaceAndClipInfo::root_scroll(pipeline_id);
|
||||
|
||||
builder.push_simple_stacking_context(
|
||||
bounds.origin,
|
||||
bounds.min,
|
||||
space_and_clip.spatial_id,
|
||||
PrimitiveFlags::IS_BACKFACE_VISIBLE,
|
||||
);
|
||||
|
@ -157,7 +157,7 @@ impl Example for App {
|
|||
);
|
||||
|
||||
let info = CommonItemProperties::new(
|
||||
LayoutRect::new(LayoutPoint::new(100.0, 0.0), LayoutSize::new(100.0, 100.0)),
|
||||
LayoutRect::from_origin_and_size(LayoutPoint::new(100.0, 0.0), LayoutSize::new(100.0, 100.0)),
|
||||
space_and_clip,
|
||||
);
|
||||
builder.push_yuv_image(
|
||||
|
@ -171,7 +171,7 @@ impl Example for App {
|
|||
);
|
||||
|
||||
let info = CommonItemProperties::new(
|
||||
LayoutRect::new(LayoutPoint::new(300.0, 0.0), LayoutSize::new(100.0, 100.0)),
|
||||
LayoutRect::from_origin_and_size(LayoutPoint::new(300.0, 0.0), LayoutSize::new(100.0, 100.0)),
|
||||
space_and_clip,
|
||||
);
|
||||
builder.push_yuv_image(
|
||||
|
|
|
@ -55,8 +55,8 @@ varying vec2 v_local_pos;
|
|||
void brush_vs(
|
||||
VertexInfo vi,
|
||||
int prim_address,
|
||||
RectWithSize local_rect,
|
||||
RectWithSize segment_rect,
|
||||
RectWithEndpoint local_rect,
|
||||
RectWithEndpoint segment_rect,
|
||||
ivec4 prim_user_data,
|
||||
int specific_resource_address,
|
||||
mat4 transform,
|
||||
|
@ -100,7 +100,7 @@ void brush_shader_main_vs(
|
|||
|
||||
// Fetch the segment of this brush primitive we are drawing.
|
||||
vec4 segment_data;
|
||||
RectWithSize segment_rect;
|
||||
RectWithEndpoint segment_rect;
|
||||
if (instance.segment_index == INVALID_SEGMENT_INDEX) {
|
||||
segment_rect = ph.local_rect;
|
||||
segment_data = vec4(0.0);
|
||||
|
@ -110,8 +110,9 @@ void brush_shader_main_vs(
|
|||
instance.segment_index * VECS_PER_SEGMENT;
|
||||
|
||||
vec4[2] segment_info = fetch_from_gpu_cache_2(segment_address);
|
||||
segment_rect = RectWithSize(segment_info[0].xy, segment_info[0].zw);
|
||||
segment_rect = RectWithEndpoint(segment_info[0].xy, segment_info[0].zw);
|
||||
segment_rect.p0 += ph.local_rect.p0;
|
||||
segment_rect.p1 += ph.local_rect.p0;
|
||||
segment_data = segment_info[1];
|
||||
}
|
||||
|
||||
|
@ -121,7 +122,7 @@ void brush_shader_main_vs(
|
|||
if (transform.is_axis_aligned) {
|
||||
|
||||
// Select the corner of the local rect that we are processing.
|
||||
vec2 local_pos = segment_rect.p0 + segment_rect.size * aPosition.xy;
|
||||
vec2 local_pos = mix(segment_rect.p0, segment_rect.p1, aPosition.xy);
|
||||
|
||||
vi = write_vertex(
|
||||
local_pos,
|
||||
|
|
|
@ -29,8 +29,8 @@ flat varying vec4 v_color_offset;
|
|||
void brush_vs(
|
||||
VertexInfo vi,
|
||||
int prim_address,
|
||||
RectWithSize local_rect,
|
||||
RectWithSize segment_rect,
|
||||
RectWithEndpoint local_rect,
|
||||
RectWithEndpoint segment_rect,
|
||||
ivec4 prim_user_data,
|
||||
int specific_resource_address,
|
||||
mat4 transform,
|
||||
|
@ -43,7 +43,7 @@ void brush_vs(
|
|||
vec2 uv1 = res.uv_rect.p1;
|
||||
|
||||
vec2 inv_texture_size = vec2(1.0) / vec2(TEX_SIZE(sColor0).xy);
|
||||
vec2 f = (vi.local_pos - local_rect.p0) / local_rect.size;
|
||||
vec2 f = (vi.local_pos - local_rect.p0) / rect_size(local_rect);
|
||||
f = get_image_quad_uv(prim_user_data.x, f);
|
||||
vec2 uv = mix(uv0, uv1, f);
|
||||
float perspective_interpolate = (brush_flags & BRUSH_FLAG_PERSPECTIVE_INTERPOLATION) != 0 ? 1.0 : 0.0;
|
||||
|
|
|
@ -60,8 +60,8 @@ ImageBrushData fetch_image_data(int address) {
|
|||
void brush_vs(
|
||||
VertexInfo vi,
|
||||
int prim_address,
|
||||
RectWithSize prim_rect,
|
||||
RectWithSize segment_rect,
|
||||
RectWithEndpoint prim_rect,
|
||||
RectWithEndpoint segment_rect,
|
||||
ivec4 prim_user_data,
|
||||
int specific_resource_address,
|
||||
mat4 transform,
|
||||
|
@ -83,17 +83,17 @@ void brush_vs(
|
|||
vec2 uv0 = res.uv_rect.p0;
|
||||
vec2 uv1 = res.uv_rect.p1;
|
||||
|
||||
RectWithSize local_rect = prim_rect;
|
||||
RectWithEndpoint local_rect = prim_rect;
|
||||
vec2 stretch_size = image_data.stretch_size;
|
||||
if (stretch_size.x < 0.0) {
|
||||
stretch_size = local_rect.size;
|
||||
stretch_size = rect_size(local_rect);
|
||||
}
|
||||
|
||||
// If this segment should interpolate relative to the
|
||||
// segment, modify the parameters for that.
|
||||
if ((brush_flags & BRUSH_FLAG_SEGMENT_RELATIVE) != 0) {
|
||||
local_rect = segment_rect;
|
||||
stretch_size = local_rect.size;
|
||||
stretch_size = rect_size(local_rect);
|
||||
|
||||
if ((brush_flags & BRUSH_FLAG_TEXEL_RECT) != 0) {
|
||||
// If the extra data is a texel rect, modify the UVs.
|
||||
|
@ -131,8 +131,7 @@ void brush_vs(
|
|||
vertical_uv_size.x = uv0.x - res.uv_rect.p0.x;
|
||||
if (vertical_uv_size.x < epsilon || repeated_stretch_size.x < epsilon) {
|
||||
vertical_uv_size.x = res.uv_rect.p1.x - uv1.x;
|
||||
repeated_stretch_size.x = prim_rect.p0.x + prim_rect.size.x
|
||||
- segment_rect.p0.x - segment_rect.size.x;
|
||||
repeated_stretch_size.x = prim_rect.p1.x - segment_rect.p1.x;
|
||||
}
|
||||
|
||||
// Adjust the the referecne uv size to compute horizontal repetitions
|
||||
|
@ -140,8 +139,7 @@ void brush_vs(
|
|||
horizontal_uv_size.y = uv0.y - res.uv_rect.p0.y;
|
||||
if (horizontal_uv_size.y < epsilon || repeated_stretch_size.y < epsilon) {
|
||||
horizontal_uv_size.y = res.uv_rect.p1.y - uv1.y;
|
||||
repeated_stretch_size.y = prim_rect.p0.y + prim_rect.size.y
|
||||
- segment_rect.p0.y - segment_rect.size.y;
|
||||
repeated_stretch_size.y = prim_rect.p1.y - segment_rect.p1.y;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -163,12 +161,14 @@ void brush_vs(
|
|||
}
|
||||
}
|
||||
if ((brush_flags & BRUSH_FLAG_SEGMENT_REPEAT_X_ROUND) != 0) {
|
||||
float nx = max(1.0, round(segment_rect.size.x / stretch_size.x));
|
||||
stretch_size.x = segment_rect.size.x / nx;
|
||||
float segment_rect_width = segment_rect.p1.x - segment_rect.p0.x;
|
||||
float nx = max(1.0, round(segment_rect_width / stretch_size.x));
|
||||
stretch_size.x = segment_rect_width / nx;
|
||||
}
|
||||
if ((brush_flags & BRUSH_FLAG_SEGMENT_REPEAT_Y_ROUND) != 0) {
|
||||
float ny = max(1.0, round(segment_rect.size.y / stretch_size.y));
|
||||
stretch_size.y = segment_rect.size.y / ny;
|
||||
float segment_rect_height = segment_rect.p1.y - segment_rect.p0.y;
|
||||
float ny = max(1.0, round(segment_rect_height / stretch_size.y));
|
||||
stretch_size.y = segment_rect_height / ny;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
@ -186,7 +186,7 @@ void brush_vs(
|
|||
max_uv - vec2(0.5)
|
||||
) / texture_size.xyxy;
|
||||
|
||||
vec2 f = (vi.local_pos - local_rect.p0) / local_rect.size;
|
||||
vec2 f = (vi.local_pos - local_rect.p0) / rect_size(local_rect);
|
||||
|
||||
#ifdef WR_FEATURE_ALPHA_PASS
|
||||
int color_mode = prim_user_data.x & 0xffff;
|
||||
|
@ -209,7 +209,7 @@ void brush_vs(
|
|||
#endif
|
||||
|
||||
// Offset and scale v_uv here to avoid doing it in the fragment shader.
|
||||
vec2 repeat = local_rect.size / stretch_size;
|
||||
vec2 repeat = rect_size(local_rect) / stretch_size;
|
||||
v_uv = mix(uv0, uv1, f) - min_uv;
|
||||
v_uv /= texture_size;
|
||||
v_uv *= repeat.xy;
|
||||
|
|
|
@ -29,8 +29,8 @@ Gradient fetch_gradient(int address) {
|
|||
void brush_vs(
|
||||
VertexInfo vi,
|
||||
int prim_address,
|
||||
RectWithSize local_rect,
|
||||
RectWithSize segment_rect,
|
||||
RectWithEndpoint local_rect,
|
||||
RectWithEndpoint segment_rect,
|
||||
ivec4 prim_user_data,
|
||||
int specific_resource_address,
|
||||
mat4 transform,
|
||||
|
|
|
@ -53,8 +53,8 @@ void get_uv(
|
|||
void brush_vs(
|
||||
VertexInfo vi,
|
||||
int prim_address,
|
||||
RectWithSize local_rect,
|
||||
RectWithSize segment_rect,
|
||||
RectWithEndpoint local_rect,
|
||||
RectWithEndpoint segment_rect,
|
||||
ivec4 prim_user_data,
|
||||
int specific_resource_address,
|
||||
mat4 transform,
|
||||
|
@ -62,7 +62,7 @@ void brush_vs(
|
|||
int brush_flags,
|
||||
vec4 unused
|
||||
) {
|
||||
vec2 f = (vi.local_pos - local_rect.p0) / local_rect.size;
|
||||
vec2 f = (vi.local_pos - local_rect.p0) / rect_size(local_rect);
|
||||
float perspective_interpolate = (brush_flags & BRUSH_FLAG_PERSPECTIVE_INTERPOLATION) != 0 ? 1.0 : 0.0;
|
||||
float perspective_f = mix(vi.world_pos.w, 1.0, perspective_interpolate);
|
||||
v_perspective = perspective_interpolate;
|
||||
|
|
|
@ -30,8 +30,8 @@ flat varying float v_opacity;
|
|||
void brush_vs(
|
||||
VertexInfo vi,
|
||||
int prim_address,
|
||||
RectWithSize local_rect,
|
||||
RectWithSize segment_rect,
|
||||
RectWithEndpoint local_rect,
|
||||
RectWithEndpoint segment_rect,
|
||||
ivec4 prim_user_data,
|
||||
int specific_resource_address,
|
||||
mat4 transform,
|
||||
|
@ -44,7 +44,7 @@ void brush_vs(
|
|||
vec2 uv1 = res.uv_rect.p1;
|
||||
|
||||
vec2 texture_size = vec2(TEX_SIZE(sColor0).xy);
|
||||
vec2 f = (vi.local_pos - local_rect.p0) / local_rect.size;
|
||||
vec2 f = (vi.local_pos - local_rect.p0) / rect_size(local_rect);
|
||||
f = get_image_quad_uv(prim_user_data.x, f);
|
||||
vec2 uv = mix(uv0, uv1, f);
|
||||
float perspective_interpolate = (brush_flags & BRUSH_FLAG_PERSPECTIVE_INTERPOLATION) != 0 ? 1.0 : 0.0;
|
||||
|
|
|
@ -22,8 +22,8 @@ SolidBrush fetch_solid_primitive(int address) {
|
|||
void brush_vs(
|
||||
VertexInfo vi,
|
||||
int prim_address,
|
||||
RectWithSize local_rect,
|
||||
RectWithSize segment_rect,
|
||||
RectWithEndpoint local_rect,
|
||||
RectWithEndpoint segment_rect,
|
||||
ivec4 prim_user_data,
|
||||
int specific_resource_address,
|
||||
mat4 transform,
|
||||
|
|
|
@ -40,8 +40,8 @@ YuvPrimitive fetch_yuv_primitive(int address) {
|
|||
void brush_vs(
|
||||
VertexInfo vi,
|
||||
int prim_address,
|
||||
RectWithSize local_rect,
|
||||
RectWithSize segment_rect,
|
||||
RectWithEndpoint local_rect,
|
||||
RectWithEndpoint segment_rect,
|
||||
ivec4 prim_user_data,
|
||||
int specific_resource_address,
|
||||
mat4 transform,
|
||||
|
@ -49,7 +49,7 @@ void brush_vs(
|
|||
int brush_flags,
|
||||
vec4 unused
|
||||
) {
|
||||
vec2 f = (vi.local_pos - local_rect.p0) / local_rect.size;
|
||||
vec2 f = (vi.local_pos - local_rect.p0) / rect_size(local_rect);
|
||||
|
||||
YuvPrimitive prim = fetch_yuv_primitive(prim_address);
|
||||
vYuvOffsetVector_Coefficient.w = prim.coefficient;
|
||||
|
|
|
@ -35,18 +35,12 @@ ClipMaskInstanceCommon fetch_clip_item_common() {
|
|||
|
||||
struct ClipVertexInfo {
|
||||
vec4 local_pos;
|
||||
RectWithSize clipped_local_rect;
|
||||
RectWithEndpoint clipped_local_rect;
|
||||
};
|
||||
|
||||
RectWithSize intersect_rect(RectWithSize a, RectWithSize b) {
|
||||
vec4 p = clamp(vec4(a.p0, a.p0 + a.size), b.p0.xyxy, b.p0.xyxy + b.size.xyxy);
|
||||
return RectWithSize(p.xy, max(vec2(0.0), p.zw - p.xy));
|
||||
}
|
||||
|
||||
|
||||
// The transformed vertex function that always covers the whole clip area,
|
||||
// which is the intersection of all clip instances of a given primitive
|
||||
ClipVertexInfo write_clip_tile_vertex(RectWithSize local_clip_rect,
|
||||
ClipVertexInfo write_clip_tile_vertex(RectWithEndpoint local_clip_rect,
|
||||
Transform prim_transform,
|
||||
Transform clip_transform,
|
||||
RectWithEndpoint sub_rect,
|
||||
|
@ -77,7 +71,7 @@ ClipVertexInfo write_clip_tile_vertex(RectWithSize local_clip_rect,
|
|||
|
||||
gl_Position = uTransform * vertex_pos;
|
||||
|
||||
init_transform_vs(vec4(local_clip_rect.p0, local_clip_rect.p0 + local_clip_rect.size));
|
||||
init_transform_vs(vec4(local_clip_rect.p0, local_clip_rect.p1));
|
||||
|
||||
ClipVertexInfo vi = ClipVertexInfo(local_pos, local_clip_rect);
|
||||
return vi;
|
||||
|
|
|
@ -25,7 +25,7 @@ PER_INSTANCE in int aBlurSourceTaskAddress;
|
|||
PER_INSTANCE in int aBlurDirection;
|
||||
|
||||
struct BlurTask {
|
||||
RectWithSize task_rect;
|
||||
RectWithEndpoint task_rect;
|
||||
float blur_radius;
|
||||
vec2 blur_region;
|
||||
};
|
||||
|
@ -68,9 +68,9 @@ void calculate_gauss_coefficients(float sigma) {
|
|||
|
||||
void main(void) {
|
||||
BlurTask blur_task = fetch_blur_task(aBlurRenderTaskAddress);
|
||||
RectWithSize src_rect = fetch_render_task_rect(aBlurSourceTaskAddress);
|
||||
RectWithEndpoint src_rect = fetch_render_task_rect(aBlurSourceTaskAddress);
|
||||
|
||||
RectWithSize target_rect = blur_task.task_rect;
|
||||
RectWithEndpoint target_rect = blur_task.task_rect;
|
||||
|
||||
vec2 texture_size = vec2(TEX_SIZE(sColor0).xy);
|
||||
|
||||
|
@ -103,10 +103,10 @@ void main(void) {
|
|||
src_rect.p0 + blur_task.blur_region - vec2(0.5));
|
||||
vUvRect /= texture_size.xyxy;
|
||||
|
||||
vec2 pos = target_rect.p0 + target_rect.size * aPosition.xy;
|
||||
vec2 pos = mix(target_rect.p0, target_rect.p1, aPosition.xy);
|
||||
|
||||
vec2 uv0 = src_rect.p0 / texture_size;
|
||||
vec2 uv1 = (src_rect.p0 + src_rect.size) / texture_size;
|
||||
vec2 uv1 = src_rect.p1 / texture_size;
|
||||
vUv = mix(uv0, uv1, aPosition.xy);
|
||||
|
||||
gl_Position = uTransform * vec4(pos, 0.0, 1.0);
|
||||
|
|
|
@ -48,7 +48,7 @@ struct BoxShadowData {
|
|||
int clip_mode;
|
||||
int stretch_mode_x;
|
||||
int stretch_mode_y;
|
||||
RectWithSize dest_rect;
|
||||
RectWithEndpoint dest_rect;
|
||||
};
|
||||
|
||||
BoxShadowData fetch_data() {
|
||||
|
@ -57,7 +57,7 @@ BoxShadowData fetch_data() {
|
|||
aClipMode,
|
||||
aStretchMode.x,
|
||||
aStretchMode.y,
|
||||
RectWithSize(aClipDestRect.xy, aClipDestRect.zw)
|
||||
RectWithEndpoint(aClipDestRect.xy, aClipDestRect.zw)
|
||||
);
|
||||
return bs_data;
|
||||
}
|
||||
|
@ -69,7 +69,7 @@ void main(void) {
|
|||
BoxShadowData bs_data = fetch_data();
|
||||
ImageSource res = fetch_image_source_direct(cmi.resource_address);
|
||||
|
||||
RectWithSize dest_rect = bs_data.dest_rect;
|
||||
RectWithEndpoint dest_rect = bs_data.dest_rect;
|
||||
|
||||
ClipVertexInfo vi = write_clip_tile_vertex(
|
||||
dest_rect,
|
||||
|
@ -85,18 +85,19 @@ void main(void) {
|
|||
vec2 texture_size = vec2(TEX_SIZE(sColor0));
|
||||
vec2 local_pos = vi.local_pos.xy / vi.local_pos.w;
|
||||
vLocalPos = vi.local_pos;
|
||||
vec2 dest_rect_size = rect_size(dest_rect);
|
||||
|
||||
switch (bs_data.stretch_mode_x) {
|
||||
case MODE_STRETCH: {
|
||||
vEdge.x = 0.5;
|
||||
vEdge.z = (dest_rect.size.x / bs_data.src_rect_size.x) - 0.5;
|
||||
vEdge.z = (dest_rect_size.x / bs_data.src_rect_size.x) - 0.5;
|
||||
vUv.x = (local_pos.x - dest_rect.p0.x) / bs_data.src_rect_size.x;
|
||||
break;
|
||||
}
|
||||
case MODE_SIMPLE:
|
||||
default: {
|
||||
vEdge.xz = vec2(1.0);
|
||||
vUv.x = (local_pos.x - dest_rect.p0.x) / dest_rect.size.x;
|
||||
vUv.x = (local_pos.x - dest_rect.p0.x) / dest_rect_size.x;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -104,14 +105,14 @@ void main(void) {
|
|||
switch (bs_data.stretch_mode_y) {
|
||||
case MODE_STRETCH: {
|
||||
vEdge.y = 0.5;
|
||||
vEdge.w = (dest_rect.size.y / bs_data.src_rect_size.y) - 0.5;
|
||||
vEdge.w = (dest_rect_size.y / bs_data.src_rect_size.y) - 0.5;
|
||||
vUv.y = (local_pos.y - dest_rect.p0.y) / bs_data.src_rect_size.y;
|
||||
break;
|
||||
}
|
||||
case MODE_SIMPLE:
|
||||
default: {
|
||||
vEdge.yw = vec2(1.0);
|
||||
vUv.y = (local_pos.y - dest_rect.p0.y) / dest_rect.size.y;
|
||||
vUv.y = (local_pos.y - dest_rect.p0.y) / dest_rect_size.y;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,9 +17,9 @@ PER_INSTANCE in vec4 aClipLocalRect;
|
|||
|
||||
struct ClipMaskInstanceImage {
|
||||
ClipMaskInstanceCommon base;
|
||||
RectWithSize tile_rect;
|
||||
RectWithEndpoint tile_rect;
|
||||
ivec2 resource_address;
|
||||
RectWithSize local_rect;
|
||||
RectWithEndpoint local_rect;
|
||||
};
|
||||
|
||||
ClipMaskInstanceImage fetch_clip_item() {
|
||||
|
@ -27,9 +27,9 @@ ClipMaskInstanceImage fetch_clip_item() {
|
|||
|
||||
cmi.base = fetch_clip_item_common();
|
||||
|
||||
cmi.tile_rect = RectWithSize(aClipTileRect.xy, aClipTileRect.zw);
|
||||
cmi.tile_rect = RectWithEndpoint(aClipTileRect.xy, aClipTileRect.zw);
|
||||
cmi.resource_address = aClipDataResourceAddress;
|
||||
cmi.local_rect = RectWithSize(aClipLocalRect.xy, aClipLocalRect.zw);
|
||||
cmi.local_rect = RectWithEndpoint(aClipLocalRect.xy, aClipLocalRect.zw);
|
||||
|
||||
return cmi;
|
||||
}
|
||||
|
@ -42,15 +42,15 @@ struct ClipImageVertexInfo {
|
|||
// This differs from write_clip_tile_vertex in that we forward transform the
|
||||
// primitive's local-space tile rect into the target space. We use scissoring
|
||||
// to ensure that the primitive does not draw outside the target bounds.
|
||||
ClipImageVertexInfo write_clip_image_vertex(RectWithSize tile_rect,
|
||||
RectWithSize local_clip_rect,
|
||||
ClipImageVertexInfo write_clip_image_vertex(RectWithEndpoint tile_rect,
|
||||
RectWithEndpoint local_clip_rect,
|
||||
Transform prim_transform,
|
||||
Transform clip_transform,
|
||||
RectWithEndpoint sub_rect,
|
||||
vec2 task_origin,
|
||||
vec2 screen_origin,
|
||||
float device_pixel_scale) {
|
||||
vec2 local_pos = clamp_rect(tile_rect.p0 + aPosition.xy * tile_rect.size, local_clip_rect);
|
||||
vec2 local_pos = rect_clamp(local_clip_rect, mix(tile_rect.p0, tile_rect.p1, aPosition.xy));
|
||||
vec4 world_pos = prim_transform.m * vec4(local_pos, 0.0, 1.0);
|
||||
vec4 final_pos = vec4(
|
||||
world_pos.xy * device_pixel_scale + (task_origin - screen_origin) * world_pos.w,
|
||||
|
@ -62,7 +62,7 @@ ClipImageVertexInfo write_clip_image_vertex(RectWithSize tile_rect,
|
|||
init_transform_vs(
|
||||
clip_transform.is_axis_aligned
|
||||
? vec4(vec2(-1.0e16), vec2(1.0e16))
|
||||
: vec4(local_clip_rect.p0, local_clip_rect.p0 + local_clip_rect.size));
|
||||
: vec4(local_clip_rect.p0, local_clip_rect.p1));
|
||||
|
||||
ClipImageVertexInfo vi = ClipImageVertexInfo(local_pos, world_pos);
|
||||
return vi;
|
||||
|
@ -85,7 +85,7 @@ void main(void) {
|
|||
cmi.base.device_pixel_scale
|
||||
);
|
||||
vLocalPos = vi.local_pos;
|
||||
vec2 uv = (vi.local_pos - cmi.tile_rect.p0) / cmi.tile_rect.size;
|
||||
vec2 uv = (vi.local_pos - cmi.tile_rect.p0) / rect_size(cmi.tile_rect);
|
||||
|
||||
vec2 texture_size = vec2(TEX_SIZE(sColor0));
|
||||
vec4 uv_rect = vec4(res.uv_rect.p0, res.uv_rect.p1);
|
||||
|
|
|
@ -50,12 +50,12 @@ ClipMaskInstanceRect fetch_clip_item() {
|
|||
}
|
||||
|
||||
struct ClipRect {
|
||||
RectWithSize rect;
|
||||
RectWithEndpoint rect;
|
||||
float mode;
|
||||
};
|
||||
|
||||
struct ClipCorner {
|
||||
RectWithSize rect;
|
||||
RectWithEndpoint rect;
|
||||
vec4 outer_inner_radius;
|
||||
};
|
||||
|
||||
|
@ -70,11 +70,11 @@ struct ClipData {
|
|||
ClipData fetch_clip() {
|
||||
ClipData clip;
|
||||
|
||||
clip.rect = ClipRect(RectWithSize(aClipLocalRect.xy, aClipLocalRect.zw), aClipMode);
|
||||
clip.top_left = ClipCorner(RectWithSize(aClipRect_TL.xy, aClipRect_TL.zw), aClipRadii_TL);
|
||||
clip.top_right = ClipCorner(RectWithSize(aClipRect_TR.xy, aClipRect_TR.zw), aClipRadii_TR);
|
||||
clip.bottom_left = ClipCorner(RectWithSize(aClipRect_BL.xy, aClipRect_BL.zw), aClipRadii_BL);
|
||||
clip.bottom_right = ClipCorner(RectWithSize(aClipRect_BR.xy, aClipRect_BR.zw), aClipRadii_BR);
|
||||
clip.rect = ClipRect(RectWithEndpoint(aClipLocalRect.xy, aClipLocalRect.zw), aClipMode);
|
||||
clip.top_left = ClipCorner(RectWithEndpoint(aClipRect_TL.xy, aClipRect_TL.zw), aClipRadii_TL);
|
||||
clip.top_right = ClipCorner(RectWithEndpoint(aClipRect_TR.xy, aClipRect_TR.zw), aClipRadii_TR);
|
||||
clip.bottom_left = ClipCorner(RectWithEndpoint(aClipRect_BL.xy, aClipRect_BL.zw), aClipRadii_BL);
|
||||
clip.bottom_right = ClipCorner(RectWithEndpoint(aClipRect_BR.xy, aClipRect_BR.zw), aClipRadii_BR);
|
||||
|
||||
return clip;
|
||||
}
|
||||
|
@ -85,8 +85,10 @@ void main(void) {
|
|||
Transform prim_transform = fetch_transform(cmi.base.prim_transform_id);
|
||||
ClipData clip = fetch_clip();
|
||||
|
||||
RectWithSize local_rect = clip.rect.rect;
|
||||
RectWithEndpoint local_rect = clip.rect.rect;
|
||||
vec2 diff = cmi.local_pos - local_rect.p0;
|
||||
local_rect.p0 = cmi.local_pos;
|
||||
local_rect.p1 += diff;
|
||||
|
||||
ClipVertexInfo vi = write_clip_tile_vertex(
|
||||
local_rect,
|
||||
|
@ -104,12 +106,12 @@ void main(void) {
|
|||
#ifdef WR_FEATURE_FAST_PATH
|
||||
// If the radii are all uniform, we can use a much simpler 2d
|
||||
// signed distance function to get a rounded rect clip.
|
||||
vec2 half_size = 0.5 * local_rect.size;
|
||||
vec2 half_size = 0.5 * rect_size(local_rect);
|
||||
float radius = clip.top_left.outer_inner_radius.x;
|
||||
vLocalPos.xy -= (half_size + cmi.local_pos) * vi.local_pos.w;
|
||||
vClipParams = vec3(half_size - vec2(radius), radius);
|
||||
#else
|
||||
RectWithEndpoint clip_rect = to_rect_with_endpoint(local_rect);
|
||||
RectWithEndpoint clip_rect = local_rect;
|
||||
|
||||
vec2 r_tl = clip.top_left.outer_inner_radius.xy;
|
||||
vec2 r_tr = clip.top_right.outer_inner_radius.xy;
|
||||
|
|
|
@ -17,7 +17,6 @@ flat varying float v_angle;
|
|||
|
||||
#define EXTEND_MODE_REPEAT 1
|
||||
|
||||
// Rectangle in origin+size format
|
||||
PER_INSTANCE in vec4 aTaskRect;
|
||||
PER_INSTANCE in vec2 aCenter;
|
||||
PER_INSTANCE in vec2 aScale;
|
||||
|
|
|
@ -13,7 +13,6 @@ flat varying float v_start_offset;
|
|||
|
||||
#define EXTEND_MODE_REPEAT 1
|
||||
|
||||
// Rectangle in origin+size format
|
||||
PER_INSTANCE in vec4 aTaskRect;
|
||||
PER_INSTANCE in vec2 aStartPoint;
|
||||
PER_INSTANCE in vec2 aEndPoint;
|
||||
|
|
|
@ -12,7 +12,6 @@ flat varying float v_start_radius;
|
|||
|
||||
#define EXTEND_MODE_REPEAT 1
|
||||
|
||||
// Rectangle in origin+size format
|
||||
PER_INSTANCE in vec4 aTaskRect;
|
||||
PER_INSTANCE in vec2 aCenter;
|
||||
PER_INSTANCE in vec2 aScale;
|
||||
|
|
|
@ -57,7 +57,7 @@ PER_INSTANCE in int aFilterGenericInt;
|
|||
PER_INSTANCE in ivec2 aFilterExtraDataAddress;
|
||||
|
||||
struct FilterTask {
|
||||
RectWithSize task_rect;
|
||||
RectWithEndpoint task_rect;
|
||||
vec3 user_data;
|
||||
};
|
||||
|
||||
|
@ -72,26 +72,26 @@ FilterTask fetch_filter_task(int address) {
|
|||
return task;
|
||||
}
|
||||
|
||||
vec4 compute_uv_rect(RectWithSize task_rect, vec2 texture_size) {
|
||||
vec4 compute_uv_rect(RectWithEndpoint task_rect, vec2 texture_size) {
|
||||
vec4 uvRect = vec4(task_rect.p0 + vec2(0.5),
|
||||
task_rect.p0 + task_rect.size - vec2(0.5));
|
||||
task_rect.p1 - vec2(0.5));
|
||||
uvRect /= texture_size.xyxy;
|
||||
return uvRect;
|
||||
}
|
||||
|
||||
vec2 compute_uv(RectWithSize task_rect, vec2 texture_size) {
|
||||
vec2 compute_uv(RectWithEndpoint task_rect, vec2 texture_size) {
|
||||
vec2 uv0 = task_rect.p0 / texture_size;
|
||||
vec2 uv1 = floor(task_rect.p0 + task_rect.size) / texture_size;
|
||||
vec2 uv1 = floor(task_rect.p1) / texture_size;
|
||||
return mix(uv0, uv1, aPosition.xy);
|
||||
}
|
||||
|
||||
void main(void) {
|
||||
FilterTask filter_task = fetch_filter_task(aFilterRenderTaskAddress);
|
||||
RectWithSize target_rect = filter_task.task_rect;
|
||||
RectWithEndpoint target_rect = filter_task.task_rect;
|
||||
|
||||
vec2 pos = target_rect.p0 + target_rect.size * aPosition.xy;
|
||||
vec2 pos = mix(target_rect.p0, target_rect.p1, aPosition.xy);
|
||||
|
||||
RectWithSize input_1_task;
|
||||
RectWithEndpoint input_1_task;
|
||||
if (aFilterInputCount > 0) {
|
||||
vec2 texture_size = vec2(TEX_SIZE(sColor0).xy);
|
||||
input_1_task = fetch_render_task_rect(aFilterInput1TaskAddress);
|
||||
|
@ -99,7 +99,7 @@ void main(void) {
|
|||
vInput1Uv = compute_uv(input_1_task, texture_size);
|
||||
}
|
||||
|
||||
RectWithSize input_2_task;
|
||||
RectWithEndpoint input_2_task;
|
||||
if (aFilterInputCount > 1) {
|
||||
vec2 texture_size = vec2(TEX_SIZE(sColor1).xy);
|
||||
input_2_task = fetch_render_task_rect(aFilterInput2TaskAddress);
|
||||
|
@ -144,8 +144,8 @@ void main(void) {
|
|||
vec2 texture_size = vec2(TEX_SIZE(sColor0).xy);
|
||||
vFilterData0 = vec4(-filter_task.user_data.xy / texture_size, vec2(0.0));
|
||||
|
||||
RectWithSize task_rect = input_1_task;
|
||||
vec4 clipRect = vec4(task_rect.p0, task_rect.p0 + task_rect.size);
|
||||
RectWithEndpoint task_rect = input_1_task;
|
||||
vec4 clipRect = vec4(task_rect.p0, task_rect.p1);
|
||||
clipRect /= texture_size.xyxy;
|
||||
vFilterData1 = clipRect;
|
||||
break;
|
||||
|
|
|
@ -18,8 +18,8 @@ flat varying vec2 v_tile_repeat;
|
|||
#ifdef WR_VERTEX_SHADER
|
||||
void write_gradient_vertex(
|
||||
VertexInfo vi,
|
||||
RectWithSize local_rect,
|
||||
RectWithSize segment_rect,
|
||||
RectWithEndpoint local_rect,
|
||||
RectWithEndpoint segment_rect,
|
||||
ivec4 prim_user_data,
|
||||
int brush_flags,
|
||||
vec4 texel_rect,
|
||||
|
@ -27,14 +27,14 @@ void write_gradient_vertex(
|
|||
vec2 stretch_size
|
||||
) {
|
||||
if ((brush_flags & BRUSH_FLAG_SEGMENT_RELATIVE) != 0) {
|
||||
v_pos = (vi.local_pos - segment_rect.p0) / segment_rect.size;
|
||||
v_pos = (vi.local_pos - segment_rect.p0) / rect_size(segment_rect);
|
||||
v_pos = v_pos * (texel_rect.zw - texel_rect.xy) + texel_rect.xy;
|
||||
v_pos = v_pos * local_rect.size;
|
||||
v_pos = v_pos * rect_size(local_rect);
|
||||
} else {
|
||||
v_pos = vi.local_pos - local_rect.p0;
|
||||
}
|
||||
|
||||
vec2 tile_repeat = local_rect.size / stretch_size;
|
||||
vec2 tile_repeat = rect_size(local_rect) / stretch_size;
|
||||
v_repeated_size = stretch_size;
|
||||
|
||||
// Normalize UV to 0..1 scale.
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
uniform sampler2D sClipMask;
|
||||
|
||||
#ifndef SWGL_CLIP_MASK
|
||||
// TODO: convert back to RectWithEndPoint if driver issues are resolved, if ever.
|
||||
// TODO: convert back to RectWithEndpoint if driver issues are resolved, if ever.
|
||||
flat varying vec4 vClipMaskUvBounds;
|
||||
varying vec2 vClipMaskUv;
|
||||
#endif
|
||||
|
@ -72,8 +72,8 @@ Instance decode_instance_attributes() {
|
|||
}
|
||||
|
||||
struct PrimitiveHeader {
|
||||
RectWithSize local_rect;
|
||||
RectWithSize local_clip_rect;
|
||||
RectWithEndpoint local_rect;
|
||||
RectWithEndpoint local_clip_rect;
|
||||
float z;
|
||||
int specific_prim_address;
|
||||
int transform_id;
|
||||
|
@ -86,8 +86,8 @@ PrimitiveHeader fetch_prim_header(int index) {
|
|||
ivec2 uv_f = get_fetch_uv(index, VECS_PER_PRIM_HEADER_F);
|
||||
vec4 local_rect = TEXEL_FETCH(sPrimitiveHeadersF, uv_f, 0, ivec2(0, 0));
|
||||
vec4 local_clip_rect = TEXEL_FETCH(sPrimitiveHeadersF, uv_f, 0, ivec2(1, 0));
|
||||
ph.local_rect = RectWithSize(local_rect.xy, local_rect.zw);
|
||||
ph.local_clip_rect = RectWithSize(local_clip_rect.xy, local_clip_rect.zw);
|
||||
ph.local_rect = RectWithEndpoint(local_rect.xy, local_rect.zw);
|
||||
ph.local_clip_rect = RectWithEndpoint(local_clip_rect.xy, local_clip_rect.zw);
|
||||
|
||||
ivec2 uv_i = get_fetch_uv(index, VECS_PER_PRIM_HEADER_I);
|
||||
ivec4 data0 = TEXEL_FETCH(sPrimitiveHeadersI, uv_i, 0, ivec2(0, 0));
|
||||
|
@ -106,12 +106,12 @@ struct VertexInfo {
|
|||
};
|
||||
|
||||
VertexInfo write_vertex(vec2 local_pos,
|
||||
RectWithSize local_clip_rect,
|
||||
RectWithEndpoint local_clip_rect,
|
||||
float z,
|
||||
Transform transform,
|
||||
PictureTask task) {
|
||||
// Clamp to the two local clip rects.
|
||||
vec2 clamped_local_pos = clamp_rect(local_pos, local_clip_rect);
|
||||
vec2 clamped_local_pos = rect_clamp(local_clip_rect, local_pos);
|
||||
|
||||
// Transform the current vertex to world space.
|
||||
vec4 world_pos = transform.m * vec4(clamped_local_pos, 0.0, 1.0);
|
||||
|
@ -151,16 +151,16 @@ vec2 intersect_lines(vec2 p0, vec2 p1, vec2 p2, vec2 p3) {
|
|||
return vec2(nx / d, ny / d);
|
||||
}
|
||||
|
||||
VertexInfo write_transform_vertex(RectWithSize local_segment_rect,
|
||||
RectWithSize local_prim_rect,
|
||||
RectWithSize local_clip_rect,
|
||||
VertexInfo write_transform_vertex(RectWithEndpoint local_segment_rect,
|
||||
RectWithEndpoint local_prim_rect,
|
||||
RectWithEndpoint local_clip_rect,
|
||||
int edge_flags,
|
||||
float z,
|
||||
Transform transform,
|
||||
PictureTask task) {
|
||||
// Calculate a clip rect from local_rect + local clip
|
||||
RectWithEndpoint clip_rect = to_rect_with_endpoint(local_clip_rect);
|
||||
RectWithEndpoint segment_rect = to_rect_with_endpoint(local_segment_rect);
|
||||
RectWithEndpoint clip_rect = local_clip_rect;
|
||||
RectWithEndpoint segment_rect = local_segment_rect;
|
||||
|
||||
#ifdef SWGL_ANTIALIAS
|
||||
// Check if the bounds are smaller than the unmodified segment rect. If so,
|
||||
|
@ -176,9 +176,9 @@ VertexInfo write_transform_vertex(RectWithSize local_segment_rect,
|
|||
|
||||
#ifdef SWGL_ANTIALIAS
|
||||
// Trim the segment geometry to the clipped bounds.
|
||||
local_segment_rect = to_rect_with_size(segment_rect);
|
||||
local_segment_rect = segment_rect;
|
||||
#else
|
||||
RectWithEndpoint prim_rect = to_rect_with_endpoint(local_prim_rect);
|
||||
RectWithEndpoint prim_rect = local_prim_rect;
|
||||
prim_rect.p0 = clamp(prim_rect.p0, clip_rect.p0, clip_rect.p1);
|
||||
prim_rect.p1 = clamp(prim_rect.p1, clip_rect.p0, clip_rect.p1);
|
||||
|
||||
|
@ -203,11 +203,11 @@ VertexInfo write_transform_vertex(RectWithSize local_segment_rect,
|
|||
float extrude_amount = 2.0;
|
||||
vec4 extrude_distance = mix(vec4(0.0), vec4(extrude_amount), clip_edge_mask);
|
||||
local_segment_rect.p0 -= extrude_distance.xy;
|
||||
local_segment_rect.size += extrude_distance.xy + extrude_distance.zw;
|
||||
local_segment_rect.p1 += extrude_distance.zw;
|
||||
#endif
|
||||
|
||||
// Select the corner of the local rect that we are processing.
|
||||
vec2 local_pos = local_segment_rect.p0 + local_segment_rect.size * aPosition.xy;
|
||||
vec2 local_pos = mix(local_segment_rect.p0, local_segment_rect.p1, aPosition.xy);
|
||||
|
||||
// Convert the world positions to device pixel space.
|
||||
vec2 task_offset = task.task_rect.p0 - task.content_origin;
|
||||
|
@ -236,14 +236,14 @@ void write_clip(vec4 world_pos, ClipArea area, PictureTask task) {
|
|||
sClipMask,
|
||||
(task.task_rect.p0 - task.content_origin) - (area.task_rect.p0 - area.screen_origin),
|
||||
area.task_rect.p0,
|
||||
area.task_rect.size
|
||||
rect_size(area.task_rect)
|
||||
);
|
||||
#else
|
||||
vec2 uv = world_pos.xy * area.device_pixel_scale +
|
||||
world_pos.w * (area.task_rect.p0 - area.screen_origin);
|
||||
vClipMaskUvBounds = vec4(
|
||||
area.task_rect.p0,
|
||||
area.task_rect.p0 + area.task_rect.size
|
||||
area.task_rect.p1
|
||||
);
|
||||
vClipMaskUv = uv;
|
||||
#endif
|
||||
|
|
|
@ -11,7 +11,7 @@ PER_INSTANCE in vec4 aRect;
|
|||
PER_INSTANCE in vec4 aColor;
|
||||
|
||||
void main(void) {
|
||||
vec2 pos = aRect.xy + aPosition.xy * aRect.zw;
|
||||
vec2 pos = mix(aRect.xy, aRect.zw, aPosition.xy);
|
||||
gl_Position = uTransform * vec4(pos, 0.0, 1.0);
|
||||
gl_Position.z = gl_Position.w; // force depth clear to 1.0
|
||||
vColor = aColor;
|
||||
|
|
|
@ -110,7 +110,7 @@ void main(void) {
|
|||
max_uv - vec2(0.5)
|
||||
) / texture_size.xyxy;
|
||||
|
||||
vec2 f = (local_pos - ph.local_rect.p0) / ph.local_rect.size;
|
||||
vec2 f = (local_pos - ph.local_rect.p0) / rect_size(ph.local_rect);
|
||||
f = get_image_quad_uv(ph.user_data.x, f);
|
||||
vec2 uv = mix(uv0, uv1, f);
|
||||
float perspective_interpolate = float(ph.user_data.y);
|
||||
|
|
|
@ -23,15 +23,15 @@ varying vec4 v_uv_clip;
|
|||
#define GLYPHS_PER_GPU_BLOCK 2U
|
||||
|
||||
#ifdef WR_FEATURE_GLYPH_TRANSFORM
|
||||
RectWithSize transform_rect(RectWithSize rect, mat2 transform) {
|
||||
vec2 center = transform * (rect.p0 + rect.size * 0.5);
|
||||
vec2 radius = mat2(abs(transform[0]), abs(transform[1])) * (rect.size * 0.5);
|
||||
return RectWithSize(center - radius, radius * 2.0);
|
||||
RectWithEndpoint transform_rect(RectWithEndpoint rect, mat2 transform) {
|
||||
vec2 size = rect_size(rect);
|
||||
vec2 center = transform * (rect.p0 + size * 0.5);
|
||||
vec2 radius = mat2(abs(transform[0]), abs(transform[1])) * (size * 0.5);
|
||||
return RectWithEndpoint(center - radius, center + radius);
|
||||
}
|
||||
|
||||
bool rect_inside_rect(RectWithSize little, RectWithSize big) {
|
||||
return all(lessThanEqual(vec4(big.p0, little.p0 + little.size),
|
||||
vec4(little.p0, big.p0 + big.size)));
|
||||
bool rect_inside_rect(RectWithEndpoint little, RectWithEndpoint big) {
|
||||
return all(lessThanEqual(vec4(big.p0, little.p1), vec4(little.p0, big.p1)));
|
||||
}
|
||||
#endif //WR_FEATURE_GLYPH_TRANSFORM
|
||||
|
||||
|
@ -110,7 +110,7 @@ void main() {
|
|||
// Note that the reference frame relative offset is stored in the prim local
|
||||
// rect size during batching, instead of the actual size of the primitive.
|
||||
TextRun text = fetch_text_run(ph.specific_prim_address);
|
||||
vec2 text_offset = ph.local_rect.size;
|
||||
vec2 text_offset = ph.local_rect.p1;
|
||||
|
||||
if (color_mode == COLOR_MODE_FROM_PASS) {
|
||||
color_mode = uMode;
|
||||
|
@ -151,21 +151,24 @@ void main() {
|
|||
// into account the translation from the transform for snapping purposes.
|
||||
vec2 raster_text_offset = floor(glyph_transform * text_offset + glyph_translation + 0.5) - glyph_translation;
|
||||
|
||||
vec2 glyph_origin = res.offset + raster_glyph_offset + raster_text_offset;
|
||||
// Compute the glyph rect in glyph space.
|
||||
RectWithSize glyph_rect = RectWithSize(res.offset + raster_glyph_offset + raster_text_offset,
|
||||
res.uv_rect.zw - res.uv_rect.xy);
|
||||
RectWithEndpoint glyph_rect = RectWithEndpoint(
|
||||
glyph_origin,
|
||||
glyph_origin + res.uv_rect.zw - res.uv_rect.xy
|
||||
);
|
||||
|
||||
// The glyph rect is in glyph space, so transform it back to local space.
|
||||
RectWithSize local_rect = transform_rect(glyph_rect, glyph_transform_inv);
|
||||
RectWithEndpoint local_rect = transform_rect(glyph_rect, glyph_transform_inv);
|
||||
|
||||
// Select the corner of the glyph's local space rect that we are processing.
|
||||
vec2 local_pos = local_rect.p0 + local_rect.size * aPosition.xy;
|
||||
vec2 local_pos = mix(local_rect.p0, local_rect.p1, aPosition.xy);
|
||||
|
||||
// If the glyph's local rect would fit inside the local clip rect, then select a corner from
|
||||
// the device space glyph rect to reduce overdraw of clipped pixels in the fragment shader.
|
||||
// Otherwise, fall back to clamping the glyph's local rect to the local clip rect.
|
||||
if (rect_inside_rect(local_rect, ph.local_clip_rect)) {
|
||||
local_pos = glyph_transform_inv * (glyph_rect.p0 + glyph_rect.size * aPosition.xy);
|
||||
local_pos = glyph_transform_inv * mix(glyph_rect.p0, glyph_rect.p1, aPosition.xy);
|
||||
}
|
||||
#else
|
||||
float raster_scale = float(ph.user_data.x) / 65535.0;
|
||||
|
@ -197,11 +200,14 @@ void main() {
|
|||
// The transform may be animated, so we don't want to do any snapping here for the
|
||||
// text offset to avoid glyphs wiggling. The text offset should have been snapped
|
||||
// already for axis aligned transforms excluding any animations during frame building.
|
||||
RectWithSize glyph_rect = RectWithSize(glyph_scale_inv * (res.offset + raster_glyph_offset) + text_offset,
|
||||
glyph_scale_inv * (res.uv_rect.zw - res.uv_rect.xy));
|
||||
vec2 glyph_origin = glyph_scale_inv * (res.offset + raster_glyph_offset) + text_offset;
|
||||
RectWithEndpoint glyph_rect = RectWithEndpoint(
|
||||
glyph_origin,
|
||||
glyph_origin + glyph_scale_inv * (res.uv_rect.zw - res.uv_rect.xy)
|
||||
);
|
||||
|
||||
// Select the corner of the glyph rect that we are processing.
|
||||
vec2 local_pos = glyph_rect.p0 + glyph_rect.size * aPosition.xy;
|
||||
vec2 local_pos = mix(glyph_rect.p0, glyph_rect.p1, aPosition.xy);
|
||||
#endif
|
||||
|
||||
VertexInfo vi = write_vertex(
|
||||
|
@ -213,7 +219,7 @@ void main() {
|
|||
);
|
||||
|
||||
#ifdef WR_FEATURE_GLYPH_TRANSFORM
|
||||
vec2 f = (glyph_transform * vi.local_pos - glyph_rect.p0) / glyph_rect.size;
|
||||
vec2 f = (glyph_transform * vi.local_pos - glyph_rect.p0) / rect_size(glyph_rect);
|
||||
#ifdef SWGL_CLIP_DIST
|
||||
gl_ClipDistance[0] = f.x;
|
||||
gl_ClipDistance[1] = f.y;
|
||||
|
@ -223,7 +229,7 @@ void main() {
|
|||
v_uv_clip = vec4(f, 1.0 - f);
|
||||
#endif
|
||||
#else
|
||||
vec2 f = (vi.local_pos - glyph_rect.p0) / glyph_rect.size;
|
||||
vec2 f = (vi.local_pos - glyph_rect.p0) / rect_size(glyph_rect);
|
||||
#endif
|
||||
|
||||
write_clip(vi.world_pos, clip_area, task);
|
||||
|
|
|
@ -12,30 +12,6 @@ struct RectWithEndpoint {
|
|||
vec2 p1;
|
||||
};
|
||||
|
||||
RectWithEndpoint to_rect_with_endpoint(RectWithSize rect) {
|
||||
RectWithEndpoint result;
|
||||
result.p0 = rect.p0;
|
||||
result.p1 = rect.p0 + rect.size;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
RectWithSize to_rect_with_size(RectWithEndpoint rect) {
|
||||
RectWithSize result;
|
||||
result.p0 = rect.p0;
|
||||
result.size = rect.p1 - rect.p0;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
RectWithSize intersect_rects(RectWithSize a, RectWithSize b) {
|
||||
RectWithSize result;
|
||||
result.p0 = max(a.p0, b.p0);
|
||||
result.size = min(a.p0 + a.size, b.p0 + b.size) - result.p0;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
float point_inside_rect(vec2 p, vec2 p0, vec2 p1) {
|
||||
vec2 s = step(p0, p) - step(p1, p);
|
||||
return s.x * s.y;
|
||||
|
@ -50,6 +26,10 @@ float signed_distance_rect(vec2 pos, vec2 p0, vec2 p1) {
|
|||
return max(d.x, d.y);
|
||||
}
|
||||
|
||||
vec2 clamp_rect(vec2 pt, RectWithSize rect) {
|
||||
return clamp(pt, rect.p0, rect.p0 + rect.size);
|
||||
vec2 rect_clamp(RectWithEndpoint rect, vec2 pt) {
|
||||
return clamp(pt, rect.p0, rect.p1);
|
||||
}
|
||||
|
||||
vec2 rect_size(RectWithEndpoint rect) {
|
||||
return rect.p1 - rect.p0;
|
||||
}
|
|
@ -9,17 +9,18 @@
|
|||
uniform HIGHP_SAMPLER_FLOAT sampler2D sRenderTasks;
|
||||
|
||||
struct RenderTaskData {
|
||||
RectWithSize task_rect;
|
||||
RectWithEndpoint task_rect;
|
||||
vec4 user_data;
|
||||
};
|
||||
|
||||
// See RenderTaskData in render_task.rs
|
||||
RenderTaskData fetch_render_task_data(int index) {
|
||||
ivec2 uv = get_fetch_uv(index, VECS_PER_RENDER_TASK);
|
||||
|
||||
vec4 texel0 = TEXEL_FETCH(sRenderTasks, uv, 0, ivec2(0, 0));
|
||||
vec4 texel1 = TEXEL_FETCH(sRenderTasks, uv, 0, ivec2(1, 0));
|
||||
|
||||
RectWithSize task_rect = RectWithSize(
|
||||
RectWithEndpoint task_rect = RectWithEndpoint(
|
||||
texel0.xy,
|
||||
texel0.zw
|
||||
);
|
||||
|
@ -32,13 +33,13 @@ RenderTaskData fetch_render_task_data(int index) {
|
|||
return data;
|
||||
}
|
||||
|
||||
RectWithSize fetch_render_task_rect(int index) {
|
||||
RectWithEndpoint fetch_render_task_rect(int index) {
|
||||
ivec2 uv = get_fetch_uv(index, VECS_PER_RENDER_TASK);
|
||||
|
||||
vec4 texel0 = TEXEL_FETCH(sRenderTasks, uv, 0, ivec2(0, 0));
|
||||
vec4 texel1 = TEXEL_FETCH(sRenderTasks, uv, 0, ivec2(1, 0));
|
||||
|
||||
RectWithSize task_rect = RectWithSize(
|
||||
RectWithEndpoint task_rect = RectWithEndpoint(
|
||||
texel0.xy,
|
||||
texel0.zw
|
||||
);
|
||||
|
@ -55,7 +56,7 @@ RectWithSize fetch_render_task_rect(int index) {
|
|||
the transform mode of primitives on this picture, among other things.
|
||||
*/
|
||||
struct PictureTask {
|
||||
RectWithSize task_rect;
|
||||
RectWithEndpoint task_rect;
|
||||
float device_pixel_scale;
|
||||
vec2 content_origin;
|
||||
};
|
||||
|
@ -75,7 +76,7 @@ PictureTask fetch_picture_task(int address) {
|
|||
#define CLIP_TASK_EMPTY 0x7FFF
|
||||
|
||||
struct ClipArea {
|
||||
RectWithSize task_rect;
|
||||
RectWithEndpoint task_rect;
|
||||
float device_pixel_scale;
|
||||
vec2 screen_origin;
|
||||
};
|
||||
|
@ -84,7 +85,7 @@ ClipArea fetch_clip_area(int index) {
|
|||
ClipArea area;
|
||||
|
||||
if (index >= CLIP_TASK_EMPTY) {
|
||||
area.task_rect = RectWithSize(vec2(0.0), vec2(0.0));
|
||||
area.task_rect = RectWithEndpoint(vec2(0.0), vec2(0.0));
|
||||
area.device_pixel_scale = 0.0;
|
||||
area.screen_origin = vec2(0.0);
|
||||
} else {
|
||||
|
|
|
@ -274,11 +274,11 @@ impl ApiResources {
|
|||
&template.visible_rect,
|
||||
template.tile_size,
|
||||
tile,
|
||||
).to_rect().cast_unit(),
|
||||
).cast_unit(),
|
||||
format: template.descriptor.format,
|
||||
};
|
||||
|
||||
assert!(descriptor.rect.size.width > 0 && descriptor.rect.size.height > 0);
|
||||
assert!(descriptor.rect.width() > 0 && descriptor.rect.height() > 0);
|
||||
blob_request_params.push(
|
||||
BlobImageParams {
|
||||
request: BlobImageRequest { key: *key, tile },
|
||||
|
|
|
@ -1232,10 +1232,10 @@ impl BatchBuilder {
|
|||
// the added bonus of avoiding quantization effects when storing
|
||||
// floats in the extra header integers.
|
||||
let prim_header = PrimitiveHeader {
|
||||
local_rect: LayoutRect::new(
|
||||
prim_rect.origin - run.reference_frame_relative_offset,
|
||||
run.snapped_reference_frame_relative_offset.to_size(),
|
||||
),
|
||||
local_rect: LayoutRect {
|
||||
min: prim_rect.min - run.reference_frame_relative_offset,
|
||||
max: run.snapped_reference_frame_relative_offset.to_point(),
|
||||
},
|
||||
local_clip_rect: prim_info.combined_local_clip_rect,
|
||||
specific_prim_address: prim_cache_address,
|
||||
transform_id,
|
||||
|
@ -1336,7 +1336,7 @@ impl BatchBuilder {
|
|||
SubpixelDirection::Vertical => DeviceVector2D::new(0.5, 0.125),
|
||||
SubpixelDirection::Mixed => DeviceVector2D::new(0.125, 0.125),
|
||||
};
|
||||
let text_offset = prim_header.local_rect.size.to_vector();
|
||||
let text_offset = prim_header.local_rect.max.to_vector();
|
||||
|
||||
let pic_bounding_rect = if run.used_font.flags.contains(FontInstanceFlags::TRANSFORM_GLYPHS) {
|
||||
let mut device_bounding_rect = DeviceRect::default();
|
||||
|
@ -1351,7 +1351,7 @@ impl BatchBuilder {
|
|||
let glyph_translation = DeviceVector2D::new(glyph_transform.m41, glyph_transform.m42);
|
||||
|
||||
for glyph in glyphs {
|
||||
let glyph_offset = prim_data.glyphs[glyph.index_in_text_run as usize].point + prim_header.local_rect.origin.to_vector();
|
||||
let glyph_offset = prim_data.glyphs[glyph.index_in_text_run as usize].point + prim_header.local_rect.min.to_vector();
|
||||
|
||||
let raster_glyph_offset = (glyph_transform.transform_point2d(glyph_offset).unwrap() + snap_bias).floor();
|
||||
let raster_text_offset = (
|
||||
|
@ -1385,10 +1385,10 @@ impl BatchBuilder {
|
|||
let glyph_raster_scale = run.raster_scale * ctx.global_device_pixel_scale.get();
|
||||
|
||||
for glyph in glyphs {
|
||||
let glyph_offset = prim_data.glyphs[glyph.index_in_text_run as usize].point + prim_header.local_rect.origin.to_vector();
|
||||
let glyph_offset = prim_data.glyphs[glyph.index_in_text_run as usize].point + prim_header.local_rect.min.to_vector();
|
||||
let glyph_scale = LayoutToDeviceScale::new(glyph_raster_scale / glyph.scale);
|
||||
let raster_glyph_offset = (glyph_offset * LayoutToDeviceScale::new(glyph_raster_scale) + snap_bias).floor() / glyph.scale;
|
||||
let local_glyph_rect = LayoutRect::new(
|
||||
let local_glyph_rect = LayoutRect::from_origin_and_size(
|
||||
(glyph.offset + raster_glyph_offset.to_vector()) / glyph_scale + text_offset,
|
||||
glyph.size.to_f32() / glyph_scale,
|
||||
);
|
||||
|
@ -1402,7 +1402,7 @@ impl BatchBuilder {
|
|||
*bounding_rect,
|
||||
ctx.spatial_tree,
|
||||
);
|
||||
map_prim_to_surface.map(&local_bounding_rect.to_box2d())
|
||||
map_prim_to_surface.map(&local_bounding_rect)
|
||||
};
|
||||
|
||||
let intersected = match pic_bounding_rect {
|
||||
|
@ -2532,7 +2532,7 @@ impl BatchBuilder {
|
|||
gpu_blocks.push([-1.0, 0.0, 0.0, 0.0].into()); //stretch size
|
||||
// negative first value makes the shader code ignore it and use the local size instead
|
||||
for tile in chunk {
|
||||
let tile_rect = tile.local_rect.translate(-prim_rect.origin.to_vector());
|
||||
let tile_rect = tile.local_rect.translate(-prim_rect.min.to_vector());
|
||||
gpu_blocks.push(tile_rect.into());
|
||||
gpu_blocks.push(GpuBlockData::EMPTY);
|
||||
}
|
||||
|
@ -3432,7 +3432,7 @@ impl ClipBatcher {
|
|||
);
|
||||
let world_clip_rect = match project_rect(
|
||||
&transform.into_transform(),
|
||||
&local_clip_rect.to_box2d(),
|
||||
&local_clip_rect,
|
||||
&world_rect,
|
||||
) {
|
||||
Some(rect) => rect,
|
||||
|
@ -3476,8 +3476,8 @@ impl ClipBatcher {
|
|||
sub_rect: normalized_sub_rect,
|
||||
..*common
|
||||
},
|
||||
local_pos: local_clip_rect.origin,
|
||||
clip_data: ClipData::uniform(local_clip_rect.size, 0.0, ClipMode::Clip),
|
||||
local_pos: local_clip_rect.min,
|
||||
clip_data: ClipData::uniform(local_clip_rect.size(), 0.0, ClipMode::Clip),
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -3597,7 +3597,7 @@ impl ClipBatcher {
|
|||
Some(local_rect)
|
||||
if clip_transform_id.transform_kind() == TransformedRectKind::AxisAligned &&
|
||||
!map_local_to_raster.get_transform().has_perspective_component() => {
|
||||
match local_rect.to_rect().intersection(&rect) {
|
||||
match local_rect.intersection(&rect) {
|
||||
Some(local_rect) => (clip_transform_id, local_rect, None),
|
||||
None => return,
|
||||
}
|
||||
|
@ -3639,7 +3639,7 @@ impl ClipBatcher {
|
|||
for tile in clip_store.visible_mask_tiles(&clip_instance) {
|
||||
let tile_sub_rect = if clip_is_axis_aligned {
|
||||
let tile_raster_rect = map_local_to_raster
|
||||
.map(&tile.tile_rect.to_box2d())
|
||||
.map(&tile.tile_rect)
|
||||
.expect("bug: should always map as axis-aligned");
|
||||
let tile_device_rect = tile_raster_rect * surface_device_pixel_scale;
|
||||
tile_device_rect
|
||||
|
@ -3668,7 +3668,7 @@ impl ClipBatcher {
|
|||
// the image boundaries will be properly initialized.
|
||||
if is_first_clip &&
|
||||
(!clip_is_axis_aligned ||
|
||||
!(map_local_to_raster.map(&rect.to_box2d()).expect("bug: should always map as axis-aligned")
|
||||
!(map_local_to_raster.map(&rect).expect("bug: should always map as axis-aligned")
|
||||
* surface_device_pixel_scale).contains_box(&actual_rect)) {
|
||||
clear_to_one = true;
|
||||
}
|
||||
|
@ -3703,8 +3703,8 @@ impl ClipBatcher {
|
|||
.slow_rectangles
|
||||
.push(ClipMaskInstanceRect {
|
||||
common,
|
||||
local_pos: rect.origin,
|
||||
clip_data: ClipData::uniform(rect.size, 0.0, ClipMode::ClipOut),
|
||||
local_pos: rect.min,
|
||||
clip_data: ClipData::uniform(rect.size(), 0.0, ClipMode::ClipOut),
|
||||
});
|
||||
|
||||
true
|
||||
|
@ -3729,8 +3729,8 @@ impl ClipBatcher {
|
|||
.slow_rectangles
|
||||
.push(ClipMaskInstanceRect {
|
||||
common,
|
||||
local_pos: rect.origin,
|
||||
clip_data: ClipData::uniform(rect.size, 0.0, ClipMode::Clip),
|
||||
local_pos: rect.min,
|
||||
clip_data: ClipData::uniform(rect.size(), 0.0, ClipMode::Clip),
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -3741,8 +3741,8 @@ impl ClipBatcher {
|
|||
let batch_list = self.get_batch_list(is_first_clip);
|
||||
let instance = ClipMaskInstanceRect {
|
||||
common,
|
||||
local_pos: rect.origin,
|
||||
clip_data: ClipData::rounded_rect(rect.size, radius, mode),
|
||||
local_pos: rect.min,
|
||||
clip_data: ClipData::rounded_rect(rect.size(), radius, mode),
|
||||
};
|
||||
if clip_instance.flags.contains(ClipNodeFlags::USE_FAST_PATH) {
|
||||
batch_list.fast_rectangles.push(instance);
|
||||
|
|
|
@ -220,7 +220,7 @@ impl<'a> SceneBuilder<'a> {
|
|||
clip_chain_id: ClipChainId,
|
||||
) {
|
||||
let mut border = *border;
|
||||
ensure_no_corner_overlap(&mut border.radius, info.rect.size);
|
||||
ensure_no_corner_overlap(&mut border.radius, info.rect.size());
|
||||
|
||||
self.add_primitive(
|
||||
spatial_node_index,
|
||||
|
@ -653,10 +653,7 @@ pub fn create_border_segments(
|
|||
border_segments: &mut Vec<BorderSegmentInfo>,
|
||||
brush_segments: &mut Vec<BrushSegment>,
|
||||
) {
|
||||
let rect = LayoutRect::new(
|
||||
LayoutPoint::zero(),
|
||||
size,
|
||||
);
|
||||
let rect = LayoutRect::from_size(size);
|
||||
|
||||
let overlap = LayoutSize::new(
|
||||
(widths.left + widths.right - size.width).max(0.0),
|
||||
|
@ -689,31 +686,31 @@ pub fn create_border_segments(
|
|||
let top_edge_info = get_edge_info(
|
||||
border.top.style,
|
||||
widths.top,
|
||||
rect.size.width - local_size_tl.width - local_size_tr.width,
|
||||
rect.width() - local_size_tl.width - local_size_tr.width,
|
||||
);
|
||||
let bottom_edge_info = get_edge_info(
|
||||
border.bottom.style,
|
||||
widths.bottom,
|
||||
rect.size.width - local_size_bl.width - local_size_br.width,
|
||||
rect.width() - local_size_bl.width - local_size_br.width,
|
||||
);
|
||||
|
||||
let left_edge_info = get_edge_info(
|
||||
border.left.style,
|
||||
widths.left,
|
||||
rect.size.height - local_size_tl.height - local_size_bl.height,
|
||||
rect.height() - local_size_tl.height - local_size_bl.height,
|
||||
);
|
||||
let right_edge_info = get_edge_info(
|
||||
border.right.style,
|
||||
widths.right,
|
||||
rect.size.height - local_size_tr.height - local_size_br.height,
|
||||
rect.height() - local_size_tr.height - local_size_br.height,
|
||||
);
|
||||
|
||||
add_edge_segment(
|
||||
LayoutRect::from_floats(
|
||||
rect.origin.x,
|
||||
rect.origin.y + local_size_tl.height + left_edge_info.local_offset,
|
||||
rect.origin.x + non_overlapping_widths.left,
|
||||
rect.origin.y + local_size_tl.height + left_edge_info.local_offset + left_edge_info.local_size,
|
||||
rect.min.x,
|
||||
rect.min.y + local_size_tl.height + left_edge_info.local_offset,
|
||||
rect.min.x + non_overlapping_widths.left,
|
||||
rect.min.y + local_size_tl.height + left_edge_info.local_offset + left_edge_info.local_size,
|
||||
),
|
||||
&left_edge_info,
|
||||
border.left,
|
||||
|
@ -726,10 +723,10 @@ pub fn create_border_segments(
|
|||
);
|
||||
add_edge_segment(
|
||||
LayoutRect::from_floats(
|
||||
rect.origin.x + local_size_tl.width + top_edge_info.local_offset,
|
||||
rect.origin.y,
|
||||
rect.origin.x + local_size_tl.width + top_edge_info.local_offset + top_edge_info.local_size,
|
||||
rect.origin.y + non_overlapping_widths.top,
|
||||
rect.min.x + local_size_tl.width + top_edge_info.local_offset,
|
||||
rect.min.y,
|
||||
rect.min.x + local_size_tl.width + top_edge_info.local_offset + top_edge_info.local_size,
|
||||
rect.min.y + non_overlapping_widths.top,
|
||||
),
|
||||
&top_edge_info,
|
||||
border.top,
|
||||
|
@ -742,10 +739,10 @@ pub fn create_border_segments(
|
|||
);
|
||||
add_edge_segment(
|
||||
LayoutRect::from_floats(
|
||||
rect.origin.x + rect.size.width - non_overlapping_widths.right,
|
||||
rect.origin.y + local_size_tr.height + right_edge_info.local_offset,
|
||||
rect.origin.x + rect.size.width,
|
||||
rect.origin.y + local_size_tr.height + right_edge_info.local_offset + right_edge_info.local_size,
|
||||
rect.min.x + rect.width() - non_overlapping_widths.right,
|
||||
rect.min.y + local_size_tr.height + right_edge_info.local_offset,
|
||||
rect.min.x + rect.width(),
|
||||
rect.min.y + local_size_tr.height + right_edge_info.local_offset + right_edge_info.local_size,
|
||||
),
|
||||
&right_edge_info,
|
||||
border.right,
|
||||
|
@ -758,10 +755,10 @@ pub fn create_border_segments(
|
|||
);
|
||||
add_edge_segment(
|
||||
LayoutRect::from_floats(
|
||||
rect.origin.x + local_size_bl.width + bottom_edge_info.local_offset,
|
||||
rect.origin.y + rect.size.height - non_overlapping_widths.bottom,
|
||||
rect.origin.x + local_size_bl.width + bottom_edge_info.local_offset + bottom_edge_info.local_size,
|
||||
rect.origin.y + rect.size.height,
|
||||
rect.min.x + local_size_bl.width + bottom_edge_info.local_offset,
|
||||
rect.min.y + rect.height() - non_overlapping_widths.bottom,
|
||||
rect.min.x + local_size_bl.width + bottom_edge_info.local_offset + bottom_edge_info.local_size,
|
||||
rect.min.y + rect.height(),
|
||||
),
|
||||
&bottom_edge_info,
|
||||
border.bottom,
|
||||
|
@ -775,16 +772,16 @@ pub fn create_border_segments(
|
|||
|
||||
add_corner_segment(
|
||||
LayoutRect::from_floats(
|
||||
rect.origin.x,
|
||||
rect.origin.y,
|
||||
rect.origin.x + local_size_tl.width,
|
||||
rect.origin.y + local_size_tl.height,
|
||||
rect.min.x,
|
||||
rect.min.y,
|
||||
rect.min.x + local_size_tl.width,
|
||||
rect.min.y + local_size_tl.height,
|
||||
),
|
||||
LayoutRect::from_floats(
|
||||
rect.origin.x,
|
||||
rect.origin.y,
|
||||
rect.max_x() - non_overlapping_widths.right,
|
||||
rect.max_y() - non_overlapping_widths.bottom
|
||||
rect.min.x,
|
||||
rect.min.y,
|
||||
rect.max.x - non_overlapping_widths.right,
|
||||
rect.max.y - non_overlapping_widths.bottom
|
||||
),
|
||||
border.left,
|
||||
border.top,
|
||||
|
@ -802,16 +799,16 @@ pub fn create_border_segments(
|
|||
);
|
||||
add_corner_segment(
|
||||
LayoutRect::from_floats(
|
||||
rect.origin.x + rect.size.width - local_size_tr.width,
|
||||
rect.origin.y,
|
||||
rect.origin.x + rect.size.width,
|
||||
rect.origin.y + local_size_tr.height,
|
||||
rect.min.x + rect.width() - local_size_tr.width,
|
||||
rect.min.y,
|
||||
rect.min.x + rect.width(),
|
||||
rect.min.y + local_size_tr.height,
|
||||
),
|
||||
LayoutRect::from_floats(
|
||||
rect.origin.x + non_overlapping_widths.left,
|
||||
rect.origin.y,
|
||||
rect.max_x(),
|
||||
rect.max_y() - non_overlapping_widths.bottom,
|
||||
rect.min.x + non_overlapping_widths.left,
|
||||
rect.min.y,
|
||||
rect.max.x,
|
||||
rect.max.y - non_overlapping_widths.bottom,
|
||||
),
|
||||
border.top,
|
||||
border.right,
|
||||
|
@ -819,9 +816,9 @@ pub fn create_border_segments(
|
|||
border.radius.top_right,
|
||||
BorderSegment::TopRight,
|
||||
EdgeAaSegmentMask::TOP | EdgeAaSegmentMask::RIGHT,
|
||||
rect.origin,
|
||||
rect.min,
|
||||
border.radius.top_left,
|
||||
rect.bottom_right(),
|
||||
rect.max,
|
||||
border.radius.bottom_right,
|
||||
brush_segments,
|
||||
border_segments,
|
||||
|
@ -829,16 +826,16 @@ pub fn create_border_segments(
|
|||
);
|
||||
add_corner_segment(
|
||||
LayoutRect::from_floats(
|
||||
rect.origin.x + rect.size.width - local_size_br.width,
|
||||
rect.origin.y + rect.size.height - local_size_br.height,
|
||||
rect.origin.x + rect.size.width,
|
||||
rect.origin.y + rect.size.height,
|
||||
rect.min.x + rect.width() - local_size_br.width,
|
||||
rect.min.y + rect.height() - local_size_br.height,
|
||||
rect.min.x + rect.width(),
|
||||
rect.min.y + rect.height(),
|
||||
),
|
||||
LayoutRect::from_floats(
|
||||
rect.origin.x + non_overlapping_widths.left,
|
||||
rect.origin.y + non_overlapping_widths.top,
|
||||
rect.max_x(),
|
||||
rect.max_y(),
|
||||
rect.min.x + non_overlapping_widths.left,
|
||||
rect.min.y + non_overlapping_widths.top,
|
||||
rect.max.x,
|
||||
rect.max.y,
|
||||
),
|
||||
border.right,
|
||||
border.bottom,
|
||||
|
@ -856,16 +853,16 @@ pub fn create_border_segments(
|
|||
);
|
||||
add_corner_segment(
|
||||
LayoutRect::from_floats(
|
||||
rect.origin.x,
|
||||
rect.origin.y + rect.size.height - local_size_bl.height,
|
||||
rect.origin.x + local_size_bl.width,
|
||||
rect.origin.y + rect.size.height,
|
||||
rect.min.x,
|
||||
rect.min.y + rect.height() - local_size_bl.height,
|
||||
rect.min.x + local_size_bl.width,
|
||||
rect.min.y + rect.height(),
|
||||
),
|
||||
LayoutRect::from_floats(
|
||||
rect.origin.x,
|
||||
rect.origin.y + non_overlapping_widths.top,
|
||||
rect.max_x() - non_overlapping_widths.right,
|
||||
rect.max_y(),
|
||||
rect.min.x,
|
||||
rect.min.y + non_overlapping_widths.top,
|
||||
rect.max.x - non_overlapping_widths.right,
|
||||
rect.max.y,
|
||||
),
|
||||
border.bottom,
|
||||
border.left,
|
||||
|
@ -873,9 +870,9 @@ pub fn create_border_segments(
|
|||
border.radius.bottom_left,
|
||||
BorderSegment::BottomLeft,
|
||||
EdgeAaSegmentMask::BOTTOM | EdgeAaSegmentMask::LEFT,
|
||||
rect.bottom_right(),
|
||||
rect.max,
|
||||
border.radius.bottom_right,
|
||||
rect.origin,
|
||||
rect.min,
|
||||
border.radius.top_left,
|
||||
brush_segments,
|
||||
border_segments,
|
||||
|
@ -1076,15 +1073,15 @@ fn add_corner_segment(
|
|||
};
|
||||
|
||||
let texture_rect = segment_rect
|
||||
.translate(-image_rect.origin.to_vector())
|
||||
.scale(1.0 / image_rect.size.width, 1.0 / image_rect.size.height);
|
||||
.translate(-image_rect.min.to_vector())
|
||||
.scale(1.0 / image_rect.width(), 1.0 / image_rect.height());
|
||||
|
||||
brush_segments.push(
|
||||
BrushSegment::new(
|
||||
segment_rect,
|
||||
/* may_need_clip_mask = */ true,
|
||||
edge_flags,
|
||||
[texture_rect.min_x(), texture_rect.min_y(), texture_rect.max_x(), texture_rect.max_y()],
|
||||
[texture_rect.min.x, texture_rect.min.y, texture_rect.max.x, texture_rect.max.y],
|
||||
BrushFlags::SEGMENT_RELATIVE | BrushFlags::SEGMENT_TEXEL_RECT,
|
||||
)
|
||||
);
|
||||
|
@ -1095,31 +1092,31 @@ fn add_corner_segment(
|
|||
// in fewer misses.
|
||||
let (h_corner_outer, h_corner_radius) = match segment {
|
||||
BorderSegment::TopLeft => {
|
||||
if h_adjacent_corner_outer.x - h_adjacent_corner_radius.width < image_rect.max_x() {
|
||||
if h_adjacent_corner_outer.x - h_adjacent_corner_radius.width < image_rect.max.x {
|
||||
(h_adjacent_corner_outer, h_adjacent_corner_radius)
|
||||
} else {
|
||||
(LayoutPoint::new(image_rect.max_x(), image_rect.min_y()), LayoutSize::zero())
|
||||
(LayoutPoint::new(image_rect.max.x, image_rect.min.y), LayoutSize::zero())
|
||||
}
|
||||
}
|
||||
BorderSegment::TopRight => {
|
||||
if h_adjacent_corner_outer.x + h_adjacent_corner_radius.width > image_rect.min_x() {
|
||||
if h_adjacent_corner_outer.x + h_adjacent_corner_radius.width > image_rect.min.x {
|
||||
(h_adjacent_corner_outer, h_adjacent_corner_radius)
|
||||
} else {
|
||||
(LayoutPoint::new(image_rect.min_x(), image_rect.min_y()), LayoutSize::zero())
|
||||
(LayoutPoint::new(image_rect.min.x, image_rect.min.y), LayoutSize::zero())
|
||||
}
|
||||
}
|
||||
BorderSegment::BottomRight => {
|
||||
if h_adjacent_corner_outer.x + h_adjacent_corner_radius.width > image_rect.min_x() {
|
||||
if h_adjacent_corner_outer.x + h_adjacent_corner_radius.width > image_rect.min.x {
|
||||
(h_adjacent_corner_outer, h_adjacent_corner_radius)
|
||||
} else {
|
||||
(LayoutPoint::new(image_rect.min_x(), image_rect.max_y()), LayoutSize::zero())
|
||||
(LayoutPoint::new(image_rect.min.x, image_rect.max.y), LayoutSize::zero())
|
||||
}
|
||||
}
|
||||
BorderSegment::BottomLeft => {
|
||||
if h_adjacent_corner_outer.x - h_adjacent_corner_radius.width < image_rect.max_x() {
|
||||
if h_adjacent_corner_outer.x - h_adjacent_corner_radius.width < image_rect.max.x {
|
||||
(h_adjacent_corner_outer, h_adjacent_corner_radius)
|
||||
} else {
|
||||
(image_rect.bottom_right(), LayoutSize::zero())
|
||||
(image_rect.max, LayoutSize::zero())
|
||||
}
|
||||
}
|
||||
_ => unreachable!()
|
||||
|
@ -1127,38 +1124,38 @@ fn add_corner_segment(
|
|||
|
||||
let (v_corner_outer, v_corner_radius) = match segment {
|
||||
BorderSegment::TopLeft => {
|
||||
if v_adjacent_corner_outer.y - v_adjacent_corner_radius.height < image_rect.max_y() {
|
||||
if v_adjacent_corner_outer.y - v_adjacent_corner_radius.height < image_rect.max.y {
|
||||
(v_adjacent_corner_outer, v_adjacent_corner_radius)
|
||||
} else {
|
||||
(LayoutPoint::new(image_rect.min_x(), image_rect.max_y()), LayoutSize::zero())
|
||||
(LayoutPoint::new(image_rect.min.x, image_rect.max.y), LayoutSize::zero())
|
||||
}
|
||||
}
|
||||
BorderSegment::TopRight => {
|
||||
if v_adjacent_corner_outer.y - v_adjacent_corner_radius.height < image_rect.max_y() {
|
||||
if v_adjacent_corner_outer.y - v_adjacent_corner_radius.height < image_rect.max.y {
|
||||
(v_adjacent_corner_outer, v_adjacent_corner_radius)
|
||||
} else {
|
||||
(image_rect.bottom_right(), LayoutSize::zero())
|
||||
(image_rect.max, LayoutSize::zero())
|
||||
}
|
||||
}
|
||||
BorderSegment::BottomRight => {
|
||||
if v_adjacent_corner_outer.y + v_adjacent_corner_radius.height > image_rect.min_y() {
|
||||
if v_adjacent_corner_outer.y + v_adjacent_corner_radius.height > image_rect.min.y {
|
||||
(v_adjacent_corner_outer, v_adjacent_corner_radius)
|
||||
} else {
|
||||
(LayoutPoint::new(image_rect.max_x(), image_rect.min_y()), LayoutSize::zero())
|
||||
(LayoutPoint::new(image_rect.max.x, image_rect.min.y), LayoutSize::zero())
|
||||
}
|
||||
}
|
||||
BorderSegment::BottomLeft => {
|
||||
if v_adjacent_corner_outer.y + v_adjacent_corner_radius.height > image_rect.min_y() {
|
||||
if v_adjacent_corner_outer.y + v_adjacent_corner_radius.height > image_rect.min.y {
|
||||
(v_adjacent_corner_outer, v_adjacent_corner_radius)
|
||||
} else {
|
||||
(LayoutPoint::new(image_rect.min_x(), image_rect.min_y()), LayoutSize::zero())
|
||||
(LayoutPoint::new(image_rect.min.x, image_rect.min.y), LayoutSize::zero())
|
||||
}
|
||||
}
|
||||
_ => unreachable!()
|
||||
};
|
||||
|
||||
border_segments.push(BorderSegmentInfo {
|
||||
local_task_size: image_rect.size,
|
||||
local_task_size: image_rect.size(),
|
||||
cache_key: BorderSegmentCacheKey {
|
||||
do_aa,
|
||||
side0: side0.into(),
|
||||
|
@ -1166,9 +1163,9 @@ fn add_corner_segment(
|
|||
segment,
|
||||
radius: radius.to_au(),
|
||||
size: widths.to_au(),
|
||||
h_adjacent_corner_outer: (h_corner_outer - image_rect.origin).to_point().to_au(),
|
||||
h_adjacent_corner_outer: (h_corner_outer - image_rect.min).to_point().to_au(),
|
||||
h_adjacent_corner_radius: h_corner_radius.to_au(),
|
||||
v_adjacent_corner_outer: (v_corner_outer - image_rect.origin).to_point().to_au(),
|
||||
v_adjacent_corner_outer: (v_corner_outer - image_rect.min).to_point().to_au(),
|
||||
v_adjacent_corner_radius: v_corner_radius.to_au(),
|
||||
},
|
||||
});
|
||||
|
@ -1207,7 +1204,7 @@ fn add_edge_segment(
|
|||
}
|
||||
};
|
||||
|
||||
if image_rect.size.width <= 0. || image_rect.size.height <= 0. {
|
||||
if image_rect.width() <= 0. || image_rect.height() <= 0. {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1306,21 +1303,18 @@ impl NinePatchDescriptor {
|
|||
&self,
|
||||
size: LayoutSize,
|
||||
) -> Vec<BrushSegment> {
|
||||
let rect = LayoutRect::new(
|
||||
LayoutPoint::zero(),
|
||||
size,
|
||||
);
|
||||
let rect = LayoutRect::from_size(size);
|
||||
|
||||
// Calculate the modified rect as specific by border-image-outset
|
||||
let origin = LayoutPoint::new(
|
||||
rect.origin.x - self.outset.left,
|
||||
rect.origin.y - self.outset.top,
|
||||
rect.min.x - self.outset.left,
|
||||
rect.min.y - self.outset.top,
|
||||
);
|
||||
let size = LayoutSize::new(
|
||||
rect.size.width + self.outset.left + self.outset.right,
|
||||
rect.size.height + self.outset.top + self.outset.bottom,
|
||||
rect.width() + self.outset.left + self.outset.right,
|
||||
rect.height() + self.outset.top + self.outset.bottom,
|
||||
);
|
||||
let rect = LayoutRect::new(origin, size);
|
||||
let rect = LayoutRect::from_origin_and_size(origin, size);
|
||||
|
||||
// Calculate the local texel coords of the slices.
|
||||
let px0 = 0.0;
|
||||
|
@ -1333,19 +1327,17 @@ impl NinePatchDescriptor {
|
|||
let py2 = (self.height as f32 - self.slice.bottom as f32) / self.height as f32;
|
||||
let py3 = 1.0;
|
||||
|
||||
let tl_outer = LayoutPoint::new(rect.origin.x, rect.origin.y);
|
||||
let tl_outer = LayoutPoint::new(rect.min.x, rect.min.y);
|
||||
let tl_inner = tl_outer + vec2(self.widths.left, self.widths.top);
|
||||
|
||||
let tr_outer = LayoutPoint::new(rect.origin.x + rect.size.width, rect.origin.y);
|
||||
let tr_outer = LayoutPoint::new(rect.min.x + rect.width(), rect.min.y);
|
||||
let tr_inner = tr_outer + vec2(-self.widths.right, self.widths.top);
|
||||
|
||||
let bl_outer = LayoutPoint::new(rect.origin.x, rect.origin.y + rect.size.height);
|
||||
let bl_outer = LayoutPoint::new(rect.min.x, rect.min.y + rect.height());
|
||||
let bl_inner = bl_outer + vec2(self.widths.left, -self.widths.bottom);
|
||||
|
||||
let br_outer = LayoutPoint::new(
|
||||
rect.origin.x + rect.size.width,
|
||||
rect.origin.y + rect.size.height,
|
||||
);
|
||||
let br_outer = rect.max;
|
||||
|
||||
let br_inner = br_outer - vec2(self.widths.right, self.widths.bottom);
|
||||
|
||||
fn add_segment(
|
||||
|
|
|
@ -222,7 +222,7 @@ impl<'a> SceneBuilder<'a> {
|
|||
// rect, no pixels will be shadowed.
|
||||
if border_radius.is_zero() && shadow_rect
|
||||
.inflate(-blur_radius, -blur_radius)
|
||||
.contains_rect(&prim_info.rect)
|
||||
.contains_box(&prim_info.rect)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -652,14 +652,14 @@ impl ClipNodeInfo {
|
|||
let repetitions = image_tiling::repetitions(
|
||||
&rect,
|
||||
&visible_rect,
|
||||
rect.size,
|
||||
rect.size(),
|
||||
);
|
||||
|
||||
for Repetition { origin, .. } in repetitions {
|
||||
let layout_image_rect = LayoutRect {
|
||||
let layout_image_rect = LayoutRect::from_origin_and_size(
|
||||
origin,
|
||||
size: rect.size,
|
||||
};
|
||||
rect.size(),
|
||||
);
|
||||
let tiles = image_tiling::tiles(
|
||||
&layout_image_rect,
|
||||
&visible_rect,
|
||||
|
@ -1247,7 +1247,7 @@ impl ClipStore {
|
|||
is_chased: bool,
|
||||
) -> Option<ClipChainInstance> {
|
||||
let local_clip_rect = match self.active_local_clip_rect {
|
||||
Some(rect) => rect.to_box2d(),
|
||||
Some(rect) => rect,
|
||||
None => return None,
|
||||
};
|
||||
profile_scope!("build_clip_chain_instance");
|
||||
|
@ -1255,7 +1255,7 @@ impl ClipStore {
|
|||
println!("\tbuilding clip chain instance with local rect {:?}", local_prim_rect);
|
||||
}
|
||||
|
||||
let local_bounding_rect = local_prim_rect.to_box2d().intersection(&local_clip_rect)?;
|
||||
let local_bounding_rect = local_prim_rect.intersection(&local_clip_rect)?;
|
||||
let mut pic_clip_rect = prim_to_pic_mapper.map(&local_bounding_rect)?;
|
||||
let world_clip_rect = pic_to_world_mapper.map(&pic_clip_rect)?;
|
||||
|
||||
|
@ -1275,11 +1275,11 @@ impl ClipStore {
|
|||
// See how this clip affects the prim region.
|
||||
let clip_result = match node_info.conversion {
|
||||
ClipSpaceConversion::Local => {
|
||||
node.item.kind.get_clip_result(&local_bounding_rect.to_rect())
|
||||
node.item.kind.get_clip_result(&local_bounding_rect)
|
||||
}
|
||||
ClipSpaceConversion::ScaleOffset(ref scale_offset) => {
|
||||
has_non_local_clips = true;
|
||||
node.item.kind.get_clip_result(&scale_offset.unmap_rect(&local_bounding_rect).to_rect())
|
||||
node.item.kind.get_clip_result(&scale_offset.unmap_rect(&local_bounding_rect))
|
||||
}
|
||||
ClipSpaceConversion::Transform(ref transform) => {
|
||||
has_non_local_clips = true;
|
||||
|
@ -1313,7 +1313,7 @@ impl ClipStore {
|
|||
// Create the clip node instance for this clip node
|
||||
if let Some(instance) = node_info.create_instance(
|
||||
node,
|
||||
&local_bounding_rect.to_rect(),
|
||||
&local_bounding_rect,
|
||||
gpu_cache,
|
||||
resource_cache,
|
||||
&mut self.mask_tiles,
|
||||
|
@ -1366,7 +1366,7 @@ impl ClipStore {
|
|||
Some(ClipChainInstance {
|
||||
clips_range,
|
||||
has_non_local_clips,
|
||||
local_clip_rect: local_clip_rect.to_rect(),
|
||||
local_clip_rect: local_clip_rect,
|
||||
pic_clip_rect: pic_clip_rect,
|
||||
pic_spatial_node_index: prim_to_pic_mapper.ref_spatial_node_index,
|
||||
needs_mask,
|
||||
|
@ -1462,7 +1462,7 @@ impl ClipItemKeyKind {
|
|||
if radii.is_zero() {
|
||||
ClipItemKeyKind::rectangle(rect, mode)
|
||||
} else {
|
||||
ensure_no_corner_overlap(&mut radii, rect.size);
|
||||
ensure_no_corner_overlap(&mut radii, rect.size());
|
||||
ClipItemKeyKind::RoundedRectangle(
|
||||
rect.into(),
|
||||
radii.into(),
|
||||
|
@ -1491,13 +1491,13 @@ impl ClipItemKeyKind {
|
|||
// Get the fractional offsets required to match the
|
||||
// source rect with a minimal rect.
|
||||
let fract_offset = LayoutPoint::new(
|
||||
shadow_rect.origin.x.fract().abs(),
|
||||
shadow_rect.origin.y.fract().abs(),
|
||||
shadow_rect.min.x.fract().abs(),
|
||||
shadow_rect.min.y.fract().abs(),
|
||||
);
|
||||
|
||||
ClipItemKeyKind::BoxShadow(
|
||||
fract_offset.into(),
|
||||
shadow_rect.size.into(),
|
||||
shadow_rect.size().into(),
|
||||
shadow_radius.into(),
|
||||
prim_shadow_rect.into(),
|
||||
Au::from_f32_px(blur_radius),
|
||||
|
@ -1617,7 +1617,7 @@ fn compute_box_shadow_parameters(
|
|||
);
|
||||
|
||||
// The minimal rect to blur.
|
||||
let mut minimal_shadow_rect = LayoutRect::new(
|
||||
let mut minimal_shadow_rect = LayoutRect::from_origin_and_size(
|
||||
LayoutPoint::new(
|
||||
blur_region + shadow_rect_fract_offset.x,
|
||||
blur_region + shadow_rect_fract_offset.y,
|
||||
|
@ -1634,21 +1634,21 @@ fn compute_box_shadow_parameters(
|
|||
// correctness, since the blur of one corner may affect the blur
|
||||
// in another corner.
|
||||
let mut stretch_mode_x = BoxShadowStretchMode::Stretch;
|
||||
if shadow_rect_size.width < minimal_shadow_rect.size.width {
|
||||
minimal_shadow_rect.size.width = shadow_rect_size.width;
|
||||
if shadow_rect_size.width < minimal_shadow_rect.width() {
|
||||
minimal_shadow_rect.max.x = minimal_shadow_rect.min.x + shadow_rect_size.width;
|
||||
stretch_mode_x = BoxShadowStretchMode::Simple;
|
||||
}
|
||||
|
||||
let mut stretch_mode_y = BoxShadowStretchMode::Stretch;
|
||||
if shadow_rect_size.height < minimal_shadow_rect.size.height {
|
||||
minimal_shadow_rect.size.height = shadow_rect_size.height;
|
||||
if shadow_rect_size.height < minimal_shadow_rect.height() {
|
||||
minimal_shadow_rect.max.y = minimal_shadow_rect.min.y + shadow_rect_size.height;
|
||||
stretch_mode_y = BoxShadowStretchMode::Simple;
|
||||
}
|
||||
|
||||
// Expand the shadow rect by enough room for the blur to take effect.
|
||||
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(),
|
||||
2.0 * blur_region + minimal_shadow_rect.width().ceil(),
|
||||
2.0 * blur_region + minimal_shadow_rect.height().ceil(),
|
||||
);
|
||||
|
||||
BoxShadowClipSource {
|
||||
|
@ -1809,7 +1809,7 @@ impl ClipItemKind {
|
|||
ClipMode::Clip => {
|
||||
let outer_clip_rect = match project_rect(
|
||||
transform,
|
||||
&clip_rect.to_box2d(),
|
||||
&clip_rect,
|
||||
&world_rect,
|
||||
) {
|
||||
Some(outer_clip_rect) => outer_clip_rect,
|
||||
|
@ -1836,7 +1836,7 @@ impl ClipItemKind {
|
|||
) -> ClipResult {
|
||||
match *self {
|
||||
ClipItemKind::Rectangle { rect, mode: ClipMode::Clip } => {
|
||||
if rect.contains_rect(prim_rect) {
|
||||
if rect.contains_box(prim_rect) {
|
||||
return ClipResult::Accept;
|
||||
}
|
||||
|
||||
|
@ -1850,7 +1850,7 @@ impl ClipItemKind {
|
|||
}
|
||||
}
|
||||
ClipItemKind::Rectangle { rect, mode: ClipMode::ClipOut } => {
|
||||
if rect.contains_rect(prim_rect) {
|
||||
if rect.contains_box(prim_rect) {
|
||||
return ClipResult::Reject;
|
||||
}
|
||||
|
||||
|
@ -1866,7 +1866,7 @@ impl ClipItemKind {
|
|||
ClipItemKind::RoundedRectangle { rect, ref radius, mode: ClipMode::Clip } => {
|
||||
// TODO(gw): Consider caching this in the ClipNode
|
||||
// if it ever shows in profiles.
|
||||
if rounded_rectangle_contains_rect_quick(&rect, radius, &prim_rect) {
|
||||
if rounded_rectangle_contains_box_quick(&rect, radius, &prim_rect) {
|
||||
return ClipResult::Accept;
|
||||
}
|
||||
|
||||
|
@ -1882,7 +1882,7 @@ impl ClipItemKind {
|
|||
ClipItemKind::RoundedRectangle { rect, ref radius, mode: ClipMode::ClipOut } => {
|
||||
// TODO(gw): Consider caching this in the ClipNode
|
||||
// if it ever shows in profiles.
|
||||
if rounded_rectangle_contains_rect_quick(&rect, radius, &prim_rect) {
|
||||
if rounded_rectangle_contains_box_quick(&rect, radius, &prim_rect) {
|
||||
return ClipResult::Reject;
|
||||
}
|
||||
|
||||
|
@ -1942,7 +1942,7 @@ pub fn rounded_rectangle_contains_point(
|
|||
return false;
|
||||
}
|
||||
|
||||
let top_left_center = rect.origin + radii.top_left.to_vector();
|
||||
let top_left_center = rect.min + radii.top_left.to_vector();
|
||||
if top_left_center.x > point.x && top_left_center.y > point.y &&
|
||||
!Ellipse::new(radii.top_left).contains(*point - top_left_center.to_vector()) {
|
||||
return false;
|
||||
|
@ -1974,12 +1974,12 @@ pub fn rounded_rectangle_contains_point(
|
|||
/// Return true if the rounded rectangle described by `container` and `radii`
|
||||
/// definitely contains `containee`. May return false negatives, but never false
|
||||
/// positives.
|
||||
fn rounded_rectangle_contains_rect_quick(
|
||||
fn rounded_rectangle_contains_box_quick(
|
||||
container: &LayoutRect,
|
||||
radii: &BorderRadius,
|
||||
containee: &LayoutRect,
|
||||
) -> bool {
|
||||
if !container.contains_rect(containee) {
|
||||
if !container.contains_box(containee) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -2038,7 +2038,7 @@ pub fn polygon_contains_point(
|
|||
|
||||
// p is a LayoutPoint that we'll be comparing to dimensionless PointKeys,
|
||||
// which were created from LayoutPoints, so it all works out.
|
||||
let p = LayoutPoint::new(point.x - rect.origin.x, point.y - rect.origin.y);
|
||||
let p = LayoutPoint::new(point.x - rect.min.x, point.y - rect.min.y);
|
||||
|
||||
// Calculate a winding number for this point.
|
||||
let mut winding_number: i32 = 0;
|
||||
|
@ -2074,7 +2074,7 @@ pub fn projected_rect_contains(
|
|||
target_rect: &WorldRect,
|
||||
) -> Option<()> {
|
||||
let points = [
|
||||
transform.transform_point2d(source_rect.origin)?,
|
||||
transform.transform_point2d(source_rect.top_left())?,
|
||||
transform.transform_point2d(source_rect.top_right())?,
|
||||
transform.transform_point2d(source_rect.bottom_right())?,
|
||||
transform.transform_point2d(source_rect.bottom_left())?,
|
||||
|
@ -2138,7 +2138,7 @@ fn add_clip_node_to_current_chain(
|
|||
};
|
||||
}
|
||||
ClipSpaceConversion::ScaleOffset(ref scale_offset) => {
|
||||
let clip_rect = scale_offset.map_rect(&clip_rect.to_box2d()).to_rect();
|
||||
let clip_rect = scale_offset.map_rect(&clip_rect);
|
||||
*local_clip_rect = match local_clip_rect.intersection(&clip_rect) {
|
||||
Some(rect) => rect,
|
||||
None => return false,
|
||||
|
@ -2170,7 +2170,7 @@ fn add_clip_node_to_current_chain(
|
|||
spatial_tree,
|
||||
);
|
||||
|
||||
if let Some(pic_clip_rect) = mapper.map(&clip_rect.to_box2d()) {
|
||||
if let Some(pic_clip_rect) = mapper.map(&clip_rect) {
|
||||
*current_pic_clip_rect = pic_clip_rect
|
||||
.intersection(current_pic_clip_rect)
|
||||
.unwrap_or(PictureRect::zero());
|
||||
|
@ -2199,7 +2199,7 @@ mod tests {
|
|||
assert_eq!(
|
||||
None,
|
||||
projected_rect_contains(
|
||||
&rect(10.0, 10.0, 0.0, 0.0),
|
||||
&rect(10.0, 10.0, 0.0, 0.0).to_box2d(),
|
||||
&Transform3D::identity(),
|
||||
&rect(20.0, 20.0, 10.0, 10.0).to_box2d(),
|
||||
),
|
||||
|
|
|
@ -345,10 +345,10 @@ impl FrameBuilder {
|
|||
scene_properties,
|
||||
global_screen_world_rect,
|
||||
spatial_tree: &scene.spatial_tree,
|
||||
max_local_clip: LayoutRect::new(
|
||||
LayoutPoint::new(-MAX_CLIP_COORD, -MAX_CLIP_COORD),
|
||||
LayoutSize::new(2.0 * MAX_CLIP_COORD, 2.0 * MAX_CLIP_COORD),
|
||||
),
|
||||
max_local_clip: LayoutRect {
|
||||
min: LayoutPoint::new(-MAX_CLIP_COORD, -MAX_CLIP_COORD),
|
||||
max: LayoutPoint::new(MAX_CLIP_COORD, MAX_CLIP_COORD),
|
||||
},
|
||||
debug_flags,
|
||||
fb_config: &scene.config,
|
||||
};
|
||||
|
|
|
@ -28,7 +28,7 @@ use api::{DebugFlags, DocumentId, PremultipliedColorF};
|
|||
#[cfg(test)]
|
||||
use api::IdNamespace;
|
||||
use api::units::*;
|
||||
use euclid::{HomogeneousVector, Rect};
|
||||
use euclid::{HomogeneousVector, Box2D};
|
||||
use crate::internal_types::{FastHashMap, FastHashSet};
|
||||
use crate::profiler::{self, TransactionProfile};
|
||||
use crate::render_backend::{FrameStamp, FrameId};
|
||||
|
@ -104,14 +104,14 @@ impl From<[f32; 4]> for GpuBlockData {
|
|||
}
|
||||
}
|
||||
|
||||
impl<P> From<Rect<f32, P>> for GpuBlockData {
|
||||
fn from(r: Rect<f32, P>) -> Self {
|
||||
impl<P> From<Box2D<f32, P>> for GpuBlockData {
|
||||
fn from(r: Box2D<f32, P>) -> Self {
|
||||
GpuBlockData {
|
||||
data: [
|
||||
r.origin.x,
|
||||
r.origin.y,
|
||||
r.size.width,
|
||||
r.size.height,
|
||||
r.min.x,
|
||||
r.min.y,
|
||||
r.max.x,
|
||||
r.max.y,
|
||||
],
|
||||
}
|
||||
}
|
||||
|
|
|
@ -468,7 +468,7 @@ impl HitTester {
|
|||
pipeline: pipeline_id,
|
||||
tag: item.tag,
|
||||
point_in_viewport,
|
||||
point_relative_to_item: point_in_layer - item.rect.origin.to_vector(),
|
||||
point_relative_to_item: point_in_layer - item.rect.min.to_vector(),
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,13 +21,13 @@ pub fn simplify_repeated_primitive(
|
|||
) {
|
||||
let stride = *stretch_size + *tile_spacing;
|
||||
|
||||
if stride.width >= prim_rect.size.width {
|
||||
if stride.width >= prim_rect.width() {
|
||||
tile_spacing.width = 0.0;
|
||||
prim_rect.size.width = f32::min(prim_rect.size.width, stretch_size.width);
|
||||
prim_rect.max.x = f32::min(prim_rect.min.x + stretch_size.width, prim_rect.max.x);
|
||||
}
|
||||
if stride.height >= prim_rect.size.height {
|
||||
if stride.height >= prim_rect.height() {
|
||||
tile_spacing.height = 0.0;
|
||||
prim_rect.size.height = f32::min(prim_rect.size.height, stretch_size.height);
|
||||
prim_rect.max.y = f32::min(prim_rect.min.y + stretch_size.height, prim_rect.max.y);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -112,23 +112,23 @@ pub fn repetitions(
|
|||
assert!(stride.width > 0.0);
|
||||
assert!(stride.height > 0.0);
|
||||
|
||||
let nx = if visible_rect.origin.x > prim_rect.origin.x {
|
||||
f32::floor((visible_rect.origin.x - prim_rect.origin.x) / stride.width)
|
||||
let nx = if visible_rect.min.x > prim_rect.min.x {
|
||||
f32::floor((visible_rect.min.x - prim_rect.min.x) / stride.width)
|
||||
} else {
|
||||
0.0
|
||||
};
|
||||
|
||||
let ny = if visible_rect.origin.y > prim_rect.origin.y {
|
||||
f32::floor((visible_rect.origin.y - prim_rect.origin.y) / stride.height)
|
||||
let ny = if visible_rect.min.y > prim_rect.min.y {
|
||||
f32::floor((visible_rect.min.y - prim_rect.min.y) / stride.height)
|
||||
} else {
|
||||
0.0
|
||||
};
|
||||
|
||||
let x0 = prim_rect.origin.x + nx * stride.width;
|
||||
let y0 = prim_rect.origin.y + ny * stride.height;
|
||||
let x0 = prim_rect.min.x + nx * stride.width;
|
||||
let y0 = prim_rect.min.y + ny * stride.height;
|
||||
|
||||
let x_most = visible_rect.max_x();
|
||||
let y_most = visible_rect.max_y();
|
||||
let x_most = visible_rect.max.x;
|
||||
let y_most = visible_rect.max.y;
|
||||
|
||||
let x_count = f32::ceil((x_most - x0) / stride.width) as i32;
|
||||
let y_count = f32::ceil((y_most - y0) / stride.height) as i32;
|
||||
|
@ -199,33 +199,34 @@ impl Iterator for TileIterator {
|
|||
|
||||
let tile_offset = self.current_tile;
|
||||
|
||||
let mut segment_rect = LayoutRect {
|
||||
origin: LayoutPoint::new(
|
||||
let mut segment_rect = LayoutRect::from_origin_and_size(
|
||||
LayoutPoint::new(
|
||||
self.x.layout_tiling_origin + tile_offset.x as f32 * self.regular_tile_size.width,
|
||||
self.y.layout_tiling_origin + tile_offset.y as f32 * self.regular_tile_size.height,
|
||||
),
|
||||
size: self.regular_tile_size,
|
||||
};
|
||||
self.regular_tile_size,
|
||||
);
|
||||
|
||||
let mut edge_flags = EdgeAaSegmentMask::empty();
|
||||
|
||||
if tile_offset.x == self.x.image_tiles.start {
|
||||
edge_flags |= EdgeAaSegmentMask::LEFT;
|
||||
segment_rect.size.width = self.x.first_tile_layout_size;
|
||||
segment_rect.origin.x = self.x.layout_prim_start;
|
||||
segment_rect.min.x = self.x.layout_prim_start;
|
||||
// TODO(nical) we may not need to do this.
|
||||
segment_rect.max.x = segment_rect.min.x + self.x.first_tile_layout_size;
|
||||
}
|
||||
if tile_offset.x == self.x.image_tiles.end - 1 {
|
||||
edge_flags |= EdgeAaSegmentMask::RIGHT;
|
||||
segment_rect.size.width = self.x.last_tile_layout_size;
|
||||
segment_rect.max.x = segment_rect.min.x + self.x.last_tile_layout_size;
|
||||
}
|
||||
|
||||
if tile_offset.y == self.y.image_tiles.start {
|
||||
segment_rect.size.height = self.y.first_tile_layout_size;
|
||||
segment_rect.origin.y = self.y.layout_prim_start;
|
||||
segment_rect.min.y = self.y.layout_prim_start;
|
||||
segment_rect.max.y = segment_rect.min.y + self.y.first_tile_layout_size;
|
||||
edge_flags |= EdgeAaSegmentMask::TOP;
|
||||
}
|
||||
if tile_offset.y == self.y.image_tiles.end - 1 {
|
||||
segment_rect.size.height = self.y.last_tile_layout_size;
|
||||
segment_rect.max.y = segment_rect.min.y + self.y.last_tile_layout_size;
|
||||
edge_flags |= EdgeAaSegmentMask::BOTTOM;
|
||||
}
|
||||
|
||||
|
@ -288,7 +289,7 @@ pub fn tiles(
|
|||
first_tile_layout_size: 0.0,
|
||||
last_tile_layout_size: 0.0,
|
||||
layout_tiling_origin: 0.0,
|
||||
layout_prim_start: prim_rect.origin.x,
|
||||
layout_prim_start: prim_rect.min.x,
|
||||
},
|
||||
y: TileIteratorExtent {
|
||||
tile_range: 0..0,
|
||||
|
@ -296,7 +297,7 @@ pub fn tiles(
|
|||
first_tile_layout_size: 0.0,
|
||||
last_tile_layout_size: 0.0,
|
||||
layout_tiling_origin: 0.0,
|
||||
layout_prim_start: prim_rect.origin.y,
|
||||
layout_prim_start: prim_rect.min.y,
|
||||
},
|
||||
regular_tile_size: LayoutSize::zero(),
|
||||
}
|
||||
|
@ -315,7 +316,7 @@ pub fn tiles(
|
|||
let x_extent = tiles_1d(
|
||||
layout_tile_size.width,
|
||||
visible_rect.x_range(),
|
||||
prim_rect.min_x(),
|
||||
prim_rect.min.x,
|
||||
image_rect.x_range(),
|
||||
device_tile_size,
|
||||
);
|
||||
|
@ -323,7 +324,7 @@ pub fn tiles(
|
|||
let y_extent = tiles_1d(
|
||||
layout_tile_size.height,
|
||||
visible_rect.y_range(),
|
||||
prim_rect.min_y(),
|
||||
prim_rect.min.y,
|
||||
image_rect.y_range(),
|
||||
device_tile_size,
|
||||
);
|
||||
|
@ -654,18 +655,18 @@ mod tests {
|
|||
assert!(!seen_tiles.contains(&tile.offset));
|
||||
seen_tiles.insert(tile.offset);
|
||||
coverage = coverage.union(&tile.rect);
|
||||
assert!(prim_rect.contains_rect(&tile.rect));
|
||||
assert!(prim_rect.contains_box(&tile.rect));
|
||||
callback(&tile.rect, tile.offset, tile.edge_flags);
|
||||
}
|
||||
assert!(prim_rect.contains_rect(&coverage));
|
||||
assert!(coverage.contains_rect(&visible_rect.intersection(&prim_rect).unwrap_or(LayoutRect::zero())));
|
||||
assert!(prim_rect.contains_box(&coverage));
|
||||
assert!(coverage.contains_box(&visible_rect.intersection(&prim_rect).unwrap_or(LayoutRect::zero())));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn basic() {
|
||||
let mut count = 0;
|
||||
checked_for_each_tile(&rect(0., 0., 1000., 1000.),
|
||||
&rect(75., 75., 400., 400.),
|
||||
checked_for_each_tile(&rect(0., 0., 1000., 1000.).to_box2d(),
|
||||
&rect(75., 75., 400., 400.).to_box2d(),
|
||||
&rect(0, 0, 400, 400).to_box2d(),
|
||||
36,
|
||||
&mut |_tile_rect, _tile_offset, _tile_flags| {
|
||||
|
@ -678,8 +679,8 @@ mod tests {
|
|||
#[test]
|
||||
fn empty() {
|
||||
let mut count = 0;
|
||||
checked_for_each_tile(&rect(0., 0., 74., 74.),
|
||||
&rect(75., 75., 400., 400.),
|
||||
checked_for_each_tile(&rect(0., 0., 74., 74.).to_box2d(),
|
||||
&rect(75., 75., 400., 400.).to_box2d(),
|
||||
&rect(0, 0, 400, 400).to_box2d(),
|
||||
36,
|
||||
&mut |_tile_rect, _tile_offset, _tile_flags| {
|
||||
|
|
|
@ -2549,7 +2549,7 @@ impl TileCacheInstance {
|
|||
);
|
||||
|
||||
let clip_chain_instance = frame_state.clip_store.build_clip_chain_instance(
|
||||
pic_rect.to_rect().cast_unit(),
|
||||
pic_rect.cast_unit(),
|
||||
&map_local_to_surface,
|
||||
&pic_to_world_mapper,
|
||||
frame_context.spatial_tree,
|
||||
|
@ -3094,7 +3094,7 @@ impl TileCacheInstance {
|
|||
);
|
||||
|
||||
// Map the primitive local rect into picture space.
|
||||
let prim_rect = match map_local_to_surface.map(&local_prim_rect.to_box2d()) {
|
||||
let prim_rect = match map_local_to_surface.map(&local_prim_rect) {
|
||||
Some(rect) => rect,
|
||||
None => return true,
|
||||
};
|
||||
|
@ -3120,7 +3120,7 @@ impl TileCacheInstance {
|
|||
return true;
|
||||
}
|
||||
|
||||
let prim_offset = ScaleOffset::from_offset(local_prim_rect.origin.to_vector().cast_unit());
|
||||
let prim_offset = ScaleOffset::from_offset(local_prim_rect.min.to_vector().cast_unit());
|
||||
|
||||
let local_prim_to_device = get_relative_scale_offset(
|
||||
prim_spatial_node_index,
|
||||
|
@ -3142,8 +3142,8 @@ impl TileCacheInstance {
|
|||
);
|
||||
|
||||
let surface_size = composite_state.get_surface_rect(
|
||||
&local_prim_rect.to_box2d(),
|
||||
&local_prim_rect.to_box2d(),
|
||||
&local_prim_rect,
|
||||
&local_prim_rect,
|
||||
compositor_transform_index,
|
||||
).size();
|
||||
|
||||
|
@ -3271,7 +3271,7 @@ impl TileCacheInstance {
|
|||
prohibited_rect: pic_clip_rect,
|
||||
is_opaque,
|
||||
descriptor: ExternalSurfaceDescriptor {
|
||||
local_surface_size: local_prim_rect.size,
|
||||
local_surface_size: local_prim_rect.size(),
|
||||
local_rect: prim_rect,
|
||||
local_clip_rect: prim_info.prim_clip_box,
|
||||
dependency,
|
||||
|
@ -5261,7 +5261,7 @@ impl PicturePrimitive {
|
|||
);
|
||||
}
|
||||
Some(ref mut raster_config) => {
|
||||
let pic_rect = self.precise_local_rect.to_box2d().cast_unit();
|
||||
let pic_rect = self.precise_local_rect.cast_unit();
|
||||
|
||||
let mut device_pixel_scale = frame_state
|
||||
.surfaces[raster_config.surface_index.0]
|
||||
|
@ -6086,7 +6086,7 @@ impl PicturePrimitive {
|
|||
match transform {
|
||||
CoordinateSpaceMapping::Local => {
|
||||
let polygon = Polygon::from_rect(
|
||||
local_rect * Scale::new(1.0),
|
||||
local_rect.to_rect() * Scale::new(1.0),
|
||||
plane_split_anchor,
|
||||
);
|
||||
splitter.add(polygon);
|
||||
|
@ -6094,7 +6094,7 @@ impl PicturePrimitive {
|
|||
CoordinateSpaceMapping::ScaleOffset(scale_offset) if scale_offset.scale == Vector2D::new(1.0, 1.0) => {
|
||||
let inv_matrix = scale_offset.inverse().to_transform().cast();
|
||||
let polygon = Polygon::from_transformed_rect_with_inverse(
|
||||
local_rect,
|
||||
local_rect.to_rect(),
|
||||
&matrix,
|
||||
&inv_matrix,
|
||||
plane_split_anchor,
|
||||
|
@ -6106,7 +6106,7 @@ impl PicturePrimitive {
|
|||
let mut clipper = Clipper::new();
|
||||
let results = clipper.clip_transformed(
|
||||
Polygon::from_rect(
|
||||
local_rect,
|
||||
local_rect.to_rect(),
|
||||
plane_split_anchor,
|
||||
),
|
||||
&matrix,
|
||||
|
@ -6382,7 +6382,7 @@ impl PicturePrimitive {
|
|||
let backdrop_to_world_mapper = SpaceMapper::new_with_target(
|
||||
ROOT_SPATIAL_NODE_INDEX,
|
||||
cluster.spatial_node_index,
|
||||
LayoutRect::max_rect().to_box2d(),
|
||||
LayoutRect::max_rect(),
|
||||
frame_context.spatial_tree,
|
||||
);
|
||||
|
||||
|
@ -6403,19 +6403,18 @@ impl PicturePrimitive {
|
|||
let prim_to_world_mapper = SpaceMapper::new_with_target(
|
||||
ROOT_SPATIAL_NODE_INDEX,
|
||||
spatial_node_index,
|
||||
LayoutRect::max_rect().to_box2d(),
|
||||
LayoutRect::max_rect(),
|
||||
frame_context.spatial_tree,
|
||||
);
|
||||
|
||||
// First map to the screen and get a flattened rect
|
||||
let prim_rect = prim_to_world_mapper
|
||||
.map(&prim_data.kind.border_rect.to_box2d())
|
||||
.unwrap_or_else(|| LayoutRect::zero().to_box2d());
|
||||
.map(&prim_data.kind.border_rect)
|
||||
.unwrap_or_else(LayoutRect::zero);
|
||||
// Backwards project the flattened rect onto the backdrop
|
||||
let prim_rect = backdrop_to_world_mapper
|
||||
.unmap(&prim_rect)
|
||||
.unwrap_or_else(|| LayoutRect::zero().to_box2d())
|
||||
.to_rect();
|
||||
.unwrap_or_else(LayoutRect::zero);
|
||||
|
||||
// TODO(aosmond): Is this safe? Updating the primitive size during
|
||||
// frame building is usually problematic since scene building will cache
|
||||
|
@ -6443,7 +6442,7 @@ impl PicturePrimitive {
|
|||
// Mark the cluster visible, since it passed the invertible and
|
||||
// backface checks.
|
||||
cluster.flags.insert(ClusterFlags::IS_VISIBLE);
|
||||
if let Some(cluster_rect) = surface.map_local_to_surface.map(&cluster.bounding_rect.to_box2d()) {
|
||||
if let Some(cluster_rect) = surface.map_local_to_surface.map(&cluster.bounding_rect) {
|
||||
surface.rect = surface.rect.union(&cluster_rect);
|
||||
}
|
||||
}
|
||||
|
@ -6458,7 +6457,7 @@ impl PicturePrimitive {
|
|||
surface.rect = raster_config.composite_mode.inflate_picture_rect(surface.rect, surface.scale_factors);
|
||||
}
|
||||
|
||||
let mut surface_rect = surface.rect.to_rect() * Scale::new(1.0);
|
||||
let mut surface_rect = surface.rect * Scale::new(1.0);
|
||||
|
||||
// Pop this surface from the stack
|
||||
let surface_index = state.pop_surface();
|
||||
|
@ -6489,7 +6488,7 @@ impl PicturePrimitive {
|
|||
);
|
||||
if let Some(parent_surface_rect) = parent_surface
|
||||
.map_local_to_surface
|
||||
.map(&surface_rect.to_box2d())
|
||||
.map(&surface_rect)
|
||||
{
|
||||
parent_surface.rect = parent_surface.rect.union(&parent_surface_rect);
|
||||
}
|
||||
|
@ -6542,8 +6541,8 @@ impl PicturePrimitive {
|
|||
request.push(shadow.color.premultiplied());
|
||||
request.push(PremultipliedColorF::WHITE);
|
||||
request.push([
|
||||
self.precise_local_rect.size.width,
|
||||
self.precise_local_rect.size.height,
|
||||
self.precise_local_rect.width(),
|
||||
self.precise_local_rect.height(),
|
||||
0.0,
|
||||
0.0,
|
||||
]);
|
||||
|
|
|
@ -132,7 +132,7 @@ pub fn prepare_primitives(
|
|||
if !cluster.opaque_rect.is_empty() {
|
||||
let surface = &mut frame_state.surfaces[pic_context.surface_index.0];
|
||||
|
||||
if let Some(cluster_opaque_rect) = surface.map_local_to_surface.map_inner_bounds(&cluster.opaque_rect.to_box2d()) {
|
||||
if let Some(cluster_opaque_rect) = surface.map_local_to_surface.map_inner_bounds(&cluster.opaque_rect) {
|
||||
surface.opaque_rect = crate::util::conservative_union_rect(&surface.opaque_rect, &cluster_opaque_rect);
|
||||
}
|
||||
}
|
||||
|
@ -215,7 +215,7 @@ fn prepare_prim_for_render(
|
|||
|
||||
if !update_clip_task(
|
||||
prim_instance,
|
||||
&prim_rect.origin,
|
||||
&prim_rect.min,
|
||||
cluster.spatial_node_index,
|
||||
pic_context.raster_spatial_node_index,
|
||||
pic_context,
|
||||
|
@ -233,7 +233,7 @@ fn prepare_prim_for_render(
|
|||
}
|
||||
|
||||
if prim_instance.is_chased() {
|
||||
println!("\tconsidered visible and ready with local pos {:?}", prim_rect.origin);
|
||||
println!("\tconsidered visible and ready with local pos {:?}", prim_rect.min);
|
||||
}
|
||||
|
||||
#[cfg(debug_assertions)]
|
||||
|
@ -353,7 +353,7 @@ fn prepare_interned_prim_for_render(
|
|||
pic_context.raster_spatial_node_index,
|
||||
)
|
||||
.into_fast_transform();
|
||||
let prim_offset = prim_data.common.prim_rect.origin.to_vector() - run.reference_frame_relative_offset;
|
||||
let prim_offset = prim_data.common.prim_rect.min.to_vector() - run.reference_frame_relative_offset;
|
||||
|
||||
let pic = &store.pictures[pic_context.pic_index.0];
|
||||
let surface = &frame_state.surfaces[pic_context.surface_index.0];
|
||||
|
@ -629,8 +629,8 @@ fn prepare_interned_prim_for_render(
|
|||
// cache with any shared template data.
|
||||
prim_data.update(frame_state, pic_context.surface_index);
|
||||
|
||||
if prim_data.stretch_size.width >= prim_data.common.prim_rect.size.width &&
|
||||
prim_data.stretch_size.height >= prim_data.common.prim_rect.size.height {
|
||||
if prim_data.stretch_size.width >= prim_data.common.prim_rect.width() &&
|
||||
prim_data.stretch_size.height >= prim_data.common.prim_rect.height() {
|
||||
|
||||
prim_data.common.may_need_repetition = false;
|
||||
}
|
||||
|
@ -676,8 +676,8 @@ fn prepare_interned_prim_for_render(
|
|||
PrimitiveInstanceKind::CachedLinearGradient { data_handle, ref mut visible_tiles_range, .. } => {
|
||||
profile_scope!("CachedLinearGradient");
|
||||
let prim_data = &mut data_stores.linear_grad[*data_handle];
|
||||
prim_data.common.may_need_repetition = prim_data.stretch_size.width < prim_data.common.prim_rect.size.width
|
||||
|| prim_data.stretch_size.height < prim_data.common.prim_rect.size.height;
|
||||
prim_data.common.may_need_repetition = prim_data.stretch_size.width < prim_data.common.prim_rect.width()
|
||||
|| prim_data.stretch_size.height < prim_data.common.prim_rect.height();
|
||||
|
||||
// Update the template this instance references, which may refresh the GPU
|
||||
// cache with any shared template data.
|
||||
|
@ -707,8 +707,8 @@ fn prepare_interned_prim_for_render(
|
|||
profile_scope!("RadialGradient");
|
||||
let prim_data = &mut data_stores.radial_grad[*data_handle];
|
||||
|
||||
prim_data.common.may_need_repetition = prim_data.stretch_size.width < prim_data.common.prim_rect.size.width
|
||||
|| prim_data.stretch_size.height < prim_data.common.prim_rect.size.height;
|
||||
prim_data.common.may_need_repetition = prim_data.stretch_size.width < prim_data.common.prim_rect.width()
|
||||
|| prim_data.stretch_size.height < prim_data.common.prim_rect.height();
|
||||
|
||||
// Update the template this instane references, which may refresh the GPU
|
||||
// cache with any shared template data.
|
||||
|
@ -741,8 +741,8 @@ fn prepare_interned_prim_for_render(
|
|||
profile_scope!("ConicGradient");
|
||||
let prim_data = &mut data_stores.conic_grad[*data_handle];
|
||||
|
||||
prim_data.common.may_need_repetition = prim_data.stretch_size.width < prim_data.common.prim_rect.size.width
|
||||
|| prim_data.stretch_size.height < prim_data.common.prim_rect.size.height;
|
||||
prim_data.common.may_need_repetition = prim_data.stretch_size.width < prim_data.common.prim_rect.width()
|
||||
|| prim_data.stretch_size.height < prim_data.common.prim_rect.height();
|
||||
|
||||
// Update the template this instane references, which may refresh the GPU
|
||||
// cache with any shared template data.
|
||||
|
@ -863,7 +863,7 @@ fn prepare_interned_prim_for_render(
|
|||
prim_instance,
|
||||
store,
|
||||
);
|
||||
cluster.opaque_rect = crate::util::conservative_union_rect(&cluster.opaque_rect.to_box2d(), &prim_local_rect.to_box2d()).to_rect();
|
||||
cluster.opaque_rect = crate::util::conservative_union_rect(&cluster.opaque_rect, &prim_local_rect);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -925,10 +925,10 @@ fn decompose_repeated_gradient(
|
|||
let repetitions = image_tiling::repetitions(prim_local_rect, &visible_rect, stride);
|
||||
for Repetition { origin, .. } in repetitions {
|
||||
let mut handle = GpuCacheHandle::new();
|
||||
let rect = LayoutRect {
|
||||
let rect = LayoutRect::from_origin_and_size(
|
||||
origin,
|
||||
size: *stretch_size,
|
||||
};
|
||||
*stretch_size,
|
||||
);
|
||||
|
||||
if let Some(callback) = &mut callback {
|
||||
if let Some(request) = frame_state.gpu_cache.request(&mut handle) {
|
||||
|
@ -1343,7 +1343,7 @@ fn write_brush_segment_description(
|
|||
) -> bool {
|
||||
// If the brush is small, we want to skip building segments
|
||||
// and just draw it as a single primitive with clip mask.
|
||||
if prim_local_rect.size.area() < MIN_BRUSH_SPLIT_AREA {
|
||||
if prim_local_rect.area() < MIN_BRUSH_SPLIT_AREA {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -1502,7 +1502,7 @@ fn build_segments_if_needed(
|
|||
frame_state.segment_builder.build(|segment| {
|
||||
segments.push(
|
||||
BrushSegment::new(
|
||||
segment.rect.translate(-prim_local_rect.origin.to_vector()),
|
||||
segment.rect.translate(-prim_local_rect.min.to_vector()),
|
||||
segment.has_mask,
|
||||
segment.edge_flags,
|
||||
[0.0; 4],
|
||||
|
|
|
@ -69,7 +69,7 @@ impl NormalBorderData {
|
|||
frame_state: &mut FrameBuildingState,
|
||||
) {
|
||||
if let Some(ref mut request) = frame_state.gpu_cache.request(&mut common.gpu_cache_handle) {
|
||||
self.write_prim_gpu_blocks(request, common.prim_rect.size);
|
||||
self.write_prim_gpu_blocks(request, common.prim_rect.size());
|
||||
self.write_segment_gpu_blocks(request);
|
||||
}
|
||||
|
||||
|
@ -124,7 +124,7 @@ impl From<NormalBorderKey> for NormalBorderTemplate {
|
|||
let mut border_segments = Vec::new();
|
||||
|
||||
create_border_segments(
|
||||
common.prim_rect.size,
|
||||
common.prim_rect.size(),
|
||||
&border,
|
||||
&widths,
|
||||
&mut border_segments,
|
||||
|
@ -248,7 +248,7 @@ impl ImageBorderData {
|
|||
frame_state: &mut FrameBuildingState,
|
||||
) {
|
||||
if let Some(ref mut request) = frame_state.gpu_cache.request(&mut common.gpu_cache_handle) {
|
||||
self.write_prim_gpu_blocks(request, &common.prim_rect.size);
|
||||
self.write_prim_gpu_blocks(request, &common.prim_rect.size());
|
||||
self.write_segment_gpu_blocks(request);
|
||||
}
|
||||
|
||||
|
@ -317,7 +317,7 @@ impl From<ImageBorderKey> for ImageBorderTemplate {
|
|||
fn from(key: ImageBorderKey) -> Self {
|
||||
let common = PrimTemplateCommonData::with_key_common(key.common);
|
||||
|
||||
let brush_segments = key.kind.nine_patch.create_segments(common.prim_rect.size);
|
||||
let brush_segments = key.kind.nine_patch.create_segments(common.prim_rect.size());
|
||||
ImageBorderTemplate {
|
||||
common,
|
||||
kind: ImageBorderData {
|
||||
|
|
|
@ -121,7 +121,7 @@ impl From<ConicGradientKey> for ConicGradientTemplate {
|
|||
let mut brush_segments = Vec::new();
|
||||
|
||||
if let Some(ref nine_patch) = item.nine_patch {
|
||||
brush_segments = nine_patch.create_segments(common.prim_rect.size);
|
||||
brush_segments = nine_patch.create_segments(common.prim_rect.size());
|
||||
}
|
||||
|
||||
let (stops, min_alpha) = stops_and_min_alpha(&item.stops);
|
||||
|
@ -132,8 +132,8 @@ impl From<ConicGradientKey> for ConicGradientTemplate {
|
|||
let stops_opacity = PrimitiveOpacity::from_alpha(min_alpha);
|
||||
|
||||
let mut stretch_size: LayoutSize = item.stretch_size.into();
|
||||
stretch_size.width = stretch_size.width.min(common.prim_rect.size.width);
|
||||
stretch_size.height = stretch_size.height.min(common.prim_rect.size.height);
|
||||
stretch_size.width = stretch_size.width.min(common.prim_rect.width());
|
||||
stretch_size.height = stretch_size.height.min(common.prim_rect.height());
|
||||
|
||||
// Avoid rendering enormous gradients. Radial gradients are mostly made of soft transitions,
|
||||
// so it is unlikely that rendering at a higher resolution that 1024 would produce noticeable
|
||||
|
|
|
@ -126,26 +126,26 @@ pub fn optimize_linear_gradient(
|
|||
|
||||
// The size of gradient render tasks depends on the tile_size. No need to generate
|
||||
// large stretch sizes that will be clipped to the bounds of the primitive.
|
||||
tile_size.width = tile_size.width.min(prim_rect.size.width);
|
||||
tile_size.height = tile_size.height.min(prim_rect.size.height);
|
||||
tile_size.width = tile_size.width.min(prim_rect.width());
|
||||
tile_size.height = tile_size.height.min(prim_rect.height());
|
||||
|
||||
simplify_repeated_primitive(&tile_size, &mut tile_spacing, prim_rect);
|
||||
|
||||
let vertical = start.x.approx_eq(&end.x);
|
||||
let horizontal = start.y.approx_eq(&end.y);
|
||||
|
||||
let mut horizontally_tiled = prim_rect.size.width > tile_size.width;
|
||||
let mut vertically_tiled = prim_rect.size.height > tile_size.height;
|
||||
let mut horizontally_tiled = prim_rect.width() > tile_size.width;
|
||||
let mut vertically_tiled = prim_rect.height() > tile_size.height;
|
||||
|
||||
// Check whether the tiling is equivalent to stretching on either axis.
|
||||
// Stretching the gradient is more efficient than repeating it.
|
||||
if vertically_tiled && horizontal && tile_spacing.height == 0.0 {
|
||||
tile_size.height = prim_rect.size.height;
|
||||
tile_size.height = prim_rect.height();
|
||||
vertically_tiled = false;
|
||||
}
|
||||
|
||||
if horizontally_tiled && vertical && tile_spacing.width == 0.0 {
|
||||
tile_size.width = prim_rect.size.width;
|
||||
tile_size.width = prim_rect.width();
|
||||
horizontally_tiled = false;
|
||||
}
|
||||
|
||||
|
@ -195,8 +195,8 @@ pub fn optimize_linear_gradient(
|
|||
|
||||
let adjust_rect = &mut |rect: &mut LayoutRect| {
|
||||
if vertical {
|
||||
swap(&mut rect.origin.x, &mut rect.origin.y);
|
||||
swap(&mut rect.size.width, &mut rect.size.height);
|
||||
swap(&mut rect.min.x, &mut rect.min.y);
|
||||
swap(&mut rect.max.x, &mut rect.max.y);
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -270,8 +270,8 @@ pub fn optimize_linear_gradient(
|
|||
}
|
||||
|
||||
let mut segment_rect = *prim_rect;
|
||||
segment_rect.origin.x += segment_start;
|
||||
segment_rect.size.width = segment_length;
|
||||
segment_rect.min.x += segment_start;
|
||||
segment_rect.max.x = segment_rect.min.x + segment_length;
|
||||
|
||||
let mut start = point2(0.0, 0.0);
|
||||
let mut end = point2(segment_length, 0.0);
|
||||
|
@ -280,14 +280,14 @@ pub fn optimize_linear_gradient(
|
|||
adjust_point(&mut end);
|
||||
adjust_rect(&mut segment_rect);
|
||||
|
||||
let origin_before_clip = segment_rect.origin;
|
||||
let origin_before_clip = segment_rect.min;
|
||||
segment_rect = match segment_rect.intersection(&clip_rect) {
|
||||
Some(rect) => rect,
|
||||
None => {
|
||||
continue;
|
||||
}
|
||||
};
|
||||
let offset = segment_rect.origin - origin_before_clip;
|
||||
let offset = segment_rect.min - origin_before_clip;
|
||||
|
||||
// Account for the clipping since start and end are relative to the origin.
|
||||
start -= offset;
|
||||
|
@ -317,7 +317,7 @@ impl From<LinearGradientKey> for LinearGradientTemplate {
|
|||
let mut brush_segments = Vec::new();
|
||||
|
||||
if let Some(ref nine_patch) = item.nine_patch {
|
||||
brush_segments = nine_patch.create_segments(common.prim_rect.size);
|
||||
brush_segments = nine_patch.create_segments(common.prim_rect.size());
|
||||
}
|
||||
|
||||
// Save opacity of the stops for use in
|
||||
|
|
|
@ -326,38 +326,36 @@ pub fn apply_gradient_local_clip(
|
|||
tile_spacing: &LayoutSize,
|
||||
clip_rect: &LayoutRect,
|
||||
) -> LayoutVector2D {
|
||||
let w = prim_rect.max_x().min(clip_rect.max_x()) - prim_rect.min_x();
|
||||
let h = prim_rect.max_y().min(clip_rect.max_y()) - prim_rect.min_y();
|
||||
let w = prim_rect.max.x.min(clip_rect.max.x) - prim_rect.min.x;
|
||||
let h = prim_rect.max.y.min(clip_rect.max.y) - prim_rect.min.y;
|
||||
let is_tiled_x = w > stretch_size.width + tile_spacing.width;
|
||||
let is_tiled_y = h > stretch_size.height + tile_spacing.height;
|
||||
|
||||
let mut offset = LayoutVector2D::new(0.0, 0.0);
|
||||
|
||||
if !is_tiled_x {
|
||||
let diff = (clip_rect.min_x() - prim_rect.min_x()).min(prim_rect.size.width);
|
||||
let diff = (clip_rect.min.x - prim_rect.min.x).min(prim_rect.width());
|
||||
if diff > 0.0 {
|
||||
prim_rect.origin.x += diff;
|
||||
prim_rect.size.width -= diff;
|
||||
prim_rect.min.x += diff;
|
||||
offset.x = -diff;
|
||||
}
|
||||
|
||||
let diff = prim_rect.max_x() - clip_rect.max_x();
|
||||
let diff = prim_rect.max.x - clip_rect.max.x;
|
||||
if diff > 0.0 {
|
||||
prim_rect.size.width -= diff;
|
||||
prim_rect.max.x -= diff;
|
||||
}
|
||||
}
|
||||
|
||||
if !is_tiled_y {
|
||||
let diff = (clip_rect.min_y() - prim_rect.min_y()).min(prim_rect.size.height);
|
||||
let diff = (clip_rect.min.y - prim_rect.min.y).min(prim_rect.height());
|
||||
if diff > 0.0 {
|
||||
prim_rect.origin.y += diff;
|
||||
prim_rect.size.height -= diff;
|
||||
prim_rect.min.y += diff;
|
||||
offset.y = -diff;
|
||||
}
|
||||
|
||||
let diff = prim_rect.max_y() - clip_rect.max_y();
|
||||
let diff = prim_rect.max.y - clip_rect.max.y;
|
||||
if diff > 0.0 {
|
||||
prim_rect.size.height -= diff;
|
||||
prim_rect.max.y -= diff;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -125,7 +125,7 @@ impl From<RadialGradientKey> for RadialGradientTemplate {
|
|||
let mut brush_segments = Vec::new();
|
||||
|
||||
if let Some(ref nine_patch) = item.nine_patch {
|
||||
brush_segments = nine_patch.create_segments(common.prim_rect.size);
|
||||
brush_segments = nine_patch.create_segments(common.prim_rect.size());
|
||||
}
|
||||
|
||||
let (stops, min_alpha) = stops_and_min_alpha(&item.stops);
|
||||
|
@ -136,8 +136,8 @@ impl From<RadialGradientKey> for RadialGradientTemplate {
|
|||
let stops_opacity = PrimitiveOpacity::from_alpha(min_alpha);
|
||||
|
||||
let mut stretch_size: LayoutSize = item.stretch_size.into();
|
||||
stretch_size.width = stretch_size.width.min(common.prim_rect.size.width);
|
||||
stretch_size.height = stretch_size.height.min(common.prim_rect.size.height);
|
||||
stretch_size.width = stretch_size.width.min(common.prim_rect.width());
|
||||
stretch_size.height = stretch_size.height.min(common.prim_rect.height());
|
||||
|
||||
// Avoid rendering enormous gradients. Radial gradients are mostly made of soft transitions,
|
||||
// so it is unlikely that rendering at a higher resolution that 1024 would produce noticeable
|
||||
|
@ -404,24 +404,24 @@ pub fn optimize_radial_gradient(
|
|||
}
|
||||
|
||||
// Bounding box of the "interesting" part of the gradient.
|
||||
let min = prim_rect.origin + center.to_vector() - radius.to_vector() * end_offset;
|
||||
let max = prim_rect.origin + center.to_vector() + radius.to_vector() * end_offset;
|
||||
let min = prim_rect.min + center.to_vector() - radius.to_vector() * end_offset;
|
||||
let max = prim_rect.min + center.to_vector() + radius.to_vector() * end_offset;
|
||||
|
||||
// The (non-repeated) gradient primitive rect.
|
||||
let gradient_rect = LayoutRect {
|
||||
origin: prim_rect.origin,
|
||||
size: *stretch_size,
|
||||
};
|
||||
let gradient_rect = LayoutRect::from_origin_and_size(
|
||||
prim_rect.min,
|
||||
*stretch_size,
|
||||
);
|
||||
|
||||
// How much internal margin between the primitive bounds and the gradient's
|
||||
// bounding rect (areas that are a constant color).
|
||||
let mut l = (min.x - gradient_rect.min_x()).max(0.0).floor();
|
||||
let mut t = (min.y - gradient_rect.min_y()).max(0.0).floor();
|
||||
let mut r = (gradient_rect.max_x() - max.x).max(0.0).floor();
|
||||
let mut b = (gradient_rect.max_y() - max.y).max(0.0).floor();
|
||||
let mut l = (min.x - gradient_rect.min.x).max(0.0).floor();
|
||||
let mut t = (min.y - gradient_rect.min.y).max(0.0).floor();
|
||||
let mut r = (gradient_rect.max.x - max.x).max(0.0).floor();
|
||||
let mut b = (gradient_rect.max.y - max.y).max(0.0).floor();
|
||||
|
||||
let is_tiled = prim_rect.size.width > stretch_size.width + tile_spacing.width
|
||||
|| prim_rect.size.height > stretch_size.height + tile_spacing.height;
|
||||
let is_tiled = prim_rect.width() > stretch_size.width + tile_spacing.width
|
||||
|| prim_rect.height() > stretch_size.height + tile_spacing.height;
|
||||
|
||||
let bg_color = stops.last().unwrap().color;
|
||||
|
||||
|
@ -454,76 +454,74 @@ pub fn optimize_radial_gradient(
|
|||
// shrunk.
|
||||
if bg_color.a != 0 {
|
||||
if l != 0.0 && t != 0.0 {
|
||||
let solid_rect = LayoutRect {
|
||||
origin: gradient_rect.origin,
|
||||
size: size2(l, t),
|
||||
};
|
||||
let solid_rect = LayoutRect::from_origin_and_size(
|
||||
gradient_rect.min,
|
||||
size2(l, t),
|
||||
);
|
||||
solid_parts(&solid_rect, bg_color);
|
||||
}
|
||||
|
||||
if l != 0.0 && b != 0.0 {
|
||||
let solid_rect = LayoutRect {
|
||||
origin: gradient_rect.bottom_left() - vec2(0.0, b),
|
||||
size: size2(l, b),
|
||||
};
|
||||
let solid_rect = LayoutRect::from_origin_and_size(
|
||||
gradient_rect.bottom_left() - vec2(0.0, b),
|
||||
size2(l, b),
|
||||
);
|
||||
solid_parts(&solid_rect, bg_color);
|
||||
}
|
||||
|
||||
if t != 0.0 && r != 0.0 {
|
||||
let solid_rect = LayoutRect {
|
||||
origin: gradient_rect.top_right() - vec2(r, 0.0),
|
||||
size: size2(r, t),
|
||||
};
|
||||
let solid_rect = LayoutRect::from_origin_and_size(
|
||||
gradient_rect.top_right() - vec2(r, 0.0),
|
||||
size2(r, t),
|
||||
);
|
||||
solid_parts(&solid_rect, bg_color);
|
||||
}
|
||||
|
||||
if r != 0.0 && b != 0.0 {
|
||||
let solid_rect = LayoutRect {
|
||||
origin: gradient_rect.bottom_right() - vec2(r, b),
|
||||
size: size2(r, b),
|
||||
};
|
||||
let solid_rect = LayoutRect::from_origin_and_size(
|
||||
gradient_rect.bottom_right() - vec2(r, b),
|
||||
size2(r, b),
|
||||
);
|
||||
solid_parts(&solid_rect, bg_color);
|
||||
}
|
||||
|
||||
if l != 0.0 {
|
||||
let solid_rect = LayoutRect {
|
||||
origin: gradient_rect.origin + vec2(0.0, t),
|
||||
size: size2(l, gradient_rect.size.height - t - b),
|
||||
};
|
||||
let solid_rect = LayoutRect::from_origin_and_size(
|
||||
gradient_rect.min + vec2(0.0, t),
|
||||
size2(l, gradient_rect.height() - t - b),
|
||||
);
|
||||
solid_parts(&solid_rect, bg_color);
|
||||
}
|
||||
|
||||
if r != 0.0 {
|
||||
let solid_rect = LayoutRect {
|
||||
origin: gradient_rect.top_right() + vec2(-r, t),
|
||||
size: size2(r, gradient_rect.size.height - t - b),
|
||||
};
|
||||
let solid_rect = LayoutRect::from_origin_and_size(
|
||||
gradient_rect.top_right() + vec2(-r, t),
|
||||
size2(r, gradient_rect.height() - t - b),
|
||||
);
|
||||
solid_parts(&solid_rect, bg_color);
|
||||
}
|
||||
|
||||
if t != 0.0 {
|
||||
let solid_rect = LayoutRect {
|
||||
origin: gradient_rect.origin + vec2(l, 0.0),
|
||||
size: size2(gradient_rect.size.width - l - r, t),
|
||||
};
|
||||
let solid_rect = LayoutRect::from_origin_and_size(
|
||||
gradient_rect.min + vec2(l, 0.0),
|
||||
size2(gradient_rect.width() - l - r, t),
|
||||
);
|
||||
solid_parts(&solid_rect, bg_color);
|
||||
}
|
||||
|
||||
if b != 0.0 {
|
||||
let solid_rect = LayoutRect {
|
||||
origin: gradient_rect.bottom_left() + vec2(l, -b),
|
||||
size: size2(gradient_rect.size.width - l - r, b),
|
||||
};
|
||||
let solid_rect = LayoutRect::from_origin_and_size(
|
||||
gradient_rect.bottom_left() + vec2(l, -b),
|
||||
size2(gradient_rect.width() - l - r, b),
|
||||
);
|
||||
solid_parts(&solid_rect, bg_color);
|
||||
}
|
||||
}
|
||||
|
||||
// Shrink the gradient primitive.
|
||||
|
||||
prim_rect.origin.x += l;
|
||||
prim_rect.origin.y += t;
|
||||
prim_rect.size.width -= l;
|
||||
prim_rect.size.height -= t;
|
||||
prim_rect.min.x += l;
|
||||
prim_rect.min.y += t;
|
||||
|
||||
stretch_size.width -= l + r;
|
||||
stretch_size.height -= b + t;
|
||||
|
|
|
@ -157,8 +157,8 @@ impl ImageData {
|
|||
None => PrimitiveOpacity::opaque(),
|
||||
};
|
||||
|
||||
if self.stretch_size.width >= common.prim_rect.size.width &&
|
||||
self.stretch_size.height >= common.prim_rect.size.height {
|
||||
if self.stretch_size.width >= common.prim_rect.width() &&
|
||||
self.stretch_size.height >= common.prim_rect.height() {
|
||||
|
||||
common.may_need_repetition = false;
|
||||
}
|
||||
|
@ -332,10 +332,10 @@ impl ImageData {
|
|||
for image_tiling::Repetition { origin, edge_flags } in repetitions {
|
||||
let edge_flags = base_edge_flags | edge_flags;
|
||||
|
||||
let layout_image_rect = LayoutRect {
|
||||
let layout_image_rect = LayoutRect::from_origin_and_size(
|
||||
origin,
|
||||
size: self.stretch_size,
|
||||
};
|
||||
self.stretch_size,
|
||||
);
|
||||
|
||||
let tiles = image_tiling::tiles(
|
||||
&layout_image_rect,
|
||||
|
|
|
@ -133,18 +133,18 @@ pub struct PictureIndex(pub usize);
|
|||
#[cfg_attr(feature = "replay", derive(Deserialize))]
|
||||
#[derive(Copy, Debug, Clone, MallocSizeOf, PartialEq)]
|
||||
pub struct RectangleKey {
|
||||
pub x: f32,
|
||||
pub y: f32,
|
||||
pub w: f32,
|
||||
pub h: f32,
|
||||
pub x0: f32,
|
||||
pub y0: f32,
|
||||
pub x1: f32,
|
||||
pub y1: f32,
|
||||
}
|
||||
|
||||
impl RectangleKey {
|
||||
pub fn intersects(&self, other: &Self) -> bool {
|
||||
self.x < other.x + other.w
|
||||
&& other.x < self.x + self.w
|
||||
&& self.y < other.y + other.h
|
||||
&& other.y < self.y + self.h
|
||||
self.x0 < other.x1
|
||||
&& other.x0 < self.x1
|
||||
&& self.y0 < other.y1
|
||||
&& other.y0 < self.y1
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -152,18 +152,18 @@ impl Eq for RectangleKey {}
|
|||
|
||||
impl hash::Hash for RectangleKey {
|
||||
fn hash<H: hash::Hasher>(&self, state: &mut H) {
|
||||
self.x.to_bits().hash(state);
|
||||
self.y.to_bits().hash(state);
|
||||
self.w.to_bits().hash(state);
|
||||
self.h.to_bits().hash(state);
|
||||
self.x0.to_bits().hash(state);
|
||||
self.y0.to_bits().hash(state);
|
||||
self.x1.to_bits().hash(state);
|
||||
self.y1.to_bits().hash(state);
|
||||
}
|
||||
}
|
||||
|
||||
impl From<RectangleKey> for LayoutRect {
|
||||
fn from(key: RectangleKey) -> LayoutRect {
|
||||
LayoutRect {
|
||||
origin: LayoutPoint::new(key.x, key.y),
|
||||
size: LayoutSize::new(key.w, key.h),
|
||||
min: LayoutPoint::new(key.x0, key.y0),
|
||||
max: LayoutPoint::new(key.x1, key.y1),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -171,8 +171,8 @@ impl From<RectangleKey> for LayoutRect {
|
|||
impl From<RectangleKey> for WorldRect {
|
||||
fn from(key: RectangleKey) -> WorldRect {
|
||||
WorldRect {
|
||||
min: WorldPoint::new(key.x, key.y),
|
||||
max: WorldPoint::new(key.x + key.w, key.y + key.h),
|
||||
min: WorldPoint::new(key.x0, key.y0),
|
||||
max: WorldPoint::new(key.x1, key.y1),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -180,10 +180,10 @@ impl From<RectangleKey> for WorldRect {
|
|||
impl From<LayoutRect> for RectangleKey {
|
||||
fn from(rect: LayoutRect) -> RectangleKey {
|
||||
RectangleKey {
|
||||
x: rect.origin.x,
|
||||
y: rect.origin.y,
|
||||
w: rect.size.width,
|
||||
h: rect.size.height,
|
||||
x0: rect.min.x,
|
||||
y0: rect.min.y,
|
||||
x1: rect.max.x,
|
||||
y1: rect.max.y,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -191,10 +191,10 @@ impl From<LayoutRect> for RectangleKey {
|
|||
impl From<PictureRect> for RectangleKey {
|
||||
fn from(rect: PictureRect) -> RectangleKey {
|
||||
RectangleKey {
|
||||
x: rect.min.x,
|
||||
y: rect.min.y,
|
||||
w: rect.width(),
|
||||
h: rect.height(),
|
||||
x0: rect.min.x,
|
||||
y0: rect.min.y,
|
||||
x1: rect.max.x,
|
||||
y1: rect.max.y,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -202,10 +202,10 @@ impl From<PictureRect> for RectangleKey {
|
|||
impl From<WorldRect> for RectangleKey {
|
||||
fn from(rect: WorldRect) -> RectangleKey {
|
||||
RectangleKey {
|
||||
x: rect.min.x,
|
||||
y: rect.min.y,
|
||||
w: rect.width(),
|
||||
h: rect.height(),
|
||||
x0: rect.min.x,
|
||||
y0: rect.min.y,
|
||||
x1: rect.max.x,
|
||||
y1: rect.max.y,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -792,10 +792,7 @@ impl ClipData {
|
|||
// same as they were, even though the origin is now always
|
||||
// zero, since they are in the clip's local space. In future,
|
||||
// we could reduce the GPU cache size of ClipData.
|
||||
let rect = LayoutRect::new(
|
||||
LayoutPoint::zero(),
|
||||
size,
|
||||
);
|
||||
let rect = LayoutRect::from_size(size);
|
||||
|
||||
ClipData {
|
||||
rect: ClipRect {
|
||||
|
@ -803,8 +800,8 @@ impl ClipData {
|
|||
mode: mode as u32 as f32,
|
||||
},
|
||||
top_left: ClipCorner {
|
||||
rect: LayoutRect::new(
|
||||
LayoutPoint::new(rect.origin.x, rect.origin.y),
|
||||
rect: LayoutRect::from_origin_and_size(
|
||||
LayoutPoint::new(rect.min.x, rect.min.y),
|
||||
LayoutSize::new(radii.top_left.width, radii.top_left.height),
|
||||
),
|
||||
outer_radius_x: radii.top_left.width,
|
||||
|
@ -813,10 +810,10 @@ impl ClipData {
|
|||
inner_radius_y: 0.0,
|
||||
},
|
||||
top_right: ClipCorner {
|
||||
rect: LayoutRect::new(
|
||||
rect: LayoutRect::from_origin_and_size(
|
||||
LayoutPoint::new(
|
||||
rect.origin.x + rect.size.width - radii.top_right.width,
|
||||
rect.origin.y,
|
||||
rect.max.x - radii.top_right.width,
|
||||
rect.min.y,
|
||||
),
|
||||
LayoutSize::new(radii.top_right.width, radii.top_right.height),
|
||||
),
|
||||
|
@ -826,10 +823,10 @@ impl ClipData {
|
|||
inner_radius_y: 0.0,
|
||||
},
|
||||
bottom_left: ClipCorner {
|
||||
rect: LayoutRect::new(
|
||||
rect: LayoutRect::from_origin_and_size(
|
||||
LayoutPoint::new(
|
||||
rect.origin.x,
|
||||
rect.origin.y + rect.size.height - radii.bottom_left.height,
|
||||
rect.min.x,
|
||||
rect.max.y - radii.bottom_left.height,
|
||||
),
|
||||
LayoutSize::new(radii.bottom_left.width, radii.bottom_left.height),
|
||||
),
|
||||
|
@ -839,10 +836,10 @@ impl ClipData {
|
|||
inner_radius_y: 0.0,
|
||||
},
|
||||
bottom_right: ClipCorner {
|
||||
rect: LayoutRect::new(
|
||||
rect: LayoutRect::from_origin_and_size(
|
||||
LayoutPoint::new(
|
||||
rect.origin.x + rect.size.width - radii.bottom_right.width,
|
||||
rect.origin.y + rect.size.height - radii.bottom_right.height,
|
||||
rect.max.x - radii.bottom_right.width,
|
||||
rect.max.y - radii.bottom_right.height,
|
||||
),
|
||||
LayoutSize::new(radii.bottom_right.width, radii.bottom_right.height),
|
||||
),
|
||||
|
@ -859,10 +856,7 @@ impl ClipData {
|
|||
// same as they were, even though the origin is now always
|
||||
// zero, since they are in the clip's local space. In future,
|
||||
// we could reduce the GPU cache size of ClipData.
|
||||
let rect = LayoutRect::new(
|
||||
LayoutPoint::zero(),
|
||||
size,
|
||||
);
|
||||
let rect = LayoutRect::from_size(size);
|
||||
|
||||
ClipData {
|
||||
rect: ClipRect {
|
||||
|
@ -870,34 +864,34 @@ impl ClipData {
|
|||
mode: mode as u32 as f32,
|
||||
},
|
||||
top_left: ClipCorner::uniform(
|
||||
LayoutRect::new(
|
||||
LayoutPoint::new(rect.origin.x, rect.origin.y),
|
||||
LayoutRect::from_origin_and_size(
|
||||
LayoutPoint::new(rect.min.x, rect.min.y),
|
||||
LayoutSize::new(radius, radius),
|
||||
),
|
||||
radius,
|
||||
0.0,
|
||||
),
|
||||
top_right: ClipCorner::uniform(
|
||||
LayoutRect::new(
|
||||
LayoutPoint::new(rect.origin.x + rect.size.width - radius, rect.origin.y),
|
||||
LayoutRect::from_origin_and_size(
|
||||
LayoutPoint::new(rect.max.x - radius, rect.min.y),
|
||||
LayoutSize::new(radius, radius),
|
||||
),
|
||||
radius,
|
||||
0.0,
|
||||
),
|
||||
bottom_left: ClipCorner::uniform(
|
||||
LayoutRect::new(
|
||||
LayoutPoint::new(rect.origin.x, rect.origin.y + rect.size.height - radius),
|
||||
LayoutRect::from_origin_and_size(
|
||||
LayoutPoint::new(rect.min.x, rect.max.y - radius),
|
||||
LayoutSize::new(radius, radius),
|
||||
),
|
||||
radius,
|
||||
0.0,
|
||||
),
|
||||
bottom_right: ClipCorner::uniform(
|
||||
LayoutRect::new(
|
||||
LayoutRect::from_origin_and_size(
|
||||
LayoutPoint::new(
|
||||
rect.origin.x + rect.size.width - radius,
|
||||
rect.origin.y + rect.size.height - radius,
|
||||
rect.max.x - radius,
|
||||
rect.max.y - radius,
|
||||
),
|
||||
LayoutSize::new(radius, radius),
|
||||
),
|
||||
|
|
|
@ -519,7 +519,7 @@ impl RenderTaskKind {
|
|||
surfaces,
|
||||
|rg_builder| {
|
||||
let clip_data = ClipData::rounded_rect(
|
||||
source.minimal_shadow_rect.size,
|
||||
source.minimal_shadow_rect.size(),
|
||||
&source.shadow_radius,
|
||||
ClipMode::Clip,
|
||||
);
|
||||
|
@ -528,7 +528,7 @@ impl RenderTaskKind {
|
|||
let mask_task_id = rg_builder.add().init(RenderTask::new_dynamic(
|
||||
cache_size,
|
||||
RenderTaskKind::new_rounded_rect_mask(
|
||||
source.minimal_shadow_rect.origin,
|
||||
source.minimal_shadow_rect.min,
|
||||
clip_data,
|
||||
device_pixel_scale,
|
||||
fb_config,
|
||||
|
@ -639,8 +639,8 @@ impl RenderTaskKind {
|
|||
data: [
|
||||
target_rect.min.x as f32,
|
||||
target_rect.min.y as f32,
|
||||
target_rect.width() as f32,
|
||||
target_rect.height() as f32,
|
||||
target_rect.max.x as f32,
|
||||
target_rect.max.y as f32,
|
||||
data[0],
|
||||
data[1],
|
||||
data[2],
|
||||
|
|
|
@ -2589,7 +2589,7 @@ impl Renderer {
|
|||
let instance = ClearInstance {
|
||||
rect: [
|
||||
r.min.x as f32, r.min.y as f32,
|
||||
r.width() as f32, r.height() as f32,
|
||||
r.max.x as f32, r.max.y as f32,
|
||||
],
|
||||
color: clear_color.unwrap_or([0.0; 4]),
|
||||
};
|
||||
|
@ -3662,7 +3662,7 @@ impl Renderer {
|
|||
ClearInstance {
|
||||
rect: [
|
||||
rect.min.x, rect.min.y,
|
||||
rect.width(), rect.height(),
|
||||
rect.max.x, rect.max.y,
|
||||
],
|
||||
color: zero_color,
|
||||
}
|
||||
|
@ -3675,7 +3675,7 @@ impl Renderer {
|
|||
ClearInstance {
|
||||
rect: [
|
||||
rect.min.x, rect.min.y,
|
||||
rect.width(), rect.height(),
|
||||
rect.max.x, rect.max.y,
|
||||
],
|
||||
color: one_color,
|
||||
}
|
||||
|
@ -3832,7 +3832,7 @@ impl Renderer {
|
|||
.map(|r| ClearInstance {
|
||||
rect: [
|
||||
r.min.x as f32, r.min.y as f32,
|
||||
r.width() as f32, r.height() as f32,
|
||||
r.max.x as f32, r.max.y as f32,
|
||||
],
|
||||
color,
|
||||
})
|
||||
|
|
|
@ -892,7 +892,7 @@ impl<'a> SceneBuilder<'a> {
|
|||
// SpatialNode::scroll(..) API as well as for properly setting sticky
|
||||
// positioning offsets.
|
||||
let frame_rect = clip_rect;
|
||||
let content_size = info.content_rect.size;
|
||||
let content_size = info.content_rect.size();
|
||||
|
||||
self.add_rect_clip_node(
|
||||
info.clip_id,
|
||||
|
@ -956,10 +956,10 @@ impl<'a> SceneBuilder<'a> {
|
|||
is_2d_scale_translation: false,
|
||||
should_snap: false
|
||||
},
|
||||
bounds.origin.to_vector(),
|
||||
bounds.min.to_vector(),
|
||||
);
|
||||
|
||||
let iframe_rect = LayoutRect::new(LayoutPoint::zero(), bounds.size);
|
||||
let iframe_rect = LayoutRect::from_size(bounds.size());
|
||||
let is_root_pipeline = self.iframe_size.is_empty();
|
||||
|
||||
self.add_scroll_frame(
|
||||
|
@ -968,7 +968,7 @@ impl<'a> SceneBuilder<'a> {
|
|||
ExternalScrollId(0, iframe_pipeline_id),
|
||||
iframe_pipeline_id,
|
||||
&iframe_rect,
|
||||
&bounds.size,
|
||||
&bounds.size(),
|
||||
ScrollSensitivity::ScriptAndInputEvents,
|
||||
ScrollFrameKind::PipelineRoot {
|
||||
is_root_pipeline,
|
||||
|
@ -976,7 +976,7 @@ impl<'a> SceneBuilder<'a> {
|
|||
LayoutVector2D::zero(),
|
||||
);
|
||||
|
||||
Some((bounds.size, pipeline.display_list.iter()))
|
||||
Some((bounds.size(), pipeline.display_list.iter()))
|
||||
}
|
||||
|
||||
fn get_space(
|
||||
|
@ -1050,7 +1050,7 @@ impl<'a> SceneBuilder<'a> {
|
|||
target_spatial_node,
|
||||
&self.spatial_tree
|
||||
);
|
||||
self.snap_to_device.snap_rect(&rect.to_box2d()).to_rect()
|
||||
self.snap_to_device.snap_rect(&rect)
|
||||
}
|
||||
|
||||
fn build_item<'b>(
|
||||
|
@ -1071,7 +1071,7 @@ impl<'a> SceneBuilder<'a> {
|
|||
spatial_node_index,
|
||||
clip_chain_id,
|
||||
&layout,
|
||||
layout.rect.size,
|
||||
layout.rect.size(),
|
||||
LayoutSize::zero(),
|
||||
info.image_key,
|
||||
info.image_rendering,
|
||||
|
@ -1258,7 +1258,7 @@ impl<'a> SceneBuilder<'a> {
|
|||
end,
|
||||
stops.to_vec(),
|
||||
ExtendMode::Clamp,
|
||||
rect.size,
|
||||
rect.size(),
|
||||
LayoutSize::zero(),
|
||||
None,
|
||||
) {
|
||||
|
@ -2396,7 +2396,7 @@ impl<'a> SceneBuilder<'a> {
|
|||
);
|
||||
|
||||
let viewport_rect = self.snap_rect(
|
||||
&LayoutRect::new(LayoutPoint::zero(), *viewport_size),
|
||||
&LayoutRect::from_size(*viewport_size),
|
||||
spatial_node_index,
|
||||
);
|
||||
|
||||
|
@ -2406,7 +2406,7 @@ impl<'a> SceneBuilder<'a> {
|
|||
ExternalScrollId(0, pipeline_id),
|
||||
pipeline_id,
|
||||
&viewport_rect,
|
||||
&viewport_rect.size,
|
||||
&viewport_rect.size(),
|
||||
ScrollSensitivity::ScriptAndInputEvents,
|
||||
ScrollFrameKind::PipelineRoot {
|
||||
is_root_pipeline: true,
|
||||
|
@ -2968,7 +2968,7 @@ impl<'a> SceneBuilder<'a> {
|
|||
let mut info = info.clone();
|
||||
|
||||
let size = get_line_decoration_size(
|
||||
&info.rect.size,
|
||||
&info.rect.size(),
|
||||
orientation,
|
||||
style,
|
||||
wavy_line_thickness,
|
||||
|
@ -2981,19 +2981,19 @@ impl<'a> SceneBuilder<'a> {
|
|||
let clip_size = match orientation {
|
||||
LineOrientation::Horizontal => {
|
||||
LayoutSize::new(
|
||||
size.width * (info.rect.size.width / size.width).floor(),
|
||||
info.rect.size.height,
|
||||
size.width * (info.rect.width() / size.width).floor(),
|
||||
info.rect.height(),
|
||||
)
|
||||
}
|
||||
LineOrientation::Vertical => {
|
||||
LayoutSize::new(
|
||||
info.rect.size.width,
|
||||
size.height * (info.rect.size.height / size.height).floor(),
|
||||
info.rect.width(),
|
||||
size.height * (info.rect.height() / size.height).floor(),
|
||||
)
|
||||
}
|
||||
};
|
||||
let clip_rect = LayoutRect::new(
|
||||
info.rect.origin,
|
||||
let clip_rect = LayoutRect::from_origin_and_size(
|
||||
info.rect.min,
|
||||
clip_size,
|
||||
);
|
||||
info.clip_rect = clip_rect
|
||||
|
@ -3188,8 +3188,8 @@ impl<'a> SceneBuilder<'a> {
|
|||
(start_point, end_point)
|
||||
};
|
||||
|
||||
let is_tiled = prim_rect.size.width > stretch_size.width
|
||||
|| prim_rect.size.height > stretch_size.height;
|
||||
let is_tiled = prim_rect.width() > stretch_size.width
|
||||
|| prim_rect.height() > stretch_size.height;
|
||||
// SWGL has a fast-path that can render gradients faster than it can sample from the
|
||||
// texture cache so we disable caching in this configuration. Cached gradients are
|
||||
// faster on hardware.
|
||||
|
@ -3326,7 +3326,7 @@ impl<'a> SceneBuilder<'a> {
|
|||
// the primitive key, when the common case is that the
|
||||
// hash will match and we won't end up creating a new
|
||||
// primitive template.
|
||||
let prim_offset = prim_info.rect.origin.to_vector() - offset;
|
||||
let prim_offset = prim_info.rect.min.to_vector() - offset;
|
||||
let glyphs = glyph_range
|
||||
.iter()
|
||||
.map(|glyph| {
|
||||
|
@ -4030,13 +4030,13 @@ fn process_repeat_size(
|
|||
// the snapped values).
|
||||
const EPSILON: f32 = 0.001;
|
||||
LayoutSize::new(
|
||||
if repeat_size.width.approx_eq_eps(&unsnapped_rect.size.width, &EPSILON) {
|
||||
snapped_rect.size.width
|
||||
if repeat_size.width.approx_eq_eps(&unsnapped_rect.width(), &EPSILON) {
|
||||
snapped_rect.width()
|
||||
} else {
|
||||
repeat_size.width
|
||||
},
|
||||
if repeat_size.height.approx_eq_eps(&unsnapped_rect.size.height, &EPSILON) {
|
||||
snapped_rect.size.height
|
||||
if repeat_size.height.approx_eq_eps(&unsnapped_rect.height(), &EPSILON) {
|
||||
snapped_rect.height()
|
||||
} else {
|
||||
repeat_size.height
|
||||
},
|
||||
|
|
|
@ -311,46 +311,46 @@ impl SegmentBuilder {
|
|||
return;
|
||||
}
|
||||
|
||||
debug_assert!(outer_rect.contains_rect(&inner_rect));
|
||||
debug_assert!(outer_rect.contains_box(&inner_rect));
|
||||
|
||||
let p0 = outer_rect.origin;
|
||||
let p1 = inner_rect.origin;
|
||||
let p2 = inner_rect.bottom_right();
|
||||
let p3 = outer_rect.bottom_right();
|
||||
let p0 = outer_rect.min;
|
||||
let p1 = inner_rect.min;
|
||||
let p2 = inner_rect.max;
|
||||
let p3 = outer_rect.max;
|
||||
|
||||
let segments = &[
|
||||
LayoutRect::new(
|
||||
LayoutPoint::new(p0.x, p0.y),
|
||||
LayoutSize::new(p1.x - p0.x, p1.y - p0.y),
|
||||
),
|
||||
LayoutRect::new(
|
||||
LayoutPoint::new(p2.x, p0.y),
|
||||
LayoutSize::new(p3.x - p2.x, p1.y - p0.y),
|
||||
),
|
||||
LayoutRect::new(
|
||||
LayoutPoint::new(p2.x, p2.y),
|
||||
LayoutSize::new(p3.x - p2.x, p3.y - p2.y),
|
||||
),
|
||||
LayoutRect::new(
|
||||
LayoutPoint::new(p0.x, p2.y),
|
||||
LayoutSize::new(p1.x - p0.x, p3.y - p2.y),
|
||||
),
|
||||
LayoutRect::new(
|
||||
LayoutPoint::new(p1.x, p0.y),
|
||||
LayoutSize::new(p2.x - p1.x, p1.y - p0.y),
|
||||
),
|
||||
LayoutRect::new(
|
||||
LayoutPoint::new(p2.x, p1.y),
|
||||
LayoutSize::new(p3.x - p2.x, p2.y - p1.y),
|
||||
),
|
||||
LayoutRect::new(
|
||||
LayoutPoint::new(p1.x, p2.y),
|
||||
LayoutSize::new(p2.x - p1.x, p3.y - p2.y),
|
||||
),
|
||||
LayoutRect::new(
|
||||
LayoutPoint::new(p0.x, p1.y),
|
||||
LayoutSize::new(p1.x - p0.x, p2.y - p1.y),
|
||||
),
|
||||
LayoutRect {
|
||||
min: LayoutPoint::new(p0.x, p0.y),
|
||||
max: LayoutPoint::new(p1.x, p1.y),
|
||||
},
|
||||
LayoutRect {
|
||||
min: LayoutPoint::new(p2.x, p0.y),
|
||||
max: LayoutPoint::new(p3.x, p1.y),
|
||||
},
|
||||
LayoutRect {
|
||||
min: LayoutPoint::new(p2.x, p2.y),
|
||||
max: LayoutPoint::new(p3.x, p3.y),
|
||||
},
|
||||
LayoutRect {
|
||||
min: LayoutPoint::new(p0.x, p2.y),
|
||||
max: LayoutPoint::new(p1.x, p3.y),
|
||||
},
|
||||
LayoutRect {
|
||||
min: LayoutPoint::new(p1.x, p0.y),
|
||||
max: LayoutPoint::new(p2.x, p1.y),
|
||||
},
|
||||
LayoutRect {
|
||||
min: LayoutPoint::new(p2.x, p1.y),
|
||||
max: LayoutPoint::new(p3.x, p2.y),
|
||||
},
|
||||
LayoutRect {
|
||||
min: LayoutPoint::new(p1.x, p2.y),
|
||||
max: LayoutPoint::new(p2.x, p3.y),
|
||||
},
|
||||
LayoutRect {
|
||||
min: LayoutPoint::new(p0.x, p1.y),
|
||||
max: LayoutPoint::new(p1.x, p2.y),
|
||||
},
|
||||
];
|
||||
|
||||
self.items.reserve(segments.len() + 1);
|
||||
|
@ -397,30 +397,30 @@ impl SegmentBuilder {
|
|||
// is a clip item for each corner, inner and edge region.
|
||||
match extract_inner_rect_safe(&rect, &radius) {
|
||||
Some(inner) => {
|
||||
let p0 = rect.origin;
|
||||
let p1 = inner.origin;
|
||||
let p2 = inner.bottom_right();
|
||||
let p3 = rect.bottom_right();
|
||||
let p0 = rect.min;
|
||||
let p1 = inner.min;
|
||||
let p2 = inner.max;
|
||||
let p3 = rect.max;
|
||||
|
||||
self.items.reserve(9);
|
||||
|
||||
let corner_segments = &[
|
||||
LayoutRect::new(
|
||||
LayoutPoint::new(p0.x, p0.y),
|
||||
LayoutSize::new(p1.x - p0.x, p1.y - p0.y),
|
||||
),
|
||||
LayoutRect::new(
|
||||
LayoutPoint::new(p2.x, p0.y),
|
||||
LayoutSize::new(p3.x - p2.x, p1.y - p0.y),
|
||||
),
|
||||
LayoutRect::new(
|
||||
LayoutPoint::new(p2.x, p2.y),
|
||||
LayoutSize::new(p3.x - p2.x, p3.y - p2.y),
|
||||
),
|
||||
LayoutRect::new(
|
||||
LayoutPoint::new(p0.x, p2.y),
|
||||
LayoutSize::new(p1.x - p0.x, p3.y - p2.y),
|
||||
),
|
||||
LayoutRect {
|
||||
min: LayoutPoint::new(p0.x, p0.y),
|
||||
max: LayoutPoint::new(p1.x, p1.y),
|
||||
},
|
||||
LayoutRect {
|
||||
min: LayoutPoint::new(p2.x, p0.y),
|
||||
max: LayoutPoint::new(p3.x, p1.y),
|
||||
},
|
||||
LayoutRect {
|
||||
min: LayoutPoint::new(p2.x, p2.y),
|
||||
max: LayoutPoint::new(p3.x, p3.y),
|
||||
},
|
||||
LayoutRect {
|
||||
min: LayoutPoint::new(p0.x, p2.y),
|
||||
max: LayoutPoint::new(p1.x, p3.y),
|
||||
},
|
||||
];
|
||||
|
||||
for segment in corner_segments {
|
||||
|
@ -432,26 +432,26 @@ impl SegmentBuilder {
|
|||
}
|
||||
|
||||
let other_segments = &[
|
||||
LayoutRect::new(
|
||||
LayoutPoint::new(p1.x, p0.y),
|
||||
LayoutSize::new(p2.x - p1.x, p1.y - p0.y),
|
||||
),
|
||||
LayoutRect::new(
|
||||
LayoutPoint::new(p2.x, p1.y),
|
||||
LayoutSize::new(p3.x - p2.x, p2.y - p1.y),
|
||||
),
|
||||
LayoutRect::new(
|
||||
LayoutPoint::new(p1.x, p2.y),
|
||||
LayoutSize::new(p2.x - p1.x, p3.y - p2.y),
|
||||
),
|
||||
LayoutRect::new(
|
||||
LayoutPoint::new(p0.x, p1.y),
|
||||
LayoutSize::new(p1.x - p0.x, p2.y - p1.y),
|
||||
),
|
||||
LayoutRect::new(
|
||||
LayoutPoint::new(p1.x, p1.y),
|
||||
LayoutSize::new(p2.x - p1.x, p2.y - p1.y),
|
||||
),
|
||||
LayoutRect {
|
||||
min: LayoutPoint::new(p1.x, p0.y),
|
||||
max: LayoutPoint::new(p2.x, p1.y),
|
||||
},
|
||||
LayoutRect {
|
||||
min: LayoutPoint::new(p2.x, p1.y),
|
||||
max: LayoutPoint::new(p3.x, p2.y),
|
||||
},
|
||||
LayoutRect {
|
||||
min: LayoutPoint::new(p1.x, p2.y),
|
||||
max: LayoutPoint::new(p2.x, p3.y),
|
||||
},
|
||||
LayoutRect {
|
||||
min: LayoutPoint::new(p0.x, p1.y),
|
||||
max: LayoutPoint::new(p1.x, p2.y),
|
||||
},
|
||||
LayoutRect {
|
||||
min: LayoutPoint::new(p1.x, p1.y),
|
||||
max: LayoutPoint::new(p2.x, p2.y),
|
||||
},
|
||||
];
|
||||
|
||||
for segment in other_segments {
|
||||
|
@ -524,8 +524,8 @@ impl SegmentBuilder {
|
|||
let mut y_events : SmallVec<[Event; 4]> = SmallVec::new();
|
||||
|
||||
for (item_index, item) in self.items.iter().enumerate() {
|
||||
let p0 = item.rect.origin;
|
||||
let p1 = item.rect.bottom_right();
|
||||
let p0 = item.rect.min;
|
||||
let p1 = item.rect.max;
|
||||
|
||||
x_events.push(Event::begin(p0.x, item_index));
|
||||
x_events.push(Event::end(p1.x, item_index));
|
||||
|
@ -535,24 +535,24 @@ impl SegmentBuilder {
|
|||
|
||||
// Add the region events, if provided.
|
||||
if let Some(inner_rect) = self.inner_rect {
|
||||
x_events.push(Event::region(inner_rect.origin.x));
|
||||
x_events.push(Event::region(inner_rect.origin.x + inner_rect.size.width));
|
||||
x_events.push(Event::region(inner_rect.min.x));
|
||||
x_events.push(Event::region(inner_rect.max.x));
|
||||
|
||||
y_events.push(Event::region(inner_rect.origin.y));
|
||||
y_events.push(Event::region(inner_rect.origin.y + inner_rect.size.height));
|
||||
y_events.push(Event::region(inner_rect.min.y));
|
||||
y_events.push(Event::region(inner_rect.max.y));
|
||||
}
|
||||
|
||||
// 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 = LayoutPointAu::new(
|
||||
Au::from_f32_px(bounding_rect.origin.x),
|
||||
Au::from_f32_px(bounding_rect.origin.y),
|
||||
Au::from_f32_px(bounding_rect.min.x),
|
||||
Au::from_f32_px(bounding_rect.min.y),
|
||||
);
|
||||
|
||||
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),
|
||||
Au::from_f32_px(bounding_rect.max.x),
|
||||
Au::from_f32_px(bounding_rect.max.y),
|
||||
);
|
||||
|
||||
// Sort the events in ascending order.
|
||||
|
@ -683,16 +683,16 @@ fn emit_segment_if_needed(
|
|||
}
|
||||
}
|
||||
|
||||
let segment_rect = LayoutRect::new(
|
||||
LayoutPoint::new(
|
||||
let segment_rect = LayoutRect {
|
||||
min: LayoutPoint::new(
|
||||
x0.to_f32_px(),
|
||||
y0.to_f32_px(),
|
||||
),
|
||||
LayoutSize::new(
|
||||
(x1 - x0).to_f32_px(),
|
||||
(y1 - y0).to_f32_px(),
|
||||
max: LayoutPoint::new(
|
||||
x1.to_f32_px(),
|
||||
y1.to_f32_px(),
|
||||
),
|
||||
);
|
||||
};
|
||||
|
||||
Some(Segment {
|
||||
rect: segment_rect,
|
||||
|
@ -706,15 +706,15 @@ fn emit_segment_if_needed(
|
|||
#[cfg(test)]
|
||||
mod test {
|
||||
use api::{BorderRadius, ClipMode};
|
||||
use api::units::{LayoutPoint, LayoutRect, LayoutSize};
|
||||
use api::units::{LayoutPoint, LayoutRect};
|
||||
use super::{Segment, SegmentBuilder, EdgeAaSegmentMask};
|
||||
use std::cmp;
|
||||
|
||||
fn rect(x0: f32, y0: f32, x1: f32, y1: f32) -> LayoutRect {
|
||||
LayoutRect::new(
|
||||
LayoutPoint::new(x0, y0),
|
||||
LayoutSize::new(x1-x0, y1-y0),
|
||||
)
|
||||
LayoutRect {
|
||||
min: LayoutPoint::new(x0, y0),
|
||||
max: LayoutPoint::new(x1, y1),
|
||||
}
|
||||
}
|
||||
|
||||
fn seg(
|
||||
|
@ -739,10 +739,10 @@ mod test {
|
|||
edge_flags: Option<EdgeAaSegmentMask>,
|
||||
) -> Segment {
|
||||
Segment {
|
||||
rect: LayoutRect::new(
|
||||
LayoutPoint::new(x0, y0),
|
||||
LayoutSize::new(x1-x0, y1-y0),
|
||||
),
|
||||
rect: LayoutRect {
|
||||
min: LayoutPoint::new(x0, y0),
|
||||
max: LayoutPoint::new(x1, y1),
|
||||
},
|
||||
has_mask,
|
||||
edge_flags: edge_flags.unwrap_or(EdgeAaSegmentMask::empty()),
|
||||
region_x,
|
||||
|
@ -755,9 +755,9 @@ mod test {
|
|||
let r1 = &s1.rect;
|
||||
|
||||
(
|
||||
(r0.origin.x, r0.origin.y, r0.size.width, r0.size.height)
|
||||
(r0.min.x, r0.min.y, r0.max.x, r0.max.y)
|
||||
).partial_cmp(&
|
||||
(r1.origin.x, r1.origin.y, r1.size.width, r1.size.height)
|
||||
(r1.min.x, r1.min.y, r1.max.x, r1.max.y)
|
||||
).unwrap()
|
||||
}
|
||||
|
||||
|
|
|
@ -166,8 +166,8 @@ impl SpatialNode {
|
|||
*frame_rect,
|
||||
scroll_sensitivity,
|
||||
LayoutSize::new(
|
||||
(content_size.width - frame_rect.size.width).max(0.0),
|
||||
(content_size.height - frame_rect.size.height).max(0.0)
|
||||
(content_size.width - frame_rect.width()).max(0.0),
|
||||
(content_size.height - frame_rect.height()).max(0.0)
|
||||
),
|
||||
external_id,
|
||||
frame_kind,
|
||||
|
@ -501,13 +501,13 @@ impl SpatialNode {
|
|||
|
||||
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 {
|
||||
let top_viewport_edge = viewport_rect.min.y + margin;
|
||||
if sticky_rect.min.y < top_viewport_edge {
|
||||
// If the sticky rect is positioned above the top edge of the viewport (plus margin)
|
||||
// we move it down so that it is fully inside the viewport.
|
||||
sticky_offset.y = top_viewport_edge - sticky_rect.min_y();
|
||||
sticky_offset.y = top_viewport_edge - sticky_rect.min.y;
|
||||
} else if info.previously_applied_offset.y > 0.0 &&
|
||||
sticky_rect.min_y() > top_viewport_edge {
|
||||
sticky_rect.min.y > top_viewport_edge {
|
||||
// However, if the sticky rect is positioned *below* the top edge of the viewport
|
||||
// and there is already some offset applied to the sticky rect's position, then
|
||||
// we need to move it up so that it remains at the correct position. This
|
||||
|
@ -515,7 +515,7 @@ impl SpatialNode {
|
|||
// offset that was already applied. We limit the reduction so that it can, at most,
|
||||
// cancel out the already-applied offset, but should never end up adjusting the
|
||||
// position the other way.
|
||||
sticky_offset.y = top_viewport_edge - sticky_rect.min_y();
|
||||
sticky_offset.y = top_viewport_edge - sticky_rect.min.y;
|
||||
sticky_offset.y = sticky_offset.y.max(-info.previously_applied_offset.y);
|
||||
}
|
||||
}
|
||||
|
@ -532,18 +532,19 @@ impl SpatialNode {
|
|||
// both top and bottom sticky margins. We adjust the item's rect
|
||||
// by the top-sticky offset, and then combine any offset from
|
||||
// the bottom-sticky calculation into sticky_offset below.
|
||||
sticky_rect.origin.y += sticky_offset.y;
|
||||
sticky_rect.min.y += sticky_offset.y;
|
||||
sticky_rect.max.y += sticky_offset.y;
|
||||
|
||||
// Same as the above case, but inverted for bottom-sticky items. Here
|
||||
// we adjust items upwards, resulting in a negative sticky_offset.y,
|
||||
// or reduce the already-present upward adjustment, resulting in a positive
|
||||
// sticky_offset.y.
|
||||
let bottom_viewport_edge = viewport_rect.max_y() - margin;
|
||||
if sticky_rect.max_y() > bottom_viewport_edge {
|
||||
sticky_offset.y += bottom_viewport_edge - sticky_rect.max_y();
|
||||
let bottom_viewport_edge = viewport_rect.max.y - margin;
|
||||
if sticky_rect.max.y > bottom_viewport_edge {
|
||||
sticky_offset.y += bottom_viewport_edge - sticky_rect.max.y;
|
||||
} else if info.previously_applied_offset.y < 0.0 &&
|
||||
sticky_rect.max_y() < bottom_viewport_edge {
|
||||
sticky_offset.y += bottom_viewport_edge - sticky_rect.max_y();
|
||||
sticky_rect.max.y < bottom_viewport_edge {
|
||||
sticky_offset.y += bottom_viewport_edge - sticky_rect.max.y;
|
||||
sticky_offset.y = sticky_offset.y.min(-info.previously_applied_offset.y);
|
||||
}
|
||||
}
|
||||
|
@ -551,25 +552,26 @@ impl SpatialNode {
|
|||
|
||||
// Same as above, but for the x-axis.
|
||||
if let Some(margin) = info.margins.left {
|
||||
let left_viewport_edge = viewport_rect.min_x() + margin;
|
||||
if sticky_rect.min_x() < left_viewport_edge {
|
||||
sticky_offset.x = left_viewport_edge - sticky_rect.min_x();
|
||||
let left_viewport_edge = viewport_rect.min.x + margin;
|
||||
if sticky_rect.min.x < left_viewport_edge {
|
||||
sticky_offset.x = left_viewport_edge - sticky_rect.min.x;
|
||||
} else if info.previously_applied_offset.x > 0.0 &&
|
||||
sticky_rect.min_x() > left_viewport_edge {
|
||||
sticky_offset.x = left_viewport_edge - sticky_rect.min_x();
|
||||
sticky_rect.min.x > left_viewport_edge {
|
||||
sticky_offset.x = left_viewport_edge - sticky_rect.min.x;
|
||||
sticky_offset.x = sticky_offset.x.max(-info.previously_applied_offset.x);
|
||||
}
|
||||
}
|
||||
|
||||
if sticky_offset.x + info.previously_applied_offset.x <= 0.0 {
|
||||
if let Some(margin) = info.margins.right {
|
||||
sticky_rect.origin.x += sticky_offset.x;
|
||||
let right_viewport_edge = viewport_rect.max_x() - margin;
|
||||
if sticky_rect.max_x() > right_viewport_edge {
|
||||
sticky_offset.x += right_viewport_edge - sticky_rect.max_x();
|
||||
sticky_rect.min.x += sticky_offset.x;
|
||||
sticky_rect.max.x += sticky_offset.x;
|
||||
let right_viewport_edge = viewport_rect.max.x - margin;
|
||||
if sticky_rect.max.x > right_viewport_edge {
|
||||
sticky_offset.x += right_viewport_edge - sticky_rect.max.x;
|
||||
} else if info.previously_applied_offset.x < 0.0 &&
|
||||
sticky_rect.max_x() < right_viewport_edge {
|
||||
sticky_offset.x += right_viewport_edge - sticky_rect.max_x();
|
||||
sticky_rect.max.x < right_viewport_edge {
|
||||
sticky_offset.x += right_viewport_edge - sticky_rect.max.x;
|
||||
sticky_offset.x = sticky_offset.x.min(-info.previously_applied_offset.x);
|
||||
}
|
||||
}
|
||||
|
@ -945,7 +947,7 @@ fn test_cst_perspective_relative_scroll() {
|
|||
root,
|
||||
ext_scroll_id,
|
||||
pipeline_id,
|
||||
&LayoutRect::new(LayoutPoint::zero(), LayoutSize::new(100.0, 100.0)),
|
||||
&LayoutRect::from_size(LayoutSize::new(100.0, 100.0)),
|
||||
&LayoutSize::new(100.0, 500.0),
|
||||
ScrollSensitivity::Script,
|
||||
ScrollFrameKind::Explicit,
|
||||
|
@ -956,7 +958,7 @@ fn test_cst_perspective_relative_scroll() {
|
|||
scroll_frame_1,
|
||||
ExternalScrollId(2, pipeline_id),
|
||||
pipeline_id,
|
||||
&LayoutRect::new(LayoutPoint::zero(), LayoutSize::new(100.0, 100.0)),
|
||||
&LayoutRect::from_size(LayoutSize::new(100.0, 100.0)),
|
||||
&LayoutSize::new(100.0, 500.0),
|
||||
ScrollSensitivity::Script,
|
||||
ScrollFrameKind::Explicit,
|
||||
|
|
|
@ -774,8 +774,8 @@ impl SpatialTree {
|
|||
// local-space, but makes for a reasonable estimate. The value
|
||||
// is arbitrary, but is generally small enough to ignore things
|
||||
// like scroll roots around text input elements.
|
||||
if info.viewport_rect.size.width > MIN_SCROLL_ROOT_SIZE &&
|
||||
info.viewport_rect.size.height > MIN_SCROLL_ROOT_SIZE {
|
||||
if info.viewport_rect.width() > MIN_SCROLL_ROOT_SIZE &&
|
||||
info.viewport_rect.height() > MIN_SCROLL_ROOT_SIZE {
|
||||
// If we've found a root that is scrollable, and a reasonable
|
||||
// size, select that as the current root for this node
|
||||
real_scroll_root = node_index;
|
||||
|
|
|
@ -635,23 +635,23 @@ pub fn pack_as_float(value: u32) -> f32 {
|
|||
|
||||
#[inline]
|
||||
fn extract_inner_rect_impl<U>(
|
||||
rect: &Rect<f32, U>,
|
||||
rect: &Box2D<f32, U>,
|
||||
radii: &BorderRadius,
|
||||
k: f32,
|
||||
) -> Option<Rect<f32, U>> {
|
||||
) -> Option<Box2D<f32, U>> {
|
||||
// `k` defines how much border is taken into account
|
||||
// We enforce the offsets to be rounded to pixel boundaries
|
||||
// by `ceil`-ing and `floor`-ing them
|
||||
|
||||
let xl = (k * radii.top_left.width.max(radii.bottom_left.width)).ceil();
|
||||
let xr = (rect.size.width - k * radii.top_right.width.max(radii.bottom_right.width)).floor();
|
||||
let xr = (rect.width() - k * radii.top_right.width.max(radii.bottom_right.width)).floor();
|
||||
let yt = (k * radii.top_left.height.max(radii.top_right.height)).ceil();
|
||||
let yb =
|
||||
(rect.size.height - k * radii.bottom_left.height.max(radii.bottom_right.height)).floor();
|
||||
(rect.height() - k * radii.bottom_left.height.max(radii.bottom_right.height)).floor();
|
||||
|
||||
if xl <= xr && yt <= yb {
|
||||
Some(Rect::new(
|
||||
Point2D::new(rect.origin.x + xl, rect.origin.y + yt),
|
||||
Some(Box2D::from_origin_and_size(
|
||||
Point2D::new(rect.min.x + xl, rect.min.y + yt),
|
||||
Size2D::new(xr - xl, yb - yt),
|
||||
))
|
||||
} else {
|
||||
|
@ -662,9 +662,9 @@ fn extract_inner_rect_impl<U>(
|
|||
/// Return an aligned rectangle that is inside the clip region and doesn't intersect
|
||||
/// any of the bounding rectangles of the rounded corners.
|
||||
pub fn extract_inner_rect_safe<U>(
|
||||
rect: &Rect<f32, U>,
|
||||
rect: &Box2D<f32, U>,
|
||||
radii: &BorderRadius,
|
||||
) -> Option<Rect<f32, U>> {
|
||||
) -> Option<Box2D<f32, U>> {
|
||||
// value of `k==1.0` is used for extraction of the corner rectangles
|
||||
// see `SEGMENT_CORNER_*` in `clip_shared.glsl`
|
||||
extract_inner_rect_impl(rect, radii, 1.0)
|
||||
|
@ -676,7 +676,7 @@ use euclid::vec3;
|
|||
#[cfg(test)]
|
||||
pub mod test {
|
||||
use super::*;
|
||||
use euclid::default::{Point2D, Rect, Size2D, Transform3D};
|
||||
use euclid::default::{Point2D, Size2D, Transform3D};
|
||||
use euclid::{Angle, approxeq::ApproxEq};
|
||||
use std::f32::consts::PI;
|
||||
use crate::clip::{is_left_of_line, polygon_contains_point};
|
||||
|
@ -702,10 +702,10 @@ pub mod test {
|
|||
0.766044438, 0.642787635, 0.0, 0.0,
|
||||
1137.10986, 113.71286, 402.0, 0.748749971,
|
||||
);
|
||||
let r = Rect::new(Point2D::zero(), Size2D::new(804.0, 804.0));
|
||||
let r = Box2D::from_size(Size2D::new(804.0, 804.0));
|
||||
{
|
||||
let points = &[
|
||||
r.origin,
|
||||
r.top_left(),
|
||||
r.top_right(),
|
||||
r.bottom_left(),
|
||||
r.bottom_right(),
|
||||
|
@ -727,14 +727,14 @@ pub mod test {
|
|||
}
|
||||
}
|
||||
// project
|
||||
let rp = project_rect(&m, &r.to_box2d(), &Box2D::from_size(Size2D::new(1000.0, 1000.0))).unwrap();
|
||||
let rp = project_rect(&m, &r, &Box2D::from_size(Size2D::new(1000.0, 1000.0))).unwrap();
|
||||
println!("Projected {:?}", rp);
|
||||
// one of the points ends up in the negative hemisphere
|
||||
assert_eq!(m.inverse_project(&rp.min), None);
|
||||
// inverse
|
||||
if let Some(ri) = m.inverse_rect_footprint(&rp) {
|
||||
// inverse footprint should be larger, since it doesn't know the original Z
|
||||
assert!(ri.contains_box(&r.to_box2d()), "Inverse {:?}", ri);
|
||||
assert!(ri.contains_box(&r), "Inverse {:?}", ri);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -758,7 +758,7 @@ pub mod test {
|
|||
let xf_rect = project_rect(
|
||||
&xref,
|
||||
&local_rect,
|
||||
&LayoutRect::max_rect().to_box2d(),
|
||||
&LayoutRect::max_rect(),
|
||||
).unwrap();
|
||||
|
||||
assert!(mapped_rect.min.x.approx_eq(&xf_rect.min.x));
|
||||
|
@ -908,8 +908,7 @@ pub mod test {
|
|||
|
||||
// We define a rect that provides a bounding clip area of
|
||||
// the polygon.
|
||||
let rect = LayoutRect::new(LayoutPoint::new(0.0, 0.0),
|
||||
LayoutSize::new(10.0, 10.0));
|
||||
let rect = LayoutRect::from_size(LayoutSize::new(10.0, 10.0));
|
||||
|
||||
// And we'll test three points of interest.
|
||||
let p_inside_once = LayoutPoint::new(5.0, 3.0);
|
||||
|
@ -1568,99 +1567,98 @@ pub fn conservative_union_rect<U>(r1: &Box2D<f32, U>, r2: &Box2D<f32, U>) -> Box
|
|||
|
||||
#[test]
|
||||
fn test_conservative_union_rect() {
|
||||
use euclid::size2;
|
||||
// Adjacent, x axis
|
||||
let r = conservative_union_rect(
|
||||
&LayoutRect { origin: point2(1.0, 2.0), size: size2(3.0, 4.0) }.to_box2d(),
|
||||
&LayoutRect { origin: point2(4.0, 2.0), size: size2(5.0, 4.0) }.to_box2d(),
|
||||
&LayoutRect { min: point2(1.0, 2.0), max: point2(4.0, 6.0) },
|
||||
&LayoutRect { min: point2(4.0, 2.0), max: point2(9.0, 6.0) },
|
||||
);
|
||||
assert_eq!(r, LayoutRect { origin: point2(1.0, 2.0), size: size2(8.0, 4.0) }.to_box2d());
|
||||
assert_eq!(r, LayoutRect { min: point2(1.0, 2.0), max: point2(9.0, 6.0) });
|
||||
|
||||
let r = conservative_union_rect(
|
||||
&LayoutRect { origin: point2(4.0, 2.0), size: size2(5.0, 4.0) }.to_box2d(),
|
||||
&LayoutRect { origin: point2(1.0, 2.0), size: size2(3.0, 4.0) }.to_box2d(),
|
||||
&LayoutRect { min: point2(4.0, 2.0), max: point2(9.0, 6.0) },
|
||||
&LayoutRect { min: point2(1.0, 2.0), max: point2(4.0, 6.0) },
|
||||
);
|
||||
assert_eq!(r, LayoutRect { origin: point2(1.0, 2.0), size: size2(8.0, 4.0) }.to_box2d());
|
||||
assert_eq!(r, LayoutRect { min: point2(1.0, 2.0), max: point2(9.0, 6.0) });
|
||||
|
||||
// Averlapping adjacent, x axis
|
||||
let r = conservative_union_rect(
|
||||
&LayoutRect { origin: point2(1.0, 2.0), size: size2(3.0, 4.0) }.to_box2d(),
|
||||
&LayoutRect { origin: point2(3.0, 2.0), size: size2(5.0, 4.0) }.to_box2d(),
|
||||
&LayoutRect { min: point2(1.0, 2.0), max: point2(4.0, 6.0) },
|
||||
&LayoutRect { min: point2(3.0, 2.0), max: point2(8.0, 6.0) },
|
||||
);
|
||||
assert_eq!(r, LayoutRect { origin: point2(1.0, 2.0), size: size2(7.0, 4.0) }.to_box2d());
|
||||
assert_eq!(r, LayoutRect { min: point2(1.0, 2.0), max: point2(8.0, 6.0) });
|
||||
|
||||
let r = conservative_union_rect(
|
||||
&LayoutRect { origin: point2(5.0, 2.0), size: size2(3.0, 4.0) }.to_box2d(),
|
||||
&LayoutRect { origin: point2(1.0, 2.0), size: size2(5.0, 4.0) }.to_box2d(),
|
||||
&LayoutRect { min: point2(5.0, 2.0), max: point2(8.0, 6.0) },
|
||||
&LayoutRect { min: point2(1.0, 2.0), max: point2(6.0, 6.0) },
|
||||
);
|
||||
assert_eq!(r, LayoutRect { origin: point2(1.0, 2.0), size: size2(7.0, 4.0) }.to_box2d());
|
||||
assert_eq!(r, LayoutRect { min: point2(1.0, 2.0), max: point2(8.0, 6.0) });
|
||||
|
||||
// Adjacent but not touching, x axis
|
||||
let r = conservative_union_rect(
|
||||
&LayoutRect { origin: point2(1.0, 2.0), size: size2(3.0, 4.0) }.to_box2d(),
|
||||
&LayoutRect { origin: point2(6.0, 2.0), size: size2(5.0, 4.0) }.to_box2d(),
|
||||
&LayoutRect { min: point2(1.0, 2.0), max: point2(4.0, 6.0) },
|
||||
&LayoutRect { min: point2(6.0, 2.0), max: point2(11.0, 6.0) },
|
||||
);
|
||||
assert_eq!(r, LayoutRect { origin: point2(6.0, 2.0), size: size2(5.0, 4.0) }.to_box2d());
|
||||
assert_eq!(r, LayoutRect { min: point2(6.0, 2.0), max: point2(11.0, 6.0) });
|
||||
|
||||
let r = conservative_union_rect(
|
||||
&LayoutRect { origin: point2(1.0, 2.0), size: size2(3.0, 4.0) }.to_box2d(),
|
||||
&LayoutRect { origin: point2(-6.0, 2.0), size: size2(1.0, 4.0) }.to_box2d(),
|
||||
&LayoutRect { min: point2(1.0, 2.0), max: point2(4.0, 6.0) },
|
||||
&LayoutRect { min: point2(-6.0, 2.0), max: point2(-5.0, 6.0) },
|
||||
);
|
||||
assert_eq!(r, LayoutRect { origin: point2(1.0, 2.0), size: size2(3.0, 4.0) }.to_box2d());
|
||||
assert_eq!(r, LayoutRect { min: point2(1.0, 2.0), max: point2(4.0, 6.0) });
|
||||
|
||||
|
||||
// Adjacent, y axis
|
||||
let r = conservative_union_rect(
|
||||
&LayoutRect { origin: point2(1.0, 2.0), size: size2(3.0, 4.0) }.to_box2d(),
|
||||
&LayoutRect { origin: point2(1.0, 6.0), size: size2(3.0, 4.0) }.to_box2d(),
|
||||
&LayoutRect { min: point2(1.0, 2.0), max: point2(4.0, 6.0) },
|
||||
&LayoutRect { min: point2(1.0, 6.0), max: point2(4.0, 10.0) },
|
||||
);
|
||||
assert_eq!(r, LayoutRect { origin: point2(1.0, 2.0), size: size2(3.0, 8.0) }.to_box2d());
|
||||
assert_eq!(r, LayoutRect { min: point2(1.0, 2.0), max: point2(4.0, 10.0) });
|
||||
|
||||
let r = conservative_union_rect(
|
||||
&LayoutRect { origin: point2(1.0, 5.0), size: size2(3.0, 4.0) }.to_box2d(),
|
||||
&LayoutRect { origin: point2(1.0, 1.0), size: size2(3.0, 4.0) }.to_box2d(),
|
||||
&LayoutRect { min: point2(1.0, 5.0), max: point2(4.0, 9.0) },
|
||||
&LayoutRect { min: point2(1.0, 1.0), max: point2(4.0, 5.0) },
|
||||
);
|
||||
assert_eq!(r, LayoutRect { origin: point2(1.0, 1.0), size: size2(3.0, 8.0) }.to_box2d());
|
||||
assert_eq!(r, LayoutRect { min: point2(1.0, 1.0), max: point2(4.0, 9.0) });
|
||||
|
||||
// Averlapping adjacent, y axis
|
||||
let r = conservative_union_rect(
|
||||
&LayoutRect { origin: point2(1.0, 2.0), size: size2(3.0, 4.0) }.to_box2d(),
|
||||
&LayoutRect { origin: point2(1.0, 3.0), size: size2(3.0, 4.0) }.to_box2d(),
|
||||
&LayoutRect { min: point2(1.0, 2.0), max: point2(4.0, 6.0) },
|
||||
&LayoutRect { min: point2(1.0, 3.0), max: point2(4.0, 7.0) },
|
||||
);
|
||||
assert_eq!(r, LayoutRect { origin: point2(1.0, 2.0), size: size2(3.0, 5.0) }.to_box2d());
|
||||
assert_eq!(r, LayoutRect { min: point2(1.0, 2.0), max: point2(4.0, 7.0) });
|
||||
|
||||
let r = conservative_union_rect(
|
||||
&LayoutRect { origin: point2(1.0, 4.0), size: size2(3.0, 4.0) }.to_box2d(),
|
||||
&LayoutRect { origin: point2(1.0, 2.0), size: size2(3.0, 4.0) }.to_box2d(),
|
||||
&LayoutRect { min: point2(1.0, 4.0), max: point2(4.0, 8.0) },
|
||||
&LayoutRect { min: point2(1.0, 2.0), max: point2(4.0, 6.0) },
|
||||
);
|
||||
assert_eq!(r, LayoutRect { origin: point2(1.0, 2.0), size: size2(3.0, 6.0) }.to_box2d());
|
||||
assert_eq!(r, LayoutRect { min: point2(1.0, 2.0), max: point2(4.0, 8.0) });
|
||||
|
||||
// Adjacent but not touching, y axis
|
||||
let r = conservative_union_rect(
|
||||
&LayoutRect { origin: point2(1.0, 2.0), size: size2(3.0, 4.0) }.to_box2d(),
|
||||
&LayoutRect { origin: point2(1.0, 10.0), size: size2(3.0, 5.0) }.to_box2d(),
|
||||
&LayoutRect { min: point2(1.0, 2.0), max: point2(4.0, 6.0) },
|
||||
&LayoutRect { min: point2(1.0, 10.0), max: point2(4.0, 15.0) },
|
||||
);
|
||||
assert_eq!(r, LayoutRect { origin: point2(1.0, 10.0), size: size2(3.0, 5.0) }.to_box2d());
|
||||
assert_eq!(r, LayoutRect { min: point2(1.0, 10.0), max: point2(4.0, 15.0) });
|
||||
|
||||
let r = conservative_union_rect(
|
||||
&LayoutRect { origin: point2(1.0, 5.0), size: size2(3.0, 4.0) }.to_box2d(),
|
||||
&LayoutRect { origin: point2(1.0, 0.0), size: size2(3.0, 3.0) }.to_box2d(),
|
||||
&LayoutRect { min: point2(1.0, 5.0), max: point2(4.0, 9.0) },
|
||||
&LayoutRect { min: point2(1.0, 0.0), max: point2(4.0, 3.0) },
|
||||
);
|
||||
assert_eq!(r, LayoutRect { origin: point2(1.0, 5.0), size: size2(3.0, 4.0) }.to_box2d());
|
||||
assert_eq!(r, LayoutRect { min: point2(1.0, 5.0), max: point2(4.0, 9.0) });
|
||||
|
||||
|
||||
// Contained
|
||||
let r = conservative_union_rect(
|
||||
&LayoutRect { origin: point2(1.0, 2.0), size: size2(3.0, 4.0) }.to_box2d(),
|
||||
&LayoutRect { origin: point2(0.0, 1.0), size: size2(10.0, 11.0) }.to_box2d(),
|
||||
&LayoutRect { min: point2(1.0, 2.0), max: point2(4.0, 6.0) },
|
||||
&LayoutRect { min: point2(0.0, 1.0), max: point2(10.0, 12.0) },
|
||||
);
|
||||
assert_eq!(r, LayoutRect { origin: point2(0.0, 1.0), size: size2(10.0, 11.0) }.to_box2d());
|
||||
assert_eq!(r, LayoutRect { min: point2(0.0, 1.0), max: point2(10.0, 12.0) });
|
||||
|
||||
let r = conservative_union_rect(
|
||||
&LayoutRect { origin: point2(0.0, 1.0), size: size2(10.0, 11.0) }.to_box2d(),
|
||||
&LayoutRect { origin: point2(1.0, 2.0), size: size2(3.0, 4.0) }.to_box2d(),
|
||||
&LayoutRect { min: point2(0.0, 1.0), max: point2(10.0, 12.0) },
|
||||
&LayoutRect { min: point2(1.0, 2.0), max: point2(4.0, 6.0) },
|
||||
);
|
||||
assert_eq!(r, LayoutRect { origin: point2(0.0, 1.0), size: size2(10.0, 11.0) }.to_box2d());
|
||||
assert_eq!(r, LayoutRect { min: point2(0.0, 1.0), max: point2(10.0, 12.0) });
|
||||
}
|
||||
|
||||
/// This is inspired by the `weak-table` crate.
|
||||
|
|
|
@ -348,7 +348,7 @@ pub fn update_primitive_visibility(
|
|||
// Pass through pictures are always considered visible in all dirty tiles.
|
||||
prim_instance.vis.state = VisibilityState::PassThrough;
|
||||
} else {
|
||||
if prim_local_rect.size.width <= 0.0 || prim_local_rect.size.height <= 0.0 {
|
||||
if prim_local_rect.width() <= 0.0 || prim_local_rect.height() <= 0.0 {
|
||||
if prim_instance.is_chased() {
|
||||
println!("\tculled for zero local rectangle");
|
||||
}
|
||||
|
@ -435,7 +435,7 @@ pub fn update_primitive_visibility(
|
|||
prim_instance.clip_set.local_clip_rect
|
||||
};
|
||||
|
||||
if prim_instance.vis.combined_local_clip_rect.size.is_empty() {
|
||||
if prim_instance.vis.combined_local_clip_rect.is_empty() {
|
||||
if prim_instance.is_chased() {
|
||||
println!("\tculled for zero local clip rectangle");
|
||||
}
|
||||
|
@ -446,7 +446,7 @@ pub fn update_primitive_visibility(
|
|||
// the area affected by the surface.
|
||||
match prim_instance.vis.combined_local_clip_rect.intersection(&local_rect) {
|
||||
Some(visible_rect) => {
|
||||
if let Some(rect) = map_local_to_surface.map(&visible_rect.to_box2d()) {
|
||||
if let Some(rect) = map_local_to_surface.map(&visible_rect) {
|
||||
surface_rect = surface_rect.union(&rect);
|
||||
}
|
||||
}
|
||||
|
@ -571,7 +571,7 @@ pub fn update_primitive_visibility(
|
|||
|
||||
// Layout space for the picture is picture space from the
|
||||
// perspective of its child primitives.
|
||||
pic.precise_local_rect = surface_rect.to_rect() * Scale::new(1.0);
|
||||
pic.precise_local_rect = surface_rect * Scale::new(1.0);
|
||||
|
||||
// If the precise rect changed since last frame, we need to invalidate
|
||||
// any segments and gpu cache handles for drop-shadows.
|
||||
|
@ -695,7 +695,7 @@ pub fn compute_conservative_visible_rect(
|
|||
// Unmap the picture culling rect from picture -> local space. If this mapping fails due
|
||||
// to matrix weirdness, best we can do is use the clip chain's local clip rect.
|
||||
match map_local_to_pic.unmap(&pic_culling_rect) {
|
||||
Some(rect) => rect.to_rect(),
|
||||
Some(rect) => rect,
|
||||
None => clip_chain.local_clip_rect,
|
||||
}
|
||||
}
|
||||
|
|
|
@ -83,7 +83,7 @@ pub type RasterVector3D = Vector3D<f32, RasterPixel>;
|
|||
#[derive(Hash, Clone, Copy, Debug, Eq, MallocSizeOf, PartialEq, Ord, PartialOrd, Deserialize, Serialize, PeekPoke)]
|
||||
pub struct LayoutPixel;
|
||||
|
||||
pub type LayoutRect = Rect<f32, LayoutPixel>;
|
||||
pub type LayoutRect = Box2D<f32, LayoutPixel>;
|
||||
pub type LayoutPoint = Point2D<f32, LayoutPixel>;
|
||||
pub type LayoutPoint3D = Point3D<f32, LayoutPixel>;
|
||||
pub type LayoutVector2D = Vector2D<f32, LayoutPixel>;
|
||||
|
@ -91,7 +91,7 @@ pub type LayoutVector3D = Vector3D<f32, LayoutPixel>;
|
|||
pub type LayoutSize = Size2D<f32, LayoutPixel>;
|
||||
pub type LayoutSideOffsets = SideOffsets2D<f32, LayoutPixel>;
|
||||
|
||||
pub type LayoutIntRect = Rect<i32, LayoutPixel>;
|
||||
pub type LayoutIntRect = Box2D<i32, LayoutPixel>;
|
||||
pub type LayoutIntPoint = Point2D<i32, LayoutPixel>;
|
||||
pub type LayoutIntSize = Size2D<i32, LayoutPixel>;
|
||||
|
||||
|
@ -139,7 +139,7 @@ pub type RasterPixelScale = Scale<f32, PicturePixel, RasterPixel>;
|
|||
|
||||
// Fixed position coordinates, to avoid float precision errors.
|
||||
pub type LayoutPointAu = Point2D<Au, LayoutPixel>;
|
||||
pub type LayoutRectAu = Rect<Au, LayoutPixel>;
|
||||
pub type LayoutRectAu = Box2D<Au, LayoutPixel>;
|
||||
pub type LayoutSizeAu = Size2D<Au, LayoutPixel>;
|
||||
pub type LayoutVector2DAu = Vector2D<Au, LayoutPixel>;
|
||||
pub type LayoutSideOffsetsAu = SideOffsets2D<Au, LayoutPixel>;
|
||||
|
@ -248,17 +248,17 @@ impl AuHelpers<LayoutPointAu> for LayoutPoint {
|
|||
|
||||
impl AuHelpers<LayoutRectAu> for LayoutRect {
|
||||
fn from_au(rect: LayoutRectAu) -> Self {
|
||||
LayoutRect::new(
|
||||
LayoutPoint::from_au(rect.origin),
|
||||
LayoutSize::from_au(rect.size),
|
||||
)
|
||||
LayoutRect {
|
||||
min: LayoutPoint::from_au(rect.min),
|
||||
max: LayoutPoint::from_au(rect.max),
|
||||
}
|
||||
}
|
||||
|
||||
fn to_au(&self) -> LayoutRectAu {
|
||||
LayoutRectAu::new(
|
||||
self.origin.to_au(),
|
||||
self.size.to_au(),
|
||||
)
|
||||
LayoutRectAu {
|
||||
min: self.min.to_au(),
|
||||
max: self.max.to_au(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -326,7 +326,7 @@ impl<U> RectExt for Box2D<f32, U> {
|
|||
|
||||
#[inline]
|
||||
pub fn layout_rect_as_picture_rect(layout_rect: &LayoutRect) -> PictureRect {
|
||||
layout_rect.to_box2d().cast_unit()
|
||||
layout_rect.cast_unit()
|
||||
}
|
||||
|
||||
#[inline]
|
||||
|
|
|
@ -43,7 +43,7 @@ fn render_blob(
|
|||
) -> BlobImageResult {
|
||||
// Allocate storage for the result. Right now the resource cache expects the
|
||||
// tiles to have have no stride or offset.
|
||||
let buf_size = descriptor.rect.size.area() *
|
||||
let buf_size = descriptor.rect.area() *
|
||||
descriptor.format.bytes_per_pixel();
|
||||
let mut texels = vec![0u8; (buf_size) as usize];
|
||||
|
||||
|
@ -51,10 +51,10 @@ fn render_blob(
|
|||
// make sense for the rendered content to depend on its tile.
|
||||
let tile_checker = (tile.x % 2 == 0) != (tile.y % 2 == 0);
|
||||
|
||||
let dirty_rect = dirty_rect.to_subrect_of(&descriptor.rect.to_box2d());
|
||||
let dirty_rect = dirty_rect.to_subrect_of(&descriptor.rect);
|
||||
|
||||
// We want the dirty rect local to the tile rather than the whole image.
|
||||
let tx: BlobToDeviceTranslation = (-descriptor.rect.origin.to_vector()).into();
|
||||
let tx: BlobToDeviceTranslation = (-descriptor.rect.min.to_vector()).into();
|
||||
|
||||
let rasterized_rect = tx.transform_box(&dirty_rect);
|
||||
|
||||
|
@ -62,8 +62,8 @@ fn render_blob(
|
|||
for x in rasterized_rect.min.x .. rasterized_rect.max.x {
|
||||
// Apply the tile's offset. This is important: all drawing commands should be
|
||||
// translated by this offset to give correct results with tiled blob images.
|
||||
let x2 = x + descriptor.rect.origin.x;
|
||||
let y2 = y + descriptor.rect.origin.y;
|
||||
let x2 = x + descriptor.rect.min.x;
|
||||
let y2 = y + descriptor.rect.min.y;
|
||||
|
||||
// Render a simple checkerboard pattern
|
||||
let checker = if (x2 % 20 >= 10) != (y2 % 20 >= 10) {
|
||||
|
@ -77,14 +77,14 @@ fn render_blob(
|
|||
match descriptor.format {
|
||||
ImageFormat::BGRA8 => {
|
||||
let a = color.a * checker + tc;
|
||||
let pixel_offset = ((y * descriptor.rect.size.width + x) * 4) as usize;
|
||||
let pixel_offset = ((y * descriptor.rect.width() + x) * 4) as usize;
|
||||
texels[pixel_offset + 0] = premul(color.b * checker + tc, a);
|
||||
texels[pixel_offset + 1] = premul(color.g * checker + tc, a);
|
||||
texels[pixel_offset + 2] = premul(color.r * checker + tc, a);
|
||||
texels[pixel_offset + 3] = a;
|
||||
}
|
||||
ImageFormat::R8 => {
|
||||
texels[(y * descriptor.rect.size.width + x) as usize] = color.a * checker + tc;
|
||||
texels[(y * descriptor.rect.width() + x) as usize] = color.a * checker + tc;
|
||||
}
|
||||
_ => {
|
||||
return Err(BlobImageError::Other(
|
||||
|
|
|
@ -586,7 +586,7 @@ fn main() {
|
|||
.split(',')
|
||||
.map(|s| s.parse::<f32>().unwrap())
|
||||
.collect::<Vec<_>>();
|
||||
let rect = LayoutRect::new(
|
||||
let rect = LayoutRect::from_origin_and_size(
|
||||
LayoutPoint::new(items[0], items[1]),
|
||||
LayoutSize::new(items[2], items[3]),
|
||||
);
|
||||
|
|
|
@ -155,7 +155,7 @@ impl<'a> RawtestHarness<'a> {
|
|||
);
|
||||
|
||||
let mut builder = DisplayListBuilder::new(self.wrench.root_pipeline_id);
|
||||
let info = self.make_common_properties(rect(0.0, 0.0, 64.0, 64.0));
|
||||
let info = self.make_common_properties(rect(0.0, 0.0, 64.0, 64.0).to_box2d());
|
||||
|
||||
builder.push_image(
|
||||
&info,
|
||||
|
@ -182,7 +182,7 @@ impl<'a> RawtestHarness<'a> {
|
|||
);
|
||||
|
||||
let mut builder = DisplayListBuilder::new(self.wrench.root_pipeline_id);
|
||||
let info = self.make_common_properties(rect(0.0, 0.0, 1024.0, 1024.0));
|
||||
let info = self.make_common_properties(rect(0.0, 0.0, 1024.0, 1024.0).to_box2d());
|
||||
|
||||
builder.push_image(
|
||||
&info,
|
||||
|
@ -207,7 +207,7 @@ impl<'a> RawtestHarness<'a> {
|
|||
);
|
||||
|
||||
let mut builder = DisplayListBuilder::new(self.wrench.root_pipeline_id);
|
||||
let info = self.make_common_properties(rect(0.0, 0.0, 1024.0, 1024.0));
|
||||
let info = self.make_common_properties(rect(0.0, 0.0, 1024.0, 1024.0).to_box2d());
|
||||
|
||||
builder.push_image(
|
||||
&info,
|
||||
|
@ -244,7 +244,7 @@ impl<'a> RawtestHarness<'a> {
|
|||
|
||||
let mut builder = DisplayListBuilder::new(self.wrench.root_pipeline_id);
|
||||
|
||||
let info = self.make_common_properties(rect(448.899994, 74.0, 151.000031, 56.));
|
||||
let info = self.make_common_properties(rect(448.899994, 74.0, 151.000031, 56.).to_box2d());
|
||||
|
||||
// setup some malicious image size parameters
|
||||
builder.push_repeating_image(
|
||||
|
@ -309,11 +309,11 @@ impl<'a> RawtestHarness<'a> {
|
|||
let root_space_and_clip = SpaceAndClipInfo::root_scroll(self.wrench.root_pipeline_id);
|
||||
let clip_id = builder.define_clip_rect(
|
||||
&root_space_and_clip,
|
||||
rect(40., 41., 200., 201.),
|
||||
rect(40., 41., 200., 201.).to_box2d(),
|
||||
);
|
||||
|
||||
let info = CommonItemProperties {
|
||||
clip_rect: rect(0.0, 0.0, 800.0, 800.0),
|
||||
clip_rect: rect(0.0, 0.0, 800.0, 800.0).to_box2d(),
|
||||
clip_id,
|
||||
spatial_id: root_space_and_clip.spatial_id,
|
||||
flags: PrimitiveFlags::default(),
|
||||
|
@ -392,11 +392,11 @@ impl<'a> RawtestHarness<'a> {
|
|||
let root_space_and_clip = SpaceAndClipInfo::root_scroll(self.wrench.root_pipeline_id);
|
||||
let clip_id = builder.define_clip_rect(
|
||||
&root_space_and_clip,
|
||||
rect(-1000.0, -1000.0, 2000.0, 2000.0),
|
||||
rect(-1000.0, -1000.0, 2000.0, 2000.0).to_box2d(),
|
||||
);
|
||||
|
||||
let info = CommonItemProperties {
|
||||
clip_rect: rect(10.0, 10.0, 400.0, 400.0),
|
||||
clip_rect: rect(10.0, 10.0, 400.0, 400.0).to_box2d(),
|
||||
clip_id,
|
||||
spatial_id: root_space_and_clip.spatial_id,
|
||||
flags: PrimitiveFlags::default(),
|
||||
|
@ -484,11 +484,11 @@ impl<'a> RawtestHarness<'a> {
|
|||
let root_space_and_clip = SpaceAndClipInfo::root_scroll(self.wrench.root_pipeline_id);
|
||||
let clip_id = builder.define_clip_rect(
|
||||
&root_space_and_clip,
|
||||
rect(-1000.0, -1000.0, 2000.0, 2000.0),
|
||||
rect(-1000.0, -1000.0, 2000.0, 2000.0).to_box2d(),
|
||||
);
|
||||
|
||||
let info = CommonItemProperties {
|
||||
clip_rect: rect(0.0, 0.0, 1000.0, 1000.0),
|
||||
clip_rect: rect(0.0, 0.0, 1000.0, 1000.0).to_box2d(),
|
||||
clip_id,
|
||||
spatial_id: root_space_and_clip.spatial_id,
|
||||
flags: PrimitiveFlags::default(),
|
||||
|
@ -496,7 +496,7 @@ impl<'a> RawtestHarness<'a> {
|
|||
|
||||
builder.push_repeating_image(
|
||||
&info,
|
||||
rect(0.0, 0.0, 500.0, 500.0),
|
||||
rect(0.0, 0.0, 500.0, 500.0).to_box2d(),
|
||||
size2(500.0, 500.0),
|
||||
size2(500.0, 500.0),
|
||||
ImageRendering::Auto,
|
||||
|
@ -528,11 +528,11 @@ impl<'a> RawtestHarness<'a> {
|
|||
let root_space_and_clip = SpaceAndClipInfo::root_scroll(self.wrench.root_pipeline_id);
|
||||
let clip_id = builder.define_clip_rect(
|
||||
&root_space_and_clip,
|
||||
rect(-1000.0, -1000.0, 2000.0, 2000.0),
|
||||
rect(-1000.0, -1000.0, 2000.0, 2000.0).to_box2d(),
|
||||
);
|
||||
|
||||
let info = CommonItemProperties {
|
||||
clip_rect: rect(0.0, 0.0, 1000.0, 1000.0),
|
||||
clip_rect: rect(0.0, 0.0, 1000.0, 1000.0).to_box2d(),
|
||||
clip_id,
|
||||
spatial_id: root_space_and_clip.spatial_id,
|
||||
flags: PrimitiveFlags::default(),
|
||||
|
@ -540,7 +540,7 @@ impl<'a> RawtestHarness<'a> {
|
|||
|
||||
builder.push_repeating_image(
|
||||
&info,
|
||||
rect(50.0, 50.0, 400.0, 400.0),
|
||||
rect(50.0, 50.0, 400.0, 400.0).to_box2d(),
|
||||
size2(400.0, 400.0),
|
||||
size2(400.0, 400.0),
|
||||
ImageRendering::Auto,
|
||||
|
@ -574,11 +574,11 @@ impl<'a> RawtestHarness<'a> {
|
|||
let root_space_and_clip = SpaceAndClipInfo::root_scroll(self.wrench.root_pipeline_id);
|
||||
let clip_id = builder.define_clip_rect(
|
||||
&root_space_and_clip,
|
||||
rect(-1000.0, -1000.0, 2000.0, 2000.0),
|
||||
rect(-1000.0, -1000.0, 2000.0, 2000.0).to_box2d(),
|
||||
);
|
||||
|
||||
let info = CommonItemProperties {
|
||||
clip_rect: rect(0.0, 0.0, 1000.0, 1000.0),
|
||||
clip_rect: rect(0.0, 0.0, 1000.0, 1000.0).to_box2d(),
|
||||
clip_id,
|
||||
spatial_id: root_space_and_clip.spatial_id,
|
||||
flags: PrimitiveFlags::default(),
|
||||
|
@ -586,7 +586,7 @@ impl<'a> RawtestHarness<'a> {
|
|||
|
||||
builder.push_repeating_image(
|
||||
&info,
|
||||
rect(50.0, 50.0, 400.0, 400.0),
|
||||
rect(50.0, 50.0, 400.0, 400.0).to_box2d(),
|
||||
size2(400.0, 400.0),
|
||||
size2(400.0, 400.0),
|
||||
ImageRendering::Auto,
|
||||
|
@ -634,7 +634,7 @@ impl<'a> RawtestHarness<'a> {
|
|||
|
||||
let mut builder = DisplayListBuilder::new(self.wrench.root_pipeline_id);
|
||||
|
||||
let info = self.make_common_properties(rect(0., 0.0, 1510., 1510.));
|
||||
let info = self.make_common_properties(rect(0., 0.0, 1510., 1510.).to_box2d());
|
||||
|
||||
let image_size = size2(1510., 1510.);
|
||||
|
||||
|
@ -660,7 +660,7 @@ impl<'a> RawtestHarness<'a> {
|
|||
|
||||
let mut builder = DisplayListBuilder::new(self.wrench.root_pipeline_id);
|
||||
|
||||
let info = self.make_common_properties(rect(-10000., 0.0, 1510., 1510.));
|
||||
let info = self.make_common_properties(rect(-10000., 0.0, 1510., 1510.).to_box2d());
|
||||
|
||||
let image_size = size2(1510., 1510.);
|
||||
|
||||
|
@ -692,7 +692,7 @@ impl<'a> RawtestHarness<'a> {
|
|||
|
||||
let mut builder = DisplayListBuilder::new(self.wrench.root_pipeline_id);
|
||||
|
||||
let info = self.make_common_properties(rect(0., 0.0, 1510., 1510.));
|
||||
let info = self.make_common_properties(rect(0., 0.0, 1510., 1510.).to_box2d());
|
||||
|
||||
let image_size = size2(1510., 1510.);
|
||||
|
||||
|
@ -758,7 +758,7 @@ impl<'a> RawtestHarness<'a> {
|
|||
|
||||
// draw the blob the first time
|
||||
let mut builder = DisplayListBuilder::new(self.wrench.root_pipeline_id);
|
||||
let info = self.make_common_properties(rect(0.0, 60.0, 200.0, 200.0));
|
||||
let info = self.make_common_properties(rect(0.0, 60.0, 200.0, 200.0).to_box2d());
|
||||
|
||||
builder.push_image(
|
||||
&info,
|
||||
|
@ -781,7 +781,7 @@ impl<'a> RawtestHarness<'a> {
|
|||
|
||||
// make a new display list that refers to the first image
|
||||
let mut builder = DisplayListBuilder::new(self.wrench.root_pipeline_id);
|
||||
let info = self.make_common_properties(rect(1.0, 60.0, 200.0, 200.0));
|
||||
let info = self.make_common_properties(rect(1.0, 60.0, 200.0, 200.0).to_box2d());
|
||||
builder.push_image(
|
||||
&info,
|
||||
info.clip_rect,
|
||||
|
@ -865,8 +865,8 @@ impl<'a> RawtestHarness<'a> {
|
|||
|
||||
// create two blob images and draw them
|
||||
let mut builder = DisplayListBuilder::new(self.wrench.root_pipeline_id);
|
||||
let info = self.make_common_properties(rect(0.0, 60.0, 200.0, 200.0));
|
||||
let info2 = self.make_common_properties(rect(200.0, 60.0, 200.0, 200.0));
|
||||
let info = self.make_common_properties(rect(0.0, 60.0, 200.0, 200.0).to_box2d());
|
||||
let info2 = self.make_common_properties(rect(200.0, 60.0, 200.0, 200.0).to_box2d());
|
||||
let push_images = |builder: &mut DisplayListBuilder| {
|
||||
builder.push_image(
|
||||
&info,
|
||||
|
@ -965,7 +965,7 @@ impl<'a> RawtestHarness<'a> {
|
|||
|
||||
// draw the blobs the first time
|
||||
let mut builder = DisplayListBuilder::new(self.wrench.root_pipeline_id);
|
||||
let info = self.make_common_properties(rect(0.0, 60.0, 200.0, 200.0));
|
||||
let info = self.make_common_properties(rect(0.0, 60.0, 200.0, 200.0).to_box2d());
|
||||
|
||||
builder.push_image(
|
||||
&info,
|
||||
|
@ -993,7 +993,7 @@ impl<'a> RawtestHarness<'a> {
|
|||
|
||||
// make a new display list that refers to the first image
|
||||
let mut builder = DisplayListBuilder::new(self.wrench.root_pipeline_id);
|
||||
let info = self.make_common_properties(rect(0.0, 60.0, 200.0, 200.0));
|
||||
let info = self.make_common_properties(rect(0.0, 60.0, 200.0, 200.0).to_box2d());
|
||||
builder.push_image(
|
||||
&info,
|
||||
info.clip_rect,
|
||||
|
@ -1018,7 +1018,7 @@ impl<'a> RawtestHarness<'a> {
|
|||
|
||||
// make a new display list that refers to the first image
|
||||
let mut builder = DisplayListBuilder::new(self.wrench.root_pipeline_id);
|
||||
let info = self.make_common_properties(rect(0.0, 60.0, 200.0, 200.0));
|
||||
let info = self.make_common_properties(rect(0.0, 60.0, 200.0, 200.0).to_box2d());
|
||||
builder.push_image(
|
||||
&info,
|
||||
info.clip_rect,
|
||||
|
@ -1053,14 +1053,14 @@ impl<'a> RawtestHarness<'a> {
|
|||
let spatial_id = SpatialId::root_scroll_node(self.wrench.root_pipeline_id);
|
||||
let clip_id = builder.define_clip_rect(
|
||||
&SpaceAndClipInfo::root_scroll(self.wrench.root_pipeline_id),
|
||||
rect(110., 120., 200., 200.),
|
||||
rect(110., 120., 200., 200.).to_box2d(),
|
||||
);
|
||||
builder.push_rect(
|
||||
&self.make_common_properties_with_clip_and_spatial(
|
||||
rect(100., 100., 100., 100.),
|
||||
rect(100., 100., 100., 100.).to_box2d(),
|
||||
clip_id,
|
||||
spatial_id),
|
||||
rect(100., 100., 100., 100.),
|
||||
rect(100., 100., 100., 100.).to_box2d(),
|
||||
ColorF::new(0.0, 0.0, 1.0, 1.0),
|
||||
);
|
||||
|
||||
|
@ -1068,7 +1068,7 @@ impl<'a> RawtestHarness<'a> {
|
|||
builder.save();
|
||||
let clip_id = builder.define_clip_rect(
|
||||
&SpaceAndClipInfo { spatial_id, clip_id },
|
||||
rect(80., 80., 90., 90.),
|
||||
rect(80., 80., 90., 90.).to_box2d(),
|
||||
);
|
||||
let space_and_clip = SpaceAndClipInfo {
|
||||
spatial_id,
|
||||
|
@ -1076,10 +1076,10 @@ impl<'a> RawtestHarness<'a> {
|
|||
};
|
||||
builder.push_rect(
|
||||
&self.make_common_properties_with_clip_and_spatial(
|
||||
rect(110., 110., 50., 50.),
|
||||
rect(110., 110., 50., 50.).to_box2d(),
|
||||
clip_id,
|
||||
spatial_id),
|
||||
rect(110., 110., 50., 50.),
|
||||
rect(110., 110., 50., 50.).to_box2d(),
|
||||
ColorF::new(0.0, 1.0, 0.0, 1.0),
|
||||
);
|
||||
builder.push_shadow(
|
||||
|
@ -1092,7 +1092,7 @@ impl<'a> RawtestHarness<'a> {
|
|||
true,
|
||||
);
|
||||
let info = CommonItemProperties {
|
||||
clip_rect: rect(110., 110., 50., 2.),
|
||||
clip_rect: rect(110., 110., 50., 2.).to_box2d(),
|
||||
clip_id,
|
||||
spatial_id,
|
||||
flags: PrimitiveFlags::default(),
|
||||
|
@ -1111,14 +1111,14 @@ impl<'a> RawtestHarness<'a> {
|
|||
builder.save();
|
||||
let clip_id = builder.define_clip_rect(
|
||||
&SpaceAndClipInfo { spatial_id, clip_id },
|
||||
rect(80., 80., 100., 100.),
|
||||
rect(80., 80., 100., 100.).to_box2d(),
|
||||
);
|
||||
builder.push_rect(
|
||||
&self.make_common_properties_with_clip_and_spatial(
|
||||
rect(150., 150., 100., 100.),
|
||||
rect(150., 150., 100., 100.).to_box2d(),
|
||||
clip_id,
|
||||
spatial_id),
|
||||
rect(150., 150., 100., 100.),
|
||||
rect(150., 150., 100., 100.).to_box2d(),
|
||||
ColorF::new(0.0, 0.0, 1.0, 1.0),
|
||||
);
|
||||
builder.clear_save();
|
||||
|
@ -1167,7 +1167,7 @@ impl<'a> RawtestHarness<'a> {
|
|||
},
|
||||
true,
|
||||
);
|
||||
let info = self.make_common_properties(rect(110., 110., 50., 2.));
|
||||
let info = self.make_common_properties(rect(110., 110., 50., 2.).to_box2d());
|
||||
builder.push_line(
|
||||
&info,
|
||||
&info.clip_rect,
|
||||
|
@ -1212,7 +1212,7 @@ impl<'a> RawtestHarness<'a> {
|
|||
|
||||
let mut builder = DisplayListBuilder::new(self.wrench.root_pipeline_id);
|
||||
|
||||
let info = self.make_common_properties(rect(300.0, 70.0, 150.0, 50.0));
|
||||
let info = self.make_common_properties(rect(300.0, 70.0, 150.0, 50.0).to_box2d());
|
||||
builder.push_image(
|
||||
&info,
|
||||
info.clip_rect,
|
||||
|
@ -1280,8 +1280,9 @@ impl<'a> RawtestHarness<'a> {
|
|||
let doc_id = self.wrench.api.add_document(window_size);
|
||||
|
||||
let mut builder = DisplayListBuilder::new(self.wrench.root_pipeline_id);
|
||||
let info = self.make_common_properties(LayoutRect::new(LayoutPoint::zero(),
|
||||
LayoutSize::new(100.0, 100.0)));
|
||||
let info = self.make_common_properties(
|
||||
LayoutRect::from_size(LayoutSize::new(100.0, 100.0))
|
||||
);
|
||||
builder.push_rect(
|
||||
&info,
|
||||
info.clip_rect,
|
||||
|
@ -1313,14 +1314,14 @@ impl<'a> RawtestHarness<'a> {
|
|||
let mut builder = DisplayListBuilder::new(self.wrench.root_pipeline_id);
|
||||
|
||||
// Add a rectangle that covers the entire scene.
|
||||
let info = self.make_common_properties(LayoutRect::new(LayoutPoint::zero(), layout_size));
|
||||
let info = self.make_common_properties(LayoutRect::from_size(layout_size));
|
||||
builder.push_hit_test(
|
||||
&info,
|
||||
(0, 1),
|
||||
);
|
||||
|
||||
// Add a simple 100x100 rectangle at 100,0.
|
||||
let info = self.make_common_properties(LayoutRect::new(
|
||||
let info = self.make_common_properties(LayoutRect::from_origin_and_size(
|
||||
LayoutPoint::new(100., 0.),
|
||||
LayoutSize::new(100., 100.)
|
||||
));
|
||||
|
@ -1340,7 +1341,7 @@ impl<'a> RawtestHarness<'a> {
|
|||
};
|
||||
|
||||
// Add a rectangle that is clipped by a rounded rect clip item.
|
||||
let rect = LayoutRect::new(LayoutPoint::new(100., 100.), LayoutSize::new(100., 100.));
|
||||
let rect = LayoutRect::from_origin_and_size(LayoutPoint::new(100., 100.), LayoutSize::new(100., 100.));
|
||||
let temp_clip_id = builder.define_clip_rounded_rect(
|
||||
&space_and_clip,
|
||||
make_rounded_complex_clip(&rect, 20.),
|
||||
|
@ -1356,7 +1357,7 @@ impl<'a> RawtestHarness<'a> {
|
|||
);
|
||||
|
||||
// Add a rectangle that is clipped by a ClipChain containing a rounded rect.
|
||||
let rect = LayoutRect::new(LayoutPoint::new(200., 100.), LayoutSize::new(100., 100.));
|
||||
let rect = LayoutRect::from_origin_and_size(LayoutPoint::new(200., 100.), LayoutSize::new(100., 100.));
|
||||
let clip_id = builder.define_clip_rounded_rect(
|
||||
&space_and_clip,
|
||||
make_rounded_complex_clip(&rect, 20.),
|
||||
|
|
|
@ -366,7 +366,7 @@ impl Wrench {
|
|||
|
||||
match metric {
|
||||
Some(metric) => {
|
||||
let glyph_rect = LayoutRect::new(
|
||||
let glyph_rect = LayoutRect::from_origin_and_size(
|
||||
LayoutPoint::new(cursor.x + metric.left as f32, cursor.y - metric.top as f32),
|
||||
LayoutSize::new(metric.width as f32, metric.height as f32)
|
||||
);
|
||||
|
|
|
@ -876,7 +876,7 @@ impl YamlFrameReader {
|
|||
|
||||
let image_rect = item["rect"]
|
||||
.as_rect()
|
||||
.unwrap_or(LayoutRect::new(LayoutPoint::zero(), image_dims));
|
||||
.unwrap_or(LayoutRect::from_size(image_dims));
|
||||
let image_repeat = item["repeat"].as_bool().expect("Expected boolean");
|
||||
Some(ImageMask {
|
||||
image: image_key,
|
||||
|
@ -1054,12 +1054,16 @@ impl YamlFrameReader {
|
|||
|
||||
area = match orientation {
|
||||
LineOrientation::Horizontal => {
|
||||
LayoutRect::new(LayoutPoint::new(start, baseline),
|
||||
LayoutSize::new(end - start, width))
|
||||
LayoutRect::from_origin_and_size(
|
||||
LayoutPoint::new(start, baseline),
|
||||
LayoutSize::new(end - start, width),
|
||||
)
|
||||
}
|
||||
LineOrientation::Vertical => {
|
||||
LayoutRect::new(LayoutPoint::new(baseline, start),
|
||||
LayoutSize::new(width, end - start))
|
||||
LayoutRect::from_origin_and_size(
|
||||
LayoutPoint::new(baseline, start),
|
||||
LayoutSize::new(width, end - start),
|
||||
)
|
||||
}
|
||||
};
|
||||
}
|
||||
|
@ -1090,7 +1094,7 @@ impl YamlFrameReader {
|
|||
.expect("gradient must have bounds");
|
||||
|
||||
let gradient = self.to_gradient(dl, item);
|
||||
let tile_size = item["tile-size"].as_size().unwrap_or(bounds.size);
|
||||
let tile_size = item["tile-size"].as_size().unwrap_or(bounds.size());
|
||||
let tile_spacing = item["tile-spacing"].as_size().unwrap_or(LayoutSize::zero());
|
||||
|
||||
dl.push_gradient(
|
||||
|
@ -1117,7 +1121,7 @@ impl YamlFrameReader {
|
|||
.as_rect()
|
||||
.expect("radial gradient must have bounds");
|
||||
let gradient = self.to_radial_gradient(dl, item);
|
||||
let tile_size = item["tile-size"].as_size().unwrap_or(bounds.size);
|
||||
let tile_size = item["tile-size"].as_size().unwrap_or(bounds.size());
|
||||
let tile_spacing = item["tile-spacing"].as_size().unwrap_or(LayoutSize::zero());
|
||||
|
||||
dl.push_radial_gradient(
|
||||
|
@ -1144,7 +1148,7 @@ impl YamlFrameReader {
|
|||
.as_rect()
|
||||
.expect("conic gradient must have bounds");
|
||||
let gradient = self.to_conic_gradient(dl, item);
|
||||
let tile_size = item["tile-size"].as_size().unwrap_or(bounds.size);
|
||||
let tile_size = item["tile-size"].as_size().unwrap_or(bounds.size());
|
||||
let tile_spacing = item["tile-spacing"].as_size().unwrap_or(LayoutSize::zero());
|
||||
|
||||
dl.push_conic_gradient(
|
||||
|
@ -1237,10 +1241,10 @@ impl YamlFrameReader {
|
|||
"image" | "gradient" | "radial-gradient" | "conic-gradient" => {
|
||||
let image_width = item["image-width"]
|
||||
.as_i64()
|
||||
.unwrap_or(bounds.size.width as i64);
|
||||
.unwrap_or(bounds.width() as i64);
|
||||
let image_height = item["image-height"]
|
||||
.as_i64()
|
||||
.unwrap_or(bounds.size.height as i64);
|
||||
.unwrap_or(bounds.height() as i64);
|
||||
let fill = item["fill"].as_bool().unwrap_or(false);
|
||||
|
||||
let slice = item["slice"].as_vec_u32();
|
||||
|
@ -1412,7 +1416,7 @@ impl YamlFrameReader {
|
|||
};
|
||||
|
||||
let bounds = item["bounds"].as_vec_f32().unwrap();
|
||||
let bounds = LayoutRect::new(
|
||||
let bounds = LayoutRect::from_origin_and_size(
|
||||
LayoutPoint::new(bounds[0], bounds[1]),
|
||||
LayoutSize::new(bounds[2], bounds[3]),
|
||||
);
|
||||
|
@ -1447,9 +1451,9 @@ impl YamlFrameReader {
|
|||
|
||||
let bounds_raws = item["bounds"].as_vec_f32().unwrap();
|
||||
let bounds = if bounds_raws.len() == 2 {
|
||||
LayoutRect::new(LayoutPoint::new(bounds_raws[0], bounds_raws[1]), image_dims)
|
||||
LayoutRect::from_origin_and_size(LayoutPoint::new(bounds_raws[0], bounds_raws[1]), image_dims)
|
||||
} else if bounds_raws.len() == 4 {
|
||||
LayoutRect::new(
|
||||
LayoutRect::from_origin_and_size(
|
||||
LayoutPoint::new(bounds_raws[0], bounds_raws[1]),
|
||||
LayoutSize::new(bounds_raws[2], bounds_raws[3]),
|
||||
)
|
||||
|
@ -1682,7 +1686,7 @@ impl YamlFrameReader {
|
|||
// A very large number (but safely far away from finite limits of f32)
|
||||
let big_number = 1.0e30;
|
||||
// A rect that should in practical terms serve as a no-op for clipping
|
||||
let full_clip = LayoutRect::new(
|
||||
let full_clip = LayoutRect::from_origin_and_size(
|
||||
LayoutPoint::new(-big_number / 2.0, -big_number / 2.0),
|
||||
LayoutSize::new(big_number, big_number));
|
||||
|
||||
|
@ -1806,8 +1810,8 @@ impl YamlFrameReader {
|
|||
let clip_rect = yaml["bounds"]
|
||||
.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 = LayoutRect::new(clip_rect.origin, content_size);
|
||||
let content_size = yaml["content-size"].as_size().unwrap_or(clip_rect.size());
|
||||
let content_rect = LayoutRect::from_origin_and_size(clip_rect.min, content_size);
|
||||
let external_scroll_offset = yaml["external-scroll-offset"].as_vector().unwrap_or(LayoutVector2D::zero());
|
||||
|
||||
let numeric_id = yaml["id"].as_i64().map(|id| id as u64);
|
||||
|
@ -2013,11 +2017,11 @@ impl YamlFrameReader {
|
|||
wrench: &mut Wrench,
|
||||
yaml: &Yaml,
|
||||
) -> SpatialId {
|
||||
let default_bounds = LayoutRect::new(LayoutPoint::zero(), wrench.window_size_f32());
|
||||
let default_bounds = LayoutRect::from_size(wrench.window_size_f32());
|
||||
let bounds = yaml["bounds"].as_rect().unwrap_or(default_bounds);
|
||||
let default_transform_origin = LayoutPoint::new(
|
||||
bounds.origin.x + bounds.size.width * 0.5,
|
||||
bounds.origin.y + bounds.size.height * 0.5,
|
||||
bounds.min.x + bounds.width() * 0.5,
|
||||
bounds.min.y + bounds.height() * 0.5,
|
||||
);
|
||||
|
||||
let transform_style = yaml["transform-style"]
|
||||
|
@ -2059,7 +2063,7 @@ impl YamlFrameReader {
|
|||
};
|
||||
|
||||
let reference_frame_id = dl.push_reference_frame(
|
||||
bounds.origin,
|
||||
bounds.min,
|
||||
*self.spatial_id_stack.last().unwrap(),
|
||||
transform_style,
|
||||
transform.or_else(|| perspective).unwrap_or_default().into(),
|
||||
|
@ -2099,14 +2103,15 @@ impl YamlFrameReader {
|
|||
is_root: bool,
|
||||
info: &mut CommonItemProperties,
|
||||
) {
|
||||
let default_bounds = LayoutRect::new(LayoutPoint::zero(), wrench.window_size_f32());
|
||||
let default_bounds = LayoutRect::from_size(wrench.window_size_f32());
|
||||
let mut bounds = yaml["bounds"].as_rect().unwrap_or(default_bounds);
|
||||
|
||||
let reference_frame_id = if !yaml["transform"].is_badvalue() ||
|
||||
!yaml["perspective"].is_badvalue() {
|
||||
let reference_frame_id = self.push_reference_frame(dl, wrench, yaml);
|
||||
self.spatial_id_stack.push(reference_frame_id);
|
||||
bounds.origin = LayoutPoint::zero();
|
||||
bounds.max -= bounds.min.to_vector();
|
||||
bounds.min = LayoutPoint::zero();
|
||||
Some(reference_frame_id)
|
||||
} else {
|
||||
None
|
||||
|
@ -2146,7 +2151,7 @@ impl YamlFrameReader {
|
|||
}
|
||||
|
||||
dl.push_stacking_context(
|
||||
bounds.origin,
|
||||
bounds.min,
|
||||
*self.spatial_id_stack.last().unwrap(),
|
||||
info.flags,
|
||||
clip_node_id,
|
||||
|
|
|
@ -284,7 +284,7 @@ impl YamlHelper for Yaml {
|
|||
|
||||
if let Some(nums) = self.as_vec_f32() {
|
||||
if nums.len() == 4 {
|
||||
return Some(LayoutRect::new(
|
||||
return Some(LayoutRect::from_origin_and_size(
|
||||
LayoutPoint::new(nums[0], nums[1]),
|
||||
LayoutSize::new(nums[2], nums[3]),
|
||||
));
|
||||
|
|
|
@ -3703,9 +3703,9 @@ ImgDrawResult nsCSSBorderImageRenderer::CreateWebRenderCommands(
|
|||
|
||||
if (gradient.IsLinear()) {
|
||||
LayoutDevicePoint startPoint =
|
||||
LayoutDevicePoint(dest.origin.x, dest.origin.y) + lineStart;
|
||||
LayoutDevicePoint(dest.min.x, dest.min.y) + lineStart;
|
||||
LayoutDevicePoint endPoint =
|
||||
LayoutDevicePoint(dest.origin.x, dest.origin.y) + lineEnd;
|
||||
LayoutDevicePoint(dest.min.x, dest.min.y) + lineEnd;
|
||||
|
||||
aBuilder.PushBorderGradient(
|
||||
dest, clip, !aItem->BackfaceIsHidden(),
|
||||
|
|
|
@ -672,14 +672,14 @@ ImgDrawResult nsImageRenderer::BuildWebRenderDisplayItems(
|
|||
|
||||
switch (extendMode) {
|
||||
case ExtendMode::REPEAT_Y:
|
||||
fill.origin.x = dest.origin.x;
|
||||
fill.size.width = dest.size.width;
|
||||
stretchSize.width = dest.size.width;
|
||||
fill.min.x = dest.min.x;
|
||||
fill.max.x = dest.max.x;
|
||||
stretchSize.width = dest.width();
|
||||
break;
|
||||
case ExtendMode::REPEAT_X:
|
||||
fill.origin.y = dest.origin.y;
|
||||
fill.size.height = dest.size.height;
|
||||
stretchSize.height = dest.size.height;
|
||||
fill.min.y = dest.min.y;
|
||||
fill.max.y = dest.max.y;
|
||||
stretchSize.height = dest.height();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
|
|
@ -6891,31 +6891,35 @@ static void AdjustAndPushBevel(wr::DisplayListBuilder& aBuilder,
|
|||
|
||||
if (horizontal) {
|
||||
if (aIsStart) {
|
||||
aRect.origin.x += offset;
|
||||
aRect.min.x += offset;
|
||||
aRect.max.x += offset;
|
||||
} else {
|
||||
bevelRect.origin.x += aRect.size.width - offset;
|
||||
bevelRect.min.x += aRect.width() - offset;
|
||||
bevelRect.max.x += aRect.width() - offset;
|
||||
}
|
||||
aRect.size.width -= offset;
|
||||
bevelRect.size.height = aRect.size.height;
|
||||
bevelRect.size.width = offset;
|
||||
aRect.max.x -= offset;
|
||||
bevelRect.max.y += aRect.height() - bevelRect.height();
|
||||
bevelRect.max.x += offset - bevelRect.width();
|
||||
if (aBevel.mSide == eSideTop) {
|
||||
borderWidths.bottom = aRect.size.height;
|
||||
borderWidths.bottom = aRect.height();
|
||||
} else {
|
||||
borderWidths.top = aRect.size.height;
|
||||
borderWidths.top = aRect.height();
|
||||
}
|
||||
} else {
|
||||
if (aIsStart) {
|
||||
aRect.origin.y += offset;
|
||||
aRect.min.y += offset;
|
||||
aRect.max.y += offset;
|
||||
} else {
|
||||
bevelRect.origin.y += aRect.size.height - offset;
|
||||
bevelRect.min.y += aRect.height() - offset;
|
||||
bevelRect.max.y += aRect.height() - offset;
|
||||
}
|
||||
aRect.size.height -= offset;
|
||||
bevelRect.size.width = aRect.size.width;
|
||||
bevelRect.size.height = offset;
|
||||
aRect.max.y -= offset;
|
||||
bevelRect.max.x += aRect.width() - bevelRect.width();
|
||||
bevelRect.max.y += offset - bevelRect.height();
|
||||
if (aBevel.mSide == eSideLeft) {
|
||||
borderWidths.right = aRect.size.width;
|
||||
borderWidths.right = aRect.width();
|
||||
} else {
|
||||
borderWidths.left = aRect.size.width;
|
||||
borderWidths.left = aRect.width();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -6977,7 +6981,7 @@ static void CreateWRCommandsForBorderSegment(
|
|||
}
|
||||
const bool horizontal = aBorderParams.mStartBevelSide == eSideTop ||
|
||||
aBorderParams.mStartBevelSide == eSideBottom;
|
||||
auto borderWidth = horizontal ? r.size.height : r.size.width;
|
||||
auto borderWidth = horizontal ? r.height() : r.width();
|
||||
|
||||
// All border style is set to none except left side. So setting the widths of
|
||||
// each side to width of rect is fine.
|
||||
|
|
|
@ -936,8 +936,8 @@ void nsNativeBasicTheme::PaintRoundedRectWithRadius(
|
|||
std::max(0.0f, float(radius) - float(borderWidth));
|
||||
wr::BorderSide side = {backgroundColor, wr::BorderStyle::Solid};
|
||||
const wr::BorderSide sides[4] = {side, side, side, side};
|
||||
float h = backgroundRect.size.width * 0.6f;
|
||||
float v = backgroundRect.size.height * 0.6f;
|
||||
float h = backgroundRect.width() * 0.6f;
|
||||
float v = backgroundRect.height() * 0.6f;
|
||||
wr::LayoutSideOffsets widths = {v, h, v, h};
|
||||
wr::BorderRadius radii = {{backgroundRadius, backgroundRadius},
|
||||
{backgroundRadius, backgroundRadius},
|
||||
|
|
Загрузка…
Ссылка в новой задаче