Skip to content

Commit

Permalink
Auto merge of #3404 - kvark:alloc-zero, r=gw3583
Browse files Browse the repository at this point in the history
Fix handling of zero regions by texture allocator

Fixes https://bugzilla.mozilla.org/show_bug.cgi?id=1513017

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/webrender/3404)
<!-- Reviewable:end -->
  • Loading branch information
bors-servo committed Dec 12, 2018
2 parents b5f1909 + 37f20f8 commit 4b32d1e
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
7 changes: 7 additions & 0 deletions webrender/src/texture_allocator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,13 @@ fn random_fill(count: usize, texture_size: i32) -> f32 {
);
let mut rng = thread_rng();
let mut allocator = ArrayAllocationTracker::new();

// check for empty allocation
assert_eq!(
allocator.allocate(&DeviceIntSize::new(0, 12)),
Some((FreeRectSlice(0), DeviceIntPoint::zero())),
);

let mut slices: Vec<Vec<DeviceIntRect>> = Vec::new();
let mut requested_area = 0f32;
// fill up the allocator
Expand Down
5 changes: 5 additions & 0 deletions webrender/src/tiling.rs
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,11 @@ impl<T: RenderTarget> RenderTargetList<T> {
}
};

if alloc_size.is_empty_or_negative() && self.targets.is_empty() {
// push an unused target here, only if we don't have any
self.targets.push(T::new(self.screen_size));
}

self.targets[free_rect_slice.0 as usize]
.add_used(DeviceIntRect::new(origin, alloc_size));

Expand Down

0 comments on commit 4b32d1e

Please sign in to comment.