Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Properly support tiling clip mask images. #3220

Merged
merged 11 commits into from Oct 23, 2018

Revert "Skip clip masks with tiled blobs, instead of crashing."

This reverts commit 4dc6618.
  • Loading branch information
emilio committed Oct 23, 2018
commit c33308571c97cb2201e1349fa470b1ec7f272132
@@ -1952,30 +1952,25 @@ impl ClipBatcher {
let gpu_address = gpu_cache.get_address(&clip_node.gpu_cache_handle);

match clip_node.item {
ClipItem::Image(ref mask, is_valid) => {
if is_valid {
if let Ok(cache_item) = resource_cache.get_cached_image(
ImageRequest {
key: mask.image,
rendering: ImageRendering::Auto,
tile: None,
}
) {
self.images
.entry(cache_item.texture_id)
.or_insert(Vec::new())
.push(ClipMaskInstance {
clip_data_address: gpu_address,
resource_address: gpu_cache.get_address(&cache_item.uv_rect_handle),
..instance
});
} else {
warn!("Warnings: skip a image mask");
debug!("Key:{:?} Rect::{:?}", mask.image, mask.rect);
continue;
ClipItem::Image(ref mask) => {
if let Ok(cache_item) = resource_cache.get_cached_image(
ImageRequest {
key: mask.image,
rendering: ImageRendering::Auto,
tile: None,
}
) {
self.images
.entry(cache_item.texture_id)
.or_insert(Vec::new())
.push(ClipMaskInstance {
clip_data_address: gpu_address,
resource_address: gpu_cache.get_address(&cache_item.uv_rect_handle),
..instance
});
} else {
warn!("Warnings: clip masks that are tiled blobs are not yet supported (#2852)");
warn!("Warnings: skip a image mask");
debug!("Key:{:?} Rect::{:?}", mask.image, mask.rect);
continue;
}
}
@@ -145,14 +145,11 @@ impl From<ClipItemKey> for ClipNode {
)
}
ClipItemKey::ImageMask(rect, image, repeat) => {
ClipItem::Image(
ImageMask {
image,
rect: LayoutRect::from_au(rect),
repeat,
},
true,
)
ClipItem::Image(ImageMask {
image,
rect: LayoutRect::from_au(rect),
repeat,
})
}
ClipItemKey::BoxShadow(shadow_rect, shadow_radius, prim_shadow_rect, blur_radius, clip_mode) => {
ClipItem::new_box_shadow(
@@ -266,7 +263,7 @@ impl ClipNode {
) {
if let Some(mut request) = gpu_cache.request(&mut self.gpu_cache_handle) {
match self.item {
ClipItem::Image(ref mask, ..) => {
ClipItem::Image(ref mask) => {
let data = ImageMaskData { local_rect: mask.rect };
data.write_gpu_blocks(request);
}
@@ -297,25 +294,15 @@ impl ClipNode {
}

match self.item {
ClipItem::Image(ref mask, ref mut is_valid) => {
if let Some(properties) = resource_cache.get_image_properties(mask.image) {
// Clip masks with tiled blob images are not currently supported.
// This results in them being ignored, which is not ideal, but
// is better than crashing in resource cache!
// See https://github.com/servo/webrender/issues/2852.
*is_valid = properties.tiling.is_none();
}

if *is_valid {
resource_cache.request_image(
ImageRequest {
key: mask.image,
rendering: ImageRendering::Auto,
tile: None,
},
gpu_cache,
);
}
ClipItem::Image(ref mask) => {
resource_cache.request_image(
ImageRequest {
key: mask.image,
rendering: ImageRendering::Auto,
tile: None,
},
gpu_cache,
);
}
ClipItem::BoxShadow(ref mut info) => {
// Quote from https://drafts.csswg.org/css-backgrounds-3/#shadow-blur
@@ -773,7 +760,7 @@ impl ClipItemKey {
pub enum ClipItem {
Rectangle(LayoutRect, ClipMode),
RoundedRectangle(LayoutRect, BorderRadius, ClipMode),
Image(ImageMask, bool),
Image(ImageMask),
BoxShadow(BoxShadowClipSource),
}

@@ -886,8 +873,8 @@ impl ClipItem {
ClipItem::Rectangle(_, ClipMode::ClipOut) => None,
ClipItem::RoundedRectangle(clip_rect, _, ClipMode::Clip) => Some(clip_rect),
ClipItem::RoundedRectangle(_, _, ClipMode::ClipOut) => None,
ClipItem::Image(ref mask, ..) if mask.repeat => None,
ClipItem::Image(ref mask, ..) => Some(mask.rect),
ClipItem::Image(ref mask) if mask.repeat => None,
ClipItem::Image(ref mask) => Some(mask.rect),
ClipItem::BoxShadow(..) => None,
}
}
@@ -1019,7 +1006,7 @@ impl ClipItem {
}
}
}
ClipItem::Image(ref mask, ..) => {
ClipItem::Image(ref mask) => {
if mask.repeat {
ClipResult::Partial
} else {
@@ -39,7 +39,7 @@ impl HitTestClipNode {
ClipItem::Rectangle(ref rect, mode) => HitTestRegion::Rectangle(*rect, mode),
ClipItem::RoundedRectangle(ref rect, ref radii, ref mode) =>
HitTestRegion::RoundedRectangle(*rect, *radii, *mode),
ClipItem::Image(ref mask, ..) => HitTestRegion::Rectangle(mask.rect, ClipMode::Clip),
ClipItem::Image(ref mask) => HitTestRegion::Rectangle(mask.rect, ClipMode::Clip),
ClipItem::BoxShadow(_) => HitTestRegion::Invalid,
};

ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.